id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	os	architecture	failure	difficulty	testcase	blockedby	blocking	related
1475	Adding imports and exports with Template Haskell	igloo		"(wished for by Adrian Hey in http://www.haskell.org/pipermail/template-haskell/2007-June/000598.html)

It would be useful to be able to add module exports with TH, although I'm not sure exactly how it would be done. Perhaps something like
{{{
$( do n <- newName ""foo""
      let d = funD n ...
      addExport (varE n)
      return [d]
}}}
but at the point we call `addExport` the typechecker doesn't know that there will be a declaration for the name.

Less useful, as TH names include the package and module of the name's definition, is the ability to add module imports. However, this can still be used to get a kind of dynamic binding effect, either with `mkName`'s names or plain Haskell code, e.g.:
{{{
$( addImport (if ... then '''Data.ByteString else '''Data.ByteString.Lazy)
             (mkName ""BS"") )

foo :: BS.ByteString
foo = BS.append ...
}}}
(we'd actually probably want a datatype that mirrors Haskell import decls more closely)."	feature request	new	normal	_|_	Template Haskell	6.8.2			ganesh.sittampalam@… alfonso.acosta@… mjm2002@… Deewiant merehap ivan.perez@… hackage.haskell.org@…	Unknown/Multiple	Unknown/Multiple	None/Unknown	Unknown				
