A functional Lisp that compiles to PHP. The pages below are ordered as a guided path: start with Basic Types and Data Structures, then work down. Already know the basics? Jump straight to any topic.
Basic Types
Phel's primitive values: nil, booleans, numbers, strings, keywords, plus truthiness, equality, and reader literals
Data structures
Phel's persistent collections: lists, vectors, maps, sets, structs, plus core functions like conj, assoc, get-in, and into
Global and local bindings
Bind values to names with def and let, rebind dynamic vars with binding, and manage mutable state with atoms
Control flow
Branch, loop, and build collections with if, cond, case, loop/recur, for, and thread macros like cond->
Functions and Recursion
Define functions with fn and defn, use multi-arity and variadics, recurse safely with recur, and dispatch with multimethods
Destructuring
Bind names to values inside vectors, lists, and maps by shape in let, function params, and loop
Error handling
Throw and catch exceptions, handle PHP exceptions, attach data with ex-info, and decide when to throw vs return nil
Namespaces
Declare namespaces with ns, require Phel modules and PHP classes, and use aliases, :refer, and namespaced keywords
Interfaces
Define contracts with definterface, implement them in structs, extend types with protocols, and dispatch via hierarchies
Macros
Write compile-time code that rewrites code: defmacro, quasiquote, macroexpand, gensym hygiene, and when a macro is worth it
Lazy Sequences
Defer computation with lazy-seq and lazy-cat, build infinite sequences, and avoid the common laziness pitfalls.
Transducers
Build composable, allocation-free transformation pipelines that decouple the transformation from the consumer, and write your own custom transducers
Reader Shortcuts
Compact catalog of the reader macros and special syntax the Phel reader expands at read time: literals, quote/quasiquote, tagged literals, anonymous functions, reader conditionals, and metadata.
Reader Conditionals
Write platform-specific code in shared .cljc source files with #?() and #?@(), resolved at parse time using :phel and :default keys
Numeric Tower
Phel's five numeric shapes (int, BigInt, Ratio, BigDecimal, float), when each appears, and how arithmetic dispatches across them
Async & Concurrency
Run work concurrently with Phel's two fiber-based layers: top-level promises and futures, plus an AMPHP event loop for timers, IO, and fan-out