Module import and use in GHC plugin?

Amos Robinson amos.robinson at
Thu May 30 00:50:24 CEST 2013

I'd love to know a nicer way to do this, but what Ben Lippmeier did as a
workaround is require a binding

"repa_primitives = R.primitives"
where repa_primitives is a record with references to all the primitive
types you need. It's not great, but it works.

Plugin code:

Primitives export:

On Thu, May 30, 2013 at 7:37 AM, Conal Elliott <conal at> wrote:

> In writing GHC plugins, how can I (a) add a module import (preferably
> qualified) and (b) make vars/ids for names imported from the newly imported
> module (to insert in the transformed Core code)?
> If it's not possible to do what I want, I'd be willing to require an
> explicit import (say "import qualified Foo") in client code, as a temporary
> workaround.
> So far I've been unable to import even from the base package. Maybe I'm
> missing something basic that you folks have learned.
> My simple & unsuccessful attempt is at
> . Help greatly appreciated.
> Thanks,
>   - Conal
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ghc-devs mailing list