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@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@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries