question about GHC API on GHC plugin

Mike Izbicki mike at
Mon Aug 17 23:12:17 UTC 2015

I'm not sure how either of those two functions can help me.  The
problem is that given an operator (e.g. `+`), I don't know the name of
the dictionary that needs to be passed in as the first argument to the
operator.  I could probably hard code these names, but then the plugin
wouldn't be able to work with alternative preludes.

On Fri, Aug 7, 2015 at 11:20 PM, Edward Z. Yang <ezyang at> wrote:
> Hello Mike,
> Give importDecl from LoadIface a try, or maybe tcLookupGlobal if
> you're in TcM.
> Edward
> Excerpts from Mike Izbicki's message of 2015-08-07 15:40:30 -0700:
>> I'm trying to write a GHC plugin.  The purpose of the plugin is to
>> provide Haskell bindings to Herbie. Herbie
>> ( is a program that takes a
>> mathematical statement as input, and gives you a numerically stable
>> formula to compute it as output.  The plugin is supposed to automate
>> this process for Haskell programs.
>> I can convert the core expressions into a format for Herbie just fine.
>> Where I'm having trouble is converting the output from Herbie back
>> into core.  Given a string that represents a numeric operator (e.g.
>> "log" or "+"), I can get that converted into a Name that matches the
>> Name of the version of that operator in scope at the location.  But in
>> order to create an Expr, I need to convert the Name into a Var.  All
>> the functions that I can find for this (e.g. mkGlobalVar) also require
>> the type of the variable.  But I can't find a way to figure out the
>> Type given a Name.  How can I do this?

More information about the ghc-devs mailing list