... | ... | @@ -182,7 +182,7 @@ The compiler needs to bring the plugin writer and users contributions together. |
|
|
|
|
|
1. Save any command line options beginning with -p so we can give them to plugins later.
|
|
|
1. Suck in Haskell source as normal, but also parsing PLUGIN pragmas
|
|
|
1. Load up any plugins we see referenced by PLUGIN pragmas, discarding those we don't know about (on the basis that PRAGMAS are meant to be extra information that isn't essential to compile the program, though we might want to at least warn if we can't find one!). This could happen via [ hs-plugins](http://www.cse.unsw.edu.au/~dons/hs-plugins/).
|
|
|
1. Load up any plugins we see referenced by PLUGIN pragmas, discarding those we don't know about (on the basis that PRAGMAS are meant to be extra information that isn't essential to compile the program, though we might want to at least warn if we can't find one!). This could happen via [hs-plugins](http://www.cse.unsw.edu.au/~dons/hs-plugins/).
|
|
|
1. Give the plugins a chance to add some "implicit" imports so that the renamer can see the pragma data types when going through the pragmas. Again this is motivated by the idea that programs that use plugins should still compile if they are absent.
|
|
|
1. Rename, type check as normal, though TcBinds.mkPragFun will need to be extended to splat binder-specific PLUGIN pragmas on those binders
|
|
|
1. Desugarer will have to do something to make the pragma data structure syntax trees into an actual in-memory value. Essentially, we want to evaluate the expression in a context where it just has access to the constructors of the plugins imported data type library. We could reuse some of the GHCi apparatus to do this, see e.g. HscMain.compileExpr, HscMain.hscStmt and Linker.linkExpr. We then wrap this value up into an existential type that has a Dynamic instance and put it into the pragma on the Core (so the typechecker will have to make sure this part of the pragma has such an instance).
|
... | ... | |