objective-1.0.4: Composable objects

Copyright(c) Fumiaki Kinoshita 2015
LicenseBSD3
MaintainerFumiaki Kinoshita <fumiexcel@gmail.com>
Stabilityprovisional
PortabilityGADTs, Rank2Types
Safe HaskellTrustworthy
LanguageHaskell2010

Control.Object.Mortal

Description

 

Synopsis

Documentation

newtype Mortal f g a Source

A Mortal is an object that may die. A mortal yields a final result upon death. Mortal f g forms a Monad: return is a dead object and (>>=) prolongs the life of the left object.

Object f g ≡ Mortal f g Void

Constructors

Mortal 

Fields

unMortal :: Object f (EitherT a g)
 

Instances

MonadTrans (Mortal f) 
Monad m => Monad (Mortal f m) 
(Functor m, Monad m) => Functor (Mortal f m) 
(Functor m, Monad m) => Applicative (Mortal f m) 

mortal :: Monad m => (forall x. f x -> EitherT a m (x, Mortal f m a)) -> Mortal f m a Source

Construct a mortal in a Object construction manner.

mortal_ :: Object f (EitherT () g) -> Mortal f g () Source

Restricted Mortal constuctor which can be applied to transit, fromFoldable without ambiguousness.

runMortal :: Monad m => Mortal f m a -> f x -> EitherT a m (x, Mortal f m a) Source

Send a message to a mortal.

immortal :: Monad m => Object f m -> Mortal f m x Source

Turn an object into a mortal without death.

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 Source

Send a message to mortals through a filter.

apprises :: (Witherable t, Monad m, Applicative m, Monoid r) => f a -> (a -> r) -> (b -> r) -> StateT (t (Mortal f m b)) m r Source

Send a message to mortals in a Witherable container.

apprises = apprisesOf wither

apprise :: (Witherable t, Monad m, Applicative m) => f a -> StateT (t (Mortal f m r)) m ([a], [r]) Source

Send a message to mortals in a container.