snoyberg / mono-traversable

Type classes for mapping, folding, and traversing monomorphic containers
155 stars 64 forks source link

How about changing whenM to take m a? #123

Closed jeiea closed 7 years ago

jeiea commented 7 years ago

Currently all your preludes export whenM :: m Bool -> m () -> m () intactly from Control.Monad. If I use act :: IO a with whenM, then it would be whenM mpred (act >> return ()). It can be bypassed by changing the signature to m Bool -> m a -> m (). And I think when is also considerable. How do you think?

snoyberg commented 7 years ago

I prefer the current signature, as it avoids bugs of accidentally ignoring return values. This is a common debate on the haskell community.

On Thu, Feb 9, 2017, 8:56 PM jeiea notifications@github.com wrote:

Currently your all preludes export whenM :: m Bool -> m () -> m () intactly from Control.Monad. If I use act :: IO a with whenM, then it would be whenM mpred (act >> return ()). It can be bypassed by changing the signature to m Bool -> m a -> m (). And I think when is also considerable. How do you think?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/snoyberg/mono-traversable/issues/123, or mute the thread https://github.com/notifications/unsubscribe-auth/AADBB2CCVd0yiDlUA2CoEadhbewY9Xqtks5ra2FKgaJpZM4L8hko .