1. 10
  1.  

  2. 2

    Are there any languages with compile-time metaprogramming capabilities similar to those offered by TemplateHaskell (compile-time Haskell programs that operate on Haskell ASTs) or GHC.Generics (utilities to operate on abstract representations of arbitrary data)?

    1. 3

      compile-time metaprogramming capabilities similar to those offered by TemplateHaskell (compile-time Haskell programs that operate on Haskell ASTs)

      • Scheme-style “dynamic” hygienic macros. The state of the art here is Racket’s syntax-parse.

      • “Static” hygienic macros. These give macros types, and well-typed macro instantiation is guaranteed to be hygienic. State of the art here is Romeo

      • Macros as typed, staged computations. See MacroML

      GHC.Generics (utilities to operate on abstract representations of arbitrary data)

      There’s a bunch of approaches that use type classes. GHC.Generics is probably the best in its class. Other approaches:

      • Ur/Web has first class records and variants with row polymorphism and allows typed folds over them. Paper

      • A recent approach relying on equirecursive types. This provides a more direct approach to datatype generic programming than using the type class mechanism to resolve recursive instantiation.