Elle Language Guide
Data Types
Elle supports a rich set of data types. All types have a mutable/immutable split.
Variables and Bindings
Functions
Control Flow
Pattern Matching
Elle's match expression provides destructuring with wildcards, & rest, nested patterns, and struct tag dispatch:
# match on structure
(match [1 2 3]
([a b c] (+ a b c)) # binds a=1, b=2, c=3
(_ 0)) # default
# match on values
(match x
(0 "zero")
(1 "one")
(_ "other"))
# destructuring with & rest
(match [1 2 3 4 5]
([first & rest] (print "first:" first "rest:" rest)))Error Handling
Errors are signals. Use try/catch or handle them at the fiber level with signal masks:
(try
(/ 10 0)
(catch e
(print "caught:" e)
(println))
(finally
(print "cleanup")))
# protect ensures cleanup runs even on error
(protect
(risky-operation)
(cleanup))Modules
Load and compose code with import-file. Each module is a closure — imports are parametric:
# in utils.elle
(defn double [x] (* x 2))
# in main.elle
(import-file "utils.elle")
(println (double 21)) # 42