"Conflicting family instance" error pretty prints data family instances poorly
This can be observed on GHC 8.0.1 or later:
{-# 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:
{-# 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.
Trac metadata
Trac field | Value |
---|---|
Version | 8.2.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler (Type checker) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |