transformers-0.5.2.0: Concrete functor and monad transformers

Copyright (c) Ross Paterson 2010 BSD-style (see the file LICENSE) R.Paterson@city.ac.uk experimental portable Safe Haskell98

Control.Applicative.Lift

Description

Adding a new kind of pure computation to an applicative functor.

Synopsis

# Lifting an applicative

data Lift f a Source #

Applicative functor formed by adding pure computations to a given applicative functor.

Constructors

 Pure a Other (f a)

Instances

 Functor f => Functor (Lift f) # Methodsfmap :: (a -> b) -> Lift f a -> Lift f b Source #(<\$) :: a -> Lift f b -> Lift f a Source # Applicative f => Applicative (Lift f) # A combination is Pure only if both parts are. Methodspure :: a -> Lift f a Source #(<*>) :: Lift f (a -> b) -> Lift f a -> Lift f b Source #(*>) :: Lift f a -> Lift f b -> Lift f b Source #(<*) :: Lift f a -> Lift f b -> Lift f a Source # Foldable f => Foldable (Lift f) # Methodsfold :: Monoid m => Lift f m -> m Source #foldMap :: Monoid m => (a -> m) -> Lift f a -> m Source #foldr :: (a -> b -> b) -> b -> Lift f a -> b Source #foldr' :: (a -> b -> b) -> b -> Lift f a -> b Source #foldl :: (b -> a -> b) -> b -> Lift f a -> b Source #foldl' :: (b -> a -> b) -> b -> Lift f a -> b Source #foldr1 :: (a -> a -> a) -> Lift f a -> a Source #foldl1 :: (a -> a -> a) -> Lift f a -> a Source #toList :: Lift f a -> [a] Source #null :: Lift f a -> Bool Source #length :: Lift f a -> Int Source #elem :: Eq a => a -> Lift f a -> Bool Source #maximum :: Ord a => Lift f a -> a Source #minimum :: Ord a => Lift f a -> a Source #sum :: Num a => Lift f a -> a Source #product :: Num a => Lift f a -> a Source # Traversable f => Traversable (Lift f) # Methodstraverse :: Applicative f => (a -> f b) -> Lift f a -> f (Lift f b) Source #sequenceA :: Applicative f => Lift f (f a) -> f (Lift f a) Source #mapM :: Monad m => (a -> m b) -> Lift f a -> m (Lift f b) Source #sequence :: Monad m => Lift f (m a) -> m (Lift f a) Source # Eq1 f => Eq1 (Lift f) # MethodsliftEq :: (a -> b -> Bool) -> Lift f a -> Lift f b -> Bool Source # Ord1 f => Ord1 (Lift f) # MethodsliftCompare :: (a -> b -> Ordering) -> Lift f a -> Lift f b -> Ordering Source # Read1 f => Read1 (Lift f) # MethodsliftReadsPrec :: (Int -> ReadS a) -> ReadS [a] -> Int -> ReadS (Lift f a) Source #liftReadList :: (Int -> ReadS a) -> ReadS [a] -> ReadS [Lift f a] Source # Show1 f => Show1 (Lift f) # MethodsliftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> Lift f a -> ShowS Source #liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [Lift f a] -> ShowS Source # Alternative f => Alternative (Lift f) # A combination is Pure only either part is. Methodsempty :: Lift f a Source #(<|>) :: Lift f a -> Lift f a -> Lift f a Source #some :: Lift f a -> Lift f [a] Source #many :: Lift f a -> Lift f [a] Source # (Eq1 f, Eq a) => Eq (Lift f a) # Methods(==) :: Lift f a -> Lift f a -> Bool #(/=) :: Lift f a -> Lift f a -> Bool # (Ord1 f, Ord a) => Ord (Lift f a) # Methodscompare :: Lift f a -> Lift f a -> Ordering #(<) :: Lift f a -> Lift f a -> Bool #(<=) :: Lift f a -> Lift f a -> Bool #(>) :: Lift f a -> Lift f a -> Bool #(>=) :: Lift f a -> Lift f a -> Bool #max :: Lift f a -> Lift f a -> Lift f a #min :: Lift f a -> Lift f a -> Lift f a # (Read1 f, Read a) => Read (Lift f a) # MethodsreadsPrec :: Int -> ReadS (Lift f a) Source #readList :: ReadS [Lift f a] Source #readPrec :: ReadPrec (Lift f a) Source # (Show1 f, Show a) => Show (Lift f a) # MethodsshowsPrec :: Int -> Lift f a -> ShowS Source #show :: Lift f a -> String Source #showList :: [Lift f a] -> ShowS Source #

unLift :: Applicative f => Lift f a -> f a Source #

Projection to the other functor.

mapLift :: (f a -> g a) -> Lift f a -> Lift g a Source #

Apply a transformation to the other computation.

# Collecting errors

type Errors e = Lift (Constant e) Source #

An applicative functor that collects a monoid (e.g. lists) of errors. A sequence of computations fails if any of its components do, but unlike monads made with ExceptT from Control.Monad.Trans.Except, these computations continue after an error, collecting all the errors.

• pure f <*> pure x = pure (f x)
• pure f <*> failure e = failure e
• failure e <*> pure x = failure e
• failure e1 <*> failure e2 = failure (e1 <> e2)

runErrors :: Errors e a -> Either e a Source #

Extractor for computations with accumulating errors.

• runErrors (pure x) = Right x
• runErrors (failure e) = Left e

failure :: e -> Errors e a Source #

Report an error.