Hi folks! I’ve already been sharing this on Slack and Discord, but I figured now that I’ve finally wrapped up everything as a nice npm package I’m ready to share this on the Discourse forum. I’ve got a conservative fork of the mainline Elm compiler called Zokka. It aims to preserve complete bidirectional compatibility with the Elm language (i.e. no changes to the language itself).
You can try it out via the quick start: GitHub - Zokka-Dev/zokka-compiler: Fork of compiler for Elm, a functional language for reliable webapps.
Or if you’d prefer to use
npm, you can directly run
Its main goal is to offer an easy way for the community to take advantage of work on patches to core libraries and compiler.
To do that it offers:
- Custom package repositories (one is provided out of the box but you can set up your own if you would like)
- Dependency overrides: for any direct or indirect dependency, you can override it with another API-compatible package.
- Bug fixes to the Elm compiler itself (e.g. sanitization of strings when generating
index.htmlfiles and fixing two bugs related to tail-call optimization)
- No changes to the Elm language itself. Should be drop-in for an pre-existing project (let me know if this is not the case!)
If you have
npm installed, you can go through a 60 second demonstration of one of Zokka’s bug fixes:
Open up the 0.19.1 Elm repl.
npx elm repl
and the paste in the following tailrecursive function (this is a variant of the factorial function)
tailrecursive value cont =
case value of
1 -> cont 1
_ -> tailrecursive (value-1) (\result -> cont (result * value))
tailrecursive 2 identity
This will result in a stack overflow. This is extremely puzzling because we have a tail-recursive function that should take constant stack space!
Do the same thing with Zokka.
# Paste in the same code
npx zokka repl
You should see the correct answer of
It plays nicely with other patches to core libraries. E.g. if you’d prefer to use Elm Janitor’s packages over the default one provided, you can do so! See GitHub - Zokka-Dev/zokka-compiler: Fork of compiler for Elm, a functional language for reliable webapps.
It also plays nicely with the standard Elm compiler itself. You can use the two freely on the same codebase, without any need to manually clear caches. If you see any bugs related to that please file a ticket!
There are some nice side benefits that come from Zokka’s approach, e.g. you can use an internal company repo for CI, indeed you can force Zokka to only use your internal company repo.
It currently is labeled alpha because the code is messier than I would like, error reporting is jankier than I would like. However, the compiler can handle real-world codebases. I use it on my own projects with no problem.