Because Functor is a very general view of an object; Not all Functor folds support. For example, there is instance 1
instance Functor (a ->) where -- > fmap :: (b -> c) -> (a -> b) -> (a -> c) fmap fg = g . f
But, although (a ->) is a Functor for all a , for infinite a there is no reasonable definition of fold . (By the way, the summary is generally catamorphism , which means it has different types for each funter. A class of type Foldable defines it for types similar to a sequence.).
Let's look at the definition of foldr for Integer -> Integer ; What would be the most external application? What will be the value
foldr (\ _ n -> 1 + n) 0 (\ n -> n + 1)
be? There is no reasonable definition of fold without a much larger argument type structure.
1 (a ->) for some reason is not legal Haskell. But I will still use it as a more readable version (->) a , since I think itβs easier for a beginner to understand.
source share