
We've reached the end of the discussion period. Most seemed in favor. Those
who suggested adding a new type class for these kind of functors, do you
feel OK not doing that (and use Monad =>) with the argument that this
distinction is probably too fine grained and having a separate class (which
people need to implement) would probably be more of a pain than it's worth?
-- Johan
On Sat, Nov 30, 2013 at 7:41 PM, Herbert Valerio Riedel
On 2013-11-30 at 12:05:06 +0100, Roman Cheplyaka wrote:
* Nicolas Trangez
[2013-11-30 02:11:02+0100] I'm without a doubt overlooking something, but couldn't this be (otoh)
fmap' :: Functor f => (a -> b) -> f a -> f b fmap' f = fmap (strictify f) where strictify s = (($!) id) . s
No. Evaluation of your 'strictify' function will be delayed for the very same reason that evaluation of 'f' is delayed in the first place.
It doesn't matter what 'strictify' *does* if it's not even evaluated.
jfyi, if compiled with
ghc -O2 -dsuppress-all -dsuppress-uniques -ddump-simpl
it can be seen that fmap' is really almost the same as a plain fmap, except for an left-over eta-expansion which ghc doesn't optimize away:
fmap' = \ @ a @ b @ f $dFunctor f1 -> fmap $dFunctor (\ x -> f1 x)
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries