#1475: Adding imports and exports with Template Haskell
---------------------------------+------------------------------------------
    Reporter:  igloo             |       Owner:                  
        Type:  feature request   |      Status:  new             
    Priority:  normal            |   Milestone:  _|_             
   Component:  Template Haskell  |     Version:  6.8.2           
    Keywords:                    |          Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  |     Failure:  None/Unknown    
  Difficulty:  Unknown           |    Testcase:                  
   Blockedby:                    |    Blocking:                  
     Related:                    |  
---------------------------------+------------------------------------------

Comment(by SimonHengel):

 Being able to generate import statements with TH would be awesome.

 Here is my use case.

 Say I have a directory that contains several modules with tests (using
 hspec as an example, and assuming that each module exports some
 {{{spec}}}):

 {{{
 test/FooSpec.hs
 test/BarSpec.hs
 test/BazSpec.hs
 }}}

 Then I'd like to generate a {{{Main.hs}}} by writing something like this:

 {{{
 -- test/Main.hs
 {-# LANGUAGE TemplateHaskell #-}

 import Test.Hspec.TH (autoRun)

 $(autoRun)
 }}}

 Which should expand to.

 {{{
 -- test/Main.hs
 import qualified FooSpec
 import qualified BarSpec
 import qualified BazSpec

 main = hspec $ do
   describe "Foo" FooSpec.spec
   describe "Bar" BarSpec.spec
   describe "Baz" BazSpec.spec
 }}}

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1475#comment:12>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler

_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to