[GHC] #11341: Reifying a GADT doesn't tell you the correct return type

GHC ghc-devs at haskell.org
Sun Jan 3 10:24:22 UTC 2016


#11341: Reifying a GADT doesn't tell you the correct return type
-------------------------------------+-------------------------------------
        Reporter:  RyanGlScott       |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Template Haskell  |              Version:  8.1
      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):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by jstolarek):

 Currently reifying a GADT data constructor tells us "what the user meant",
 not "what the user wrote", ie. type synonyms are expanded.

 I think the most important question is what should the GADT data
 constructor representation look like. I believe that TH should represent
 source code syntax. That said, your third example shows that the current
 representation is not sufficient. So I would propose to represent GADT
 data constructor as:

 {{{#!hs
 data Con = ...
          | GadtC [Name] [StrictType] Type
 }}}
 Where `Type` is the result type written by the user. In
 `TcSplice.reifyDataCon` we have access to `dcOrigResTy` field of a
 `DataCon`, which should allow us to reify original result type.

 {{{#!hs
 data T a where
   MkT :: a -> T a
 }}}
 Note that by ''result type'' of `MkT` I mean `T a`, not `a -> T a`. (I
 believe `dcOrigResTy` stores the latter).

 In this setting I don't think it is a good idea to store indices inside
 `GadtC`. This would duplicate information already stored inside the
 constructor and make it possible to create inconsistent data constructors.

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


More information about the ghc-tickets mailing list