sessiontypes-0.1.2: Session types library

Control.SessionTypes.Indexed

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 # Methodsfmap :: (a -> b) -> f j k a -> f j k b Source # Monad m => IxFunctor (Cap a) (STTerm a m) Source # Methodsfmap :: (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

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 # Methodspure :: 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 # Methodspure :: 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

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

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 # Methodslift :: m a -> m m s s a 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

Minimal complete definition

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

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

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.

Minimal complete definition

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.

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 # MethodsliftIO :: 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 #