motor-0.4.0: Type-safe effectful state machines in Haskell

Safe HaskellNone
LanguageHaskell2010

Motor.FSM.Class

Description

The MonadFSM class is the indexed monad for finite-state machines.

Synopsis

Documentation

class IxMonad m => MonadFSM (m :: Row * -> Row * -> * -> *) where Source #

An indexed monad for finite-state machines, managing the state of named resources.

Methods

new :: Name n -> a -> m r (Extend n a r) () Source #

Creates a new resource by name.

get :: HasType n a r => Name n -> m r r a Source #

Returns an existing resource.

delete :: Name n -> m r (r .- n) () Source #

Deletes an existing resource named by its Name.

enter :: r' ~ ((n .== b) .// r) => Name n -> b -> m r r' () Source #

Replaces the state of an existing resource named by its Name.

update :: (HasType n a r, Modify n a r ~ r) => Name n -> (a -> a) -> m r r () Source #

Updates the state, using a pure function, of an existing resource named by its Name.

call :: m Empty Empty a -> m r r a Source #

Embed another MonadFSM computation, with empty resource rows, in this computation.

Instances
Monad m => MonadFSM (FSM m) Source # 
Instance details

Defined in Motor.FSM

Methods

new :: Name n -> a -> FSM m r (Extend n a r) () Source #

get :: HasType n a r => Name n -> FSM m r r a Source #

delete :: Name n -> FSM m r (r .- n) () Source #

enter :: r' ~ ((n .== b) .// r) => Name n -> b -> FSM m r r' () Source #

update :: (HasType n a r, Modify n a r ~ r) => Name n -> (a -> a) -> FSM m r r () Source #

call :: FSM m Empty Empty a -> FSM m r r a Source #

data Name (n :: Symbol) where Source #

A name of a resource, represented using a Symbol.

Constructors

Name :: KnownSymbol n => Name n 
Instances
(KnownSymbol n, n ~ n') => IsLabel n (Name n') Source # 
Instance details

Defined in Motor.FSM.Class

Methods

fromLabel :: Name n' #