<div dir="ltr"><div>I've updated the wiki page, expanding the descriptions and adding code from the actual implementation: <a href="http://ghc.haskell.org/trac/ghc/wiki/Ghc/Hooks" target="_blank" style="font-size:12.727272033691406px;font-family:arial,sans-serif">http://ghc.haskell.org/trac/ghc/wiki/Ghc/Hooks<br>
</a>An demo program that uses all hooks here: <a href="https://gist.github.com/luite/6444273">https://gist.github.com/luite/6444273</a></div><div>(I've listed the users (or proposers) of every hook, and how they use it, Thomas / Edsko, can you check that they indeed do what you need?)</div>
<div>The patch is here:</div><div><a href="https://github.com/ghcjs/ghcjs-build/blob/master/refs/patches/ghc-hooks.patch">https://github.com/ghcjs/ghcjs-build/blob/master/refs/patches/ghc-hooks.patch</a><br></div><div><br>
</div><div>In addition to defining the heterogeneous map and the hooks themselves, extra exports have been added to make it possible for users to actually make a hook implementation without copying most of the module's source code. The demo program implements all hooks to check this.</div>
<div><br></div><div>Also the GHCJS patch is here:</div><div><br></div><div><a href="https://github.com/ghcjs/ghcjs-build/blob/master/refs/patches/ghc-ghcjs.patch">https://github.com/ghcjs/ghcjs-build/blob/master/refs/patches/ghc-ghcjs.patch</a><br>
</div><div><br></div><div><div>It adds the following:</div></div><div>- in DynFlags an extra WayCustom constructor to add a custom 'tag' to generated files (GHCJS builds multiple architectures to support Template Haskell among other things, one with the 'js' tag)<br>
</div><div><div>- in ForeignCall the JavaScriptCallConv calling convention</div><div>- in Platform an ArchJavaScript architecture</div><div>- `foreign import javascript' support in the parser and lexer</div><div>- The JavaScriptFFI extension that enables the `foreign import javascript' syntax, only supported on ArchJavaScript (So using it on a regular GHC would always result in a compile error saying that it's unsupported on the user's platform)</div>
</div><div><br></div><div>luite</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Sep 5, 2013 at 12:17 AM, Thomas Schilling <span dir="ltr"><<a href="mailto:nominolo@googlemail.com" target="_blank">nominolo@googlemail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I started a wiki page at: <a href="http://ghc.haskell.org/trac/ghc/wiki/Ghc/Hooks" target="_blank">http://ghc.haskell.org/trac/ghc/wiki/Ghc/Hooks</a><br>
<br>
Luite: could you please fill in the hooks that your latest patch defines?<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
On 4 Sep 2013, at 19:40, Simon Peyton-Jones <<a href="mailto:simonpj@microsoft.com">simonpj@microsoft.com</a>> wrote:<br>
<br>
> I do need more than a patch, please, please. A wiki page explaining the design, as seen by the user (of the GHC API), the problems it solves, and the use-cases it enables, would be most helpful.<br>
><br>
> Simon<br>
><br>
> | -----Original Message-----<br>
> | From: Thomas Schilling [mailto:<a href="mailto:nominolo@googlemail.com">nominolo@googlemail.com</a>]<br>
> | Sent: 04 September 2013 17:26<br>
> | To: Simon Peyton-Jones; Luite Stegeman<br>
> | Cc: Nicolas Frisby; "Pedro Magalhães (<a href="mailto:dreixel@gmail.com">dreixel@gmail.com</a>)"; Richard<br>
> | Eisenberg (<a href="mailto:eir@cis.upenn.edu">eir@cis.upenn.edu</a>); Geoffrey Mainland<br>
> | (<a href="mailto:mainland@cs.drexel.edu">mainland@cs.drexel.edu</a>); Iavor Diatchki; Austin Seipp; Edsko de Vries;<br>
> | Ryan Newton (<a href="mailto:rrnewton@gmail.com">rrnewton@gmail.com</a>); David Luposchainsky; ghc-<br>
> | <a href="mailto:devs@haskell.org">devs@haskell.org</a><br>
> | Subject: Re: GHC 7.8 release status<br>
> |<br>
> |<br>
> | On 4 Sep 2013, at 15:52, Simon Peyton-Jones <<a href="mailto:simonpj@microsoft.com">simonpj@microsoft.com</a>><br>
> | wrote:<br>
> |<br>
> | > Edsko/Thomas/Luite: if you want anything for 7.8 it'll have to be<br>
> | jolly soon. At the moment I don't even know the motivation or design,<br>
> | let alone implementation. Could you make a wiki page explaining the<br>
> | proposed design? Is it really important to do this for 7.8?<br>
> |<br>
> | Yes, it is quite important to get this into 7.8. Not having these<br>
> | features in GHC makes it very difficult for people to adopt GHCJS. One<br>
> | could argue that GHCJS is not yet production-ready anyway and users that<br>
> | want to try it can figure out building GHC from source to use it, but<br>
> | this doesn't quite apply.<br>
> |<br>
> | 1. GHCJS targets a wider audience than users brave enough to compile<br>
> | GHC from source. In addition, the next chance to get these features into<br>
> | GHC is in a year from now, so when GHCJS becomes more mature then this<br>
> | will be a major hurdle for adoption.<br>
> |<br>
> | 2. These changes are also required for IDE tools which really mustn't<br>
> | require users to build a custom version of GHC.<br>
> |<br>
> |<br>
> | Luite's design is actually very flexible. It simply allows GHC API<br>
> | users to provide functions that are called instead of (or in addition<br>
> | to) existing functions in GHC. Instead of calling, say, "genHardCode",<br>
> | the driver now looks up whether the user has specified a hook for<br>
> | genHardCode and calls that instead.<br>
> |<br>
> | Currently we only specify a small number of hooks that are sufficient<br>
> | for our use cases. Future releases of GHC can be extended to include<br>
> | more hooks, if that is needed.<br>
> |<br>
> | Hooks are stored as an untyped map inside the DynFlags (to avoid issues<br>
> | with circular dependencies). Each hook is looked up using a single-<br>
> | constructor type and type families are used to make this type safe.<br>
> | There is one use of unsafeCoerce to avoid having to make every hook<br>
> | function an instance of Typeable.<br>
> |<br>
> | Unlike CorePlugins, it is only a GHC API feature, and users cannot<br>
> | specify plugins to be added via command line options. If we can come up<br>
> | with a good design, then we could add this in GHC 7.10, but it is not<br>
> | necessary at this point.<br>
> |<br>
> | Luite: Do you have a link to your latest patch?<br>
<br>
</div></div></blockquote></div><br></div>