Copyright | (c) Michael Szvetits 2020 |
---|---|
License | BSD3 (see the file LICENSE) |
Maintainer | typedbyte@qualified.name |
Stability | stable |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
This module defines some constraint synonyms and kinds that are used throughout this library, hopefully to increase the readability of the code at some points.
Synopsis
- type SomeMonad = Type -> Type
- type Effect = SomeMonad -> Constraint
- type Transformer = SomeMonad -> Type -> Type
- type Handle (eff :: Effect) (t :: Transformer) m = eff (t m)
- type Lift (eff :: Effect) (t :: Transformer) m = (eff m, Monad (t m), MonadTrans t)
- type Control (eff :: Effect) (t :: Transformer) m = (eff m, Monad (t m), MonadTransControl t)
Documentation
type Effect = SomeMonad -> Constraint Source #
The kind of effects, which are type classes with a monad type parameter at the end.
type Transformer = SomeMonad -> Type -> Type Source #
The kind of monad transformers, also known as effect handlers or effect interpreters.
type Handle (eff :: Effect) (t :: Transformer) m = eff (t m) Source #
This type synonym indicates that an effect is handled by a specific monad transformer.
type Lift (eff :: Effect) (t :: Transformer) m = (eff m, Monad (t m), MonadTrans t) Source #
This constraint synonym indicates that a first-order effect is not handled by a specific monad transformer and must thus be delegated ("lifted") further down the monad transformer stack in order to find its associated handler.
Roughly speaking, a first-order effect is a type class whose monad type
parameter m
appears only in positive position when looking at the types of
its corresponding class methods (e.g., m
appears only in the result type).
An example of a first-order effect is the State'
effect.
type Control (eff :: Effect) (t :: Transformer) m = (eff m, Monad (t m), MonadTransControl t) Source #
This constraint synonym indicates that a higher-order effect is not handled by a specific monad transformer and must thus be delegated ("lifted") further down the monad transformer stack in order to find its associated handler.
Roughly speaking, a higher-order effect is a type class whose monad type
parameter m
appears in negative position when looking at the types of its
corresponding class methods (e.g., m
appears in the type of a method
parameter).
An example of a higher-order effect is the Reader'
effect,
since its class method local'
has a parameter of
type m a
.