Adding rules in a plugin?

Simon Peyton Jones simonpj at
Thu Feb 11 10:59:43 UTC 2016

Correct. I’ve added more comments.

From: ghc-devs [mailto:ghc-devs-bounces at] On Behalf Of Conal Elliott
Sent: 10 February 2016 18:17
To: ghc-devs at
Subject: Re: Adding rules in a plugin?

More study of GHC source code answered my question: when I generate a rule, set ru_auto to False rather than True, so that findExternalRules won't delete the rule.

On Tue, Feb 9, 2016 at 6:47 PM, Conal Elliott <conal at<mailto:conal at>> wrote:
I'm writing a GHC plugin that generates new rules. The top-level identifier for the new rules' LHSs is always the same and is imported from another module. One of the arguments in the rule's LHSs, however, is defined in that module. I'm creating rules and adding them to the mg_rules of the module's ModGuts. I don't see them in the .hi files (viewed with "ghc --show-iface Foo.hi"), and they're not getting found in modules that import the modules where I'm trying to generate rules. Am I missing a crucial step? For instance, do I need also to use `addIdSpecialisations` with the argument identifiers, and if so, need I replace all instances of those identifiers in the module or just some of them?

Thanks, -- Conal

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ghc-devs mailing list