Reaction box and stepping function. Reaction
s leave the monad parameter free for the programmer. Around m a state transformer gives them the chance to use per reaction state.
- data Reaction m = forall a b . (Typeable a, Show b, Read b, Typeable b) => Reaction {}
- step :: (Monad m, Functor m) => Reaction m -> Internal -> Maybe (m ([Reaction m], [Internal], Maybe (Reaction m)))
- type External = Serial
- type Internal = Untyped
- type Recover = Serial
- data Response m = Response {}
- prop_data_reactor_reaction :: Gen Bool
Documentation
A Reaction object is a container for a reaction. It's free in the type of value to react and in its internal state.
:: (Monad m, Functor m) | |
=> Reaction m | reaction box containing the reaction to try |
-> Internal | the event for the reaction |
-> Maybe (m ([Reaction m], [Internal], Maybe (Reaction m))) | new reactions, events and possibly a renewed Reaction, or Nothing if the reaction is dead |
Try a reaction of a Reaction, given an event in an Untyped box. If the event is not of the right type, the result is Nothing, otherwise an action in the monad m returning a modified Response
, with Bool mapped to Maybe (Reaction m).
The value reactions compute.