
L4 with IDE
L4 is a domain-specific programming language for law by Legalese. It formalizes legal rules and contracts as executable specifications, bringing software engineering rigor to legal drafting and analysis.
This repository contains the L4 compiler, IDE tooling (VS Code extension, LSP, REPL, web editor), and a decision service that exposes L4 rules as REST APIs and MCP tools.
What You Get From a Single L4 File
- REST APIs — Expose functions as HTTP endpoints with
@export annotations
- AI tool integration — MCP server for Claude, Cursor, and VS Code Copilot; WebMCP for in-browser agents
- Interactive visualizations — Ladder diagrams and evaluation traces rendered via GraphViz
- Audit-grade explainability — Every evaluation produces a trace you can follow from the top-level question down to the deciding condition
- Test suites — Golden-file tests and assertions
- Generated schemas — OpenAPI 3.0 specs and JSON schemas for integration
Getting Started
Repository Layout
Haskell (Cabal):
| Package | Purpose |
|---|
| jl4-core | Core language (parser, typechecker, evaluator) |
| jl4 | CLI tool and JSON schema generator |
| jl4-lsp | Language Server Protocol for IDE support |
| jl4-repl | Interactive REPL |
| jl4-service | REST API for decision evaluation |
| jl4-query-plan | Query planning utilities |
| jl4-actus-analyzer | Static analyzer classifying L4 contracts by ACTUS / FIBO |
| jl4-wasm | WebAssembly build of L4 for browser/Node.js |
| jl4-mlir | MLIR/WASM compiler backend: L4 → .wasm decision binary |
TypeScript (npm workspaces + Turborepo):
Documentation: The language reference, tutorials, courses, and concept guides are published at legalese.com/l4; their source is in doc/.
VS Code Extension