Copyright | (c) Hanzhong Xu, Meng Meng 2016, |
---|---|
License | MIT License |
Maintainer | hanzh.xu@gmail.com |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
- newtype TF s a b = TF (s -> a -> (SM s a b, b))
- type STF s a b = s -> a -> (s, b)
- data SM s a b = SM (TF s a b) s
- tf :: SM s a b -> s -> a -> (SM s a b, b)
- st :: SM s a b -> s
- newSM :: (s -> a -> (SM s a b, b)) -> s -> SM s a b
- simpleSM :: (s -> a -> (s, b)) -> s -> SM s a b
- type SMH a b = SM () a b
- data Event a
Documentation
TF
is a type representing a transition function.
s: storage, a: input, b: output
Let's explain more about TF
. When a state gets an input a,
it should do three things base on the storage and input:
find the next state, update storage and output b.
That's why it looks like this:
(storage -> a -> (SM newState newStorage, b))
type TF storage input output = (storage -> input -> (SM storage input output, output))
Also, it is an instance of Arrow, it represents a machine without initial storage.
composing two TF represents that two SM shares the same storage
SM
is a type representing a state machine.
(TF s a b): initial state(transition function), s: initial storage
SM storage input output = SM (TF storage input output) storage