Safe Haskell | Safe-Inferred |
---|
- isLeft :: Either l r -> Bool
- isRight :: Either l r -> Bool
- fromLeft :: Either l r -> l
- fromRight :: Either l r -> r
- fromEither :: Either a a -> a
Documentation
isLeft :: Either l r -> BoolSource
Test if an Either
value is the Left
constructor.
Provided as standard with GHC 7.8 and above.
isRight :: Either l r -> BoolSource
Test if an Either
value is the Right
constructor.
Provided as standard with GHC 7.8 and above.
fromLeft :: Either l r -> lSource
The fromLeft
function extracts the element out of a Left
and
throws an error if its argument is Right
.
Much like fromJust
, using this function in polished code is usually a bad idea.
\x -> fromLeft (Left x) == x \x -> fromLeft (Right x) == undefined
fromRight :: Either l r -> rSource
The fromRight
function extracts the element out of a Right
and
throws an error if its argument is Left
.
Much like fromJust
, using this function in polished code is usually a bad idea.
\x -> fromRight (Right x) == x \x -> fromRight (Left x) == undefined
fromEither :: Either a a -> aSource
Pull the value out of an Either
where both alternatives
have the same type.
\x -> fromEither (Left x ) == x \x -> fromEither (Right x) == x