
10 Apr
2019
10 Apr
'19
2:04 p.m.
On 2019-04-10 11:36 a.m., James Ashwell wrote:
This would mimic the behaviour of Control.Monad.when for monoids rather than applicatives.
mwhen :: Monoid m => Bool -> m -> m
mwhen b a | b = a | otherwise = mempty
Or shorter mwhen = bool (const mempty) id I'd rather construct the right-hand side than memorize the left, so -1 from me.