neither-0.3.1: Provide versions of Either with good monad and applicative instances. (deprecated)

Data.Neither

Contents

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

Applicative version

data AEither a b Source

Constructors

ALeft a 
ARight b 

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 

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 

Fields

runMEitherT :: m (MEither e a)
 

Instances

Monad m => Failure e (MEitherT e m) 
MonadTrans (MEitherT e) 
Monad m => Monad (MEitherT e m) 
Functor m => Functor (MEitherT e m) 
(Functor m, Monad m) => Applicative (MEitherT e m) 
MonadIO m => MonadIO (MEitherT e m) 

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

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