Proposal: Add Chris Done's "om" combinator to Control.Monad

John Wiegley johnw at fpcomplete.com
Fri Jul 26 23:27:02 CEST 2013


>>>>> Bryan O'Sullivan <bos at serpentine.com> writes:

> Sure, this is a common pattern. But the name is terrible, and it's not clear
> to me that the functionality is a useful generalization. Why not advocate
> for whenM instead?

> whenM :: Monad m => m Bool -> m () -> m ()

The entire point of the proposal is that "om" subsumes such specialized
functions, saving you from having to use whenM, unlessM, etc.  You simply put
"om" (or whatever name you want to call it, the name wasn't the objective of
this proposal) in front of functions you already know and use, and suddenly
they become able to accept monadic arguments where they couldn't before.

Consider the "om forM_" example from before, which is actually quite handy and
clarifying, once you know how to read the combinator.

-- 
John Wiegley
FP Complete                         Haskell tools, training and consulting
http://fpcomplete.com               johnw on #haskell/irc.freenode.net




More information about the Libraries mailing list