#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
Severity: normal | Resolution:
Keywords: | Difficulty: Unknown
Testcase: | Architecture: Unknown
Os: Unknown |
------------------------------+---------------------------------------------
Comment (by m4dc4p):
I don't need TH to dynamically create a module, compile it and import it
in one go (though my message does imply that). Just being able to add
import statements would be enough. Continuing with haskelldb, "table"
definitions can be stored in separate modules. For example, If I have two
tables, customers and orders, then they would normally be in the modules
Acme.Customers and Acme.Orders. If I have a third module which defines all
my queries, Acme.Queries, then I import the two tables as:
{{{
module Acme.Queries where
import qualified Acme.Customers as Customers
import qualified Acme.Orders as Orders
}}}
Notice the qualified imports - those are necessary to avoid name clashes
between the two modules (e.g., imagine if both tables have an ID column).
As I add more tables, I need to add more import statements. Maybe I have a
registration table:
{{{
import qualified Acme.Registration as Registration
}}}
And so on, adding more and more clutter. Right now I have a file that
imports about 15 "tables" and it's painful. I'd much rather have TH
generate the import definition for me. For example:
{{{
module Acme.Queries where
$(importTables "Acme", ["Registration", "Customers", "Orders"])
}}}
This becomes more important when you consider that I am trying to create a
tool for other developers in my organization to use. They don't know
Haskell, and I'd rather they didn't know they are learning Haskell until
it's too late. Having to add these import statements would be a barrier
for them.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1475#comment:6>
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