Finding & assembling class dictionaries from GHC plugins?
Conal Elliott
conal at conal.net
Tue Nov 5 21:10:54 UTC 2013
Hi Simon,
I don't think I need to construct dictionaries for new Typeable instances.
I only need to find and assemble *existing* Typeable instances into
combinations like Typeable [(Bool,Int -> String)], and I don't know how to
do so in a GHC plug-in. Pointers greatly appreciated!
-- Conal
On Tue, Nov 5, 2013 at 1:13 AM, Simon Peyton-Jones <simonpj at microsoft.com>wrote:
> I’m not sure what you mean by “synthesise”.
>
>
>
> Typeable instances can no longer be hand-written; they must be derived by
> GHC. That’s to keep them type-secure.
>
>
>
> A core-level plug-in can’t generate fresh instances. There are some new
> plug-in hooks that fit earlier in the pipeline, which can. Maybe you can
> use that, and generate a data type decl with “deriving Typeable”?
>
>
> Simon
>
>
>
> *From:* ghc-devs [mailto:ghc-devs-bounces at haskell.org] *On Behalf Of *Conal
> Elliott
> *Sent:* 04 November 2013 20:08
> *To:* ghc-devs at haskell.org
> *Subject:* Finding & assembling class dictionaries from GHC plugins?
>
>
>
> I'm working on a GHC plugin (for compiling Haskell to hardware), and I
> need to synthesize Typeable (and maybe other) class dictionaries for a wide
> range of types, including composite types (functions, pairs, lists, etc).
> Can it be done, and how? I think I'm mainly looking for mechanics of
> finding existing class instances (however they're defined) and assembling
> them (for parametrized/composite dictionaries), rather than mechanisms
> specific to Typeable.
>
> Thanks, -- Conal
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20131105/82850899/attachment.html>
More information about the ghc-devs
mailing list