aelve / haskell-issues

An unofficial issue tracker for all things Haskell-related
18 stars 0 forks source link

transformers: add hoistMaybe and hoistEither #8

Open neongreen opened 8 years ago

neongreen commented 8 years ago
hoistMaybe :: Monad m => Maybe a -> MaybeT m a
hoistEither :: Monad m => Either e a -> ExceptT e m a 
neongreen commented 8 years ago

Also consider adding isJustT and isNothingT.

neongreen commented 8 years ago

Alternatively, we could have liftMaybe :: Alternative f => Maybe a -> f a.

Gurkenglas commented 8 years ago

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?

neongreen commented 8 years ago

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.

Gurkenglas commented 8 years ago

In that same vein:

fromMaybeT :: Monad m => m a -> MaybeT m a -> m a

(fromMaybeT = flip (<!|>))