
30 Nov
2011
30 Nov
'11
11:51 a.m.
Mikhail Vorozhtsov
On 11/30/2011 02:11 PM, Liyang HU wrote:
whenJust :: (Monad m) => Maybe a -> (a -> m ()) -> m () We already have it. See Data.Foldable.forM_
Good point! Hadn't crossed my mind that Maybe is Foldable; kind of obvious
really.
Evan Laforge
I prefer it to Foldable.forM_ because it's explicit about the type it takes, forM_ sounds too much like a loop.
Well, forM_ is just mapM_ flipped, and shurely we map over Maybe all the time? I'm much less inclined towards my proposal now, with the possible proviso that some people might find Foldable confusing. Also, if we go down the route of whenJust, why not whenLeft and whenRight (and so on) too? Cheers, /Liyang