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

Greg Fitzgerald garious at gmail.com
Fri Jul 26 19:57:44 CEST 2013


> Are there any examples of "nom" being useful?

I find 'nom' to be useful if defined as "const id":


-- Given 'om'
om f m = (m >>=) . flip f

-- And 'nom'
nom = const id

-- And the natural name for a monadic version of 'no'thing
noM = return ()

-- We construct a useful example of 'nom':
eatCookies :: IO ()
eatCookies = om nom noM noM


:-)

Happy Friday,
Greg


On Thu, Jul 25, 2013 at 2:21 PM, Ganesh Sittampalam <ganesh at earth.li> wrote:
> On 25/07/2013 20:16, John Wiegley wrote:
>> The function is:
>>
>>     om f m = (m >>=) . flip f
> [...]
>> A rider to this proposal is to also add "nom = flip om", but I can live
>> without that one.  "om", however, is handy enough that I've started locally
>> defining in all the modules where I find myself now reaching for it.
>
> I have to admit my first reaction to this was that it isn't April 1st...
>
> More seriously, "om" sounds useful but the name seems a bit obscure ("on
> monad"?) Are there any examples of "nom" being useful?
>
> Cheers,
>
> Ganesh
>
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries




More information about the Libraries mailing list