lookupRdrNameInModuleForPlugins with constructors
conal at conal.net
Wed Mar 23 16:48:57 UTC 2016
Indeed, tyConDataCons does the trick. I don't know how to start with the
Class (given a name string), but I'm able to use 'mkClsOcc . Unqual' with
lookupRdrNameInModuleForPlugins and then lookupTyCon on the resulting name,
followed by 'head . tyConDataCons' to get the constructor.
On Wed, Mar 23, 2016 at 1:32 AM, Simon Peyton Jones <simonpj at microsoft.com>
> Start with the Class. Use classTyCon to get the TyCon. Use tyConDataCons
> to get the data constructor.
> *From:* ghc-devs [mailto:ghc-devs-bounces at haskell.org] *On Behalf Of *Conal
> *Sent:* 23 March 2016 00:09
> *To:* ghc-devs at haskell.org
> *Subject:* lookupRdrNameInModuleForPlugins with constructors
> I'm trying to construct a dictionary in a GHC plugin. I'm stuck on finding
> the constructor for the dictionary. When I use `-ddump-simpl` on the module
> that defines the class, I see "Circat.Rep.C:HasRep". To try finding that
> constructor, I say
> > lookupRdrNameInModuleForPlugins hsc_env
> > (mkModuleName "Circat.Rep") (mkVarUnqual "C:HasRep")
> However, I keep getting `Nothing` as a result. (Same without the "C:".)
> I've also had this same difficulty when looking up constructors for
> algebraic data types and when looking up TyCons. For regular value Ids,
> lookup succeeds.
> What am I missing?
> Thanks, - Conal
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ghc-devs