Skip to content

Reorganisation of exports in template-haskell library

When working on documentation for the template-haskell library (see #4429 (closed)), I noticed a few inconveniences with the library. Here are some changes I would suggest:

  • I think runQ should not be exported from Language.Haskell.TH -- rather, it should only be exported from Language.Haskell.TH.Syntax.Internals. It should only be used by GHC internals or debugging, and not for ordinary use of template haskell
  • I think the "Internal functions" in Language.Haskell.TH.Syntax should be moved to Language.Haskell.TH.Syntax.Internals.
  • it is quite annoying that Language.Haskell.TH manually reexports almost all functions from Language.Haskell.TH.Syntax and indeed all functions from Language.Haskell.TH.Lib. I would like to turn these name-by-name exports into module exports like so:
module Language.Haskell.TH(
  module Language.Haskell.TH.Syntax,
  module Language.Haskell.TH.Lib,
  -- * Pretty-printing
  ...
 )

There are a few reasons I would like to do this last change:

  • it is a constant effort to keep the export list of Language.Haskell.TH synchronised with those of Language.Haskell.TH.Syntax and Language.Haskell.TH.Lib
  • I've added a number of notes (like the $unresolvedinfix note I added earlier) to Language.Haskell.TH.Syntax, and it is not possible to also export these from Language.Haskell.TH without copy-pasting the notes. This means that the documentation of Language.Haskell.TH.Syntax is better than the documentation for Language.Haskell.TH, so users will eventually have to look there. Why not just link them there directly?

I'm not sure what the correct place is for a discussion like this of library design, so I posted here.

Trac metadata
Trac field Value
Version 7.2.1
Type Task
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Template Haskell
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information