Adding an ignore function to Control.Monad

Malcolm Wallace malcolm.wallace at cs.york.ac.uk
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
                  `orElse`
                  fmap (:) `apply`   item
                           `discard` satisfy ":"
                           `apply`   list

Regards,
     Malcolm



More information about the Libraries mailing list