Agda-2.4.0: A dependently typed functional programming language and proof assistant

Safe HaskellSafe-Inferred

Agda.Utils.Either

Description

Utilities for the Either type

Synopsis

Documentation

whileLeft :: Monad m => (a -> Either b c) -> (a -> b -> m a) -> (a -> c -> m d) -> a -> m dSource

Loop while we have an exception.

caseEitherM :: Monad m => m (Either a b) -> (a -> m c) -> (b -> m c) -> m cSource

Monadic version of either with a different argument ordering.

mapEither :: (a -> c) -> (b -> d) -> Either a b -> Either c dSource

Either is a bifunctor.

mapLeft :: (a -> c) -> Either a b -> Either c bSource

'Either _ b' is a functor.

mapRight :: (b -> d) -> Either a b -> Either a dSource

'Either a' is a functor.

isLeft :: Either a b -> BoolSource

Returns True iff the argument is Left x for some x.

isRight :: Either a b -> BoolSource

Returns True iff the argument is Right x for some x.

allRight :: [Either a b] -> Maybe [b]Source

Returns Just with tags stripped if all elements are to the right, and otherwise Nothing.

  allRight xs ==
    if all isRight xs then
      Just (map ((Right x) -> x) xs)
     else
      Nothing