2 ms·
What a delightful blog post. One need not fully understand all the prologue bits to understand the interface and implementation produced. This technique could
by cryptonector 2y ago
What a delightful blog post. One need not fully understand all the prologue bits to understand the interface and implementation produced.
This technique could be very useful in developing other DSLs on Haskell. Basically the author found a simple monadic-looking mapping of Haskell functions onto a different Category where you can do interesting things with those functions. In TFA's case the idea is to write flow diagrams where "boxes" embed [user-provided] Haskell functions, then the machinery can do whatever might be expected for diagrams, like: render visual representations of them, evaluate them, analyze them, etc. Because the boxes embed Haskell functions the flow diagrams can do useful work, so they're more than just documentation, they can be code and documentation. Basically this is a flow diagram programming language as a DSL embedded in Haskell.
Imagine using this technique to build things like networking stacks, say. Or emulators of various sorts (CPUs/ISAs, say). Or maybe one could use this to make something like a PLC in Haskell. It's really quite a neat and powerful idea, especially if it really does compile to efficient code.
What else might one use this for?