
#14179: "Conflicting family instance" error pretty prints data family instances poorly -------------------------------------+------------------------------------- Reporter: RyanGlScott | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 (Type checker) | 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: -------------------------------------+------------------------------------- This can be observed on GHC 8.0.1 or later: {{{#!hs {-# LANGUAGE TypeFamilies #-} module Bug where data family Fam a data instance Fam Int data instance Fam Int }}} {{{ $ /opt/ghc/8.2.1/bin/ghci Bug.hs GHCi, version 8.2.1: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci [1 of 1] Compiling Bug ( Bug.hs, interpreted ) 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 | ^^^ }}} Notice how GHC attempts to pretty-print the RHS by using a `=` symbol, but there is no RHS! This gets even more confusing with this program, which requires GHC HEAD: {{{#!hs {-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeFamilies #-} module Bug where data family Fam :: k -> * data instance Fam :: * -> * data instance Fam :: * -> * }}} {{{ $ ghc5/inplace/bin/ghc-stage2 --interactive Bug.hs GHCi, version 8.3.20170818: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/rgscott/.ghci [1 of 1] Compiling Bug ( Bug.hs, interpreted ) 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 :: * -> * | ^^^ }}} Not only is there no RHS, but the kind signatures of each instance aren't printed either. This is an issue, since the entire reason why the two instances conflict are because of their kinds! We should rethink how data family instances are pretty printer here to avoid this issue. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14179 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler