Reified data family instances type variables not related to value constructor fields
When using the reify template-haskell operation on a data family, the returned data instances lose the relationship between the type variables in the parameters and those in the value constructors.
In this paste I show that reify forgets the relationship, but that declaration splices preserve it. Note the two occurrences of a_6989586621679027007 .
I would specifically expect the occurences of a_6989586621679015819 and a_6989586621679015790 to be the same.
The code that implements this reification is in compiler/typecheck/TcSplice.hs , the template-haskell package merely exposes the functionality, so this is why I've specified "compiler (type checker)"
I've confirmed that this bug exists in GHC 8.0.2 and 8.2.1-rc1. I suspect it exists in older versions, too.
$ /Users/emertens/Tools/ghc-8.2.1-rc1/bin/ghci
GHCi, version 8.2.0.20170404: http://www.haskell.org/ghc/ :? for help
Prelude> :set -XTypeFamilies
Prelude> :set -XTemplateHaskell
Prelude> import Language.Haskell.TH
Prelude Language.Haskell.TH> import Text.Show.Pretty (ppShow)
Prelude Language.Haskell.TH Text.Show.Pretty> data family DF a; data instance DF [a] = DFList a
Prelude Language.Haskell.TH Text.Show.Pretty> putStrLn $(stringE . ppShow =<< reify ''DF)
FamilyI
(DataFamilyD
Ghci1.DF [ KindedTV a_6989586621679015789 StarT ] (Just StarT))
[ DataInstD
[]
Ghci1.DF
[ AppT ListT (VarT a_6989586621679015819) ]
Nothing
[ NormalC
Ghci1.DFList
[ ( Bang NoSourceUnpackedness NoSourceStrictness
, VarT a_6989586621679015790
)
]
]
[]
]
Prelude Language.Haskell.TH Text.Show.Pretty> putStrLn $(stringE . ppShow =<< [d| data family DF a; data instance DF [a] = DFList a |])
[ DataFamilyD
DF_6989586621679027004 [ PlainTV a_6989586621679027006 ] Nothing
, DataInstD
[]
DF_6989586621679027004
[ AppT ListT (VarT a_6989586621679027007) ]
Nothing
[ NormalC
DFList_6989586621679027005
[ ( Bang NoSourceUnpackedness NoSourceStrictness
, VarT a_6989586621679027007
)
]
]
[]
]
Trac metadata
Trac field | Value |
---|---|
Version | 8.2.1-rc1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler (Type checker) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |