[Haskell-cafe] Template Haskell: hiding declarations

Vo Minh Thu noteed at gmail.com
Mon Oct 4 02:52:04 EDT 2010


2010/10/4 Jonas Almström Duregård <jonas.duregard at chalmers.se>:
> 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


More information about the Haskell-Cafe mailing list