-- | Extra functions for dealing with Maybe. module Data.Maybe.Extra where import Control.Monad -- | When the predicate is true, return maybe the action's return value. whenMaybe :: Monad m => Bool -> m a -> m (Maybe a) whenMaybe False _ = return Nothing whenMaybe True m = liftM Just m