Improving void

Edward Kmett ekmett at gmail.com
Mon Aug 5 21:06:07 CEST 2013


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20130805/df314d5c/attachment.htm>


More information about the Libraries mailing list