capability-0.5.0.1: Extensional capabilities and deriving combinators
Safe HaskellNone
LanguageHaskell2010

Capability.Derive

Synopsis

Documentation

derive :: forall t (derived :: [Capability]) (ambient :: [Capability]) m a. (forall x. Coercible (t m x) (m x), All derived (t m), All ambient m) => (forall m'. (All derived m', All ambient m') => m' a) -> m a Source #

Runs an action that requires additional capabilities.

derive @t @derived @ambient act runs act by providing both the capabilities in derived and ambient. The difference is that ambient capabilities are assumed to be available, whereas derived instances are provided by t.

derive assumes that t is a newtype defined in the form:

newtype T m a = T (m a)

Then derive uses type-class instances for T to provide for each of the capabilities in derived.

A common instance of this is wrapError, whereby exceptions raised by act can be repackaged in a larger exception type.

The derive function is experimental and is subject to change.