Programming in Elm for Pebble watches

Over the past few weeks, I’ve been evolving a side project I’ve had in mind since last Elm Camp: programming in Elm for Pebble watches rather than web frontends.

As you may know, there are new Pebble watches running the original operating system, and they even support developing watch faces and apps in JavaScript. However, even a simple Elm worker compiles to JavaScript that is too large to run on the watch.

So here is what Elm Pebble includes so far:

  • an IDE built with Phoenix LiveView for Elm development of watch apps, watch faces, and companion apps (on the phone)
  • an Elm-to-C compiler (reference counting, no GC; tokenizer/parser generated via Leex/Yecc, with dead-code stripping to keep watch binaries small)
  • CodeMirror editor with LSP-backed formatting, completions, diagnostics, hover, and folding (and yes, VIM mode)
  • almost complete coverage of the Pebble C API via Elm packages
  • a three-root project layout: watch, protocol, and phone, with watch<->phone communication derived from shared Elm types
  • companion-app JS APIs exposed as Elm packages
  • integrated time-travel debugger that evaluates Elm code for both watch and phone, with timeline events, replay, snapshots, model/view inspection, and tick controls
  • project templates for watch faces, games, companion demos, and tutorials
  • automated publishing to the Pebble app store, including screenshot capture per watch model
  • embedded Pebble emulator for realistic app testing
  • experimental WASM Pebble emulator for browser-based emulation
  • companion (phone) app generated with the original Elm compiler
  • support for Elm packages (on the watch, HTTP/HTML packages are excluded)
  • (animated) vector graphics uploadable as SVG
  • GitHub integration for project persistence
  • MCP/ACP integration so coding agents can read, edit, and build projects through the IDE
  • hosted IDE at ide.elm-pebble.dev, or self-hosted via Docker
  • website with package documentation built with elm-pages at elm-pebble.dev

Let me know what you think, would be glad to see your Elm watch face in the app store!

7 Likes

Great effort. I also like how you list the Elm-to-C compiler as just part of the work achieved.

You mentioned this uses “tokenizer/parser generated via Leex/Yecc” - which makes me think is this a complete compiler rewrite starting even from parsing the .elm sources ? Does it re-implement typechecking too ? All the error message stuff ? I am just curious how much of a full rewrite this is and whether it can be used outside of the pebble watch context.

In the monorepo GitHub - synalysis/elm-pebble: IDE for developing Pebble apps and watch faces in Elm · GitHub I’ve intentionally kept the Elm tokenizer/parser elm_ex and Elm-to-C compiler elmc separate from the IDE, so at least elm_ex could be provided as a reusable package on hex.pm.

So yes, it’s a complete compiler rewrite in Elixir as I wanted to use AST et cetera for syntax highlighting, formatting, folding…
The error messages are not fully on the level of those the original Elm compiler emits but eventually that’s the goal.

The Elm-to-C compiler is quite specific for the Pebble target as it tries to minimize code size as much as possible. (Smaller programs can even run on the original Pebble models)

2 Likes