neither-0.1.0: Provide versions of Either with good monad and applicative instances.Source codeContentsIndex
Data.Neither
Contents
Applicative version
Monadic version
Monad transformer
Neither typeclass
Utility functions
Description

This module provides three different datatypes: AEither is the applicative version of Either. It does not provide a monad instance, and mappends together error values. MEither is the monadic version, which only holds onto the first error value. MEitherT is a monad transformer.

Also, *Either datatypes and utility functions from Data.Either are generalized with Neither type class.

Synopsis
data AEither a b
= ALeft a
| ARight b
aeither :: (a -> c) -> (b -> c) -> AEither a b -> c
data MEither a b
= MLeft a
| MRight b
meither :: (a -> c) -> (b -> c) -> MEither a b -> c
newtype MEitherT e m a = MEitherT {
runMEitherT :: m (MEither e a)
}
mapMEitherT :: (m (MEither e a) -> n (MEither e' b)) -> MEitherT e m a -> MEitherT e' n b
throwMEither :: Monad m => e -> MEitherT e m a
class Neither e where
left :: a -> e a b
right :: b -> e a b
either :: (a -> c) -> (b -> c) -> e a b -> c
mapLeft :: Neither e => (a -> c) -> e a b -> e c b
mapRight :: Neither e => (b -> c) -> e a b -> e a c
mapEither :: Neither e => (a -> c) -> (b -> d) -> e a b -> e c d
lefts :: (Neither e, MonadPlus m) => m (e a b) -> m a
rights :: (Neither e, MonadPlus m) => m (e a b) -> m b
partitionEithers :: (Neither e, MonadPlus m) => m (e a b) -> (m a, m b)
Applicative version
data AEither a b Source
Constructors
ALeft a
ARight b
show/hide Instances
Typeable2 AEither
Neither AEither
Functor (AEither a)
Monoid a => Applicative (AEither a)
(Eq a, Eq b) => Eq (AEither a b)
(Data a, Data b) => Data (AEither a b)
(Ord a, Ord b) => Ord (AEither a b)
(Read a, Read b) => Read (AEither a b)
(Show a, Show b) => Show (AEither a b)
aeither :: (a -> c) -> (b -> c) -> AEither a b -> cSource
Monadic version
data MEither a b Source
Constructors
MLeft a
MRight b
show/hide Instances
Typeable2 MEither
Neither MEither
Failure e (MEither e)
Monad (MEither a)
Functor (MEither a)
Applicative (MEither a)
(Eq a, Eq b) => Eq (MEither a b)
(Data a, Data b) => Data (MEither a b)
(Ord a, Ord b) => Ord (MEither a b)
(Read a, Read b) => Read (MEither a b)
(Show a, Show b) => Show (MEither a b)
meither :: (a -> c) -> (b -> c) -> MEither a b -> cSource
Monad transformer
newtype MEitherT e m a Source
Constructors
MEitherT
runMEitherT :: m (MEither e a)
show/hide Instances
mapMEitherT :: (m (MEither e a) -> n (MEither e' b)) -> MEitherT e m a -> MEitherT e' n bSource
throwMEither :: Monad m => e -> MEitherT e m aSource
Neither typeclass
class Neither e whereSource
Methods
left :: a -> e a bSource
right :: b -> e a bSource
either :: (a -> c) -> (b -> c) -> e a b -> cSource
show/hide Instances
Utility functions
mapLeft :: Neither e => (a -> c) -> e a b -> e c bSource
mapRight :: Neither e => (b -> c) -> e a b -> e a cSource
mapEither :: Neither e => (a -> c) -> (b -> d) -> e a b -> e c dSource
lefts :: (Neither e, MonadPlus m) => m (e a b) -> m aSource
rights :: (Neither e, MonadPlus m) => m (e a b) -> m bSource
partitionEithers :: (Neither e, MonadPlus m) => m (e a b) -> (m a, m b)Source
Produced by Haddock version 2.6.0