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

GHC ghc-devs at haskell.org
Wed Apr 26 20:55:17 UTC 2017


#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


More information about the ghc-tickets mailing list