#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 simonpj):
Whoa! Can you give more detail on your example? At the moment you
definitely can't write a TH function that generates a Haskell module,
compiles it, and imports it. You can generate those definitions in the
current module though.
Remember too that a TH definition can mention things in scope, and those
things do not need to be imported where the TH function is called.
Example
{{{
module T(f) where
import List
f = [| null |]
module Foo where
import T
h = $f
}}}
Here `$f` expands to `null`, but you do not need to import `List` in
module `Foo`. In fact `$f` expands to `Data.List.null`, a kind of
absolute reference to `null`.
As the intro to this ticket says, TH-generated imports are really only
useful for a form of dynamic binding.
Simon
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1475#comment:5>
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