I'm trying to understand MaybeT by running a few examples in ghci:
λ: import Control.Monad.Trans.Maybe
λ: let x = return $ 42 :: MaybeT (Either String) Int
λ: :t x
x :: MaybeT (Either String) Int
Then, I ran it:
λ: runMaybeT x
Right (Just 42)
Please give me value, y, such that
runMaybeT y === Left (Just "...")
runMaybeT y === Left Nothing
runMaybeT y === Right Nothing
You will never get a Left Nothing or Left (Just ..), as the monad here is Either String …, so that in the left you will always have a String.
Here is what you can get:
> let y = fail "Failed" :: MaybeT (Either String) Int
> runMaybeT y
Right Nothing
> let y = lift (Left "Failed") :: MaybeT (Either String) Int
> runMaybeT y
Left "Failed"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With