After giving up on my idea of transpiling ocaml to lua, I thought that a nice edsl that generates code ay be good enough. However,I don’t have any experience on the topic,and the few already existing edsl are too complex to learn from, so, do anyone know any good tutorial about designing good edsl?
The Domain-specific languages (DSLs) embedded in OCaml page was a great resource for me. I used that to help craft the dkml-dune-dsl Dune eDSL.
I believe the author is Professor Oleg Kiselyov.
Thanks. I readied that already, and it is a good resource. I will probably need to read it a couple of times, because the first part was easy to grasp, but as soon as I reached the optimization framework I started to feel confused.
Also, there is a huge gap between the tinny, tinny language they propose and a real world project, and I was hoping for something in between.
That said, that is probably the only good resource that I found, and I am the kind of person that understands a concept better by reading different explanations on the same subject.
I was not aware of your DSL tough, so I will also take a look at it.
Search for tagless-final?
I had this post here about embedding Forth in OCaml: Can I write a ppx to replace `1` with `(add_to_stack 1)`?
Martin Fowler also wrote a book on it, but it’s from the OOP perspective: Domain Specific Languages
You mention giving up transpiling OCaml to Lua. Would that be the goal of the EDSL? To generate Lua code?
Last year I did a one day experiment towards creating a DSL to interface with Redis by generating Lua from Scala code. You can find my short write-up here: ReDiSL. The code snippets are in Scala, but the core of the approach is to have a HOAS GADT based AST (a “deep embedding”) and then compile that to Lua. It should be fairly straightforward to translate the core to OCaml and OCaml actually properly supports defining and pattern matching over GADTs unlike legacy Scala.
That is exactly the objective. Thanks for sharing your project,I’ll take a look