data-extra-2.3.0: Extra utilities for working on Data.* types.

Safe HaskellSafe-Inferred

Data.Either.Extra

Description

Extra functions for dealing with Either.

Synopsis

Documentation

mapEither :: (a -> b1) -> (b -> b2) -> Either a b -> Either b1 b2Source

A map for Either values.

leftToMaybe :: Either a b -> Maybe aSource

Maybe get the left side of an Either.

rightToMaybe :: Either a b -> Maybe bSource

Maybe get the right side of an Either.

isLeft :: Either a b -> BoolSource

Is a value Left?

isRight :: Either a b -> BoolSource

Is a value Right?

fromLeft :: a -> Either a b -> aSource

Extract the left value or a default.

fromRight :: b -> Either a b -> bSource

Extract the right value or a default.

whenRight :: Monad m => Either a b -> (b -> m c) -> m ()Source

When a value is Right, do something with it, monadically.

whenLeft :: Monad m => Either a b -> (a -> m c) -> m ()Source

When a value is Left, do something with it, monadically.