objective-1.3: Composable objects
Copyright(c) Fumiaki Kinoshita 2015
LicenseBSD3
MaintainerFumiaki Kinoshita <fumiexcel@gmail.com>
Stabilityprovisional
PortabilityGADTs, Rank2Types
Safe HaskellSafe
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

Instances

Instances details
MonadTrans (Mortal f) Source # 
Instance details

Defined in Control.Object.Mortal

Methods

lift :: Monad m => m a -> Mortal f m a #

Monad m => Monad (Mortal f m) Source # 
Instance details

Defined in Control.Object.Mortal

Methods

(>>=) :: Mortal f m a -> (a -> Mortal f m b) -> Mortal f m b #

(>>) :: Mortal f m a -> Mortal f m b -> Mortal f m b #

return :: a -> Mortal f m a #

Monad m => Functor (Mortal f m) Source # 
Instance details

Defined in Control.Object.Mortal

Methods

fmap :: (a -> b) -> Mortal f m a -> Mortal f m b #

(<$) :: a -> Mortal f m b -> Mortal f m a #

Monad m => Applicative (Mortal f m) Source # 
Instance details

Defined in Control.Object.Mortal

Methods

pure :: a -> Mortal f m a #

(<*>) :: Mortal f m (a -> b) -> Mortal f m a -> Mortal f m b #

liftA2 :: (a -> b -> c) -> Mortal f m a -> Mortal f m b -> Mortal f m c #

(*>) :: Mortal f m a -> Mortal f m b -> Mortal f m b #

(<*) :: Mortal f m a -> Mortal f m b -> Mortal f m a #

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

Construct a mortal in a Object construction manner.

mortal_ :: Object f (ExceptT () g) -> Mortal f g () Source #

A smart constructor of Mortal where the result type is restricted to ()

runMortal :: Monad m => Mortal f m a -> f x -> ExceptT 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.

apprises :: (Witherable t, Monad 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.

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

Send a message to mortals in a container.