:: Either a b -> Maybe b
Given an
Either, convert it to a
Maybe, where
Left becomes
Nothing.
\x -> eitherToMaybe (Left x) == Nothing
\x -> eitherToMaybe (Right x) == Just x
Safe projection from
Right.
maybeRight (Right b) = Just b
maybeRight Left{} = Nothing
A
fromRight that fails in the
Maybe monad
Convert an
Either to a
Maybe.
A
Right value becomes
Just.
>>> eitherToMaybe $ Right 3
Just 3
A
Left value becomes
Nothing.
>>> eitherToMaybe $ Left "bye"
Nothing
Maps right part of
Either to
Maybe.
>>> rightToMaybe (Left True)
Nothing
>>> rightToMaybe (Right "aba")
Just "aba"
To prevent a dependency on package errors