ether- Monad transformers and classes

Safe HaskellNone



Type-level machinery for tag manipulation.



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


Associated Types

type Untagged m :: * -> * Source


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

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


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

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.


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.