Template Haskell: hiding declarations

Hi Café, I'm doing some code generation with Template Haskell that results in few hundred top level declaration, of which only 10 or so should actually be exposed to the user (the rest are only used by generated code). Since I cant splice stuff into the module header (i.e. into the export list), I cant think of a good way to hide the internal declarations. One way would be to put all the declarations into one or several where-clauses, but this doesn't work very well when several functions share the hidden declarations. Also I might want to hide a few data types. Does anyone have a clever solution? Has anyone had a similar problem (maybe TH needs to be extended with support for hidden declarations)? /J

2010/10/4 Jonas Almström Duregård
Hi Café,
I'm doing some code generation with Template Haskell that results in few hundred top level declaration, of which only 10 or so should actually be exposed to the user (the rest are only used by generated code).
Since I cant splice stuff into the module header (i.e. into the export list), I cant think of a good way to hide the internal declarations. One way would be to put all the declarations into one or several where-clauses, but this doesn't work very well when several functions share the hidden declarations. Also I might want to hide a few data types.
Does anyone have a clever solution? Has anyone had a similar problem (maybe TH needs to be extended with support for hidden declarations)?
Maybe this, although I guess this is what you mean by "doesn't work very well": (a,b,c,d,...) = (a,b,c,d,...) -- those areyour top-level declarations where a = ... b = ... c = ... d = ... ... all you other code Cheers, Thu

Perhaps try importing the huge module with lots of imports in another
module, and then only export the ones you want.
Cheers.
~Liam
2010/10/4 Vo Minh Thu
2010/10/4 Jonas Almström Duregård
: Hi Café,
I'm doing some code generation with Template Haskell that results in few hundred top level declaration, of which only 10 or so should actually be exposed to the user (the rest are only used by generated code).
Since I cant splice stuff into the module header (i.e. into the export list), I cant think of a good way to hide the internal declarations. One way would be to put all the declarations into one or several where-clauses, but this doesn't work very well when several functions share the hidden declarations. Also I might want to hide a few data types.
Does anyone have a clever solution? Has anyone had a similar problem (maybe TH needs to be extended with support for hidden declarations)?
Maybe this, although I guess this is what you mean by "doesn't work very well":
(a,b,c,d,...) = (a,b,c,d,...) -- those areyour top-level declarations where a = ... b = ... c = ... d = ... ... all you other code
Cheers, Thu _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (3)
-
Jonas Almström Duregård
-
Liam O'Connor
-
Vo Minh Thu