arrows-0.4.4.2: Arrow classes and transformers

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.Automaton

Description

Simple Mealy-style automata.

Synopsis

- newtype Automaton (a :: Type -> Type -> Type) b c = Automaton (a b (c, Automaton a b c))
- runAutomaton :: (ArrowLoop a, ArrowApply a) => Automaton a (e, b) c -> a (e, Stream b) (Stream c)

# Documentation

newtype Automaton (a :: Type -> Type -> Type) b c Source #

An arrow type comprising Mealy-style automata, each step of which is is a computation in the original arrow type.

Constructors

Automaton (a b (c, Automaton a b c)) |

#### Instances

Instances details

Arrow a => ArrowTransformer Automaton a Source # |
Instance details Defined in Control.Arrow.Transformer.Automaton Methods lift :: a b c -> Automaton a b c Source #
ArrowError r a => ArrowError r (Automaton a) Source # |
Instance details Defined in Control.Arrow.Transformer.Automaton Methods raise :: Automaton a r b Source # handle :: Automaton a e b -> Automaton a (e, r) b -> Automaton a e b Source # tryInUnless :: Automaton a e b -> Automaton a (e, b) c -> Automaton a (e, r) c -> Automaton a e c Source # newError :: Automaton a e b -> Automaton a e (Either r b) Source #
ArrowReader r a => ArrowReader r (Automaton a) Source # |
Instance details Defined in Control.Arrow.Transformer.Automaton Methods readState :: Automaton a b r Source # newReader :: Automaton a e b -> Automaton a (e, r) b Source #
ArrowState s a => ArrowState s (Automaton a) Source # |
Instance details Defined in Control.Arrow.Transformer.Automaton Methods fetch :: Automaton a e s Source # store :: Automaton a s () Source #
ArrowWriter w a => ArrowWriter w (Automaton a) Source # |
Instance details Defined in Control.Arrow.Transformer.Automaton Methods write :: Automaton a w () Source # newWriter :: Automaton a e b -> Automaton a e (b, w) Source #
Arrow a => Category (Automaton a :: Type -> Type -> Type) Source # |
Instance details Defined in Control.Arrow.Transformer.Automaton Methods id :: Automaton a a0 a0 Source # (.) :: Automaton a b c -> Automaton a a0 b -> Automaton a a0 c Source #
ArrowAddReader r a a' => ArrowAddReader r (Automaton a) (Automaton a') Source # |
Instance details Defined in Control.Arrow.Transformer.Automaton Methods liftReader :: Automaton a' e b -> Automaton a e b Source # elimReader :: Automaton a e b -> Automaton a' (e, r) b Source #
ArrowAddState r a a' => ArrowAddState r (Automaton a) (Automaton a') Source # |
Instance details Defined in Control.Arrow.Transformer.Automaton Methods liftState :: Automaton a' e b -> Automaton a e b Source # elimState :: Automaton a e b -> Automaton a' (e, r) (b, r) Source #
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 #
ArrowLoop a => ArrowCircuit (Automaton a) Source # |
Instance details Defined in Control.Arrow.Transformer.Automaton Methods delay :: b -> Automaton a b b Source #
Arrow a => Arrow (Automaton a) Source # |

Instance details

Defined in Control.Arrow.Transformer.Automaton

Methods

arr :: (b -> c) -> Automaton a b c Source #

first :: Automaton a b c -> Automaton a (b, d) (c, d) Source #

second :: Automaton a b c -> Automaton a (d, b) (d, c) Source #

(***) :: Automaton a b c -> Automaton a b' c' -> Automaton a (b, b') (c, c') Source #

(&&&) :: Automaton a b c -> Automaton a b c' -> Automaton a b (c, c') Source #

ArrowChoice a => ArrowChoice (Automaton a) Source # |

Instance details

Defined in Control.Arrow.Transformer.Automaton

Methods

