HORIZON HASKELLDocslts/ghc-10.0.xfc4e5982026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · fc4e598 · 2026-10-11

Modulevortex-combinators-0.1.1.0GHC2024

Vortex.Combinators.Theory

What an interpreter combinator needs to know about a theory, each as its own small class, and the handler shape every combinator transforms.

Every class here extends FirstOrder. A combinator ships an operation to another process, runs it twice, stores it in a log or a cache, or sends it to one of several owners; each of those treats the operation as a value. A higher-order (scoped) operation such as Local f m or Catch m h holds a computation in the interpreter's own monad, which can be neither serialised nor run twice without running its effects twice, so it cannot be treated as a value and no combinator here accepts it.

  • 8 types
  • 6 classes
  • 12 values

First-order theories

4 declarations
classclass FirstOrder (e :: Effect) where
#

A theory whose operations hold no computation, so an operation can be moved to any monad index. Write the instance as reindex = coerce: it typechecks exactly when the monad parameter is phantom, which is what first-order means, and polysemy's own interpret checks the same coercion.

Methods

Instances1FirstOrder
  • FirstOrder (KVStore k v)Defined in vortex-combinators-0.1.1.0 · Vortex.Combinators.Theory
datadata Inert a
#

The monad index of an operation held as a value. It has no values, so an e Inert a cannot hold a computation to run.

valueinert :: FirstOrder e => e m a -> e Inert a
#

An operation as a value, ready to log, cache or ship.

datadata SomeOp (e :: Effect) where
#

An operation whose result type is forgotten, as decoded from the wire or drawn from a generator.

Constructors

Instances1Show
  • Wire e => Show (SomeOp e)Defined in vortex-combinators-0.1.1.0 · Vortex.Combinators.Theory

Verbs and the wire

4 declarations
newtypenewtype Verb
#

An operation's name, as the vortex wire spells it in a Call.

Constructors

Instances4Eq, Ord, Show, IsString
  • Eq VerbDefined in vortex-combinators-0.1.1.0 · Vortex.Combinators.Theory
  • Ord VerbDefined in vortex-combinators-0.1.1.0 · Vortex.Combinators.Theory
  • Show VerbDefined in vortex-combinators-0.1.1.0 · Vortex.Combinators.Theory
  • IsString VerbDefined in vortex-combinators-0.1.1.0 · Vortex.Combinators.Theory
classclass FirstOrder e => Verbs (e :: Effect) where
#

Every operation has a verb: what a meter counts by.

Methods

Instances1Verbs
  • Verbs (KVStore k v)Defined in vortex-combinators-0.1.1.0 · Vortex.Combinators.Theory
classclass Verbs e => Wire (e :: Effect) where
#

The wire form of a theory, in vortex's convention: an operation is a Call of its verb with its arguments show-rendered, and a result is the show of the value, recovered with read.

Methods

Instances1Wire

Results

2 declarations
classclass FirstOrder e => ResultEq (e :: Effect) where
#

Equality on each operation's result, for tee and replay.

Methods

Instances1ResultEq
  • Eq v => ResultEq (KVStore k v)Defined in vortex-combinators-0.1.1.0 · Vortex.Combinators.Theory

Reads and writes

2 declarations
datadata Access k
#

What an operation does to the state, by the keys it touches. A read depends on its keys; a write changes them and so invalidates every read that depends on any of them. An uncached read changes nothing but is never served from a cache: its answer depends on more than the state its keys could name, such as the caller, the clock or a token it checks.

Constructors

Instances3Functor, Eq, Show
  • Functor AccessDefined in vortex-combinators-0.1.1.0 · Vortex.Combinators.Theory
  • Eq k => Eq (Access k)Defined in vortex-combinators-0.1.1.0 · Vortex.Combinators.Theory
  • Show k => Show (Access k)Defined in vortex-combinators-0.1.1.0 · Vortex.Combinators.Theory
classclass (FirstOrder e, Ord (InvalidationKey e)) => ReadWrite (e :: Effect) where
#

The read/write split of a theory, for the cache. A read, cached or not, must not change the state; a write must declare every key whose reads it can change. The cache coherence law checks the declaration.

Associated types

Methods

Instances1ReadWrite
  • Ord k => ReadWrite (KVStore k v)Defined in vortex-combinators-0.1.1.0 · Vortex.Combinators.Theory

Routing

1 declaration
classclass (FirstOrder e, Ord (Route e)) => Routed (e :: Effect) where
#

The key that names which owner an operation belongs to: a namespace, an owner or a shard key. Every operation has exactly one.

Associated types

Methods

Instances1Routed
  • Ord k => Routed (KVStore k v)Defined in vortex-combinators-0.1.1.0 · Vortex.Combinators.Theory

Failure

2 declarations
datadata Failure
#

Why an operation has no result. Refused is the theory's own refusal, the rest are the combinators': no reply came, a reply did not decode, or no owner holds the key.

Instances4Eq, Ord, Read, Show
  • Eq FailureDefined in vortex-combinators-0.1.1.0 · Vortex.Combinators.Theory
  • Ord FailureDefined in vortex-combinators-0.1.1.0 · Vortex.Combinators.Theory
  • Read FailureDefined in vortex-combinators-0.1.1.0 · Vortex.Combinators.Theory
  • Show FailureDefined in vortex-combinators-0.1.1.0 · Vortex.Combinators.Theory

Observations

5 declarations

Handlers

6 declarations
valuefromInterpreter
  1. :: FirstOrder e
  2. => forall x. Sem (e ': r) x -> Sem r' x
  3. -> Handler e r'
#

The handler of an ordinary polysemy interpreter, such as polysemy-kvstore's runKVStoreAsState: each operation is sent as a one-operation program and run.

valuefocus
  1. :: Member (State t) r
  2. => t -> s
  3. -> s -> t -> t
  4. -> Handler e (State s ': r)
  5. -> Handler e r
#

Run a handler over one part of a larger state. A failing operation leaves the part as it was.