[GHC] #14179: "Conflicting family instance" error pretty prints data family instances poorly

GHC ghc-devs at haskell.org
Fri Sep 1 14:20:48 UTC 2017


#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):

 Indeed, the particular pretty printer that's being used in this error
 message is really broken. If you give GHC these conflicting instances:

 {{{#!hs
 module Bug where

 data family   Fam a
 data instance Fam [a] where
   Fam1 :: Fam [Int]
   Fam2 :: Fam [Bool]
 data instance Fam [a] where
   Fam3 :: Fam [a]
   Fam4 :: Fam [Char]
 }}}

 Then the error message will print out information that's just plain wrong:

 {{{
 $ 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:6:15: error:
     Conflicting family instance declarations:
       Fam [a] = Fam1 | Fam2 -- Defined at Bug.hs:6:15
       Fam [a] = Fam3 | Fam4 -- Defined at Bug.hs:9:15
   |
 6 | data instance Fam [a] where
   |               ^^^
 }}}

 I use the word "particular" above since the general-purpose data family
 instance pretty printer actually does the right thing:

 {{{
 λ> :i Fam
 data family Fam a       -- Defined at Bug.hs:5:1
 data instance Fam [a] where
   Fam3 :: Fam [a]
   Fam4 :: Fam [Char]
         -- Defined at Bug.hs:11:15
 }}}

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14179#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list