
#8776: Displaying pattern synonym for a GADT -------------------------------------+------------------------------------ Reporter: monoidal | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.7 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by simonpj): Yes, this does pop up, and there is only half of an idiomatic solution. * When pretty-printing (a type, say), the idiomatic solution is not to "rename type variables on the fly", but rather to "tidy" the type (which gives each variable a distinct print-name), and then pretty-print it (without renaming). Separate the two concerns. Functions like `tidyType` do this. * Alas, for type constructors, `TyCon`, tidying does not work well, because a `TyCon` includes `DataCon`s which include `Type`s, which mention `TyCon`s. And tidying can't tidy a mutually recursive data structure graph, only trees. * One alternative would be to ensure that `TyCons` get type variables with distinct print-names. That's ok for type variables but less easy for kind variables. Processing data type declarations is already so complicated that I don't think it's sensible to add the extra requirement that it generates only "pretty" types and kinds. * One place the non-pretty names can show up is in GHCi. But another is in interface files. Look at `MkIface.tyThingToIfaceDecl` which converts a `TyThing` (i.e. `TyCon`, `Class` etc) to an `IfaceDecl`. '''And it does tidying as part of that conversion.''' Why? Because interface files contains fast-strings, not uniques, so the names must at least be distinct. (You can see this happening for pattern synonyms in `patSynToIfaceDecl`. * SO MY PLAN is that the `:info` stuff in GHCi should work in two stages: * Use `tyThingToIfaceDecl` to convert the `TyThing` to an `IfaceDecl` * Pretty print that. Nothing very hard. It requires quite a bit of re-working in `PprTyThing`, but I think fairly routine. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8776#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler