Skip to content
Snippets Groups Projects
Commit 49ca2a37 authored by twanvl's avatar twanvl Committed by Simon Peyton Jones
Browse files

Changed deriving of Functor, Foldable, Traversable to fix #7436. Added foldMap...

Changed deriving of Functor, Foldable, Traversable to fix #7436. Added foldMap to derived Foldable instance.

The derived instances will no longer eta-expand the function. I.e. instead of
    fmap f (Foo a) = Foo (fmap (\x -> f x) a)
we now derive
    fmap f (Foo a) = Foo (fmap f a)

Some superflous lambdas are generated as a result. For example
    data X a = X (a,a)
    fmap f (X x) = (\y -> case y of (a,b) -> (f a, f b)) x
The optimizer should be able to simplify this code, as it is just beta reduction.

The derived Foldable instance now includes foldMap in addition to foldr.
parent fbff64a4
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment