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

Modulesheaf-0.2.0.0GHC2021

Sheaf.Theory

A theory as first-class data: the signature of a vortex DSL — its sorts, its operations (each a sorted arity), and the equations its terms satisfy. Pure syntax, no interpretation and no IO: a theory says what can be written, never what it means. A model (an interpreter) is a separate thing an app supplies; see the estate master plan, L4.

This is the L4-P0 skeleton (master-plan G18a): the vocabulary the category of theories is about, plus a canonical printer and parser whose round-trip law (parse . print = Right) is this phase's exit check. Morphisms, pushouts, and the sheaf gluing come later and build on this datatype; nothing here commits to them.

The representation is deliberately small and self-contained (base + containers). A later phase reconciles Term with vortex-elab's own typed-term representation rather than keeping two; until the host (vortex-theory) exists, this stands alone so the DSL closure the elaborator will load carries no host code.

  • 7 types
  • 10 values
  • Packagesheaf-0.2.0.0
  • Exports17
  • LanguageGHC2021
  • LicenceMIT
  • SourceTheory.hs

The signature

6 declarations
newtypenewtype Sort
#

A sort: a named carrier the theory ranges over (e.g. Signal, Mesh, Machine). Just a name at this layer.

Constructors

Instances4Eq, Ord, Read, Show
  • Eq SortDefined in sheaf-0.2.0.0 · Sheaf.Theory
  • Ord SortDefined in sheaf-0.2.0.0 · Sheaf.Theory
  • Read SortDefined in sheaf-0.2.0.0 · Sheaf.Theory
  • Show SortDefined in sheaf-0.2.0.0 · Sheaf.Theory
datadata Op
#

An operation: a name, the sorts of its arguments (in order), and the sort of its result. This is a sorted arity — the whole of what the signature says about an op. A nullary op (empty argument list) is a constant of its result sort.

Constructors

Instances4Eq, Ord, Read, Show
  • Eq OpDefined in sheaf-0.2.0.0 · Sheaf.Theory
  • Ord OpDefined in sheaf-0.2.0.0 · Sheaf.Theory
  • Read OpDefined in sheaf-0.2.0.0 · Sheaf.Theory
  • Show OpDefined in sheaf-0.2.0.0 · Sheaf.Theory
datadata Equation
#

An equation: two terms asserted equal (they must be of the same sort in a well-formed theory; that is checked, not assumed here), under premises. With no premises it holds everywhere; with premises it is a conditional equation (a Horn clause of equational logic), holding wherever every premise does. A side condition that is a predicate is stated as a premise p(…) = true over a declared boolean sort, which keeps premises positive, as Horn clauses require.

Instances4Eq, Ord, Read, Show
datadata Premise
#

A premise of a conditional equation: two terms that must be equal for the equation to hold.

Constructors

Instances4Eq, Ord, Read, Show
  • Eq PremiseDefined in sheaf-0.2.0.0 · Sheaf.Theory
  • Ord PremiseDefined in sheaf-0.2.0.0 · Sheaf.Theory
  • Read PremiseDefined in sheaf-0.2.0.0 · Sheaf.Theory
  • Show PremiseDefined in sheaf-0.2.0.0 · Sheaf.Theory
datadata Term
#

A term over the signature: a variable (its name and sort) or an operation applied to sub-terms. Terms are what equations relate and what a later fold interprets; here they exist so equations can be stated and so the printer/parser have something to round-trip.

Constructors

Instances4Eq, Ord, Read, Show
  • Eq TermDefined in sheaf-0.2.0.0 · Sheaf.Theory
  • Ord TermDefined in sheaf-0.2.0.0 · Sheaf.Theory
  • Read TermDefined in sheaf-0.2.0.0 · Sheaf.Theory
  • Show TermDefined in sheaf-0.2.0.0 · Sheaf.Theory

Construction

4 declarations
valuetheory :: [Sort] -> [Op] -> [Equation] -> Theory
#

Build a theory, canonicalising the sort and op lists (deduplicated and ordered) so two theories that declare the same signature in a different order are equal and print identically. Equations keep their given order (order can be semantically relevant to a later rewrite system, so we do not reorder them — only sorts and ops are sets).

valueemptyTheory :: Theory
#

The empty theory: no sorts, no ops, no equations. The initial object of the category; a colimit's identity element.

Queries

5 declarations

Check well-formedness: every op's argument and result sorts are declared, op names are unique, every term in an equation names a declared op with the right arity, every variable is used at a single sort across a clause, the two sides of each equation and of each of its premises have the same sort, and no op is named like a keyword. Returns the list of problems (empty = well formed).

datadata WellFormedError
#

Ways a theory can fail well-formedness (verification level #1 in the master plan: everything refers only to declared sorts, and equations are sort-consistent). Total and decidable.

Constructors

Instances2Eq, Show

Canonical form

2 declarations
valueprintTheory :: Theory -> String
#

Print a theory to its canonical textual form. The form is line oriented and stable (sorts then ops then equations, each already in canonical order from theory), so parseTheory . printTheory is the identity on well-constructed theories — the round-trip law that is this phase's exit check. This is a human- and diff-friendly serialisation; it is not the wire protocol (that is vortex-wire).

Parse the canonical form back to a Theory. Deliberately small and forgiving of surrounding whitespace; it is the inverse of printTheory on that printer's own output, which is all the exit check requires. Returns Left with a message on malformed input.