| Copyright | (c) Max Amanshauser 2016 |
|---|---|
| License | MIT |
| Maintainer | max@lambdalifting.org |
| Safe Haskell | None |
| Language | Haskell2010 |
Mealstrom.FSM
Contents
Description
These defintions are concerned with the basic functions of finite state machines, keeping a memory and state transitions.
- type MachineTransformer s e a = Machine s e a -> IO (Machine s e a)
- data MealyStatus
- = MealyError
- | Pending
- | Done
- class (Hashable k, Eq k) => FSMKey k where
- class FSMKey k => MealyInstance k s e a
- data Change s e a
- data Instance k s e a = Instance {}
- data Machine s e a = Machine {}
- mkEmptyMachine :: s -> Machine s e a
- mkEmptyInstance :: k -> s -> Instance k s e a
- mkInstance :: k -> s -> [Msg e] -> Instance k s e a
- data Msg e = Msg {
- msgID :: Maybe UUID
- msgContents :: e
- mkMsg :: t -> IO (Msg t)
- mkMsgs :: [t] -> IO [Msg t]
- mkBogusMsg :: Eq t => t -> Msg t
- histAppend :: (Eq s, Eq e) => Change s e a -> [Change s e a] -> [Change s e a]
Documentation
data MealyStatus Source #
A data type that often comes in handy when describing whether updates have succeeded in the backend.
Constructors
| MealyError | |
| Pending | |
| Done |
Instances
class (Hashable k, Eq k) => FSMKey k where Source #
FSMs are uniquely identified by a type k, which must be convertible from/to Text.
class FSMKey k => MealyInstance k s e a Source #
This typeclass is needed to provide a constraint for the FSMStore abstraction.
A change in a FSM is either a (Step Timestamp oldState event newState Actions) or an increase in a counter.
Instances
| (Eq s, Eq e) => Eq (Change s e a) Source # | Steps are equal to each other when they originated in the same state received the same event and ended up in the same state |
| (Show a, Show e, Show s) => Show (Change s e a) Source # | |
| (ToJSON s, ToJSON e, ToJSON a) => ToJSON (Change s e a) Source # | |
| (FromJSON s, FromJSON e, FromJSON a) => FromJSON (Change s e a) Source # | |
Constructors
| Machine | |
mkEmptyMachine :: s -> Machine s e a Source #
mkEmptyInstance :: k -> s -> Instance k s e a Source #
mkInstance :: k -> s -> [Msg e] -> Instance k s e a Source #
Type of messages that are sent between FSMs Messages are always identified by UUID. The purpose of Msg is to attach a unique ID to an event, so that certain guarantees can be provided.
Constructors
| Msg | |
Fields
| |
mkBogusMsg :: Eq t => t -> Msg t Source #
histAppend :: (Eq s, Eq e) => Change s e a -> [Change s e a] -> [Change s e a] Source #
Append a Change to a history. Identical steps are just counted, otherwise they are consed to the history.