Skip to main content

Spore (孢子)

A general-purpose programming language optimized for Agent-human intent interaction.

Spore is a compiled language where function signatures are "gravity centers" — complete specifications carrying type, error, required effect, and cost information. The compiler serves as a documentation assistant, and the hole system enables Agent-driven collaborative development.

Key Features

  • Hole System: ?name partial functions as first-class collaboration protocol with Agents
  • Effect System: IO effects gated by required effects, verified at compile time
  • Cost Model: 4-dimension cost analysis (compute, alloc, io, parallel) with compile-time budgets
  • Content-Addressed: Dual hash (sig + impl) for modules — no semver, pure hash addressing
  • Effect Handlers: All IO through Platform-provided effect handlers, application code stays pure
  • Structured Concurrency: Task trees with cancellation propagation, channels for communication
  • Expression-Based: Everything is an expression, no loops (recursion + higher-order functions)

Canonical Surface Syntax

  • Modules come only from file paths; there is no module ... header.
  • Effect checks live on function signatures and package/Platform boundaries only; source files have no module-level uses carrier.
  • Stable generic bounds use a single comma-separated clause: where T: Trait, U: Trait.
  • Effect operations use explicit effect declarations plus perform Effect.op(...); reusable unions use effect Name = A | B.
  • Error sets are checked contracts: throw expr must match the current ! E1 | E2, calling a throwing function requires compatible caller errors, and ? is propagation sugar.
  • Current implementation primitives are I32/I64/U32/U64/F32/F64/Bool/Str/(). The locked surface also keeps Int/Float as I64/F64 aliases; implementation catch-up is tracked separately.
  • The live structured-concurrency surface includes parallel_scope { ... }, spawn { ... }, postfix task.await, Channel.new[...], and select { ... timeout(...) => ... }.

Quick Start

cargo build                                      # build the compiler
cargo run --bin spore -- new hello-app          # create a new application project
cd hello-app && ../target/debug/spore run src/main.sp  # run the application from this checkout
cargo test --all                                 # run all compiler tests

For single-file exploration:

cargo run --bin spore -- run examples/demo.sp   # run standalone file (no Platform)
cargo run --bin spore -- check examples/demo.sp # type-check standalone file
cargo run --bin spore -- test examples/demo.sp  # validate spec examples in file

If spore is installed on your PATH, you can replace the explicit Cargo or target/debug/spore invocations above with bare spore ....

Examples

Hello World (Application Project)

The canonical way to write Spore programs is as a project with a Platform contract:

spore new hello-app

This generates src/main.sp with a Platform-aware entry point:

import basic_cli.stdout

fn main() -> () uses [Console] {
    println("Hello from hello-app!")
    return
}

Applications declare fn main() -> () and require effects that are handled by the Platform. The basic-cli Platform handles effect operations like Console for terminal IO.

Standalone File Mode

For quick experiments, you can run single .sp files without a project:

fn demo() -> I32 {
    let x = 42;
    x * 2
}

fn main() -> I32 {
    demo()
}

Standalone mode does not participate in a package-backed Platform contract and does not have access to platform builtins such as println. Console I/O requires a project with an explicit Platform effect boundary (e.g. basic-cli). See examples/demo.sp for a standalone example file.

Structs and Pattern Matching

struct Point { x: I32, y: I32 }

type Shape {
    Circle(I32),
    Rect(I32, I32),
}

fn area(s: Shape) -> I32 {
    match s {
        Circle(r) => r * r * 3,
        Rect(w, h) => w * h,
    }
}

Lambdas, Pipes, and Higher-Order Functions

fn apply(f: (I32) -> I32, x: I32) -> I32 { f(x) }

fn compute() -> I32 {
    let double = |x: I32| x * 2;
    apply(double, 21)
}

Required Effects, Costs, and Error Sets

These annotations are part of the function signature — the compiler verifies required effects, cost budgets, checked error contracts, and explicit effect surfaces at call boundaries. throw expr must be covered by the current function's ! E1 | E2, calling a throwing function requires a compatible caller signature, and ? is sugar for that propagation rule.

The parser accepts where, uses, cost, and spec clauses in any order. Documentation examples use the canonical order: where, uses, cost, spec, and stable where syntax is a single comma-separated clause such as where T: Trait, U: Trait. Active cost syntax is the fixed-order vector cost [compute, alloc, io, parallel]; each slot currently uses the minimal subset only: integer constants, parameter variables, or linear O(n) terms. Old scalar cost <= expr, log/max/min, and richer algebraic terms are deferred.

effect NetConnect {
    fn fetch(url: Str) -> Str ! NetError | Timeout
}

fn fetch(url: Str) -> Str ! NetError | Timeout
    uses [NetConnect]
    cost [1, 0, 1, 0]
{
    perform NetConnect.fetch(url)
}

Parallel Fetch

fn fetch_all(urls: List[Str], n: I32) -> List[Str] ! NetError | Timeout
    uses [NetConnect, Spawn]
    cost [O(n), O(n), n, n]
{
    parallel_scope {
        urls |> map(|url| spawn { fetch(url) })
             |> map(|task| task.await?)
    }
}

This is part of the live structured-concurrency surface: the parser, typechecker, and interpreter all cover the current parallel_scope / spawn / await / select subset. Until richer cost-slot terms land, examples use explicit parameters such as n instead of projections like urls.len. The same active-docs target also uses Channel.new[...] and select { msg from rx => ..., timeout(5.seconds) => ... }.

Traits and Implementations

trait Display[T] {
    fn show(self: T) -> Str
}

impl Display for Point {
    fn show(self: Point) -> Str { "point" }
}

Architecture

sporec (stateless compiler CLI / product)
└── sporec-driver    Host-side compiler driver crate
    ├── sporec-parser     Source text -> AST
    ├── sporec-typeck     Type checking, effect & cost analysis
    │   ├── hir          HIR with pipe desugaring
    │   ├── effect sets  Effect-set algebra (∪/∩/hierarchy)
    │   ├── cost         4D cost vectors + cost checker
    │   ├── hole         Hole dependency graph + topological ordering
    │   ├── sig_hash     BLAKE3 256-bit signature hashing
    │   ├── incremental  Incremental compilation DB
    │   ├── module       Module registry + import resolution
    │   ├── concurrency  Structured concurrency analysis
    │   └── platform     Platform system (cli/web/embedded)
    └── sporec-codegen   Tree-walk interpreter (PoC) / Cranelift (planned)

spore (stateful codebase manager — handles IO / project workflow)
├── File watching, incremental compilation
├── Package management (content-addressed)
├── Platform management
└── LSP server (spore-lsp)

Project Status

Compiler infrastructure implemented. Parser is feature-complete for the syntax spec. Type checker covers unification, pattern exhaustiveness, trait conformance, error set checking, cost analysis, and the current structured-concurrency subset. Interpreter is a PoC tree-walking evaluator with enum constructors, 30+ builtin functions (list/string/math/IO), method-style dispatch, try-operator support, and the current structured-concurrency runtime.

See docs/DESIGN.md for the canonical in-repo design document. Topic-level normative proposals live in the sibling spore-evolution repo under seps/.

Packaging

The spore CLI is packaged from crates/spore via maturin so it can be built and published as a PyPI binary package.

just package-cli        # build a wheel into dist/
just package-cli-sdist  # build a source distribution into dist/

Development

Local hooks

just pre-commit-install  # install pre-commit + commit-msg hooks via prek
just pre-commit          # run the configured hooks on all files

In this repository, the local Spore hooks intentionally focus on the canonical example surface under examples/. The reusable published hooks below are for arbitrary .sp files in downstream repos.

Reusable hooks

With the root pyproject.toml in place, the repository can also expose reusable pre-commit hooks for .sp files:

repos:
  - repo: https://github.com/spore-lang/spore
    rev: <tag-or-sha>
    hooks:
      - id: spore-format
      - id: spore-check

Until a dedicated thin mirror repo exists, installing these hooks from the source repo still builds Spore from source, so consumers need a working Rust toolchain.

Documentation

Canonical design docs

Document Description
docs/DESIGN.md Primary in-repo design document, syntax authority, and durable design summary
docs/specs/README.md Redirect for the retired per-topic spec drafts
docs/research/README.md Redirect for the retired research drafts

SEP mapping

Detailed topic proposals now live in spore-evolution/seps/:

License

MIT OR Apache-2.0

Metadata

Release files for spore-lang 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spore-lang 0.0.3
File Size Uploaded Provenance
spore_lang-0.0.3.tar.gz 239.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for spore-lang 0.0.3
File Interpreter ABI Platform
spore_lang-0.0.3-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details

Total release size: 1.3 MB

Release files / spore_lang-0.0.3.tar.gz

Download URL spore_lang-0.0.3.tar.gz
Size 239.3 kB
Tags Source
SHA-256 checksum
How to use checksums
c30f4e787918a4e90516d51b9ade8a2196751b681807218fdaeefccb4ee33a11
BLAKE2b-256 checksum
How to use checksums
4cb4f7c0e27d4b9a971c00cbd45c3f6ed783379a03d8af2aea6d4dcf61401ed2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / spore_lang-0.0.3-py3-none-macosx_11_0_arm64.whl

Download URL spore_lang-0.0.3-py3-none-macosx_11_0_arm64.whl
Size 1.1 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6c75e2f7bc01d8856e64b9ada08fe56e93a55b06d0a0d081cd891bd8872a2cee
BLAKE2b-256 checksum
How to use checksums
0d1f3c7bd718a40ec04eee89c1b0a64af21201ceec587e294c23d85d02de5fe8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for spore-lang 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page