Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- type Handler (ctx :: Type -> Type) (m :: Type -> Type) (n :: Type -> Type) = forall x. ctx (m x) -> n (ctx x)
- (~<~) :: forall (n :: Type -> Type) (ctx1 :: Type -> Type) (m :: Type -> Type) (ctx2 :: Type -> Type) (l :: Type -> Type). (Functor n, Functor ctx1) => Handler ctx1 m n -> Handler ctx2 l m -> Handler (Compose ctx1 ctx2) l n
Documentation
type Handler (ctx :: Type -> Type) (m :: Type -> Type) (n :: Type -> Type) = forall x. ctx (m x) -> n (ctx x) Source #
Handlers take an action in m
bundled up with some state in some context functor ctx
, and return an action in n
producing a derived state in ctx
.
These are expected to be well-behaved distributive laws, and are required to adhere to the following laws:
handler.
fmap
pure
=pure
handler.
fmap
(k=<<
) = handler.
fmap
k<=<
handler
respectively expressing that the handler does not alter the context of pure computations, and that the handler distributes over monadic composition.
Handlers compose with handlers, using e.g. Data.Functor.Compose.
to ensure that the result is itself well-typed as a Compose
Handler
:
fmap
Compose
.
handler1.
fmap
handler2.
getCompose
and with monad homomorphisms on the left and right:
hom .
handler
handler.
fmap
hom
Since: 1.1.0.0