A functional programming language for 3D CAD design
COVARIANT is a new approach to 3D CAD that treats design as compilable code with first-class engineering semantics.
Unlike traditional CAD systems that record GUI operations or SCAD-like languages that generate meshes imperatively, COVARIANT:
- ✅ Preserves design intent through semantic representation
- ✅ Supports incremental compilation for fast iteration
- ✅ Provides step-by-step debugging of geometry construction
- ✅ Treats engineering features (threads, holes, fillets) as first-class values
- ✅ Expresses mathematical geometry naturally (curves, surfaces, sweeps)
// Define a mounting plate with threaded holes
let plate = box(vec3(80mm, 50mm, 5mm))
let hole = threaded_hole(
ISO_METRIC, M3, TAP,
depth = 8mm,
chamfer = 0.5mm
)
let model = difference(plate,
union_many([
move(hole, vec3(10mm, 10mm, 0)),
move(hole, vec3(70mm, 10mm, 0)),
move(hole, vec3(70mm, 40mm, 0)),
move(hole, vec3(10mm, 40mm, 0))
])
)
export_stl("plate.stl", model)
Every design is a pure expression:
- No side effects
- Referential transparency
- Composable and reusable
Engineering features are not just shapes:
// This isn't just a cylinder - it's a specification
threaded_hole(ISO_METRIC, M3, TAP, depth=10mm, chamfer=0.5mm)
The system knows:
- Exact thread dimensions from standards (ISO, UTS, etc.)
- Different export modes (preview/cosmetic/full threads)
- Engineering intent for downstream tools
Work with curves and surfaces directly:
let profile = circle2d(radius = 2mm)
let path = helix(radius = 10mm, pitch = 5mm, turns = 3)
let spring = sweep(profile, path)
Step through your design construction:
render_debug(model, step=2) // See exactly what happens at each step
Current Phase: Language design and specification
- Core language philosophy defined
- Type system designed
- Geometric primitives specified
- Engineering features (threaded holes) designed
- Debug mechanism specified
- Parser implementation
- IR (DAG) implementation
- Geometric kernel integration
- Preview renderer
- STL export
- SPEC.md - Complete language specification
- DESIGN.md - Design decisions and rationale (planned)
- TUTORIAL.md - Getting started guide (planned)
- Design as Code: Designs are expressions that can be version-controlled, tested, and composed
- Engineering First: Threaded holes, tolerances, and manufacturing constraints are primitives
- Incremental: Fast recompilation on design changes
- Debuggable: Step-by-step visualization of construction
- Mathematical: Native support for curves, surfaces, and parametric geometry
- Sculpting/artistic modeling
- Direct mesh manipulation
- GUI operation recording
- Real-time physics
┌──────────────┐
│ Source Code │
│ (.cov) │
└──────┬───────┘
│
▼
┌──────────────┐
│ AST │
└──────┬───────┘
│
▼
┌──────────────┐ ┌─────────┐
│ IR (DAG) │────▶│ Cache │
└──────┬───────┘ └─────────┘
│
▼
┌──────────────┐
│ Evaluation │
└──────┬───────┘
│
▼
┌──────────────┐
│ Geometry │
│ (Preview/ │
│ Export) │
└──────────────┘
Note: Implementation has not yet started. This is currently a design document.
When implementation begins:
cargo build --release
cargo run -- example.covThis project is in the design phase. Contributions to the specification and design are welcome!
Areas of interest:
- Language syntax and semantics
- Geometric kernel selection/integration
- Thread standard databases
- Debug visualization approaches
Inspired by:
- OpenSCAD: Pioneering code-based CAD
- Haskell: Functional programming principles
- ImplicitCAD: Mathematics-first CAD