Mere REPL — written in Mere, running in the browser

Paste a Mere expression or a full file on the left and press Run. The Wasm module on this page tokenizes, parses, and evaluates your input — all written in Mere itself, no server round-trip. The companion page self-host fmt covers the format half of the pipeline; this one closes the loop.

Source: eval.mere (tree-walking interpreter), parser.mere, lexer.mere, bridged by selfhost-repl.mere. The shared AST lives in contrib/parser/ast.mere.

Result
(press Run to evaluate)
print output

        

Pipeline

Four contrib libraries combine into the Wasm running on this page:

  1. lexer.mere — source → tokens
  2. parser.mere — tokens → AST
  3. eval.mere — AST → value (this stage)
  4. selfhost-repl.mere — DOM glue (textarea → parse_and_eval → output)

eval.mere covers literals, the binary / comparison / logical operator groups, if, closures with captured env, let and match with the full pattern set, let rec with mutual recursion via the VRecBinding placeholder trick (pure-functional, no ref), constructors, tuples, lists (with [1, 2, 3] reconstruction over Cons / Nil), and records (literal / field access / update / pattern match). The host-provided builtin set is currently just print and show — most useful work flows through the operator-level paths instead.

Limitations

Why this matters

Phase 51 closes §S2.A — the self-host evaluator. Combined with §S1 (self-host parser + fmt, Phase 49 + 50), Mere can now parse, format, AND evaluate its own source code, in the browser, with no server round-trip.