arrows-0.4.4.2: Arrow classes and transformers
Copyright(c) Ross Paterson 2003
LicenseBSD-style (see the LICENSE file in the distribution)
MaintainerR.Paterson@city.ac.uk
Stabilityexperimental
Portabilitynon-portable (multi-parameter type classes)
Safe HaskellSafe-Inferred
LanguageHaskell98

Control.Arrow.Transformer.Writer

Description

Arrow transformer that adds accumulation of output.

Synopsis

Documentation

newtype WriterArrow w a b c Source #

An arrow type that augments an existing arrow with accumulating output. The ArrowWriter class contains the relevant operations.

Constructors

WriterArrow (a b (c, w)) 

Instances

Instances details
(ArrowError ex a, Monoid w) => ArrowError ex (WriterArrow w a) Source # 
Instance details

Defined in Control.Arrow.Transformer.Writer

Methods

raise :: WriterArrow w a ex b Source #

handle :: WriterArrow w a e b -> WriterArrow w a (e, ex) b -> WriterArrow w a e b Source #

tryInUnless :: WriterArrow w a e b -> WriterArrow w a (e, b) c -> WriterArrow w a (e, ex) c -> WriterArrow w a e c Source #

newError :: WriterArrow w a e b -> WriterArrow w a e (Either ex b) Source #

(Arrow a, Monoid w) => ArrowWriter w (WriterArrow w a) Source # 
Instance details

Defined in Control.Arrow.Transformer.Writer

Methods

write :: WriterArrow w a w () Source #

newWriter :: WriterArrow w a e b -> WriterArrow w a e (b, w) Source #

(ArrowState s a, Monoid w) => ArrowState s (WriterArrow w a) Source # 
Instance details

Defined in Control.Arrow.Transformer.Writer

Methods

fetch :: WriterArrow w a e s Source #

store :: WriterArrow w a s () Source #

(ArrowReader r a, Monoid w) => ArrowReader r (WriterArrow w a) Source # 
Instance details

Defined in Control.Arrow.Transformer.Writer

Methods

readState :: WriterArrow w a b r Source #

newReader :: WriterArrow w a e b -> WriterArrow w a (e, r) b Source #

(Arrow a, Monoid w) => ArrowAddWriter w (WriterArrow w a) a Source # 
Instance details

Defined in Control.Arrow.Transformer.Writer

Methods

liftWriter :: a e b -> WriterArrow w a e b Source #

elimWriter :: WriterArrow w a e b -> a e (b, w) Source #

(ArrowAddError ex a a', Monoid w) => ArrowAddError ex (WriterArrow w a) (WriterArrow w a') Source # 
Instance details

Defined in Control.Arrow.Transformer.Writer

Methods

liftError :: WriterArrow w a' e b -> WriterArrow w a e b Source #

elimError :: WriterArrow w a e b -> WriterArrow w a' (e, ex) b -> WriterArrow w a' e b Source #

(ArrowAddReader r a a', Monoid w) => ArrowAddReader r (WriterArrow w a) (WriterArrow w a') Source # 
Instance details

Defined in Control.Arrow.Transformer.Writer

Methods

liftReader :: WriterArrow w a' e b -> WriterArrow w a e b Source #

elimReader :: WriterArrow w a e b -> WriterArrow w a' (e, r) b Source #

(ArrowAddState s a a', Monoid w) => ArrowAddState s (WriterArrow w a) (WriterArrow w a') Source # 
Instance details

Defined in Control.Arrow.Transformer.Writer

Methods

liftState :: WriterArrow w a' e b -> WriterArrow w a e b Source #

elimState :: WriterArrow w a e b -> WriterArrow w a' (e, s) (b, s) Source #

(Arrow a, Monoid w) => ArrowTransformer (WriterArrow w) a Source # 
Instance details

Defined in Control.Arrow.Transformer.Writer

Methods

lift :: a b c -> WriterArrow w a b c Source #

(Arrow a, Monoid w) => Category (WriterArrow w a :: Type -> Type -> Type) Source # 
Instance details

Defined in Control.Arrow.Transformer.Writer

Methods

id :: forall (a0 :: k). WriterArrow w a a0 a0 #

(.) :: forall (b :: k) (c :: k) (a0 :: k). WriterArrow w a b c -> WriterArrow w a a0 b -> WriterArrow w a a0 c #

