Skip to content

Comments

Add web REPL and stdin eval pipeline#1

Draft
aidenybai wants to merge 2 commits intoalii:masterfrom
aidenybai:web-repl
Draft

Add web REPL and stdin eval pipeline#1
aidenybai wants to merge 2 commits intoalii:masterfrom
aidenybai:web-repl

Conversation

@aidenybai
Copy link

Summary

  • src/arc/eval.gleam: Public eval(source) that runs parse → compile → VM with standard globals
  • src/arc_ffi.erl: Erlang FFI to read stdin
  • src/arc.gleam: Reads stdin on start — evals if present, otherwise prints banner
  • examples/server.ts: Bun HTTP server with Chrome DevTools-style console UI

Usage

# CLI
echo "1 + 2" | gleam run          # → 3
echo "Math.sqrt(144)" | gleam run # → 12

# Web REPL
cd examples && bun run server.ts
# open http://localhost:3000

Test plan

  • gleam build compiles clean
  • echo "1 + 2" | gleam run3
  • echo "var x = 'hello'; x.toUpperCase()" | gleam run"HELLO"
  • echo "Math.sqrt(144)" | gleam run12
  • echo "invalid @@@ syntax" | gleam runSyntaxError: ...
  • cd examples && bun run server.ts → interactive REPL at localhost:3000

🤖 Generated with Claude Code

aidenybai and others added 2 commits February 23, 2026 02:23
- src/arc/eval.gleam: eval(source) runs the full parse → compile → VM pipeline
- src/arc_ffi.erl: Erlang FFI to read all of stdin
- src/arc.gleam: if stdin has content, eval it; otherwise print banner
- examples/server.ts: Bun HTTP server with Chrome DevTools-style console UI

echo "1 + 2" | gleam run → 3

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The same dict of standard globals (NaN, Infinity, undefined, Object, etc.)
was duplicated in eval.gleam, test262_exec.gleam, and compiler_test.gleam.
Move it to a single pub fn globals() in builtins.gleam.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
function parseGleamOutput(exitCode: number, stdout: string, stderr: string) {
const result = stdout.trim();
// Filter out gleam's own build output from stderr
const appErrors = stderr
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To merge this we should do something better than spawning a gleam subprocess per request. We should have an actor that consumes Arc as a library and maybe over websockets we send/receive messages to it. Reki would be good fit to implement that actor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants