Derw, a useful ML-like language for the web, status: Feburary 2022
This is a short one this month, mostly composed of small fixes as I work my way through real world solutions with Derw.
Changelog
List prepending and unpacking
As lists are heavily used in ML-languages, it was clear to me that there needs to be special syntax for lists, as alternatives are pretty heavy handed. For example, you might have some code that checks out the first element in a list. Without special syntax, you end up with code that looks like:
Particularly, you have to handle the base case with a check on list length, followed by unpacking the head and tail manually. In Derw this can now be simplified to look this:
Additionally the same syntax can be used to compose lists by prepending (or cons, as it’s known in FP).
I’m working on making it so that you can pattern match against parts of list. Imagine you have a list of tokens, and you’d like to be able to grab part of a string that appears between two quotations. You’ll be able to do the following:
Where between is a list of lexer tokens that appeared between two Speech values. This is particularly useful for doing list-based processing of languages.
Misc
Async updates for html programs via send (from Coed)
An example of how to use send
Fix a formatting bug for let..in for Derw and Elm
Constants can be if or case statements now
Fixed a bug with left/right pipe in brackets not being parsed correctly
Nested case..of support
Fix a bug with Elm generation of constructors with no arguments
if/else branches can have let..in
Fix bug with generation of Derw nested list types
Use https instead of git urls for Github to support package installs in CI
Fix some —watch behaviour
Add documentation for testing and constants
Wrote HtmlToDerw so that html code can easily be turned into the Derw equivalent
Fix importing when a module is both aliased and exposing items
Log only errors from esbuild when using derw bundle
Thought cauldron
My big goal at the moment is to create a RealWorldApp instance for Derw. To my surprise, it’s actually more difficult to set one up than I thought. A lot them involve setting up postgres or some other server-based database. I ideally just want an SQLite based endpoint, but it seems that’s hard to find. The end goal will be to have some frontend Derw code which I can compare in size and speed to Elm, React, etc.
Meta
I’ve been doing a lot of writing for work in the last month. I wrote up: