An executable Haskell implementation of Semprola (Semiotic Programming Language)
Find a file
2026-11-05 11:57:22 +01:00
app Initial commit: Semprola Haskell MVP 2026-11-05 11:57:22 +01:00
docs Initial commit: Semprola Haskell MVP 2026-11-05 11:57:22 +01:00
examples Initial commit: Semprola Haskell MVP 2026-11-05 11:57:22 +01:00
src/Semprola Initial commit: Semprola Haskell MVP 2026-11-05 11:57:22 +01:00
test Initial commit: Semprola Haskell MVP 2026-11-05 11:57:22 +01:00
.gitignore Initial commit: Semprola Haskell MVP 2026-11-05 11:57:22 +01:00
cabal.project Initial commit: Semprola Haskell MVP 2026-11-05 11:57:22 +01:00
LICENSE Initial commit: Semprola Haskell MVP 2026-11-05 11:57:22 +01:00
README.md Initial commit: Semprola Haskell MVP 2026-11-05 11:57:22 +01:00
semprola.cabal Initial commit: Semprola Haskell MVP 2026-11-05 11:57:22 +01:00

Semprola (Haskell MVP)

An executable Haskell implementation of the core ideas in Oli Sharpe's Semprola: A Semiotic Programming Language (Programming 2018, DOI 10.1145/3191697.3214330).

The paper is a vision and architecture paper rather than a complete language specification. This repository therefore implements a documented MVP profile of its central mechanisms:

  • cold signifiers and cold nodedges;
  • hot signs produced by context-sensitive interpretation;
  • multiple ontological spaces;
  • semantic-depth and explicit-space resolution;
  • exact quantities with units;
  • asynchronous messages and request/response correlation;
  • a small stack-based SPVM;
  • a constrained textual Semprola projection;
  • SQLite persistence for cold spaces.

It does not claim to implement the paper's full distributed platform, complete IDE, or unspecified conflict-resolution semantics. See docs/SEMANTICS.md for the precise profile.

Quick start

New here? Start with the 20-minute hands-on tutorial: docs/TUTORIAL.md.

Requirements: GHC 9.6+, Cabal 3.10+, and SQLite development headers (libsqlite3-dev on Debian/Ubuntu).

cabal build all
cabal test
cabal run semprola -- demo

The demo runs the paper's Viv weight example, the tree disambiguation example, and the reading-group dialogue.

Commands

# Run the built-in examples.
cabal run semprola -- demo

# Inspect the example spaces and nodedges.
cabal run semprola -- inspect

# Run a textual Semprola program against Viv's spaces.
cabal run semprola -- run examples/clinic-weight.sem
cabal run semprola -- run examples/viv.sem

# Run the reading-group dialogue and drain its messages.
cabal run semprola -- run examples/reading-group.sem --space reading

# Persist the example cold spaces to SQLite.
cabal run semprola -- persist /tmp/semprola.db

run currently supports the clinic and reading catalogues. The example programs are in examples/.

What the demo shows

  1. patient.weight uses the immediate referent in the active clinic space and reads 52.1 kg.
  2. @patient.weight asks the context for the semantically deepest permitted referent and reads the home value 54.5 kg.
  3. Assignment through @patient.weight := 53.5 kg updates the selected cold nodedge, not a process-local pointer.
  4. The same text "Tree" resolves against different concepts and spaces.
  5. A reading-group sign's list is iterated and one invite message is delivered to each member.

Architecture

textual projection / structural editor
                 │
                 ▼
        Semprola source graph
                 │
                 ▼
             compiler
                 │
                 ▼
        SPVM instructions
                 │
                 ▼
 SPVM ── context-sensitive resolver ── ontological spaces
   │                                      │
   └──────── message broker ──────────────┘
                 │
                 ▼
        SQLite cold persistence

Modules

Module Responsibility
Semprola.Core.SPUID Opaque globally unique logical addresses
Semprola.Core.Canonical Deterministic JSON encoding for cold storage
Semprola.Core.Signifier Cold signifiers and literal constructors
Semprola.Core.Nodedge Cold nodedges and cold graphs
Semprola.Core.Bootstrap Stable bootstrap concepts, units, spaces
Semprola.Core.Quantity Exact rational quantities and unit conversion
Semprola.Store.Types Space metadata and catalogues
Semprola.Store.SQLite Versioned cold-space persistence
Semprola.Runtime.Context User/space/permission/time context
Semprola.Runtime.Resolver Cold signifier to hot sign interpretation
Semprola.Runtime.HotGraph Process-local hot graph loading
Semprola.Runtime.Message STM broker and request/response correlation
Semprola.Runtime.VM Stack-based SPVM and fast/slow verifier
Semprola.Language.AST Surface AST
Semprola.Language.Parser Constrained textual projection parser
Semprola.Language.Compiler AST to SPVM instructions
Semprola.Language.Eval Compile-and-run convenience API
Semprola.Examples Viv, reading-group, and tree examples
Semprola.CLI demo, run, inspect, persist, version

Semantics in one page

  • Cold signifier: persisted symbolic material. It is either a direct SPUID reference or a compound signifier with a concept SPUID, optional text, language, author context, and extra signifier-valued properties.
  • Hot sign: a cold signifier interpreted in a context. It carries all permitted candidate referents, the selected referent, and an optional literal value. Hot signs are never persisted.
  • Ontological space: a cold graph with an owner and name. Spaces are peers; none is the master ontology.
  • Resolution: candidates are found by concept identity, not by matching display text. Immediate prefers the active space. Best ranks by explicit semantic-depth metadata, then context priority, then a stable SPUID tie-breaker. InSpace and ByPath restrict the candidate set.
  • Quantities: magnitudes are exact rationals and units are explicit SPUIDs. Conversion checks dimensions and never silently uses naked floating point.
  • Dialogue: messages are cold, serializable envelopes. The in-process broker is deliberately behind a transport-shaped API so a network transport can be added later.
  • Fast/slow code: the verifier rejects sends, dynamic resolution, and property access in fast instruction sequences.

Tests

cabal test --test-show-details=direct

The suite covers SPUID round trips, cold graph serialization, exact unit conversion, immediate/best/explicit/taxonomy resolution, permission filtering, tree disambiguation, SPVM property access and assignment, reading-group message delivery, parser behavior, SQLite restart persistence, request/response correlation, and fast/slow verification.

Scope and next steps

Implemented now: local multi-space runtime, cold persistence, exact quantities, small SPVM, textual examples, local asynchronous dialogue.

Deferred: real network transport and space discovery, authentication and capability tokens, conflict resolution, durable pause/resume of interactions, a graphical structural IDE, full response-handler execution, self-hosting, and the paper's unspecified “best referent” algorithm beyond the documented policy.

The next engineering steps are to add a network broker behind Semprola.Runtime.Message, a structural graph editor, and a versioned behaviour/bytecode update path. The current code keeps those boundaries explicit so they can be added without changing the cold data model.