bound-2.0.1: Making de Bruijn Succ Less

Copyright(C) 2012-2015 Edward Kmett
LicenseBSD-style (see the file LICENSE)
MaintainerEdward Kmett <ekmett@gmail.com>
Stabilityexperimental
Portabilityportable
Safe HaskellSafe
LanguageHaskell98

Bound.Class

Description

This module provides the Bound class, for performing substitution into things that are not necessarily full monad transformers.

Synopsis

Documentation

class Bound t where Source #

Instances of Bound generate left modules over monads.

This means they should satisfy the following laws:

m >>>= return ≡ m
m >>>= (λ x → k x >>= h) ≡ (m >>>= k) >>>= h

This guarantees that a typical Monad instance for an expression type where Bound instances appear will satisfy the Monad laws (see doc/BoundLaws.hs).

If instances of Bound are monad transformers, then m >>>= f ≡ m >>= lift . f implies the above laws, and is in fact the default definition.

This is useful for types like expression lists, case alternatives, schemas, etc. that may not be expressions in their own right, but often contain expressions.

Note: Free isn't "really" a monad transformer, even if the kind matches. Therefore there isn't Bound Free instance.

Methods

(>>>=) :: Monad f => t f a -> (a -> f c) -> t f c infixl 1 Source #

Perform substitution

If t is an instance of MonadTrans and you are compiling on GHC >= 7.4, then this gets the default definition:

m >>>= f = m >>= lift . f

(>>>=) :: (MonadTrans t, Monad f, Monad (t f)) => t f a -> (a -> f c) -> t f c infixl 1 Source #

Perform substitution

If t is an instance of MonadTrans and you are compiling on GHC >= 7.4, then this gets the default definition:

m >>>= f = m >>= lift . f

Instances

Bound ListT Source # 

Methods

(>>>=) :: Monad f => ListT f a -> (a -> f c) -> ListT f c Source #

Bound MaybeT Source # 

Methods

(>>>=) :: Monad f => MaybeT f a -> (a -> f c) -> MaybeT f c Source #

Bound (IdentityT *) Source # 

Methods

(>>>=) :: Monad f => IdentityT * f a -> (a -> f c) -> IdentityT * f c Source #

Error e => Bound (ErrorT e) Source # 

Methods

(>>>=) :: Monad f => ErrorT e f a -> (a -> f c) -> ErrorT e f c Source #

Bound (StateT s) Source # 

Methods

(>>>=) :: Monad f => StateT s f a -> (a -> f c) -> StateT s f c Source #

Monoid w => Bound (WriterT w) Source # 

Methods

(>>>=) :: Monad f => WriterT w f a -> (a -> f c) -> WriterT w f c Source #

Bound (Scope b) Source # 

Methods

(>>>=) :: Monad f => Scope b f a -> (a -> f c) -> Scope b f c Source #

Bound (Scope b) Source # 

Methods

(>>>=) :: Monad f => Scope b f a -> (a -> f c) -> Scope b f c Source #

Bound (ContT * c) Source # 

Methods

(>>>=) :: Monad f => ContT * c f a -> (a -> f c) -> ContT * c f c Source #

Bound (ReaderT * r) Source # 

Methods

(>>>=) :: Monad f => ReaderT * r f a -> (a -> f c) -> ReaderT * r f c Source #

Monoid w => Bound (RWST r w s) Source # 

Methods

(>>>=) :: Monad f => RWST r w s f a -> (a -> f c) -> RWST r w s f c Source #

(=<<<) :: (Bound t, Monad f) => (a -> f c) -> t f a -> t f c infixr 1 Source #

A flipped version of (>>>=).

(=<<<) = flip (>>>=)