asai-0.0.0.0: A minimal library for delimited continuations.

Portabilityportable
Stabilityexperimental
Maintainermad.one@gmail.com
Safe HaskellSafe-Inferred

Control.Indexed.Monad

Contents

Description

Indexed Monads.

When using RebindableSyntax with GHC, it's possible to overload regular do-notation to use the IxMonad typeclass. See the section "Using do-notation" in the tutorial module Control.Delimited.Tutorial.

Currently, indexed transformers are not provided. In the future, this module may be replaced by the indexed or index-core libraries which provide more general types while still having do-notation, and providing transformers. In light of that, this module will be expanded as needed.

Synopsis

Indexed Monads

class IxApplicative m => IxMonad m whereSource

Indexed Monads.

Regular monads can be lifted into this type class using lift.

Methods

(!>>=) :: m t u a -> (a -> m s t b) -> m s u bSource

Indexed >>=.

joinI :: m t u (m s t a) -> m s u aSource

Indexed join.

failI :: String -> m s s aSource

Indexed fail.

Instances

IxMonad Delim

Delimited continuations form an IxMonad.

Monad m => IxMonad (MW m)

Lifts regular instances of Monad into IxMonad.

Lifting ordinary Monads

data MW m s t a Source

This type lifts any regular Monad into an IxMonad.

Instances

Monad m => IxFunctor (MW m)

Lifts regular instances of Monad into IxFunctor.

Monad m => IxPointed (MW m)

Lifts regular instances of Monad into IxPointed.

Monad m => IxApplicative (MW m)

Lifts regular instances of Monad into IxApplicative.

Monad m => IxMonad (MW m)

Lifts regular instances of Monad into IxMonad.

lift :: Monad m => m a -> MW m s t aSource

This method lifts a regular Monad into MW which is an instance of IxMonad.

runI :: Monad m => MW m s t a -> m aSource

This demotes a indexed monad into a regular monad. Useful for when you're using e.g. RebindableSyntax and want to do IO.

Operators

(!>>) :: IxMonad m => m s t a -> m t u b -> m s u bSource

Indexed >>.

(!>=>) :: IxMonad m => (a -> m t u b) -> (b -> m s t c) -> a -> m s u cSource

Left-to-right Kleisli composition of indexed Monads.

(<=<!) :: IxMonad m => (b -> m s t c) -> (a -> m t u b) -> a -> m s u cSource

Right-to-left Kleisli composition of indexed Monads.

(=<<!) :: IxMonad m => (a -> m s t b) -> m t u a -> m s u bSource

Right-to-left version of !>>=.

Other functions

liftIxM :: IxMonad m => (a -> b) -> m s t a -> m s t bSource

This is liftM for indexed Monads.

liftIxM2 :: IxMonad m => (a -> b -> c) -> m t u a -> m s t b -> m s u cSource

This is liftM2 for indexed Monads.