copilot-libraries-4.8: Libraries for the Copilot language.

Safe Haskell | Safe-Inferred
Language | Haskell2010

Copilot.Library.StateMachines

Description

Simulate state machines using streams.

Synopsis

- type StateMachine a = (a, a, Stream Bool, [(a, Stream Bool, a)], a)
- stateMachine :: (Eq a, Typed a) => StateMachine a -> Stream a
- stateMachineEnum :: (Eq b, Typed b, Num b, Enum a) => StateMachine a -> Stream b

# Documentation

type StateMachine a = (a, a, Stream Bool, [(a, Stream Bool, a)], a) Source #

A definition of a state machine where some elements are defined as streams.

A state machine is defined by an initial state, a final state, a no transition stream (true when tere is no input coming in), a list of transitions, and a bad state.

stateMachine :: (Eq a, Typed a) => StateMachine a -> Stream a Source #

Produce a stream that, at any given time, contains the current state of the state machine.

stateMachineEnum :: (Eq b, Typed b, Num b, Enum a) => StateMachine a -> Stream b Source #

Produce a stream that, at any given time, contains the current state of the state machine as the numeric representation of an enum.