| Using this we could say (on the toplevel of a module): | addDeriving ("Fold", deriveFold) | | Note that this would let us derive not only instances but new | functions or even new data types. Mega Awsome! Can't you do this already? data T = MkT Int $(deriveFold 'T) where deriveFold :: TH.Name -> Q [Dec] | Splicing pragmas | =============== | | It would be nice to be able to splice in compiler pragmas. For example | if one writes a TH module for deriving folds and builds one would like | to generate rules pragmas so that GHC can fuse these functions when | they are used. Generating self-optimising code :). | | Concretely one would add a constructor to the Dec data type. Something | like this: | | data Dec = ... | | PragmaD Pragma Yes, more and more GHC extensions are creeping into TH, and maybe that's OK. It is tiresome, but not difficult, to extend the abstract syntax and to-and-fro conversions. Ian Lynagh has become quite good at it. OK with me! | >From Meta Haskell to Meta X | =========================== I don't know how to make a good job of this, but it seems like a good problem for someone to study. The thing is that language X has scoping and typing rules that are different to Haskell's. How to express them? It's not just syntax! Simon