Skip to the content
Diaspar

Decision D007 · accepted; set-theoretic types proposed

Types are inferred; the compiler warns

A record of the language's design, as it stood on 2026-11-18: written for the people who build Diaspar, and kept as it was written. Its code is a sketch, not a program of the site, and an older record may show syntax that a later one changed. It names files of the language's source, which is not public yet.

Status: accepted (2026-11-15) for inference and warnings instead of required annotations; proposed for set-theoretic types and open maps

Decision

The core of Diaspar is dynamic: a program runs without type annotations. The compiler infers types itself and reports likely errors as warnings, not as a refusal to compile. The reference point is Elixir 1.20 (June 2026): set-theoretic types (unions, intersections, negations) inferred for existing code without annotations.

Example (sketch; syntax not settled)

(defn total [#{:price p :qty q}] (* p q))

(total #{:price 10})                    ; warning: key :qty is missing
(total #{:price 10 :qty 2 :note "x"})   ; no warning: maps are open

(defn describe [x]
  (if (string? x)
    (upper x)      ; here x is a string: the type narrows after the check
    (str x)))

Unused values (accepted, 2026-11-16)

A value computed in the middle of a body and thrown away, by an expression that has no effect, is a warning, as Rust's "path statement with no effect" and Go's "evaluated but not used":

(deftest slow-sync :tags #[:slow]     ; warning: this value is not used
  (is …))
warning: this value is not used
  --> sync.dias:1:20
   = note: it has no effect, so computing it does nothing
  • Where: every position whose value is discarded: all but the last form of do, of a fn or let body, of when, of a handler; top-level expressions are not affected, since they are not discarded in the REPL.
  • Which expressions: literals (numbers, strings, keywords, nil), quoted data, references to locals and globals, field reads (p.x), data literals made only of such parts, and f-strings without calls. With effect inference, any call whose inferred effects are empty also counts (a pure function's result that is dropped is almost always a mistake); without it, as in the bootstrap, calls are never reported.
  • Deliberately ignoring a value is written (let [_ expr] …).
  • The interpreter and the compiler report the same warning at the same place (D003).

Why

  • A live environment. Strict types break when functions are redefined in the REPL; warnings do not. The same argument as for effects (D005).
  • Strict gradual typing is expensive. Typed Racket: checks at the boundary between typed and untyped code slow programs by more than 20×; "shallow" checks by up to 6×. Inference without runtime checks has no such cost.
  • Set-theoretic types fit a Lisp: maps, unions, and narrowing after checks (string?) are ordinary Lisp code.
  • Help for agents. Type-constrained decoding cuts models' compile errors by more than half (PLDI 2025), and giving a model access to the checker helps low-resource languages most.

Rejected alternatives

  • Required static types with Hindley–Milner inference (as in Coalton, Carp): fit badly with maps and live redefinition. Coalton also dropped currying because of distorted APIs and poor errors.
  • Strict gradual typing (Typed Racket Deep): expensive at run time.
  • No types at all: loses early error detection and help for agents.

Open questions

  • May annotations be written explicitly, and what do they give: documentation only, warnings, or checks?
  • Where does a warning become an error: in the runtime, in std.unsafe modules, in CI behind a flag?