A better type signature for `forM_`

John Wiegley johnw at newartisans.com
Fri Apr 1 03:46:32 UTC 2016


>>>>> Erik de Castro Lopo <mle+hs at mega-nerd.com> writes:

> As pointed out to me on IRC (thanks pjdeport), chaning the type signature of
> `forM_` to
>     forM_' :: (Monad m, Foldable t) => t a -> (a -> m ()) -> m ()
> would have resulted in an error.

What about mapM_, replicateM_, etc.? In each case, '_' means "if you return a
value from your action, it is ignored", and not "you must return unit".

-- 
John Wiegley                  GPG fingerprint = 4710 CF98 AF9B 327B B80F
http://newartisans.com                          60E1 46C4 BD1A 7AC1 4BA2


More information about the Libraries mailing list