Open treeowl opened 8 years ago
You are right that it is overly strict for fmap (f . g) = fmap f . fmap g
to hold in the case of bottoms. For example fmap (const () . const undefined) == fmap (const ()) . fmap (const undefined)
does not hold. However, I do wonder in what cases that is that an actual problem? I wonder in particular, as I really like my data-structures to be unable to contain any thunk if they are in WHNF. This makes a common class of space leaks just go away.
Put differently I currently believe that it is OK or even preferable for data structures that do not model control to be this strict. It is clear to me that for Applicative
and Monad
we want to have the lazy versions that can deal with bottoms. It is not yet clear to me, what we loose from an overly strict Functor
that is not an Applicative
.
The
Elem
constructor is strict inv
, which is bogus for aFunctor
. The constructor should be made lazy, and the forcing done by other functions.