
#14179: "Conflicting family instance" error pretty prints data family instances poorly -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler (Type | Version: 8.2.1 checker) | Resolution: | Keywords: TypeFamilies Operating System: Unknown/Multiple | Architecture: Type of failure: Poor/confusing | Unknown/Multiple error message | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by RyanGlScott): This is an interesting one. I think that the solution here might be to pretty-print conflicting data family instances slightly differently than conflicting data family instances, for two reasons: 1. Type family instances are unique in that you have can have duplicate instances (see #14440). Thus, the pretty-printer //must// show their right-hand sides, because otherwise a user wouldn't know why they were conflicting. Data family instances, on the other hand, do not permit duplicates. These conflict, for instance: {{{#!hs data family Foo a data instance Foo a data instance Foo a }}} 2. The right-hand side of a data family instance can be quite large if there are many constructors. We could address this with `pprDeeperList`, but it's of questionable utility, since a. We might be suppressing the constructors in which two data family instance differ, and b. Part 1. brings into question whether it's worth going through this trouble in the first place, since the constructors themselves aren't the thing which causes data family instances to conflict. In light of this, I would propose simply pretty-printing the data family instances without any constructors at all. In other words, for the programs in the original description, I would propose having these be the respective error messages: {{{ Bug.hs:5:15: error: Conflicting family instance declarations: Fam Int -- Defined at Bug.hs:5:15 Fam Int -- Defined at Bug.hs:6:15 | 5 | data instance Fam Int | ^^^ }}} {{{ Bug.hs:6:15: error: Conflicting family instance declarations: Fam :: * -> * -- Defined at Bug.hs:6:15 Fam :: * -> * -- Defined at Bug.hs:7:15 | 6 | data instance Fam :: * -> * | ^^^ }}} And for the program in comment:1: {{{ Bug.hs:6:15: error: Conflicting family instance declarations: Fam [a] -- Defined at Bug.hs:6:15 Fam [a] -- Defined at Bug.hs:9:15 | 6 | data instance Fam [a] where | ^^^ }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14179#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler