HORIZON HASKELLDocslts/ghc-10.0.x2b276322026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 2b27632 · 2026-10-31

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.

Contents
  1. First-order theories
  2. Verbs and the wire
  3. Results
  4. Reads and writes
  5. Routing
  6. Failure
  7. Observations
  8. Handlers
Synopsis

First-order theories

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.

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

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

Reads and writes

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

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

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

Handlers

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.