4 ms·
To me, it seems impossible to have both macros and a type system on par with Haskell. Either your macros can no longer do arbitrary textural transformations, o
by AnimalMuppet 12y ago
To me, it seems impossible to have both macros and a type system on par with Haskell. Either your macros can no longer do arbitrary textural transformations, or your type system can't reason about macro cases. (Or, I suppose, your type system has to run after the macro transformations, and you could get a type error then just like you could get a syntax error then. But that means your IDE/development environment can't give you any type assistance on macro calls - you have to compile it to find out if it works. (Or, I suppose, your IDE has to run the macro for you and then do the type checking on the resulting post-macro code.))
I am open to being proven wrong, though...
- doublec 12y agoATS had macros: http://ats-lang.sourceforge.net/htdocs-old/TUTORIAL/contents/macros.html http://ats-lang.sourceforge.net/htdocs-old/TUTORIAL/contents... I'm not sure if these made it into ATS2 though.
- necubi 12y agoScala has macros [0], and as you reasoned the type checker has to run after the macro expansion. That's not a huge downside; to the user it still appears to be a single pipeline (parsing -> macro expansion -> type checking -> compilation). Haskell also has very powerful metaprogramming facilities, like template haskell [1]. [0] http://scalamacros.org/ http://scalamacros.org/ [1] https://wiki.haskell.org/Template_Haskell https://wiki.haskell.org/Template_Haskell
- sordina 12y ago> it seems impossible to have both macros and a type system on par with Haskell You should check out the work being done on typed template Haskell then.
- andrewchambers 12y agoYou can have a language which has to be parsed top down, then you can have both complete type info, and arbitrary macros.
- deech 12y agoThe second half of the talk (http://www.youtube.com/watch?v=lMcRBdSdO_U&t=17m30s http://www.youtube.com/watch?v=lMcRBdSdO_U&t=17m30s) is about turning a JSON object into a type using macros and meta-programming.
- gmfawcett 12y agoMetaOcaml's type-safe staged metaprogramming is not strictly a macro system, but it is morally equivalent: http://okmij.org/ftp/ML/MetaOCaml.html http://okmij.org/ftp/ML/MetaOCaml.html