objective-0.3: Extensible objects

Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Object

Synopsis

Documentation

newtype Object e m Source

The type 'Object e m' represents objects which can handle messages e, perform actions in the environment m. It can be thought of as an automaton that converts effects. Objects can be composed just like functions using .>>.; the identity element is echo.

Constructors

Object 

Fields

runObject :: forall x. e x -> m (x, Object e m)
 

Instances

Typeable ((* -> *) -> (* -> *) -> *) Object 

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.

echo :: Functor e => Object e e Source

Parrots messages given.

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

Compose two objects (aka Dependency Injection).

oneshot :: (Functor e, Monad m) => (forall a. e (m a) -> m a) -> Object e m Source

Build an object.

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

Build a stateful object.

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

Build a stateful object, sharing out the state.

class Stateful s f | f -> s where Source

Like MonadState, but doesn't require Monad as a prerequisite.

Methods

get_ :: f s Source

put_ :: s -> f () Source

Instances

(Functor f, Stateful s f) => Stateful s (Free f) 
Stateful s (AccessT s f) 

data AccessT s f a Source

Inflicts external state accessibility to arbitrary effects.

Constructors

Get (s -> a) 
Put s a 
LiftAccessT (f a) 

Instances

Stateful s (AccessT s f) 
Functor f => Functor (AccessT s f) 
Typeable (* -> (* -> *) -> * -> *) AccessT 

variable :: Applicative f => s -> Object (Access s) f Source

A mutable variable.

sequential :: Monad m => Object e m -> Object (Free e) m Source

Convert a method sequence into a sequential method execution.