Re: Proposal: add Control.Monad.whenJust ∷ (Monad m) ⇒ Maybe α→(α→ m ()) → m ()
Henning Thielemann
lemming at henning-thielemann.de
Thu Dec 1 10:44:50 CET 2011
On Thu, 1 Dec 2011, Mikhail Vorozhtsov wrote:
> On 11/30/2011 11:26 PM, Evan Laforge wrote:
>> On Tue, Nov 29, 2011 at 11:11 PM, Liyang HU<haskell.org at liyang.hu> wrote:
>>> This particular pattern crops up a lot for me. Does it for anyone else?
>>
>> Yep, I have that in my personal library, and use it fairly often.
>>
>> I prefer it to Foldable.forM_ because it's explicit about the type it
>> takes, forM_ sounds too much like a loop.
>
> Well, it is a loop over collection, which in the case of Maybe can contain at
> most one element.
Hoogle even lists forM_ and for_ in the second and third position when
searching for the signature
"Maybe a -> (a-> m ()) -> m ()"
Nonetheless I also needed whenJust recently and missed "for_"!
More information about the Libraries
mailing list