Skip to content

Teach TemplateHaskell to generate less eye-hurting names

If you look at the Haddocks for, e.g., the singletons package, one sees dozens of signatures containing unsightly names containing long integers. For instance, in the equation list for Data.Singletons.Prelude.Either.IsLeft we have

  IsLeft (Left _z_6989586621679437436) = TrueSym0	 
  IsLeft (Right _z_6989586621679437439) = FalseSym0

For definitions with lots of variables things quickly become unreadable.

These names appear this way because they are generated by TemplateHaskell's newName function. This name is ultimately converted to a GHC System name by Convert.thRdrName. Such Names are then pretty-printed including their uniques (see Name.pprSystem). I'm not sure I see the rationale for this. Surely if the names are tidied properly (e.g. using TyConRep.tidyType) there should be no need for the unique suffix.

Trac metadata
Trac field Value
Version 8.2.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
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