--
You received this message because you are subscribed to the Google Groups "Elm Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Some context: there's two families of macros.
C family (and more recently Rust) are more of the templating type; they generate source code via basic symbol substitution. C is straight up format strings, while Rust will at least check that the template is valid and sorta types the macro parameters, though still at its heart is just substitution.
Haskell (TH) is full blown code generating AST values, which are interpolated at the call site. At compile time, TH will evaluate imported code - it can even do IO.
Ok, so pretty diverse prior art. Cool.
A separate feature of Haskell is genetics, which allow you to write code that operates on a representation of the type - a value encoding the shape of a type (like the fields and types of a record, or the constructors and parameters of union types). In modern Ghc, virtually all Haskell types can do this generic stuff and get a "Typerep" for free.
===
Type directed macros (invoked with deriving syntax) could be basically the "evaluation at compile time" of a pure Elm function from a "type representation value" to a "value of Elm AST". Notice the three or four big challenges in there!
Does anybody know if any other classes of macros, other than syntax templating and arbitrary code evaluation? Maybe something in between? I thought that the lisps are supposed to have some cool stuff going on with macros.
Also typo in the list email, genetics should be generics.
My personal priority right now is around making a Promises API that'll take the place of the existing Http and WebSockets library, perhaps even becoming the general way to do any effectful stuff that cannot fit into Signals easily.
What's more important: getting automatic json, or getting a more general feature that enables automatic json?
There's this tension between practicality (json is this ubiquitous thing, from which all apps will benefit NOW) and pausing to solve the bigger problem (which would render any more narrow short term solution obsolete, but take longer).