Copyright | (c) Ross Paterson 2003 |
---|---|
License | BSD-style (see the LICENSE file in the distribution) |
Maintainer | R.Paterson@city.ac.uk |
Stability | experimental |
Portability | non-portable (multi-parameter type classes) |
Safe Haskell | Safe-Inferred |
Language | Haskell98 |
Control.Arrow.Transformer.Writer
Description
Arrow transformer that adds accumulation of output.
Synopsis
- newtype WriterArrow w a b c = WriterArrow (a b (c, w))
- runWriter :: (Arrow a, Monoid w) => WriterArrow w a e b -> a e (b, w)
- class (ArrowWriter w a, Arrow a') => ArrowAddWriter w a a' | a -> a' where
- liftWriter :: a' e b -> a e b
- elimWriter :: a e b -> a' e (b, w)
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
(ArrowError ex a, Monoid w) => ArrowError ex (WriterArrow w a) Source # | |
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 # | |
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 # | |
Defined in Control.Arrow.Transformer.Writer | |
(ArrowReader r a, Monoid w) => ArrowReader r (WriterArrow w a) Source # | |
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 # | |
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 # | |
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 # | |
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 # | |
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 # | |
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 # | |
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 # | |
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') | |
(ArrowApply a, Monoid w) => ArrowApply (WriterArrow w a) Source # | |
Defined in Control.Arrow.Transformer.Writer Methods app :: WriterArrow w a (WriterArrow w a b c, b) c | |
(ArrowChoice a, Monoid w) => ArrowChoice (WriterArrow w a) Source # | |
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 | |
(ArrowLoop a, Monoid w) => ArrowLoop (WriterArrow w a) Source # | |
Defined in Control.Arrow.Transformer.Writer Methods loop :: WriterArrow w a (b, d) (c, d) -> WriterArrow w a b c | |
(ArrowPlus a, Monoid w) => ArrowPlus (WriterArrow w a) Source # | |
Defined in Control.Arrow.Transformer.Writer Methods (<+>) :: WriterArrow w a b c -> WriterArrow w a b c -> WriterArrow w a b c | |
(ArrowZero a, Monoid w) => ArrowZero (WriterArrow w a) Source # | |
Defined in Control.Arrow.Transformer.Writer Methods zeroArrow :: WriterArrow w a b c | |
(ArrowCircuit a, Monoid w) => ArrowCircuit (WriterArrow w a) Source # | |
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 # | |
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 # | |
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 # | |
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 # | |
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 # | |
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|)