
The (<$) operator is part of the Functor type class. The default
implementation is `fmap . const`, but instances can provide a more
optimized implementation. Since void is `fmap (const ())`, this
proposal will make it more efficient for some Functors.
Erik
On Tue, Aug 6, 2013 at 8:32 AM, Malcolm Wallace
Can you explain why you think it is an improvement? To me, it looks like line noise.
Regards, Malcolm
On 5/08/2013, at 20:06, Edward Kmett
wrote: Right now the definition of Control.Monad.void is:
void :: Functor f => f a -> f ()
void = fmap (const ())
I propose we replace it with
void :: Functor f => f a -> f ()
void = (() <$)
This expands out to the former definition by the default definition of (<$) and Data.Functor.Functor exports (<$) explicitly to make it possible to optimize this sort of thing. It seems a shame not to use it.
Discussion Period: 2 weeks
_______________________________________________
Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries
_______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries