[GHC] #13618: Reified data family instances type variables not related to value constructor fields

#13618: Reified data family instances type variables not related to value constructor fields -------------------------------------+------------------------------------- Reporter: glguy | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1-rc1 (Type checker) | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Incorrect result Unknown/Multiple | at runtime Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- 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. {{{#!haskell $ /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 ) ] ] [] ] }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13618 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13618: Reified data family instances type variables not related to value constructor fields -------------------------------------+------------------------------------- Reporter: glguy | Owner: (none) Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler (Type | Version: 8.2.1-rc1 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3505 Wiki Page: | -------------------------------------+------------------------------------- Changes (by RyanGlScott): * status: new => patch * differential: => Phab:D3505 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13618#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13618: Reified data family instances type variables not related to value
constructor fields
-------------------------------------+-------------------------------------
Reporter: glguy | Owner: (none)
Type: bug | Status: patch
Priority: normal | Milestone:
Component: Compiler (Type | Version: 8.2.1-rc1
checker) |
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect result | Unknown/Multiple
at runtime | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D3505
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#13618: Reified data family instances type variables not related to value constructor fields -------------------------------------+------------------------------------- Reporter: glguy | Owner: (none) Type: bug | Status: merge Priority: normal | Milestone: 8.2.1 Component: Compiler (Type | Version: 8.2.1-rc1 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3505 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => merge * milestone: => 8.2.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13618#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13618: Reified data family instances type variables not related to value constructor fields -------------------------------------+------------------------------------- Reporter: glguy | Owner: (none) Type: bug | Status: closed Priority: normal | Milestone: 8.2.1 Component: Compiler (Type | Version: 8.2.1-rc1 checker) | Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Incorrect result | Unknown/Multiple at runtime | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D3505 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed Comment: Merged to `ghc-8.2` as f977b76340aa0924a63592b9262203a7b13dc5b6. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13618#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC