Proposal: add ifM and whenM to Control.Monad

John Wiegley johnw at newartisans.com
Sun Apr 20 21:10:34 UTC 2014


>>>>> Edward Kmett <ekmett at gmail.com> writes:

> However, given that they keep getting reinvented with the exact same names
> and functionality. I'm finally ready to give in.

> +1 from me.

How about a more general combinator, like om (name needed)?

    om :: Monad m => (a -> b -> m c) -> m a -> b -> m c
    om f m = (m >>=) . flip f

whenM = om when
unlessM = om unless

etc.

John


More information about the Libraries mailing list