Improving void

wren ng thornton wren at freegeek.org
Wed Aug 7 05:18:01 CEST 2013


On 8/5/13 3:06 PM, 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.

+1. That was the entire point of (<$) being added to the class afterall.

-- 
Live well,
~wren





More information about the Libraries mailing list