| License | MIT |
|---|---|
| Stability | experimental |
| Safe Haskell | None |
| Language | Haskell2010 |
Polysemy.Uncontrolled
Description
Uncontrolled is the evil dual of Methodology. Where a `Methodology b c`
represents a way to turn b into c in a controlled decomposition,
Uncontrolled represents a purely unknown side effect - that materialises
bs out of nowhere, and sends cs into the void where we have no knowledge
of what happens to them. This is equivalent to the combination of Input
and Output considered as a single unit.
This exists for symmetry with Methodology and out of curiosity, but should
be considered extremely dangerous. Uncontrolled can only ever be
reinterpreted as an equally or more severe side effect than the context in
which it's introduced. For experimentation though, this module might be fun
to see how much evil you can get away with.
There is a simple interpretation in the form of runUncontrolledAsState, as
well as ways of getting between Uncontrolled and Input/Output.
Combined with teeMethodology and plugMethodology, this may give you a
way to teleport state around your architecture.
Synopsis
- data Uncontrolled c b m a where
- Send :: c -> Uncontrolled c b m ()
- Receive :: Uncontrolled c b m b
- send :: forall c b r. MemberWithError (Uncontrolled c b) r => c -> Sem r ()
- receive :: forall c b r. MemberWithError (Uncontrolled c b) r => Sem r b
- runUncontrolledAsState :: forall s b c r a. Members '[State s] r => (c -> s) -> (s -> b) -> Sem (Uncontrolled c b ': r) a -> Sem r a
- runUncontrolledAsStateSem :: forall s b c r a. Members '[State s] r => (c -> Sem r s) -> (s -> Sem r b) -> Sem (Uncontrolled c b ': r) a -> Sem r a
- runUncontrolledAsInputOutput :: Members '[Input b, Output c] r => Sem (Uncontrolled c b ': r) a -> Sem r a
- adaptUncontrolledPure :: Members '[Uncontrolled c' b'] r => (c -> c') -> (b' -> b) -> Sem (Uncontrolled c b ': r) a -> Sem r a
- adaptUncontrolledSem :: forall c b c' b' r a. Members '[Uncontrolled c' b'] r => (c -> Sem r c') -> (b' -> Sem r b) -> Sem (Uncontrolled c b ': r) a -> Sem r a
- runInputAsUncontrolled :: forall c b r a. Members '[Uncontrolled c b] r => Sem (Input b ': r) a -> Sem r a
- runOutputAsUncontrolled :: forall c b r a. Members '[Uncontrolled c b] r => Sem (Output c ': r) a -> Sem r a
- runMethodologyAsUncontrolled :: forall c b r a. Members '[Uncontrolled b c] r => Sem (Methodology b c ': r) a -> Sem r a
Definition
data Uncontrolled c b m a where Source #
An Uncontrolled generalises an unmanaged side effect.
Since: 0.1.0.0
Constructors
| Send :: c -> Uncontrolled c b m () | |
| Receive :: Uncontrolled c b m b |
send :: forall c b r. MemberWithError (Uncontrolled c b) r => c -> Sem r () Source #
receive :: forall c b r. MemberWithError (Uncontrolled c b) r => Sem r b Source #
Eliminators
runUncontrolledAsState :: forall s b c r a. Members '[State s] r => (c -> s) -> (s -> b) -> Sem (Uncontrolled c b ': r) a -> Sem r a Source #
Run an Uncontrolled as State, using a neutral element and accessors.
Since: 0.1.0.0
runUncontrolledAsStateSem :: forall s b c r a. Members '[State s] r => (c -> Sem r s) -> (s -> Sem r b) -> Sem (Uncontrolled c b ': r) a -> Sem r a Source #
Like runUncontrolledAsState, but uses monadic accessors. Using this would be completely insane. ;)
Since: 0.1.0.0
runUncontrolledAsInputOutput :: Members '[Input b, Output c] r => Sem (Uncontrolled c b ': r) a -> Sem r a Source #
Run an Uncontrolled as an Input/Output pair.
Since: 0.1.0.0
Adapters
adaptUncontrolledPure :: Members '[Uncontrolled c' b'] r => (c -> c') -> (b' -> b) -> Sem (Uncontrolled c b ': r) a -> Sem r a Source #
Run an Uncontrolled as another kind of Uncontrolled, using pure functions to dimap from one to the other.
Since: 0.1.0.0
adaptUncontrolledSem :: forall c b c' b' r a. Members '[Uncontrolled c' b'] r => (c -> Sem r c') -> (b' -> Sem r b) -> Sem (Uncontrolled c b ': r) a -> Sem r a Source #
Like adaptUncontrolledPure, but with monadic adapters. If you use this I have no idea what you're trying to accomplish.
Since: 0.1.0.0
Coeliminators
runInputAsUncontrolled :: forall c b r a. Members '[Uncontrolled c b] r => Sem (Input b ': r) a -> Sem r a Source #
Run an Input as one side of an Uncontrolled.
Since: 0.1.0.0
runOutputAsUncontrolled :: forall c b r a. Members '[Uncontrolled c b] r => Sem (Output c ': r) a -> Sem r a Source #
Run an Output as one side of an Uncontrolled.
Since: 0.1.0.0
runMethodologyAsUncontrolled :: forall c b r a. Members '[Uncontrolled b c] r => Sem (Methodology b c ': r) a -> Sem r a Source #
Run a Methodology as an Uncontrolled pure side effect.
Since: 0.1.0.0