Hello!
Lately, I have been interested in implementing programming languages from Types and Programming Languages (TAPL) and Essentials of Compilation (EOC). Neither of these books use Haskell to implement the language and give you parsers in OCaml or Racket. I have also seen a bunch of “Implement You A Scheme” tutorials with S-Expression parsers that don’t handle (1a)
and (1 a)
as different things. In fact, Haskell’s parser has this issue: https://twitter.com/chiroptical/status/1471568781906518018
So, welcome Snail to the world! Snail is a programming language with no semantics (for gastropods). Here is an example Snail program,
-- An example comment
(let [x 10] (print x))
It is essentially ASCII Fennel with Haskell’s line and block comments right now. Note: this program does nothing! However, you can use snail to get an AST which you can convert into the AST of your programming language! It isn’t really meant as anything serious but hopefully takes one step out of the process of implementing languages from books where the implementation language is not Haskell.
Some examples include https://github.com/chiroptical/snail-arith/blob/main/src/Lib.hs where I implemented arith
from TAPL as an interpreter (using Except
). I am also actively working on EOC here: GitHub - chiroptical/essentials-of-compilation: A gastropod approaches https://mitpress.mit.edu/9780262047760/essentials-of-compilation (using MonadError
).
Links: