Gradual typing
Browser runtime: loading…
Add annotations where they help, lean on inference elsewhere, and use structural interfaces when you want typed boundaries without explicit implementation declarations. Each runnable snippet uses the same WASM engine as the playground.
Type annotations
Sapphire is gradually typed: you can add name: Type and -> Type where they help, and lean on inference elsewhere. The type checker enforces the annotations you choose; untyped code still runs.
types.spr
Press Run to execute this snippet. ⌘↵ runs from the editor.
Interfaces and mixins
Interfaces are structural: a value satisfies an interface by implementing the required methods, without an explicit declaration. Modules package reusable methods and include(...) mixes them into a class.
interfaces.spr
Press Run to execute this snippet. ⌘↵ runs from the editor.