purescript-transformers icon indicating copy to clipboard operation
purescript-transformers copied to clipboard

Add a `maybe` function for `MaybeT` like the `except` for `ExceptT`

Open garyb opened this issue 5 years ago • 4 comments

garyb avatar May 07 '20 13:05 garyb

I definitely support this, however, should it be named maybe? as it would clash with maybe.

ursi avatar Jan 26 '21 23:01 ursi

Perhaps maybeT?

JordanMartinez avatar Dec 04 '21 04:12 JordanMartinez

We can rely on qualified imports to disambiguate, at least. I would expect the naming to be the same as is used for ExceptT, which would be to follow @garyb’s proposal for the name

thomashoneyman avatar Dec 04 '21 04:12 thomashoneyman

:-1: to both maybe and maybeT. When I see a function with the lowercase name of a type, I expect that function to be a destructor (bool, maybe, either, etc).

In Haskell this function is called hoistMaybe. Why doesn't that work?

If readability/succinctness is an issue, something like the following might work

class Hoist m n a | m -> a, m -> n where
  hoist :: n a -> m a

instance Hoist (MaybeT m) Maybe a where -- ...
instance Hoist (ExceptT e m) (Either e) a where -- ...

Quelklef avatar Jan 24 '22 07:01 Quelklef