Safe Haskell | Safe-Inferred |
---|---|

Language | Haskell2010 |

- newtype Object e m = Object {}
- liftO :: Functor f => (forall x. e x -> f x) -> Object e f
- transObject :: Functor g => (forall x. f x -> g x) -> Object e f -> Object e g
- adaptObject :: Functor m => (forall x. e x -> f x) -> Object f m -> Object e m
- echo :: Functor e => Object e e
- (.>>.) :: Functor n => Object e m -> Object m n -> Object e n
- oneshot :: (Functor e, Monad m) => (forall a. e (m a) -> m a) -> Object e m
- stateful :: (Functor e, Monad m) => (forall a. e (StateT s m a) -> StateT s m a) -> s -> Object (AccessT s e) m
- class Stateful s f where
- data AccessT s f a
- = Get (s -> a)
- | Put s a
- | LiftAccessT (f a)

- variable :: Applicative f => s -> Object (AccessT s Zero) f

# Documentation

The type 'Object e m' represents objects which can handle messages `e`

, perform actions in the environment `m`

.
It can be thought of as a function between effects.
Thus, it can be composed just like functions using '(.>>.)' (not often needed); the identity element is `echo`

.

liftO :: Functor f => (forall x. e x -> f x) -> Object e f Source

Lift a natural transformation into an object.

transObject :: Functor g => (forall x. f x -> g x) -> Object e f -> Object e g Source

Change the workspace of the object.

adaptObject :: Functor m => (forall x. e x -> f x) -> Object f m -> Object e m Source

Apply a function to the messages coming into the object.

(.>>.) :: Functor n => Object e m -> Object m n -> Object e n Source

Compose two objects (aka Dependency Injection).

stateful :: (Functor e, Monad m) => (forall a. e (StateT s m a) -> StateT s m a) -> s -> Object (AccessT s e) m Source

Build a stateful object.

Inflicts external state accessibility to arbitrary effects.

Get (s -> a) | |

Put s a | |

LiftAccessT (f a) |