← Back to Documentation

Cure Language: Ultimate Implementation Description

Version: 0.1.0 (October 2025) Status: Research/Educational Implementation with Production-Ready Core Components

---

Executive Summary

Cure is a strongly-typed, dependently-typed programming language for the BEAM VM with native finite state machine (FSM) support. The implementation consists of 23 Erlang modules (~15,000 LOC) implementing the complete compiler toolchain, and 11 standard library modules written in Cure itself.

Current State: The core compiler pipeline is fully functional with demonstrated end-to-end compilation and execution. Recent additions include multi-clause functions with union type derivation, record types with pattern matching, and pattern guards - bringing the language closer to production readiness. Several advanced features are implemented but require refinement for production use. The FSM system is production-grade with comprehensive runtime support.

---

Part 1: Erlang Implementation (src/) - Detailed Analysis

1.1 Lexer (src/lexer/)

File: cure_lexer.erl (~2,500 LOC)

Fully Implemented

🟡 Implemented with Provisos

Not Implemented

Production Readiness: 90% - Fully functional for compilation, needs incremental support for IDE features

---

1.2 Parser (src/parser/)

Files: cureparser.erl (~3,800 LOC), cureast.erl (~1,200 LOC), cureast.hrl (record definitions), cureerror_reporter.erl (~600 LOC)

Fully Implemented

Recently Completed

🟡 Implemented with Provisos

Not Implemented

Production Readiness: 90% - Core parsing is solid with multi-clause functions, records, and guards now fully supported; needs better error recovery

---

1.3 Type System (src/types/)

Files: curetypes.erl (~4,200 LOC), curetypechecker.erl (~3,500 LOC), curetypeoptimizer.erl (~3,800 LOC)

Fully Implemented

Core Type System (cure_types.erl): Type Checker (cure_typechecker.erl): Type Optimizer (curetypeoptimizer.erl):

🟡 Implemented with Provisos

Dependent Types: Higher-Kinded Types: Wildcard and Any Type Handling:

Not Implemented

Production Readiness: 75% - Core type system solid, dependent types need SMT integration, advanced features incomplete

---

1.4 Code Generation (src/codegen/)

Files: curecodegen.erl (~2,800 LOC), curebeamcompiler.erl (~1,400 LOC), cureguardcodegen.erl (~800 LOC), cureactioncompiler.erl (~600 LOC), curecompile_wrapper.erl (~400 LOC)

Fully Implemented

🟡 Implemented with Provisos

Not Implemented

Production Readiness: 85% - Core codegen is production-quality, needs complete guard validation and debug info

---

1.5 FSM Runtime (src/fsm/)

Files: curefsmruntime.erl (~1,800 LOC), curefsmcureapi.erl (~400 LOC), curefsmbuiltins.erl (~600 LOC), curefsm_runtime.hrl (record definitions)

Fully Implemented

🟡 Implemented with Provisos

Not Implemented

Production Readiness: 90% - FSM runtime is production-grade for single-node applications

---

1.6 SMT Solver Integration (src/smt/)

Files: curesmtsolver.erl (~900 LOC, two copies in src/smt/ and src/types/)

Fully Implemented (Stub/Fallback)

🟡 Implemented with Provisos

Not Implemented

Production Readiness: 30% - Architecture is correct, but needs actual solver integration for dependent type verification Critical for Production: This is the main blocker for advanced dependent type features. Currently, complex dependent type constraints are not verified at compile time.

---

1.7 LSP Server (src/lsp/)

File: curelspserver.erl (~800 LOC)

Fully Implemented

🟡 Implemented with Provisos

Not Implemented

Production Readiness: 40% - Basic LSP framework works, needs all editor features implemented

---

1.8 Runtime Support (src/runtime/)

Files: cureruntime.erl (~300 LOC), curestd.erl (~200 LOC)

Fully Implemented

🟡 Implemented with Provisos

Not Implemented

Production Readiness: 60% - Basic runtime works, needs more OTP integration

---

1.9 CLI and Build System (src/)

File: cure_cli.erl (~1,100 LOC), Makefile, rebar.config

Fully Implemented

🟡 Implemented with Provisos

Not Implemented

Production Readiness: 70% - CLI and build work, needs package management

---

Part 2: Cure Standard Library (lib/std/) - Detailed Analysis

The standard library consists of 11 modules written in Cure, totaling ~800 LOC.

2.1 Core Module (lib/std/core.cure)

Exports: 25 functions

Fully Implemented

Production Readiness: 95% - Comprehensive core utilities, well-tested

---

2.2 List Module (lib/std/list.cure)

Exports: 10 functions

Fully Implemented

Not Implemented (Commented Out)

Production Readiness: 80% - Core list operations work, needs indexing functions

---

2.3 Vector Module (lib/std/vector.cure)

Exports: 6 functions

Fully Implemented

🟡 Implemented with Provisos

Production Readiness: 85% - Dependent vector types work, needs runtime length validation

---

2.4 FSM Module (lib/std/fsm.cure)

Exports: 9 functions

Fully Implemented (via curify FFI)

All functions properly delegate to Erlang FSM runtime via type-safe curify bindings.

Production Readiness: 95% - FSM API is production-ready

---

2.5 I/O Module (lib/std/io.cure)

Exports: 5 functions

Fully Implemented

🟡 Implemented with Provisos

Not Implemented

Production Readiness: 60% - Basic output works, needs input and file I/O

