ether-0.3.1.0: Monad transformers and classes

Safe HaskellNone
LanguageHaskell2010

Control.Ether.Tagged

Description

Type-level machinery for tag manipulation.

Synopsis

Documentation

class Taggable m Source

The Taggable class defines the type families to manage tags in monad transformer stacks. Its kind is restricted to * -> * to prevent incorrect instances.

Associated Types

type Tag m :: Maybe * Source

The Tag type family equals Nothing for most types, but for tagged monad transformers it equals Just tag.

type Inner m :: Maybe (* -> *) Source

The Inner type family equals Nothing for most types, but for monad transformers with inner monad m it equals Just m.

class (Taggable m, Tag m ~ Just tag) => Tagged m tag | m -> tag where Source

The Tagged type class establishes a relationship between a tagged monad transformer and its untagged counterpart.

Minimal complete definition

Nothing

Associated Types

type Untagged m :: * -> * Source

Methods

tagged :: proxy tag -> Untagged m a -> m a Source

untagged :: proxy tag -> m a -> Untagged m a Source

Instances

Tagged (ReaderT tag r m) tag Source 
Tagged (WriterT tag w m) tag Source 
Tagged (StateT tag s m) tag Source 
Tagged (StateT tag s m) tag Source 
Tagged (ExceptT tag e m) tag Source 

type Tags m = MaybeToList (Tag m) ++ ListMapTag (Inners m) Source

The Tags type function returns a type-level list of all tags in a monad transformer stack. Requires Taggable instances.

type Inners m = Inners' (Inner m) Source

The Inners type function recursively applies Inner and returns the results in a type-level list.

class UniqueTag a Source

The main purpose of the UniqueTag class is to provide clear error messages when the tag uniqueness property is violated. You should never write instances for it unless you know what you're doing.

type family UniqueTags m :: Constraint Source

The UniqueTags constraint placed on a type variable representing a monad transformer stack ensures that every tag in the stack appears only once.

Equations

UniqueTags m = Unique (Tags m) 

ensureUniqueTags :: UniqueTags m => m a -> m a Source

Type-restricted version of id that adds a UniqueTags constraint to the provided monadic value.