arrows-0.4.4.1: Arrow classes and transformers

Copyright | (c) Ross Paterson 2003
License | BSD-style (see the LICENSE file in the distribution)
Maintainer | ross@soi.city.ac.uk
Stability | experimental
Portability | non-portable (multi-parameter type classes)
Safe Haskell | Safe
Language | Haskell98

Control.Arrow.Transformer.Automaton

Description

Simple Mealy-style automata.

Synopsis

- newtype Automaton a 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 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

Arrow a => ArrowTransformer Automaton a Source # |
Methods lift :: a b c -> Automaton a b c Source #
ArrowError r a => ArrowError r (Automaton a) Source # |
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 #
ArrowWriter w a => ArrowWriter w (Automaton a) Source # |
Methods write :: Automaton a w () Source # newWriter :: Automaton a e b -> Automaton a e (b, w) Source #
ArrowState s a => ArrowState s (Automaton a) Source # |
Methods fetch :: Automaton a e s Source # store :: Automaton a s () Source #
ArrowReader r a => ArrowReader r (Automaton a) Source # |
Methods readState :: Automaton a b r Source # newReader :: Automaton a e b -> Automaton a (e, r) b Source #
ArrowAddWriter w a a' => ArrowAddWriter w (Automaton a) (Automaton a') Source # |
Methods liftWriter :: Automaton a' e b -> Automaton a e b Source # elimWriter :: Automaton a e b -> Automaton a' e (b, w) Source #
ArrowAddReader r a a' => ArrowAddReader r (Automaton a) (Automaton a') Source # |
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 # |
Methods liftState :: Automaton a' e b -> Automaton a e b Source # elimState :: Automaton a e b -> Automaton a' (e, r) (b, r) Source #
Arrow a => Arrow (Automaton a) Source # |
Methods arr :: (b -> c) -> Automaton a b c # first :: Automaton a b c -> Automaton a (b, d) (c, d) # second :: Automaton a b c -> Automaton a (d, b) (d, c) # (***) :: Automaton a b c -> Automaton a b' c' -> Automaton a (b, b') (c, c') # (&&&) :: Automaton a b c -> Automaton a b c' -> Automaton a b (c, c') #
ArrowZero a => ArrowZero (Automaton a) Source # |
Methods zeroArrow :: Automaton a b c #
ArrowPlus a => ArrowPlus (Automaton a) Source # |
Methods (<+>) :: Automaton a b c -> Automaton a b c -> Automaton a b c #
ArrowChoice a => ArrowChoice (Automaton a) Source # |
Methods left :: Automaton a b c -> Automaton a (Either b d) (Either c d) # right :: Automaton a b c -> Automaton a (Either d b) (Either d c) # (+++) :: Automaton a b c -> Automaton a b' c' -> Automaton a (Either b b') (Either c c') # (|||) :: Automaton a b d -> Automaton a c d -> Automaton a (Either b c) d #
ArrowLoop a => ArrowLoop (Automaton a) Source # |
Methods loop :: Automaton a (b, d) (c, d) -> Automaton a b c #
ArrowLoop a => ArrowCircuit (Automaton a) Source # |
Methods delay :: b -> Automaton a b b Source #
(ArrowLoop a, ArrowApply a) => ArrowAddStream (Automaton a) a Source # |
Methods liftStream :: a e b -> Automaton a e b Source # elimStream :: Automaton a (e, b) c -> a (e, Stream b) (Stream c) Source #
Arrow a => Category * (Automaton a) Source # |
Methods id :: cat a a # (.) :: cat b c -> cat a b -> cat a c #
Arrow a => Functor (Automaton a b) Source # |
Methods fmap :: (a -> b) -> Automaton a b a -> Automaton a b b # (<$) :: a -> Automaton a b b -> Automaton a b a #
Arrow a => Applicative (Automaton a b) Source # |
Methods pure :: a -> Automaton a b a # (<*>) :: Automaton a b (a -> b) -> Automaton a b a -> Automaton a b b # (*>) :: Automaton a b a -> Automaton a b b -> Automaton a b b # (<*) :: Automaton a b a -> Automaton a b b -> Automaton a b a #
ArrowPlus a => Alternative (Automaton a b) Source # |
Methods empty :: Automaton a b a # (<|>) :: Automaton a b a -> Automaton a b a -> Automaton a b a # some :: Automaton a b a -> Automaton a b [a] # many :: Automaton a b a -> Automaton a b [a] #
ArrowPlus a => Monoid (Automaton a b c) Source # |
Methods mempty :: Automaton a b c # mappend :: Automaton a b c -> Automaton a b c -> Automaton a b c # mconcat :: [Automaton a b c] -> Automaton a b c #

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.