---

2.6 Math Module (lib/std/math.cure)

Exports: 10 functions

Fully Implemented

Not Implemented

Production Readiness: 50% - Basic integer math works, needs floating point functions

---

2.7 Result Module (lib/std/result.cure)

Exports: 7 functions

🟡 Implemented with Provisos

Proviso: Uses simplified Int representation instead of proper Result(T, E) ADT. This is a temporary workaround until variant types are fully supported in the compiler. Production Readiness: 60% - Works but needs proper ADT support

---

2.8 Show Module (lib/std/show.cure)

Exports: 1 function

🟡 Implemented with Provisos

Not Implemented

Production Readiness: 20% - Stub implementation only

---

2.9 System Module (lib/std/system.cure)

Exports: 3 functions

Fully Implemented (via curify FFI)

Production Readiness: 95% - Complete time functionality via Erlang

---

2.10 Pair Module (lib/std/pair.cure)

Exports: 1 function

Fully Implemented

Production Readiness: 95% - Simple and effective Erlang tuple bridge

---

2.11 Rec Module (lib/std/rec.cure)

Exports: 3 functions

Fully Implemented (via curify FFI)

Production Readiness: 95% - Complete record/map functionality via Erlang

---

Part 3: What's Needed for Full Production Readiness

3.1 Critical Blockers (Must-Have for Production)

1. SMT Solver Integration (Priority: CRITICAL)

2. FSM Registration Automation (Priority: HIGH)

3. Standard Library Completion (Priority: HIGH)

4. Error Recovery in Parser (Priority: MEDIUM-HIGH)

5. Package Manager (Priority: MEDIUM)

---

3.2 Important Enhancements (Should-Have)

6. LSP Feature Completion (Priority: MEDIUM)

7. Comprehensive Test Coverage (Priority: MEDIUM)

8. Documentation Generation (Priority: MEDIUM)

9. Incremental Compilation (Priority: MEDIUM)

---

3.3 Advanced Features (Nice-to-Have)

10. Hot Code Loading (Priority: LOW-MEDIUM)

11. Distributed FSMs (Priority: LOW-MEDIUM)

12. Type Classes/Traits (Priority: LOW)

13. Effect System (Priority: LOW)

---

Part 4: Current Production Readiness Assessment

By Component

| Component | Readiness | Status | Blockers |

|-----------|-----------|--------|----------|

| Lexer | 90% | ✅ Production | Incremental lexing for IDE |

|| Parser | 90% | ✅ Production | Error recovery |

| Type System | 75% | 🟡 Functional | SMT integration, advanced features |

| Code Generation | 85% | ✅ Production | Complete guard validation, debug info |

| FSM Runtime | 90% | ✅ Production | Auto-registration, persistence |

| SMT Solver | 30% | ❌ Stub | Actual solver integration |

| LSP Server | 40% | 🟡 Basic | All editor features |

| Runtime | 60% | 🟡 Basic | OTP integration, profiling |

| CLI/Build | 70% | 🟡 Functional | Package management |

| Standard Library | 65% | 🟡 Functional | Complete implementations, ADTs |

Overall Assessment

Current Status: 70% Production-Ready Strengths: Weaknesses:

---

Part 5: Recommended Roadmap to Production

Phase 1: Core Stability (4-6 weeks)

  1. SMT Solver Integration (2-3 weeks)
  2. FSM Registration Automation (3-5 days)
  3. Parser Error Recovery (1 week)
  4. Standard Library Essentials (1-2 weeks)
Deliverable: Cure 0.2.0 - Stable core with verified dependent types

---

Phase 2: Developer Experience (4-6 weeks)

  1. LSP Feature Completion (2-3 weeks)
  2. Comprehensive Documentation (1-2 weeks)
  3. Package Manager MVP (3-4 weeks)
  4. Incremental Compilation (2-3 weeks)
Deliverable: Cure 0.3.0 - Production-ready developer tooling

---

Phase 3: Ecosystem Growth (8-12 weeks)

  1. Standard Library Expansion (3-4 weeks)
  2. Community Packages Support (2-3 weeks)
  3. Hot Code Loading (2-3 weeks)
  4. Distributed FSMs (3-4 weeks)
Deliverable: Cure 1.0.0 - Full-featured production language

---

Phase 4: Advanced Features (Future)

  1. Type Classes/Traits (4-6 weeks)
  2. Effect System (6-8 weeks)
  3. Linear Types (8-12 weeks)
  4. Macro System (6-8 weeks)
Deliverable: Cure 2.0.0 - Research-grade advanced type system

---

Part 6: Conclusion

Cure is a remarkably complete implementation of a dependently-typed functional programming language for the BEAM. The core compiler pipeline is production-ready, and the FSM system is best-in-class.

The primary gap is SMT solver integration - without it, dependent type verification is limited to symbolic evaluation. Once this is addressed, along with standard library completion and basic tooling improvements, Cure will be ready for serious production use. Timeline to Production: With focused development, Cure could be production-ready in 8-12 weeks (Phase 1 + Phase 2). Current Best Use Cases: Future Potential:

With completion of the roadmap, Cure could become the premier choice for type-safe, formally-verified BEAM applications, especially in domains requiring strong correctness guarantees (financial systems, safety-critical systems, complex state machines).

---

Document Version: 1.0 Last Updated: October 2025 Authors: Cure Development Team