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 the types EachVia
and its corresponding type synonym
Via
which indicate that specific effects are handled by a specific monad
transformer (also known as effect handler or effect interpreter).
It also defines the G
type, which is the global tag that is used for
untagged effects.
Last but not least, it defines some constraint synonyms and kinds that are used throughout this library, hopefully to increase the readability of the code at some points.
Synopsis
- newtype EachVia (effs :: [Effect]) (t :: Transformer) m a = EachVia {
- runVia :: t m a
- type Via eff t m a = EachVia '[eff] t m a
- data G
- type SomeMonad = Type -> Type
- type Effect = SomeMonad -> Constraint
- type Transformer = SomeMonad -> Type -> Type
- type Handle (eff :: Effect) (t :: Transformer) m = eff (t m)
- type Find eff effs t m = (Monad (t m), eff (EachVia effs 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)
Core Types
newtype EachVia (effs :: [Effect]) (t :: Transformer) m a Source #
This type indicates that the effects (i.e., type classes) effs
are handled by
a specific monad transformer t
. The type is a simple wrapper around the
monad transformer itself. The whole purpose of this type is to guide the type
system to pick the instances of type classes effs
given by the type t
, and
to delegate all other effects that are not in effs
to their handlers which are
located somewhere further down the monad transformer stack.
Since: 0.2.0.0
Instances
Control (RWS' tag r w s) t m => RWS' (tag :: k) r w s (EachVia ('[] :: [Effect]) t m) Source # | |
Defined in Control.Effect.RWS | |
Find (RWS' tag r w s) effs t m => RWS' (tag :: k) r w s (EachVia (other ': effs) t m) Source # | |
Defined in Control.Effect.RWS | |
(Monad (t m), Reader' tag r (EachVia effs t m), Writer' tag w (EachVia effs t m), State' tag s (EachVia effs t m)) => RWS' (tag :: k) r w s (EachVia (RWS' tag r w s ': effs) t m) Source # | |
Defined in Control.Effect.RWS | |
Handle (Map' tag k2 v) t m => Map' (tag :: k1) k2 v (EachVia (Map' tag k2 v ': effs) t m) Source # | |
Find (Map' tag k2 v) effs t m => Map' (tag :: k1) k2 v (EachVia (other ': effs) t m) Source # | |
Lift (Map' tag k2 v) t m => Map' (tag :: k1) k2 v (EachVia ('[] :: [Effect]) t m) Source # | |
Handle (Error' tag e) t m => Error' (tag :: k) e (EachVia (Error' tag e ': effs) t m) Source # | |
Defined in Control.Effect.Error | |
Find (Error' tag e) effs t m => Error' (tag :: k) e (EachVia (other ': effs) t m) Source # | |
Defined in Control.Effect.Error throwError' :: e -> EachVia (other ': effs) t m a Source # catchError' :: EachVia (other ': effs) t m a -> (e -> EachVia (other ': effs) t m a) -> EachVia (other ': effs) t m a Source # | |
Control (Error' tag e) t m => Error' (tag :: k) e (EachVia ('[] :: [Effect]) t m) Source # | |
Defined in Control.Effect.Error throwError' :: e -> EachVia '[] t m a Source # catchError' :: EachVia '[] t m a -> (e -> EachVia '[] t m a) -> EachVia '[] t m a Source # | |
Handle (Embed' tag n) t m => Embed' (tag :: k) n (EachVia (Embed' tag n ': effs) t m) Source # | |
Find (Embed' tag n) effs t m => Embed' (tag :: k) n (EachVia (other ': effs) t m) Source # | |
Defined in Control.Effect.Embed | |
Lift (Embed' tag n) t m => Embed' (tag :: k) n (EachVia ('[] :: [Effect]) t m) Source # | |
Defined in Control.Effect.Embed | |
Handle (Reader' tag r) t m => Reader' (tag :: k) r (EachVia (Reader' tag r ': effs) t m) Source # | |
Find (Reader' tag r) effs t m => Reader' (tag :: k) r (EachVia (other ': effs) t m) Source # | |
Control (Reader' tag r) t m => Reader' (tag :: k) r (EachVia ('[] :: [Effect]) t m) Source # | |
Handle (State' tag s) t m => State' (tag :: k) s (EachVia (State' tag s ': effs) t m) Source # | |
Find (State' tag s) effs t m => State' (tag :: k) s (EachVia (other ': effs) t m) Source # | |
Lift (State' tag s) t m => State' (tag :: k) s (EachVia ('[] :: [Effect]) t m) Source # | |
Handle (Writer' tag w) t m => Writer' (tag :: k) w (EachVia (Writer' tag w ': effs) t m) Source # | |
Defined in Control.Effect.Writer | |
Find (Writer' tag w) effs t m => Writer' (tag :: k) w (EachVia (other ': effs) t m) Source # | |
Control (Writer' tag w) t m => Writer' (tag :: k) w (EachVia ('[] :: [Effect]) t m) Source # | |
Handle (Cont' tag) t m => Cont' (tag :: k) (EachVia (Cont' tag ': effs) t m) Source # | |
Find (Cont' tag) effs t m => Cont' (tag :: k) (EachVia (other ': effs) t m) Source # | |
Control (Cont' tag) t m => Cont' (tag :: k) (EachVia ('[] :: [Effect]) t m) Source # | |
Handle (Managed' tag) t m => Managed' (tag :: k) (EachVia (Managed' tag ': effs) t m) Source # | |
Find (Managed' tag) effs t m => Managed' (tag :: k) (EachVia (other ': effs) t m) Source # | |
Control (Managed' tag) t m => Managed' (tag :: k) (EachVia ('[] :: [Effect]) t m) Source # | |
Handle (Resource' tag) t m => Resource' (tag :: k) (EachVia (Resource' tag ': effs) t m) Source # | |
Defined in Control.Effect.Resource bracket' :: EachVia (Resource' tag ': effs) t m a -> (a -> EachVia (Resource' tag ': effs) t m c) -> (a -> EachVia (Resource' tag ': effs) t m b) -> EachVia (Resource' tag ': effs) t m b Source # bracketOnError' :: EachVia (Resource' tag ': effs) t m a -> (a -> EachVia (Resource' tag ': effs) t m c) -> (a -> EachVia (Resource' tag ': effs) t m b) -> EachVia (Resource' tag ': effs) t m b Source # | |
Find (Resource' tag) effs t m => Resource' (tag :: k) (EachVia (other ': effs) t m) Source # | |
Defined in Control.Effect.Resource bracket' :: EachVia (other ': effs) t m a -> (a -> EachVia (other ': effs) t m c) -> (a -> EachVia (other ': effs) t m b) -> EachVia (other ': effs) t m b Source # bracketOnError' :: EachVia (other ': effs) t m a -> (a -> EachVia (other ': effs) t m c) -> (a -> EachVia (other ': effs) t m b) -> EachVia (other ': effs) t m b Source # | |
Control (Resource' tag) t m => Resource' (tag :: k) (EachVia ('[] :: [Effect]) t m) Source # | |
(Monad (t m), MonadBase b m, MonadTrans t) => MonadBase b (EachVia effs t m) Source # | |
Defined in Control.Effect.Machinery.Via | |
(Monad (t m), MonadBaseControl b m, MonadTransControl t) => MonadBaseControl b (EachVia effs t m) Source # | |
MonadTrans t => MonadTrans (EachVia effs t) Source # | |
Defined in Control.Effect.Machinery.Via | |
MonadTransControl t => MonadTransControl (EachVia effs t) Source # | |
Monad (t m) => Monad (EachVia effs t m) Source # | |
Functor (t m) => Functor (EachVia effs t m) Source # | |
Applicative (t m) => Applicative (EachVia effs t m) Source # | |
Defined in Control.Effect.Machinery.Via pure :: a -> EachVia effs t m a # (<*>) :: EachVia effs t m (a -> b) -> EachVia effs t m a -> EachVia effs t m b # liftA2 :: (a -> b -> c) -> EachVia effs t m a -> EachVia effs t m b -> EachVia effs t m c # (*>) :: EachVia effs t m a -> EachVia effs t m b -> EachVia effs t m b # (<*) :: EachVia effs t m a -> EachVia effs t m b -> EachVia effs t m a # | |
MonadIO (t m) => MonadIO (EachVia effs t m) Source # | |
Defined in Control.Effect.Machinery.Via | |
type StT (EachVia effs t) a Source # | |
Defined in Control.Effect.Machinery.Via | |
type StM (EachVia effs t m) a Source # | |
Defined in Control.Effect.Machinery.Via |
type Via eff t m a = EachVia '[eff] t m a Source #
This type synonym can be used to indicate that a single effect eff
is
handled by a specific monad transformer t
.
Since: 0.2.0.0
This type is used as tag for all untagged effects. In order words, every
effect is tagged, even untagged ones, but all the untagged ones simply have
the same tag G
(short for "Global", because you can view tags as some
kind of namespace mechanism, and all untagged effects live in the same
global namespace).
If you don't want to use tagged effects (i.e., you write effect type classes without a tag type parameter), you can ignore this type completely.
Constraint Synonyms and Kinds
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 constraint synonym indicates that an effect is handled by a specific monad transformer.
type Find eff effs t m = (Monad (t m), eff (EachVia effs t m)) Source #
This constraint synonym indicates that an effect eff
is not at the head of the
type level list of effects to be handled, so the effect must be found further
down in the tail effs
.
Since: 0.2.0.0
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
.