Adding an ignore function to Control.Monad

Malcolm Wallace malcolm.wallace at
Mon Dec 14 11:43:54 EST 2009

>> ## Control.Monad.void m a -> m ()
>> (or void :: f a -> f ())

By the latter, I take it you mean

     void :: Functor f => f a -> f ()
     void = fmap (const ())

thereby avoiding any premature restriction to Monad.  I would be in  
favour of the generalisation (and of the name 'void').

>> ## Control.Monad.discard :: f a -> f ()

I vote against 'discard', mainly because I already use it frequently,  
as an infix operator

     discard :: Applicative f => f a -> f b -> f a

It can be jolly useful to intersperse with the `apply` operator e.g.

     list item  = empty
                  fmap (:) `apply`   item
                           `discard` satisfy ":"
                           `apply`   list


More information about the Libraries mailing list