index-core-1.0.1: Indexed Types

Safe HaskellSafe-Infered

Control.IMonad.Core

Contents

Description

This module provides the IFunctor and IMonad classes which are the indexed counterparts to Functor and Monad from Control.Monad.

Synopsis

Indexed Monads

I deviate from Conor's terminology, referring to his monads on indexed types as "indexed monads" and referring to his indexed monads as "restricted monads". This module provides "indexed monads".

Indexed monads generalize the traditional approach to parametrizing the initial and final states of ordinary monads. The IMonad class does not require specifying a concrete index of kind * for the intermediate or final state of the bindI operation, permitting operations which may end in multiple possible states.

class IFunctor f whereSource

An endofunctor within the category of index-preserving functions

All instances must satisfy the functor laws:

 fmapI id == id

 fmapI (f . g) == fmapI f . fmapI g

Methods

fmapI :: (a :-> b) -> f a :-> f bSource

Instances

Monad m => IFunctor (U m) 

class IFunctor m => IMonad m whereSource

An indexed monad

All instances must satisfy the monad laws:

 returnI >?> f = f

 f >?> returnI = f

 (f >?> g) >?> h = f >?> (g >?> h)

Methods

returnI :: a :-> m aSource

bindI :: (a :-> m b) -> m a :-> m bSource

Instances

Monad m => IMonad (U m) 

Functions

Functions derived from returnI and bindI

(?>=) :: IMonad m => m a i -> (a :-> m b) -> m b iSource

An infix bindI with arguments flipped

(=<?) :: IMonad m => (a :-> m b) -> m a :-> m bSource

An infix bindI

(>?>) :: IMonad m => (a :-> m b) -> (b :-> m c) -> a :-> m cSource

Composition of indexed Kleisli arrows

This is equivalent to (>>>) from Control.Category.

(<?<) :: IMonad m => (b :-> m c) -> (a :-> m b) -> a :-> m cSource

Composition of indexed Kleisli arrows

This is equivalent to (<<<) from Control.Category.