Proposal: add Control.Monad.whenJust ∷ (Monad m) ⇒ Maybe α→(α→ m ()) → m ()

Mikhail Vorozhtsov mikhail.vorozhtsov at gmail.com
Wed Nov 30 10:40:27 CET 2011


On 11/30/2011 02:11 PM, Liyang HU wrote:
> This particular pattern crops up a lot for me. Does it for anyone else?
>
> I (half-heartedly) propose adding to Control.Monad the following:
>
>> -- | A variation of 'when' for 'Maybe a'.
>> whenJust :: (Monad m) =>  Maybe a ->  (a ->  m ()) ->  m ()
>> whenJust =  flip (maybe (return ()))

We already have it. See Data.Foldable.forM_




More information about the Libraries mailing list