haskell-issues
haskell-issues copied to clipboard
transformers: add hoistMaybe and hoistEither
hoistMaybe :: Monad m => Maybe a -> MaybeT m a
hoistEither :: Monad m => Either e a -> ExceptT e m a
Also consider adding isJustT
and isNothingT
.
Alternatively, we could have liftMaybe :: Alternative f => Maybe a -> f a
.
liftMaybe = maybe empty pure
isJustT/isNothingT proliferate boolean blindness and ought not to be needed in modern code - post an example where you would use it, and I'll see about solving it without bools?
I only mentioned isJustT
and isNothingT
because I saw them in errors, but presently I don't have any use for them. As for liftMaybe
, sure, the definition is simple, but it's been reinvented a few times by now so I feel that it could find a place in e.g. Data.Maybe
.
In that same vein:
fromMaybeT :: Monad m => m a -> MaybeT m a -> m a
(fromMaybeT
= flip (<!|>)
)