(Arrow a, Monoid w) => Arrow (WriterArrow w a) Source # 
Instance details

Defined in Control.Arrow.Transformer.Writer

Methods

arr :: (b -> c) -> WriterArrow w a b c #

first :: WriterArrow w a b c -> WriterArrow w a (b, d) (c, d) #

second :: WriterArrow w a b c -> WriterArrow w a (d, b) (d, c) #

(***) :: WriterArrow w a b c -> WriterArrow w a b' c' -> WriterArrow w a (b, b') (c, c') #

(&&&) :: WriterArrow w a b c -> WriterArrow w a b c' -> WriterArrow w a b (c, c') #

(ArrowZero a, Monoid w) => ArrowZero (WriterArrow w a) Source # 
Instance details

Defined in Control.Arrow.Transformer.Writer

Methods

zeroArrow :: WriterArrow w a b c #

(ArrowPlus a, Monoid w) => ArrowPlus (WriterArrow w a) Source # 
Instance details

Defined in Control.Arrow.Transformer.Writer

Methods

(<+>) :: WriterArrow w a b c -> WriterArrow w a b c -> WriterArrow w a b c #

(ArrowChoice a, Monoid w) => ArrowChoice (WriterArrow w a) Source # 
Instance details

Defined in Control.Arrow.Transformer.Writer

Methods

left :: WriterArrow w a b c -> WriterArrow w a (Either b d) (Either c d) #

right :: WriterArrow w a b c -> WriterArrow w a (Either d b) (Either d c) #

(+++) :: WriterArrow w a b c -> WriterArrow w a b' c' -> WriterArrow w a (Either b b') (Either c c') #

(|||) :: WriterArrow w a b d -> WriterArrow w a c d -> WriterArrow w a (Either b c) d #

(ArrowApply a, Monoid w) => ArrowApply (WriterArrow w a) Source # 
Instance details

Defined in Control.Arrow.Transformer.Writer

Methods

app :: WriterArrow w a (WriterArrow w a b c, b) c #

(ArrowLoop a, Monoid w) => ArrowLoop (WriterArrow w a) Source # 
Instance details

Defined in Control.Arrow.Transformer.Writer

Methods

loop :: WriterArrow w a (b, d) (c, d) -> WriterArrow w a b c #

(ArrowCircuit a, Monoid w) => ArrowCircuit (WriterArrow w a) Source # 
Instance details

Defined in Control.Arrow.Transformer.Writer

Methods

delay :: b -> WriterArrow w a b b Source #

(Arrow a, Monoid w) => Functor (WriterArrow w a b) Source # 
Instance details

Defined in Control.Arrow.Transformer.Writer

Methods

fmap :: (a0 -> b0) -> WriterArrow w a b a0 -> WriterArrow w a b b0 #

(<$) :: a0 -> WriterArrow w a b b0 -> WriterArrow w a b a0 #

(Arrow a, Monoid w) => Applicative (WriterArrow w a b) Source # 
Instance details

Defined in Control.Arrow.Transformer.Writer

Methods

pure :: a0 -> WriterArrow w a b a0 #

(<*>) :: WriterArrow w a b (a0 -> b0) -> WriterArrow w a b a0 -> WriterArrow w a b b0 #

liftA2 :: (a0 -> b0 -> c) -> WriterArrow w a b a0 -> WriterArrow w a b b0 -> WriterArrow w a b c #

(*>) :: WriterArrow w a b a0 -> WriterArrow w a b b0 -> WriterArrow w a b b0 #

(<*) :: WriterArrow w a b a0 -> WriterArrow w a b b0 -> WriterArrow w a b a0 #

(ArrowPlus a, Monoid w) => Alternative (WriterArrow w a b) Source # 
Instance details

Defined in Control.Arrow.Transformer.Writer

Methods

empty :: WriterArrow w a b a0 #

(<|>) :: WriterArrow w a b a0 -> WriterArrow w a b a0 -> WriterArrow w a b a0 #

some :: WriterArrow w a b a0 -> WriterArrow w a b [a0] #

many :: WriterArrow w a b a0 -> WriterArrow w a b [a0] #

(ArrowPlus a, Monoid w) => Semigroup (WriterArrow w a b c) Source # 
Instance details

Defined in Control.Arrow.Transformer.Writer

Methods

(<>) :: WriterArrow w a b c -> WriterArrow w a b c -> WriterArrow w a b c #

