mtsl-0.2.0.0: Reified monad transformer stacks

Copyright(c) Samuel Schlesinger 2020
LicenseMIT
Maintainersgschlesinger@gmail.com
Stabilityexperimental
PortabilityPOSIX, Windows
Safe HaskellNone
LanguageHaskell2010

Control.Monad.Trans.Stack

Description

 
Synopsis

Documentation

newtype Stack (ts :: [(* -> *) -> * -> *]) (m :: * -> *) a Source #

A computation consisting of a stack of monad transformers and a base monad.

Constructors

Stack 

Fields

Instances
(forall (f' :: Type -> Type). Monad f' => Monad (t f'), MonadTrans t, forall (f' :: Type -> Type). Monad f' => Monad (Stack ts f'), MonadTrans (Stack ts)) => MonadTrans (Stack (t ': ts)) Source # 
Instance details

Defined in Control.Monad.Trans.Stack

Methods

lift :: Monad m => m a -> Stack (t ': ts) m a #

MonadTrans (Stack ([] :: [(Type -> Type) -> Type -> Type])) Source # 
Instance details

Defined in Control.Monad.Trans.Stack

Methods

lift :: Monad m => m a -> Stack [] m a #

(forall (f' :: Type -> Type). Monad f' => Monad (t f'), MonadTrans t, Monad f, Monad (Stack ts f)) => Monad (Stack (t ': ts) f) Source # 
Instance details

Defined in Control.Monad.Trans.Stack

Methods

(>>=) :: Stack (t ': ts) f a -> (a -> Stack (t ': ts) f b) -> Stack (t ': ts) f b #

(>>) :: Stack (t ': ts) f a -> Stack (t ': ts) f b -> Stack (t ': ts) f b #

return :: a -> Stack (t ': ts) f a #

fail :: String -> Stack (t ': ts) f a #

Monad f => Monad (Stack ([] :: [(Type -> Type) -> Type -> Type]) f) Source # 
Instance details

Defined in Control.Monad.Trans.Stack

Methods

(>>=) :: Stack [] f a -> (a -> Stack [] f b) -> Stack [] f b #

(>>) :: Stack [] f a -> Stack [] f b -> Stack [] f b #

return :: a -> Stack [] f a #

fail :: String -> Stack [] f a #

(forall (f' :: Type -> Type). Monad f' => Monad (t f'), Monad f, Monad (Stack ts f)) => Functor (Stack (t ': ts) f) Source # 
Instance details

Defined in Control.Monad.Trans.Stack

Methods

fmap :: (a -> b) -> Stack (t ': ts) f a -> Stack (t ': ts) f b #

(<$) :: a -> Stack (t ': ts) f b -> Stack (t ': ts) f a #

Functor f => Functor (Stack ([] :: [(Type -> Type) -> Type -> Type]) f) Source # 
Instance details

Defined in Control.Monad.Trans.Stack

Methods

fmap :: (a -> b) -> Stack [] f a -> Stack [] f b #

(<$) :: a -> Stack [] f b -> Stack [] f a #

(forall (f' :: Type -> Type). Monad f' => Monad (t f'), Monad f, Monad (Stack ts f)) => Applicative (Stack (t ': ts) f) Source # 
Instance details

Defined in Control.Monad.Trans.Stack

Methods

pure :: a -> Stack (t ': ts) f a #

(<*>) :: Stack (t ': ts) f (a -> b) -> Stack (t ': ts) f a -> Stack (t ': ts) f b #

liftA2 :: (a -> b -> c) -> Stack (t ': ts) f a -> Stack (t ': ts) f b -> Stack (t ': ts) f c #

(*>) :: Stack (t ': ts) f a -> Stack (t ': ts) f b -> Stack (t ': ts) f b #

(<*) :: Stack (t ': ts) f a -> Stack (t ': ts) f b -> Stack (t ': ts) f a #

Applicative f => Applicative (Stack ([] :: [(Type -> Type) -> Type -> Type]) f) Source # 
Instance details

Defined in Control.Monad.Trans.Stack

Methods

pure :: a -> Stack [] f a #

(<*>) :: Stack [] f (a -> b) -> Stack [] f a -> Stack [] f b #

liftA2 :: (a -> b -> c) -> Stack [] f a -> Stack [] f b -> Stack [] f c #

(*>) :: Stack [] f a -> Stack [] f b -> Stack [] f b #

(<*) :: Stack [] f a -> Stack [] f b -> Stack [] f a #

type family Stack' (ts :: [(* -> *) -> * -> *]) (m :: * -> *) :: * -> * where ... Source #

The type family which we interleave with Stack for its implementation.

Equations

Stack' (t ': ts) m = t (Stack ts m) 
Stack' '[] m = m 

type family Substack n ts f where ... Source #

Computes a substack, or a suffix, of the given stack of monad transformers.

Equations

Substack Z (t ': ts) f = t (Stack ts f) 
Substack (S n) (t ': ts) f = Substack n ts f 

data N Source #

Type level natural numbers.

Constructors

S N 
Z 

class (n :: N) > (m :: N) Source #

Greater than constraint.

Instances
n > m => (S n) > m Source # 
Instance details

Defined in Control.Monad.Trans.Stack

(S n) > Z Source # 
Instance details

Defined in Control.Monad.Trans.Stack

class Uplift n ts f where Source #

A type family used to lift substacks up into the full Stack computation.

Methods

liftSubstack :: Substack n ts f a -> Stack ts f a Source #

Instances
Uplift Z (t ': ts) f Source # 
Instance details

Defined in Control.Monad.Trans.Stack

Methods

liftSubstack :: Substack Z (t ': ts) f a -> Stack (t ': ts) f a Source #

(MonadTrans t, MonadTrans (Stack (t ': ts)), Monad (Stack ts f), Uplift n ts f) => Uplift (S n) (t ': ts) f Source # 
Instance details

Defined in Control.Monad.Trans.Stack

Methods

liftSubstack :: Substack (S n) (t ': ts) f a -> Stack (t ': ts) f a Source #

type family IndexIn t ts where ... Source #

Computes the index of an item in a type level list.

Equations

IndexIn t (t ': ts) = Z 
IndexIn t (t' ': ts) = S (IndexIn t ts) 
IndexIn t ts = TypeError (((Text "Could not find " :<>: ShowType t) :<>: Text " in list ") :<>: ShowType ts) 

uplift :: forall t ts f a. Uplift (IndexIn t ts) ts f => Substack (IndexIn t ts) ts f a -> Stack ts f a Source #

Lifts a substack, or a suffix, of the Stack all the way up into the Stack computation. Expected to be used with TypeApplications.

newtype Runner ts Source #

A Runner for a stack of transformers in an arbitrary monad.

Constructors

Runner (forall f a. Monad f => Stack ts f a -> f a) 

class WithRunner ts where Source #

Laws: (runner >>= phi -> run phi (x >>= f)) == (runner >>= phi -> run phi x >>= run phi f)

Minimal complete definition

Nothing

Methods

runner :: (Monad f, Monad (Stack ts f)) => Stack ts f (Runner ts) Source #

withRunner :: (Monad f, Monad (Stack ts f)) => (Runner ts -> Stack ts f a) -> Stack ts f a Source #

Instances
WithRunner ([] :: [(Type -> Type) -> Type -> Type]) Source # 
Instance details

Defined in Control.Monad.Trans.Stack

Methods

runner :: (Monad f, Monad (Stack [] f)) => Stack [] f (Runner []) Source #

withRunner :: (Monad f, Monad (Stack [] f)) => (Runner [] -> Stack [] f a) -> Stack [] f a Source #

(Representable t, WithRunner ts, forall (f :: Type -> Type). Monad f => Monad (t f), forall (f :: Type -> Type). Monad f => Monad (Stack ts f), MonadTrans t) => WithRunner (t ': ts) Source # 
Instance details

Defined in Control.Monad.Trans.Stack

Methods

runner :: (Monad f, Monad (Stack (t ': ts) f)) => Stack (t ': ts) f (Runner (t ': ts)) Source #

withRunner :: (Monad f, Monad (Stack (t ': ts) f)) => (Runner (t ': ts) -> Stack (t ': ts) f a) -> Stack (t ': ts) f a Source #

class Representable t where Source #

The class of Representable transformers. Basically, these can be constant size containers or functions, or arbitrary combination of the two.

Associated Types

type Rep t Source #

Methods

tabulate :: (Rep t -> f a) -> t f a Source #

index :: t f a -> Rep t -> f a Source #

Instances
Representable (ReaderT r :: (k -> Type) -> k -> Type) Source # 
Instance details

Defined in Control.Monad.Trans.Stack

Associated Types

type Rep (ReaderT r) :: Type Source #

Methods

tabulate :: (Rep (ReaderT r) -> f a) -> ReaderT r f a Source #

index :: ReaderT r f a -> Rep (ReaderT r) -> f a Source #

run :: Monad f => Runner ts -> Stack ts f a -> f a Source #

Run a stack with a Runner