On Tue, Nov 5, 2013 at 4:37 PM, Simon Peyton-Jones <simonpj@microsoft.com> wrote:

And I for my part don’t know where to start helping you!  Conal wrote


Ha! Fair enough.
 

 

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

 

That’s exactly what the constraint solver does.  (TcSimplify and friends.)  But again I need more context.


Even "TcSimplify and friends" gives me something new-to-my-brain to dig around with; I'm new to this part of the compiler.

I'll defer to Conal to more fully characterize his needs for you. My role in this specific project is to distill his and your eventual conclusion into a HERMIT module that Conal and others can use in the future.

However, I will include my own estimation of the challenge — it's a question I've wondered before. "Given a list of non-top-level dictionary bindings and a constraint type, construct a Core term inhabiting that constraint type that can also use any top-level dictionaries in scope." How do I do that using the functions in the module in the compiler/typechecker directory?

I think a wiki page for this would be great. Maybe one even already exists!

(I have some unshared scaffolding for being able to run TcRn monads from a Core plugin.)

We could have a skype call if that would help


Thanks for putting that on the table. I'll certainly need to do some more research before taking up a chunk of your time, but it will be very helpful when it happens.

 

 

From: Nicolas Frisby [mailto:nicolas.frisby@gmail.com]
Sent: 05 November 2013 14:36
To: Simon Peyton-Jones
Cc: ghc-devs@haskell.org; Conal Elliott
Subject: RE: Finding & assembling class dictionaries from GHC plugins?

 

On Nov 5, 2013 3:14 AM, "Simon Peyton-Jones" <simonpj@microsoft.com> wrote:

>
> 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”?

We're willing to do some awkward shoehorning in HERMIT to make this work in limited circumstances. (Hopefully including Conal's.)

We just don't know how to start — ie how call the right functions from the type checker. Are there any resources explaining the relevant subset of the TcRnIf API?

Thanks.

>  
>
> From: ghc-devs [mailto:ghc-devs-bounces@haskell.org] On Behalf Of Conal Elliott
> Sent: 04 November 2013 20:08
> To: ghc-devs@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
>
>
> _______________________________________________
> ghc-devs mailing list
> ghc-devs@haskell.org
> http://www.haskell.org/mailman/listinfo/ghc-devs
>