left :: Automaton a b c -> Automaton a (Either b d) (Either c d) Source #

right :: Automaton a b c -> Automaton a (Either d b) (Either d c) Source #

(+++) :: Automaton a b c -> Automaton a b' c' -> Automaton a (Either b b') (Either c c') Source #

(|||) :: Automaton a b d -> Automaton a c d -> Automaton a (Either b c) d Source #

ArrowLoop a => ArrowLoop (Automaton a) Source # |
Instance details Defined in Control.Arrow.Transformer.Automaton Methods loop :: Automaton a (b, d) (c, d) -> Automaton a b c Source #
ArrowPlus a => ArrowPlus (Automaton a) Source # |
Instance details Defined in Control.Arrow.Transformer.Automaton Methods (<+>) :: Automaton a b c -> Automaton a b c -> Automaton a b c Source #
ArrowZero a => ArrowZero (Automaton a) Source # |
Instance details Defined in Control.Arrow.Transformer.Automaton Methods zeroArrow :: Automaton a b c Source #
(ArrowLoop a, ArrowApply a) => ArrowAddStream (Automaton a) a Source # |
Instance details Defined in Control.Arrow.Transformer.Automaton Methods liftStream :: a e b -> Automaton a e b Source # elimStream :: Automaton a (e, b) c -> a (e, Stream b) (Stream c) Source #
ArrowPlus a => Alternative (Automaton a b) Source # |
Instance details Defined in Control.Arrow.Transformer.Automaton Methods empty :: Automaton a b a0 Source # (<|>) :: Automaton a b a0 -> Automaton a b a0 -> Automaton a b a0 Source # some :: Automaton a b a0 -> Automaton a b [a0] Source # many :: Automaton a b a0 -> Automaton a b [a0] Source #
Arrow a => Applicative (Automaton a b) Source # |

Instance details

Defined in Control.Arrow.Transformer.Automaton

Methods

pure :: a0 -> Automaton a b a0 Source #

(<*>) :: Automaton a b (a0 -> b0) -> Automaton a b a0 -> Automaton a b b0 Source #

liftA2 :: (a0 -> b0 -> c) -> Automaton a b a0 -> Automaton a b b0 -> Automaton a b c Source #

(*>) :: Automaton a b a0 -> Automaton a b b0 -> Automaton a b b0 Source #

(<*) :: Automaton a b a0 -> Automaton a b b0 -> Automaton a b a0 Source #

Arrow a => Functor (Automaton a b) Source # |
Instance details Defined in Control.Arrow.Transformer.Automaton Methods fmap :: (a0 -> b0) -> Automaton a b a0 -> Automaton a b b0 Source # (<$) :: a0 -> Automaton a b b0 -> Automaton a b a0 Source #
ArrowPlus a => Monoid (Automaton a b c) Source # |
Instance details Defined in Control.Arrow.Transformer.Automaton Methods mempty :: Automaton a b c Source # mappend :: Automaton a b c -> Automaton a b c -> Automaton a b c Source # mconcat :: [Automaton a b c] -> Automaton a b c Source #
ArrowPlus a => Semigroup (Automaton a b c) Source # |
Instance details Defined in Control.Arrow.Transformer.Automaton Methods (<>) :: Automaton a b c -> Automaton a b c -> Automaton a b c Source # sconcat :: NonEmpty (Automaton a b c) -> Automaton a b c Source # stimes :: Integral b0 => b0 -> Automaton a b c -> Automaton a b c Source #

runAutomaton :: (ArrowLoop a, ArrowApply a) => Automaton a (e, b) c -> a (e, Stream b) (Stream c) Source #

Encapsulating an automaton by running it on a stream of inputs, obtaining a stream of outputs.

Typical usage in arrow notation:

       proc p -> do
           ...
           ys <- (|runAutomaton (\x -> ...)|) xs

Here `xs` refers to the input stream and `x` to individual elements of that stream. `ys` is bound to the output stream.