sconcat :: NonEmpty (WriterArrow w a b c) -> WriterArrow w a b c #

stimes :: Integral b0 => b0 -> WriterArrow w a b c -> WriterArrow w a b c #

(ArrowPlus a, Monoid w) => Monoid (WriterArrow w a b c) Source # 
Instance details

Defined in Control.Arrow.Transformer.Writer

Methods

mempty :: WriterArrow w a b c #

mappend :: WriterArrow w a b c -> WriterArrow w a b c -> WriterArrow w a b c #

mconcat :: [WriterArrow w a b c] -> WriterArrow w a b c #

runWriter :: (Arrow a, Monoid w) => WriterArrow w a e b -> a e (b, w) Source #

Encapsulation of a writer computation, providing the accumulated output.

Typical usage in arrow notation:

   proc p -> do
       ...
       (result, output) <- (|runWriter cmd|)

class (ArrowWriter w a, Arrow a') => ArrowAddWriter w a a' | a -> a' where Source #

Adding a WriterArrow to an arrow type, but not necessarily as the outer arrow transformer.

Typically a composite arrow type is built by applying a series of arrow transformer to a base arrow (usually either a function arrow or a Kleisli arrow. One can add a transformer to the top of this stack using the lift method of the ArrowTransformer class, or remove a state transformer from the top of the stack using the runWriter encapsulation operator. The methods of this class add and remove state transformers anywhere in the stack. In the instance

   instance Arrow a => ArrowAddWriter w (ArrowWriter w a) a

they are equivalent to lift and runWriter respectively. Instances are lifted through other transformers with

   instance ArrowAddWriter w a a' =>
       ArrowAddWriter w (FooArrow a) (FooArrow a')

Methods

liftWriter :: a' e b -> a e b Source #

Lift a computation from an arrow to one with added output.

Typical usage in arrow notation:

   proc p -> ...
       (|liftWriter cmd|)

elimWriter :: a e b -> a' e (b, w) Source #

Elimination of an output writer from a computation, providing the accumulated output.

Typical usage in arrow notation:

   proc p -> do
       ...
       (result, output) <- (|elimWriter cmd|)

Instances

Instances details
ArrowAddWriter w a a' => ArrowAddWriter w (Automaton a) (Automaton a') Source # 
Instance details

Defined in Control.Arrow.Transformer.Automaton

Methods

liftWriter :: Automaton a' e b -> Automaton a e b Source #

elimWriter :: Automaton a e b -> Automaton a' e (b, w) Source #

(Arrow a, Monoid w) => ArrowAddWriter w (WriterArrow w a) a Source # 
Instance details

Defined in Control.Arrow.Transformer.Writer

Methods

liftWriter :: a e b -> WriterArrow w a e b Source #

elimWriter :: WriterArrow w a e b -> a e (b, w) Source #

(ArrowAddWriter w a a', ArrowChoice a, ArrowChoice a') => ArrowAddWriter w (ErrorArrow ex a) (ErrorArrow ex a') Source # 
Instance details

Defined in Control.Arrow.Transformer.Error

Methods

liftWriter :: ErrorArrow ex a' e b -> ErrorArrow ex a e b Source #

elimWriter :: ErrorArrow ex a e b -> ErrorArrow ex a' e (b, w) Source #

ArrowAddWriter s a a' => ArrowAddWriter s (ReaderArrow r a) (ReaderArrow r a') Source # 
Instance details

Defined in Control.Arrow.Transformer.Reader

Methods

liftWriter :: ReaderArrow r a' e b -> ReaderArrow r a e b Source #

elimWriter :: ReaderArrow r a e b -> ReaderArrow r a' e (b, s) Source #

ArrowAddWriter w a a' => ArrowAddWriter w (StateArrow s a) (StateArrow s a') Source # 
Instance details

Defined in Control.Arrow.Transformer.State

Methods

liftWriter :: StateArrow s a' e b -> StateArrow s a e b Source #

elimWriter :: StateArrow s a e b -> StateArrow s a' e (b, w) Source #

(ArrowAddWriter w a a', Applicative f) => ArrowAddWriter w (StaticArrow f a) (StaticArrow f a') Source # 
Instance details

Defined in Control.Arrow.Transformer.Static

Methods

liftWriter :: StaticArrow f a' e b -> StaticArrow f a e b Source #

elimWriter :: StaticArrow f a e b -> StaticArrow f a' e (b, w) Source #