Module import and use in GHC plugin?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Module import and use in GHC plugin?

Conal Elliott
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
https://github.com/conal/plugin-import-id . Help greatly appreciated.

Thanks,

  - Conal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20130529/d2bfc468/attachment.htm>

Reply | Threaded
Open this post in threaded view
|

Module import and use in GHC plugin?

Amos Robinson
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:
http://code.ouroborus.net/repa/repa-head/repa-plugin/Data/Array/Repa/Plugin/Primitives.hs

Primitives export:
http://code.ouroborus.net/repa/repa-head/repa-series/Data/Array/Repa/Series/Prim.hs



On Thu, May 30, 2013 at 7:37 AM, Conal Elliott <conal at conal.net> 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
> https://github.com/conal/plugin-import-id . Help greatly appreciated.
>
> Thanks,
>
>   - Conal
>
>
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at haskell.org
> http://www.haskell.org/mailman/listinfo/ghc-devs
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20130530/3f0e6868/attachment.htm>

Reply | Threaded
Open this post in threaded view
|

Module import and use in GHC plugin?

Simon Peyton Jones
Plugin support is not well documented, and could do with some love. If someone would like to take it up, I'm sure it could be improved a lot.

Simon

From: ghc-devs-bounces at haskell.org [mailto:ghc-devs-bounces at haskell.org] On Behalf Of Amos Robinson
Sent: 29 May 2013 23:50
To: Conal Elliott
Cc: glasgow-haskell-users at haskell.org; ghc-devs at haskell.org
Subject: Re: Module import and use in GHC plugin?

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:
http://code.ouroborus.net/repa/repa-head/repa-plugin/Data/Array/Repa/Plugin/Primitives.hs

Primitives export:
http://code.ouroborus.net/repa/repa-head/repa-series/Data/Array/Repa/Series/Prim.hs


On Thu, May 30, 2013 at 7:37 AM, Conal Elliott <conal at conal.net<mailto:conal at conal.net>> 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 https://github.com/conal/plugin-import-id . Help greatly appreciated.

Thanks,

  - Conal

_______________________________________________
ghc-devs mailing list
ghc-devs at haskell.org<mailto:ghc-devs at haskell.org>
http://www.haskell.org/mailman/listinfo/ghc-devs

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20130530/c34d5e0b/attachment.htm>