free-foil-0.2.0: Efficient Type-Safe Capture-Avoiding Substitution for Free (Scoped Monads)
Safe HaskellNone
LanguageHaskell2010

Control.Monad.Foil.Relative

Synopsis

Documentation

class RelMonad (f :: S -> Type) (m :: S -> Type) where Source #

Relative monads, restricted to types indexed by scopes in kind S.

Methods

rreturn :: forall (a :: S). f a -> m a Source #

Relative version of return.

rbind :: forall (b :: S) (a :: S). Distinct b => Scope b -> m a -> (f a -> m b) -> m b Source #

Relative version of >>=.

Note the two special additions to the usual definition of a relative binding operation:

  1. Scope b is added since is corresponds to the runtime counterpart of the type parameter b.
  2. Distinct b constraint helps to ensure we only work with scopes that are distinct.

Technically, it is also possible add similar components for a parameter. Also, we could probably treat types in S as singletons and extract distinct scopes that way, preserving the more general type signature for rbind.

Instances

Instances details
RelMonad Name Expr Source #

Expr is a monad relative to Name.

Instance details

Defined in Control.Monad.Foil.Example

Methods

rreturn :: forall (a :: S). Name a -> Expr a Source #

rbind :: forall (b :: S) (a :: S). Distinct b => Scope b -> Expr a -> (Name a -> Expr b) -> Expr b Source #

(Bifunctor sig, CoSinkable binder, SinkableK binder) => RelMonad Name (AST binder sig) Source #

AST sig is a monad relative to Name.

Instance details

Defined in Control.Monad.Free.Foil

Methods

rreturn :: forall (a :: S). Name a -> AST binder sig a Source #

rbind :: forall (b :: S) (a :: S). Distinct b => Scope b -> AST binder sig a -> (Name a -> AST binder sig b) -> AST binder sig b Source #

liftRM :: forall f m (b :: S) (a :: S). (RelMonad f m, Distinct b) => Scope b -> (f a -> f b) -> m a -> m b Source #

Relative version of liftM (an fmap restricted to Monad).