Skip to content

Split out a `template-haskell` pretty printing package

Problem

Currently template-haskell contains two modules: Language.Haskell.TH.Ppr and Language.Haskell.TH.PprLib. These expose a variety of pretty printing functions and add a dependency on pretty.

These modules are both part of the public interface of template-haskell and are used internally by GHC, mostly for reporting errors.

This is problematic because it means that users of template-haskell cannot re-install pretty.

This would even be the case if #24703 (closed) is implemented. A dependency on pretty would have to be moved onto some non-reinstallable dependency of the template-haskell library.

Proposed solution

Split out a template-haskell-pretty library. This library would depend on the internals of the template-haskell library through the package split out in #24703 (closed) and define the pretty printing modules. Then both template-haskell and ghc would depend on template-haskell-pretty. Note template-haskell-pretty could be another standard reinstallable package.

This would mean that simply depending on template-haskell (assuming #24703 (closed) is implemented) wouldn't make pretty non-reinstallable. Though depending on ghc still would.

In the future we could stop re-exporting the modules from template-haskell-pretty from template-haskell altogether but that would have to come after a long deprecation period.

Edited by Teo Camarasu
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information