TH to generate imports?

Hi guys, I wanted to know if it's possible to use TH on an "import" statement. What I want to do is to generate the names of the packages I need to import. For example: import $(genImport "MyPackage") genImport :: String -> Q TH.Exp genImport s = ... Is that possible? Thanks! Corentin

https://ghc.haskell.org/trac/ghc/ticket/1475
On Thu, Jun 11, 2015 at 11:12 AM, Corentin Dupont wrote: Hi guys,
I wanted to know if it's possible to use TH on an "import" statement.
What I want to do is to generate the names of the packages I need to
import.
For example: import $(genImport "MyPackage") genImport :: String -> Q TH.Exp
genImport s = ... Is that possible?
Thanks!
Corentin _______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe

Thanks!
So, at the moment it's not possible?
So is it possible instead to do:
$(genPackage "MyPackage")
import MyPackage
The template Haskell expression would just create the Haskell package in a
corresponding file, so we can import it.
Nothing would be spliced in.
On Thu, Jun 11, 2015 at 11:45 AM, Adam Bergmark
https://ghc.haskell.org/trac/ghc/ticket/1475
On Thu, Jun 11, 2015 at 11:12 AM, Corentin Dupont < corentin.dupont@gmail.com> wrote:
Hi guys, I wanted to know if it's possible to use TH on an "import" statement. What I want to do is to generate the names of the packages I need to import. For example:
import $(genImport "MyPackage")
genImport :: String -> Q TH.Exp genImport s = ...
Is that possible? Thanks! Corentin
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe

On Thu, Jun 11 2015, Adam Bergmark
HSpec uses the ghc -F -pgmF flags to run a custom pre-processor which generates imports before a testing. e.g. '{-# OPTIONS_GHC -F -pgmF hspec-discover #-}'. You might also find some inspiration in the 'imports' library on Hackage: http://hackage.haskell.org/package/imports-0.1.2.1. -Christopher
On Thu, Jun 11, 2015 at 11:12 AM, Corentin Dupont
wrote:
Hi guys, I wanted to know if it's possible to use TH on an "import" statement. What I want to do is to generate the names of the packages I need to import. For example:
import $(genImport "MyPackage")
genImport :: String -> Q TH.Exp genImport s = ...
Is that possible? Thanks! Corentin
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
-- Christopher Reichert irc: creichert gpg: C81D 18C8 862A 3618 1376 FFA5 6BFC A992 9955 929B
participants (3)
-
Adam Bergmark
-
Christopher Reichert
-
Corentin Dupont