mealstrom-0.0.0.1: Manipulate FSMs and store them in PostgreSQL.

Copyright(c) Max Amanshauser 2016
LicenseMIT
Maintainermax@lambdalifting.org
Safe HaskellNone
LanguageHaskell2010

Mealstrom.FSM

Contents

Description

These defintions are concerned with the basic functions of finite state machines, keeping a memory and state transitions.

Synopsis

Documentation

type MachineTransformer s e a = Machine s e a -> IO (Machine s e a) Source #

data MealyStatus Source #

A data type that often comes in handy when describing whether updates have succeeded in the backend.

Constructors

MealyError 
Pending 
Done 

class (Hashable k, Eq k) => FSMKey k where Source #

FSMs are uniquely identified by a type k, which must be convertible from/to Text.

Minimal complete definition

toText, fromText

Methods

toText :: k -> Text Source #

fromText :: Text -> k Source #

class FSMKey k => MealyInstance k s e a Source #

This typeclass is needed to provide a constraint for the FSMStore abstraction.

data Change s e a Source #

A change in a FSM is either a (Step Timestamp oldState event newState Actions) or an increase in a counter.

Constructors

Step UTCTime s e s [a] 
Count Int 

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

Methods

(==) :: Change s e a -> Change s e a -> Bool #

(/=) :: Change s e a -> Change s e a -> Bool #

(Show a, Show e, Show s) => Show (Change s e a) Source # 

Methods

showsPrec :: Int -> Change s e a -> ShowS #

show :: Change s e a -> String #

showList :: [Change s e a] -> ShowS #

(ToJSON s, ToJSON e, ToJSON a) => ToJSON (Change s e a) Source # 

Methods

toJSON :: Change s e a -> Value #

toEncoding :: Change s e a -> Encoding #

toJSONList :: [Change s e a] -> Value #

toEncodingList :: [Change s e a] -> Encoding #

(FromJSON s, FromJSON e, FromJSON a) => FromJSON (Change s e a) Source # 

Methods

parseJSON :: Value -> Parser (Change s e a) #

parseJSONList :: Value -> Parser [Change s e a] #

data Instance k s e a Source #

Constructors

Instance 

Fields

Instances

(Eq e, Eq a, Eq s, Eq k) => Eq (Instance k s e a) Source # 

Methods

(==) :: Instance k s e a -> Instance k s e a -> Bool #

(/=) :: Instance k s e a -> Instance k s e a -> Bool #

(Show e, Show a, Show s, Show k) => Show (Instance k s e a) Source # 

Methods

showsPrec :: Int -> Instance k s e a -> ShowS #

show :: Instance k s e a -> String #

showList :: [Instance k s e a] -> ShowS #

Generic (Instance k s e a) Source # 

Associated Types

type Rep (Instance k s e a) :: * -> * #

Methods

from :: Instance k s e a -> Rep (Instance k s e a) x #

to :: Rep (Instance k s e a) x -> Instance k s e a #

type Rep (Instance k s e a) Source # 
type Rep (Instance k s e a) = D1 (MetaData "Instance" "Mealstrom.FSM" "mealstrom-0.0.0.1-KyQkyZ1pogZ8aiEUm4n6QB" False) (C1 (MetaCons "Instance" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "key") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 k)) (S1 (MetaSel (Just Symbol "machine") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Machine s e a)))))

data Machine s e a Source #

Constructors

Machine 

Fields

Instances

(Eq s, Eq a, Eq e) => Eq (Machine s e a) Source # 

Methods

(==) :: Machine s e a -> Machine s e a -> Bool #

(/=) :: Machine s e a -> Machine s e a -> Bool #

(Show s, Show a, Show e) => Show (Machine s e a) Source # 

Methods

showsPrec :: Int -> Machine s e a -> ShowS #

show :: Machine s e a -> String #

showList :: [Machine s e a] -> ShowS #

Generic (Machine s e a) Source # 

Associated Types

type Rep (Machine s e a) :: * -> * #

Methods

from :: Machine s e a -> Rep (Machine s e a) x #

to :: Rep (Machine s e a) x -> Machine s e a #

type Rep (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 #

data Msg e 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

Instances

Eq e => Eq (Msg e) Source # 

Methods

(==) :: Msg e -> Msg e -> Bool #

(/=) :: Msg e -> Msg e -> Bool #

Show e => Show (Msg e) Source # 

Methods

showsPrec :: Int -> Msg e -> ShowS #

show :: Msg e -> String #

showList :: [Msg e] -> ShowS #

Generic (Msg e) Source # 

Associated Types

type Rep (Msg e) :: * -> * #

Methods

from :: Msg e -> Rep (Msg e) x #

to :: Rep (Msg e) x -> Msg e #

type Rep (Msg e) Source # 
type Rep (Msg e) = D1 (MetaData "Msg" "Mealstrom.FSM" "mealstrom-0.0.0.1-KyQkyZ1pogZ8aiEUm4n6QB" False) (C1 (MetaCons "Msg" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "msgID") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (Maybe UUID))) (S1 (MetaSel (Just Symbol "msgContents") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 e))))

mkMsg :: t -> IO (Msg t) Source #

mkMsgs :: [t] -> IO [Msg t] Source #

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.

Orphan instances