Copyright | (c) Hanzhong Xu Meng Meng 2016 |
---|---|
License | MIT License |
Maintainer | hanzh.xu@gmail.com |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
Arrowized functional state machines.
This module is inspired by Yampa and the paper Functional Reactive Programming, Continued* written by Henrik Nilsson, Antony Courtney and John Peterson.
- module Control.Arrow
- data Event a
- data SM a b
- type SMState s a b = s -> a -> (SM a b, b)
- newSM :: SMState s a b -> s -> SM a b
- simpleSM :: (s -> a -> (s, b)) -> s -> SM a b
- constSM :: b -> SM a b
- idSM :: SM a a
- foldlSM :: (s -> a -> s) -> s -> SM a s
- foldlDelaySM :: (s -> a -> s) -> s -> SM a s
- delaySM :: a -> SM a a
- execSM :: SM a b -> SM [a] [b]
- concatSM :: SM a [[b]] -> SM a [b]
- exec :: SM a b -> [a] -> (SM a b, [b])
Documentation
module Control.Arrow
Event
type, there are 4 different events: event a, no event, error event string and exit event.
The SM
type
SM
is a type representing a state machine.
The SMState
type
type SMState s a b = s -> a -> (SM a b, b) Source #
SMState
is the transition function
s: storage, a: input, b: output
Constructors
simpleSM :: (s -> a -> (s, b)) -> s -> SM a b Source #
build a simple SM which have only one SMState.
Basic State Machines
foldlDelaySM :: (s -> a -> s) -> s -> SM a s Source #
the difference from foldlSM is it output the storage first.
High order functions
execSM :: SM a b -> SM [a] [b] Source #
converts SM a b -> SM [a] [b], it is very useful to compose SM a [b] and SM b c to SM a [c].