AFSM-0.1.3.1: Arrowized functional state machines

Copyright(c) Hanzhong Xu, Meng Meng 2016,
LicenseMIT License
Maintainerhanzh.xu@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

Control.AFSM.CoreType

Description

 

Synopsis

Documentation

newtype TF s a b Source #

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

Constructors

TF (s -> a -> (SM s a b, b)) 

type STF s a b = s -> a -> (s, b) Source #

STF is the type of simple transition function.

data SM s a b Source #

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

Constructors

SM (TF s a b) s 

Instances

Show s => Show (SM s a b) Source # 

Methods

showsPrec :: Int -> SM s a b -> ShowS #

show :: SM s a b -> String #

showList :: [SM s a b] -> ShowS #

tf :: SM s a b -> s -> a -> (SM s a b, b) Source #

st :: SM s a b -> s Source #

newSM :: (s -> a -> (SM s a b, b)) -> s -> SM s a b Source #

It is the same with the SM constructor.

simpleSM :: (s -> a -> (s, b)) -> s -> SM s a b Source #

build a simple SM which have only one TF.

type SMH a b = SM () a b Source #

SMH is the type of the state machine with hidden or no storage. It is the same type with Circuit a b = Circuit (a -> Circuit a b, b)

data Event a Source #

Event type, there are 4 different events: event a, no event, error event string and exit event.

Instances

Eq a => Eq (Event a) Source # 

Methods

(==) :: Event a -> Event a -> Bool #

(/=) :: Event a -> Event a -> Bool #

Ord a => Ord (Event a) Source # 

Methods

compare :: Event a -> Event a -> Ordering #

(<) :: Event a -> Event a -> Bool #

(<=) :: Event a -> Event a -> Bool #

(>) :: Event a -> Event a -> Bool #

(>=) :: Event a -> Event a -> Bool #

max :: Event a -> Event a -> Event a #

min :: Event a -> Event a -> Event a #

Show a => Show (Event a) Source # 

Methods

showsPrec :: Int -> Event a -> ShowS #

show :: Event a -> String #

showList :: [Event a] -> ShowS #