sessiontypes-0.1.2: Session types library

Safe HaskellSafe
LanguageHaskell2010

Control.SessionTypes.Indexed

Contents

Description

This module provides a set of indexed type classes (IxFunctor, IxApplicative, IxMonad, etc..) that correspond to existing type classes (Functor, Applicative, Monad, etc..)

The intent of this module is to replace the use of non-indexed type classes with indexed type class.

For that reason the indexed type classes expose functions that are named the same as the functions exposed by a corresponding non-indexed type class.

There are two ways to use this module:

import           SessionTypes
import qualified SessionTypes.Indexed as I

prog = send 5 I.>> eps0
{-# LANGUAGE RebindableSyntax #-}
import SessionTypes
import SessionTypes.Indexed

prog = do
 send 5
 eps0

With RebindableSyntax we construct a custom do notation by rebinding (>>=) with (>>=) of IxMonad. Rebinding is not limited to only (>>=), but also all other functions in Prelude.

We do not want to force importing Prelude if you use RebindableSyntax. Therefore this module also exports Prelude that hides functions already defined by the indexed type classes.

Synopsis

Classes

class IxFunctor (f :: p -> p -> Type -> Type) where Source #

Minimal complete definition

fmap

Methods

fmap :: (a -> b) -> f j k a -> f j k b Source #

Instances

IxFunctor (Cap *) (IxC m) Source # 

Methods

fmap :: (a -> b) -> f j k a -> f j k b Source #

Monad m => IxFunctor (Cap a) (STTerm a m) Source # 

Methods

fmap :: (a -> b) -> f j k a -> f j k b Source #

class IxFunctor f => IxApplicative (f :: p -> p -> Type -> Type) where Source #

Minimal complete definition

pure, (<*>)

Methods

pure :: a -> f i i a Source #

(<*>) :: f s r (a -> b) -> f r k a -> f s k b Source #

Instances

IxApplicative (Cap *) (IxC m) Source # 

Methods

pure :: a -> f i i a Source #

(<*>) :: f s r (a -> b) -> f r k a -> f s k b Source #

Monad m => IxApplicative (Cap a) (STTerm a m) Source # 

Methods

pure :: a -> f i i a Source #

(<*>) :: f s r (a -> b) -> f r k a -> f s k b Source #

class IxApplicative m => IxMonad (m :: p -> p -> Type -> Type) where Source #

Minimal complete definition

(>>=), return

Methods

(>>=) :: m s t a -> (a -> m t k b) -> m s k b infixl 1 Source #

(>>) :: m s t a -> m t k b -> m s k b infixl 1 Source #

return :: a -> m i i a Source #

fail :: String -> m i i a Source #

Instances

IxMonad (Cap *) (IxC m) Source # 

Methods

(>>=) :: m s t a -> (a -> m t k b) -> m s k b Source #

(>>) :: m s t a -> m t k b -> m s k b Source #

return :: a -> m i i a Source #

fail :: String -> m i i a Source #

Monad m => IxMonad (Cap a) (STTerm a m) Source # 

Methods

(>>=) :: m s t a -> (a -> m t k b) -> m s k b Source #

(>>) :: m s t a -> m t k b -> m s k b Source #

return :: a -> m i i a Source #

fail :: String -> m i i a Source #

Transformers

class IxMonad (t m) => IxMonadT t m where Source #

Type class for lifting monadic computations

Minimal complete definition

lift

Methods

lift :: m a -> t m s s a Source #

Instances

Monad m => IxMonadT (Cap a) (STTerm a) m Source # 

Methods

lift :: m a -> m m s s a Source #

class IxMonad (t m) => IxMonadIxT t m where Source #

Type class for lifting indexed monadic computations

Minimal complete definition

ilift

Methods

ilift :: m s r a -> t m s r a Source #

Mtl

class IxMonad m => IxMonadReader r m | m -> r where Source #

Type class representing the indexed monad reader

Minimal complete definition

ask, local, reader

Methods

ask :: m s s r Source #

local :: (r -> r) -> m s t a -> m s t a Source #

reader :: (r -> a) -> m i i a Source #

Exception

class IxMonad m => IxMonadThrow m s where Source #

Type class for indexed monads in which exceptions may be thrown.

Minimal complete definition

throwM

Methods

throwM :: Exception e => e -> m s s a Source #

Provide an Exception to be thrown

class IxMonadThrow m s => IxMonadCatch m s where Source #

Type class for indexed monads to allow catching of exceptions.

Minimal complete definition

catch

Methods

catch :: Exception e => m s s a -> (e -> m s s a) -> m s s a Source #

Provide a handler to catch exceptions.

class IxMonadCatch m s => IxMonadMask m s where Source #

Type class for indexed monads that may mask asynchronous exceptions.

Minimal complete definition

mask, uninterruptibleMask

Methods

mask :: ((m s s b -> m s s b) -> m s s b) -> m s s b Source #

run an action that disables asynchronous exceptions. The provided function can be used to restore the occurrence of asynchronous exceptions.

uninterruptibleMask :: ((m s s b -> m s s b) -> m s s b) -> m s s b Source #

Ensures that even interruptible functions may not raise asynchronous exceptions.

MonadIO

class IxMonadIO m where Source #

Type class for indexed monads that may lift IO computations.

Minimal complete definition

liftIO

Methods

liftIO :: IO a -> m s s a Source #

Instances

MonadIO m => IxMonadIO (Cap a) (STTerm a m) Source # 

Methods

liftIO :: IO a -> m s s a Source #

Combinators

ap :: IxMonad m => m s r (a -> b) -> m r k a -> m s k b Source #

Rebind

ifThenElse :: Bool -> t -> t -> t Source #