On 2013-11-30 at 12:05:06 +0100, Roman Cheplyaka wrote:jfyi, if compiled with
> * Nicolas Trangez <nicolas@incubaid.com> [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.
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