(no title)
mrgriffin | 6 years ago
map :: Bool -> (() -> b) -> Maybe b
map True f = Just (f ())
map False _ = Nothing
Or, in Haskell because you've got laziness you could go with: map :: Bool -> b -> Maybe b
Which already exists as a combination of Control.Monad.guard and Data.Functor.(<$). map tf b = b <$ guard tf
No comments yet.