-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Extensible objects -- @package objective @version 1.0.3 module Control.Object.Object -- | The type Object f g represents objects which can handle -- messages f, perform actions in the environment g. It -- can be thought of as an automaton that converts effects. -- Objects can be composed just like functions using -- @>>@; the identity element is echo. Objects are -- morphisms of the category of actions. -- -- newtype Object f g Object :: (forall x. f x -> g (x, Object f g)) -> Object f g runObject :: Object f g -> forall x. f x -> g (x, Object f g) -- | An alias for runObject (@-) :: Object f g -> f x -> g (x, Object f g) class HProfunctor k (^>>@) :: (HProfunctor k, Functor h) => (forall x. f x -> g x) -> k g h -> k f h (@>>^) :: (HProfunctor k, Functor h) => k f g -> (forall x. g x -> h x) -> k f h -- | The trivial object echo :: Functor f => Object f f -- | Lift natural transformation into an object liftO :: Functor g => (forall x. f x -> g x) -> Object f g -- | Object composition (@>>@) :: Functor h => Object f g -> Object g h -> Object f h -- | Reversed '(>>)' (@<<@) :: Functor h => Object g h -> Object f g -> Object f h -- | The unwrapped analog of stateful unfoldO runObject = -- id unfoldO iterObject = iterable unfoldO :: Functor g => (forall a. r -> f a -> g (a, r)) -> r -> Object f g -- | Same as unfoldO but requires Monad instead unfoldOM :: Monad m => (forall a. r -> f a -> m (a, r)) -> r -> Object f m -- | Build a stateful object. -- -- stateful t s = t ^>> variable s@ stateful :: Monad m => (forall a. t a -> StateT s m a) -> s -> Object t m -- | Flipped stateful (@~) :: Monad m => s -> (forall a. t a -> StateT s m a) -> Object t m -- | Cascading iterObject :: Monad m => Object f m -> Free f a -> m (a, Object f m) -- | Objects can consume free monads iterative :: Monad m => Object f m -> Object (Free f) m -- | A mutable variable. variable :: Monad m => s -> Object (StateT s m) m -- | Send a message to objects in a container. announce :: (Traversable t, Monad m) => f a -> StateT (t (Object f m)) m [a] instance Typeable Object instance HProfunctor Object module Control.Object.Mortal -- | Object with a final result. -- --
--   Object f g ≡ Mortal f g Void
--   
newtype Mortal f g a Mortal :: Object f (EitherT a g) -> Mortal f g a unMortal :: Mortal f g a -> Object f (EitherT a g) -- | Construct a mortal in a Object construction manner. mortal :: (forall x. f x -> EitherT a m (x, Mortal f m a)) -> Mortal f m a -- | Restricted Mortal constuctor which can be applied to -- transit, fromFoldable without ambiguousness. mortal_ :: Object f (EitherT () g) -> Mortal f g () -- | Send a message to a mortal. runMortal :: Mortal f m a -> f x -> EitherT a m (x, Mortal f m a) -- | Turn an immortal into a mortal with eternal life. immortal :: Monad m => Object f m -> Mortal f m x -- | Send a message to mortals in a container. apprisesOf :: (Monad m, Monoid r) => ((Mortal f m b -> WriterT r m (Maybe (Mortal f m b))) -> s -> WriterT r m s) -> f a -> (a -> r) -> (b -> r) -> StateT s m r -- | Send a message to mortals in a container. apprises :: (Witherable t, Monad m, Applicative m, Monoid r) => f a -> (a -> r) -> (b -> r) -> StateT (t (Mortal f m b)) m r -- | Send a message to mortals in a container. apprise :: (Witherable t, Monad m, Applicative m) => f a -> StateT (t (Mortal f m r)) m ([a], [r]) withBuilder :: Functor f => ((a -> Endo [a]) -> f (Endo [a])) -> f [a] instance MonadTrans (Mortal f) instance Monad m => Monad (Mortal f m) instance (Functor m, Monad m) => Applicative (Mortal f m) instance (Functor m, Monad m) => Functor (Mortal f m) module Control.Object.Instance -- | TMVar-based instance data Instance f g InstRef :: TMVar (Object f g) -> Instance f g InstLmap :: (forall x. f x -> g x) -> Instance g h -> Instance f h InstRmap :: Instance f g -> (forall x. g x -> h x) -> Instance f h -- | Invoke a method with an explicit landing function. invokeOn :: (MonadIO m, MonadMask m) => (forall x. g x -> m x) -> Instance f g -> f a -> m a -- | Invoke a method with an explicit landing function. invokeOnSTM :: (forall x. g x -> STM x) -> Instance f g -> f a -> STM a -- | Invoke a method, atomically. (..-) :: MonadSTM m => Instance f STM -> f a -> m a -- | Invoke a method. (.-) :: (MonadIO m, MonadMask m) => Instance f m -> f a -> m a -- | Create a new instance. new :: MonadIO m => Object f g -> m (Instance f g) -- | Create a new instance, having it sitting on the current environment. newSettle :: MonadIO m => Object f m -> m (Instance f m) -- | Create a new instance. newSTM :: Object f g -> STM (Instance f g) instance HProfunctor Instance module Data.Functor.Request -- | Request a b is the type of a request that sends -- a to receive b. data Request a b r Request :: a -> (b -> r) -> Request a b r mapRequest :: (a -> a') -> Request a b r -> Request a' b r request :: a -> Request a b b accept :: Functor m => (a -> m b) -> Request a b r -> m r mealy :: Functor m => (a -> m (b, Object (Request a b) m)) -> Object (Request a b) m -- | The flyweight pattern flyweight :: (Applicative m, Eq k, Hashable k) => (k -> m a) -> Object (Request k a) m (>~~>) :: Monad m => Object (Request a b) m -> Object (Request b c) m -> Object (Request a c) m accumulator :: Applicative m => (b -> a -> b) -> b -> Object (Request a b) m -- |
--   animate f ≡ accumulator (+) 0 >~~> liftO (accept f)
--   
animate :: (Applicative m, Num t) => (t -> m a) -> Object (Request t a) m transit :: (Alternative m, Fractional t, Ord t) => t -> (t -> m a) -> Object (Request t a) m instance Typeable Request instance Functor (Request a b) instance Monoid a => Applicative (Request a b) instance Profunctor (Request a) -- | Stateful effect transducer: The Mealy machine for effects. module Control.Object