MonadCompose-0.8.4.2: Methods for composing monads.

Safe HaskellSafe
LanguageHaskell98

Control.Monad.PlusMonad

Contents

Description

A construction combining two monads, based on the work of Luth and Ghani, "Composing Monads Using Coproducts."

Synopsis

Documentation

data Composition m n t Source

Instances

type (::+) m n = Yoneda (Composition m n) Source

The following construction on two monads is a monad provided the two monads have extended distributive laws, defined below.

class Dist n where Source

An extended distributive law allows one to permute two layers.

Laws are:

>>> join . T dist = dist . join :: TTS -> TST
>>> TS join . dist . dist = dist :: TS -> TST

Methods

dist :: Applicative m => n (m t) -> n (m (n t)) Source

leftMap :: (Monad m, Functor n, Functor x) => (forall u. m u -> n u) -> (m ::+ x) t -> (n ::+ x) t Source

Left and right maps...

rightMap :: (Monad x, Monad m, Functor n) => (forall u. m u -> n u) -> (x ::+ m) t -> (x ::+ n) t Source

inl :: (Dist m, Dist n, Monad m, Monad n) => m t -> (m ::+ n) t Source

Injections into the ::+ type.

inr :: (Dist m, Dist n, Monad m, Monad n) => n t -> (m ::+ n) t Source

sym :: Monad m => (m ::+ m) t -> m t Source

If you have a ::+ over a monad, you can extract the underlying action.

commute :: (Monad m, Monad n) => (m ::+ n) t -> (n ::+ m) t Source

::+ is commutative.

mapPlus :: (Monad m, Monad n, Functor m1, Functor n1) => (forall u. m u -> m1 u) -> (forall u. n u -> n1 u) -> (m ::+ n) t -> (m1 ::+ n1) t Source

refl :: MonadPlus m => (m ::+ m) t -> m t Source

Example

data File t Source

Example of an IO-performing ADT.