[Haskell-cafe] TH to generate imports?

Christopher Reichert creichert07 at gmail.com
Thu Jun 11 16:31:43 UTC 2015


On Thu, Jun 11 2015, Adam Bergmark <adam at bergmark.nl> wrote:
> https://ghc.haskell.org/trac/ghc/ticket/1475
>


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 <corentin.dupont at 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 at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>>
>>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150611/34355635/attachment.sig>


More information about the Haskell-Cafe mailing list