A better type signature for `forM_`
David Feuer
david.feuer at gmail.com
Fri Apr 1 05:20:38 UTC 2016
Suppose you have something like
data Free f a = Pure a | Free (f (Free f a))
instance Functor f => Functor (Free f) where
fmap = mapFree
-- Separated out for clarity
mapFree :: Functor f
=> (a -> b)
-> Free f a -> Free f b
mapFree f (Pure a) = Pure (f a)
mapFree f (Free m) = Free (fmap (mapFree f) m)
Now void x = () <$ x, and `Free f` doesn't offer any potential for a cheap
<$. So voiding out Free f a is going to cost you some. Laziness will help,
but you'll face extra allocation.
On Apr 1, 2016 1:02 AM, "Erik de Castro Lopo" <mle+hs at mega-nerd.com> wrote:
> David Feuer wrote:
>
> > I think it's an interesting idea from a safety standpoint. Unfortunately,
> > as Ed pointed out to me in a similar context, `void` isn't always free.
>
> I would love to see an elaboration of that.
>
> Erik
> --
> ----------------------------------------------------------------------
> Erik de Castro Lopo
> http://www.mega-nerd.com/
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20160401/6fb84974/attachment.html>
More information about the Libraries
mailing list