shade-0.1.0.4: A control structure used to combine heterogenous types with delayed effects.

Safe HaskellSafe
LanguageHaskell2010

Control.Monad.Shade

Description

A control structure used to combine heterogenous types with delayed effects.

Synopsis

Documentation

data Shade m b Source #

A shade consists of a hidden value and an image of that value. The hidden values are stored in a context and cannot be accessed directly.

Instances

Monad m => Monad (Shade m) Source #

m >>= f applies f to the projected value inside the original context of m. The result is the a shade which becomes the source object in the result. This resut is nested twice inside the same context, and these are joined together.

Methods

(>>=) :: Shade m a -> (a -> Shade m b) -> Shade m b #

(>>) :: Shade m a -> Shade m b -> Shade m b #

return :: a -> Shade m a #

fail :: String -> Shade m a #

Functor (Shade m) Source #

fmap applies a function to the result of the projected value inside the values original context.

Methods

fmap :: (a -> b) -> Shade m a -> Shade m b #

(<$) :: a -> Shade m b -> Shade m a #

Applicative m => Applicative (Shade m) Source #

pure is the identity projection of the original value stored in a pure context.

a <*> b combines the contexts of the hidden values and applies the shadow of b value onto the shadow of a.

Methods

pure :: a -> Shade m a #

(<*>) :: Shade m (a -> b) -> Shade m a -> Shade m b #

(*>) :: Shade m a -> Shade m b -> Shade m b #

(<*) :: Shade m a -> Shade m b -> Shade m a #

(Applicative m, Monoid b) => Monoid (Shade m b) Source #

mempty is simply the shadow and source of the neutral element of the stored value.

mappend combines the contexts of two shadows and mappends their stored values.

Methods

mempty :: Shade m b #

mappend :: Shade m b -> Shade m b -> Shade m b #

mconcat :: [Shade m b] -> Shade m b #

shade :: m a -> (a -> b) -> Shade m b Source #

Insert a contextual value and its projection into a shade.

hide :: m a -> Shade m a Source #

Hide a boxed value inside a shade with the identity as projection.

shadow :: Functor m => Shade m b -> m b Source #

The projection of the hidden value (the "shadow").

transfer :: (forall a. m a -> n a) -> Shade m t -> Shade n t Source #

Changed the context of a hidden value. The first argument must be universally quantified since no assumptions may be made as to what value is stored inside the shade.