extra-1.4.1: Extra functions I use.

Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Either.Extra

Synopsis

Documentation

isLeft :: Either a b -> Bool

Return True if the given value is a Left-value, False otherwise.

Since: 4.7.0.0

isRight :: Either a b -> Bool

Return True if the given value is a Right-value, False otherwise.

Since: 4.7.0.0

fromLeft :: Either l r -> l Source

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 -> r Source

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 -> a Source

Pull the value out of an Either where both alternatives have the same type.

\x -> fromEither (Left x ) == x
\x -> fromEither (Right x) == x