Copyright | Copyright 2022 Shea Levy. |
---|---|
License | Apache-2.0 |
Maintainer | shea@shealevy.com |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Natural transformations can lift monadic actions from the source to the
target, but something stronger is needed to lift general higher-order control
operations like catch
.
This module relates to Control.Natural in a similar way to how Control.Monad.Trans.Control relates to Control.Monad.Trans.Class.
Synopsis
- data ControlTransformation st m n = ControlTransformation {
- transWith :: !(forall a. ((forall x. n x -> Compose m st x) -> m a) -> n a)
- restoreState :: !(forall a. st a -> n a)
- toNatural :: ControlTransformation st m n -> forall x. m x -> n x
- type StatelessControlTransformation = ControlTransformation Identity
- statelessControlTransformation :: forall m n. (Functor m, Applicative n) => (forall a. ((forall x. n x -> m x) -> m a) -> n a) -> StatelessControlTransformation m n
- statelessTransWith :: Functor m => StatelessControlTransformation m n -> ((forall x. n x -> m x) -> m a) -> n a
Documentation
data ControlTransformation st m n Source #
A transformation from m
to n
that can lift control operations.
The st
functor is needed to track the higher monad's state
in the lower monad. See StatelessControlTransformation
for the case
where no state tracking is needed.
ControlTransformation | |
|
toNatural :: ControlTransformation st m n -> forall x. m x -> n x Source #
Extract a natural transformation from a ControlTransformation
type StatelessControlTransformation = ControlTransformation Identity Source #
A transformation from m
to n
that can lift control operations.
This type is only appropriate for the case where the higher monad
does not have any additional state that must be accounted for when
running within the lower monad. For the more general case, see
ControlTransformation
.
I'm told this is a right kan extension.
statelessControlTransformation Source #
:: forall m n. (Functor m, Applicative n) | |
=> (forall a. ((forall x. n x -> m x) -> m a) -> n a) | Lift an action in |
-> StatelessControlTransformation m n |
Create a StatelessControlTransformation
statelessTransWith :: Functor m => StatelessControlTransformation m n -> ((forall x. n x -> m x) -> m a) -> n a Source #
Lift an action in m
, defined in a context where n
actions can be lowered into m
, into n
.