AILANG REPL Commands Reference
Starting the REPL
ailang repl
The REPL auto-imports std/prelude
on startup, providing:
- Numeric defaults:
Num → Int
,Fractional → Float
- Type class instances for
Num
,Eq
,Ord
,Show
- String concatenation with
++
operator - Record literals and field access
Basic Commands
:help, :h
- Show all available commands:quit, :q
- Exit the REPL (also works: Ctrl+D):type <expr>
- Show qualified type with constraints:import <module>
- Import type class instances:instances
- List available instances with superclass provisions:history
- Show command history:clear
- Clear the screen:reset
- Reset environment (auto-reimports prelude)
Debugging Commands
:dump-core
- Toggle Core AST display for debugging:dump-typed
- Toggle Typed AST display:dry-link
- Show required dictionary instances without evaluating:trace-defaulting on/off
- Enable/disable defaulting trace
AI-First Commands
:effects <expr>
- Inspect type and effects without evaluation:test [--json]
- Run tests with optional JSON output:compact on/off
- Toggle JSON compact mode for token efficiency
Interactive Features
- Arrow Key History: Navigate command history with ↑/↓ arrows
- Persistent History: Commands saved in
~/.ailang_history
- Tab Completion: Auto-complete REPL commands with Tab key
- Multi-line Input: Automatic continuation for incomplete expressions
Example Session
λ> 1 + 2
3 :: Int
λ> 3.14 * 2.0
6.28 :: Float
λ> "Hello " ++ "AILANG!"
Hello AILANG! :: String
λ> [1, 2, 3]
[1, 2, 3] :: [Int]
λ> {name: "Alice", age: 30}
{name: Alice, age: 30} :: {name: String, age: Int}
λ> :type \x. x + x
\x. x + x :: ∀α. Num α ⇒ α → α
λ> let double = \x. x * 2 in double(21)
42 :: Int
λ> :instances
Available instances:
Num:
• Num[Int], Num[Float]
Eq:
• Eq[Int], Eq[Float], Eq[String], Eq[Bool]
Ord:
• Ord[Int] (provides Eq[Int])
• Ord[Float] (provides Eq[Float])
• Ord[String] (provides Eq[String])
Show:
• Show[Int], Show[Float], Show[String], Show[Bool]
λ> :quit # Exit REPL
Multi-line Input Support
The REPL supports multi-line expressions with automatic continuation:
λ> let user = {name: "Alice", age: 30} in
... user
{name: Alice, age: 30} :: {name: String, age: Int}
Type Class Pipeline
The REPL executes the full pipeline:
- Parse - Surface syntax to AST
- Elaborate - AST to Core (ANF)
- TypeCheck - Infer types with constraints
- Dictionary Elaboration - Transform operators to dictionary calls
- ANF Verification - Ensure well-formed Core
- Link - Resolve dictionary references
- Evaluate - Execute with runtime dictionaries