eventuo11y-0.9.0.0: An event-oriented observability library
CopyrightCopyright 2022 Shea Levy.
LicenseApache-2.0
Maintainershea@shealevy.com
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Natural.Control

Description

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

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.

Constructors

ControlTransformation 

Fields

  • transWith :: !(forall a. ((forall x. n x -> Compose m st x) -> m a) -> n a)

    Lift an action in m, defined in a context where n actions can be lowered into m with state tracking, into n.

  • restoreState :: !(forall a. st a -> n a)

    Restore the state captured by transWith

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 #

Arguments

:: forall m n. (Functor m, Applicative n) 
=> (forall a. ((forall x. n x -> m x) -> m a) -> n a)

Lift an action in m, defined in a context where n actions can be lowered into m, into n.

-> StatelessControlTransformation m n 

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.