AFSM-0.1.1.3: Arrowized functional state machines

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

Control.AFSM

Contents

Description

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.

Synopsis

Documentation

data Event a Source

Constructors

E a 
NoE 
ErrE String 
ExitE 

Instances

Eq a => Eq (Event a) Source 
Ord a => Ord (Event a) Source 
Show a => Show (Event a) Source 

The SM type

data SM a b Source

SM is a type representing a state machine.

The SMState type

type SMState s a b = s -> a -> (SM a b, b) Source

Constructors

newSM :: s -> SMState s a b -> SM a b Source

newSM is the same with SM constructor.

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

simpleSM is to build a simple SM which have only one SMState.

Basic State Machines

constSM :: b -> SM a b Source

constSM build a SM which always return b

High order functions

execSM :: SM a b -> SM [a] [b] Source

execSM converts SM a b -> SM [a] [b], it is very useful to compose SM a [b] and SM b c to SM a [c].

Evaluation

exec :: SM a b -> [a] -> (SM a b, [b]) Source

execute SM a b with input [a].