-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Extensible objects
--
@package objective
@version 0.0
module Control.Object
-- | The type 'Object e m' represents objects which can handle messages
-- e, perform actions in the Monad m. It can be
-- thought of as a function where both domain and codomain are effects.
-- Thus, it can be composed just like functions using '(.>>.)' (not
-- often needed); the identity element is echo.
newtype Object e m
Object :: (forall x. e x -> m (x, Object e m)) -> Object e m
runObject :: Object e m -> forall x. e x -> m (x, Object e m)
-- | Change the workspace of the object.
transObject :: Monad n => (forall x. m x -> n x) -> Object e m -> Object e n
-- | Apply a function to the messages coming into the object.
adaptObject :: Monad m => (forall x. e x -> f x) -> Object f m -> Object e m
-- | Parrots messages given.
echo :: Functor e => Object e e
-- | Compose two objects (aka Dependency Injection).
(.>>.) :: Monad n => Object e m -> Object m n -> Object e n
-- | Build an object.
oneshot :: (Functor e, Monad m) => (forall a. e (m a) -> m a) -> Object e m
-- | Build a stateful object.
stateful :: (Functor e, Monad m) => (forall a. e (StateT s m a) -> StateT s m a) -> s -> Object (AccessT s e) m
-- | Like MonadState, but doesn't require Monad as a
-- prerequisite.
class Stateful s f
get_ :: Stateful s f => f s
put_ :: Stateful s f => s -> f ()
-- | Inflicts external state accessibility to arbitrary effects.
data AccessT s f a
Get :: (s -> a) -> AccessT s f a
Put :: s -> a -> AccessT s f a
LiftAccessT :: (f a) -> AccessT s f a
variable :: Monad m => s -> Object (AccessT s Zero) m
instance Typeable Object
instance Typeable AccessT
instance Functor f => Functor (AccessT s f)
instance Stateful s (AccessT s f)
module Control.Monad.Objective.Class
class Monad m => MonadObjective s m where type family Base m :: * -> * data family Control s (e :: * -> *)
(.-) :: MonadObjective s m => Control s e -> e a -> m a
invoke :: MonadObjective s m => Object e (Base m) -> m (Control s e)
(.&) :: (MonadObjective k m, Stateful s e) => Control k e -> StateT s m a -> m a