Missed cases get caught
Add a case to a type, and every match that forgets it fails to compile instead of failing at runtime.
Python-like syntax, static types, runs on the JVM. When something is wrong, the compiler tells you where, why, and how to fix it.

import java.time.LocalDate as LocalDate
variant Shape:
Circle(radius: Float)
Rect(width: Float, height: Float)
func area(shape: Shape) -> Float:
return match shape:
case Shape.Circle as circle:
3.14159 * circle.radius * circle.radius
case Shape.Rect as rect:
rect.width * rect.height
print(area(Shape.Circle(radius=1.0)))
print(area(Shape.Rect(width=2.0, height=3.5)))
let day = LocalDate.parse("2026-10-05")
if day != null:
print(day.getDayOfWeek())Output:
3.14159
7.0
MONDAYAdd a Triangle to Shape later and forget to update area, and sprig check points straight at it:
SPR-MATCH-NONEXHAUSTIVE [FLOW] main.spr:9:12: Missing case: Shape.Triangle
hint: Add 'case Shape.Triangle:' (there is no default case)Sprig is young. The current release is the experimental v0.9.0-beta.1, requiring JDK 21+. The features above and the syntax used by the tutorial are included in this SDK. It has no Sprig class inheritance or variance and is not meant for production use yet. This site follows main; consult release status and your installed compiler for later changes. See known limitations for the full list.
You need JDK 21 or newer. Once the SDK is installed:
sprig init hello
cd hello
sprig resolve
sprig runWhen you see Hello, Sprig!, head to the tutorial and build a small expense tracker in about half an hour.
中文 · Apache-2.0 · GitHub