GHC 7.8 release status

Luite Stegeman stegeman at gmail.com
Sat Sep 7 21:03:40 UTC 2013


·         **Why aren’t you using Data.Dynamic for the hook things?  You are
precisely doing dynamic typing after all.  (Moreover I want to change
Data.Dynamic so that it says

>       data Dynamic where
>          Dyn :: Typeable a => a -> Dynamic
> and you want to take advantage of this.
>

Ah the goal is to avoid the Typeable constraint on the hooked function, and
to identify what things are actually hooks. Wrapping it in a newtype also
achieves the first goal and does make the design a bit simpler.

No need for these strange “data DsForeignsHook = DsForeignsHook” things, or
> for the Hook type family.  Simple!
>
But it means that hooks are no longer recognisable by their type, they're
just some Typeable (the type families approach would at least prevent users
from accidentally inserting wrong hooks, even though they would still be
able to make bogus instances on purpose)

> **
>
> **·         **The design **must** list all the hooks that GHC uses and
> their types.  There’s no point in adding a hook that GHC doesn’t call!
>
It appears to be difficult to define all hooks in one module or have them
in one record because of dependencies and the DLL split on Windows.
Re-exporting everything from a single module can be done, but would offer
no guarantees about completeness.

With the type families design, everything that's an instance of Hook is a
hook, although the definitions are scattered throughout the GHC source. The
Dynamic design would just have to rely on a consistent naming convention.
Would listing the hooks in comments (in the Hooks module) and on the wiki
be a reasonable way to document them?

I've uploaded a new patch, using Dynamic, although I'm not sure if it's an
improvement over the original one:

- patch:
https://github.com/ghcjs/ghcjs-build/blob/master/refs/patches/ghc-hooks-dynamic.patch
- updated hooksDemo: https://gist.github.com/luite/6478973

It also adds hscParse' and tcRnModule' exports for Edsko's use case (I
think that makes it somewhat more flexible than exporting another version
of hscFileFrontend, since it allows users to write a hook that does
something between parsing and typechecking or one that overrides one of
these phases)

luite
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20130907/68a610da/attachment.htm>


More information about the ghc-devs mailing list