[GHC] #10828: TH could do a better job of representing GADTs

GHC ghc-devs at haskell.org
Wed Nov 11 09:18:13 UTC 2015


#10828: TH could do a better job of representing GADTs
-------------------------------------+-------------------------------------
        Reporter:  spinda            |                Owner:  jstolarek
            Type:  feature request   |               Status:  new
        Priority:  normal            |            Milestone:  8.0.1
       Component:  Template Haskell  |              Version:  7.10.2
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by jstolarek):

 These are `Foldable` instances derived automatically for data types in
 comment:8

 {{{#!hs
 instance Foldable T1 where
   foldr f z (MkT1 a1) = f a1 z
   foldMap f (MkT1 a1) = f a1

 instance Foldable T1' where
   foldr f z (MkT1' a1) = f a1 z
   foldMap f (MkT1' a1) = f a1

 instance Foldable T2 where
   foldr f z (MkT2 a1) = (\ b1 b2 -> b2) a1 z
   foldMap f (MkT2 a1) = (\ b1 -> mempty) a1

 instance Foldable T2' where
   foldr f z (MkT2' a1) = (\ b1 b2 -> b2) a1 z
   foldMap f (MkT2' a1) = (\ b1 -> mempty) a1

 instance Foldable T3 where
   foldr f z (MkT3 a1) = (\ b1 b2 -> b2) a1 z
   foldMap f (MkT3 a1) = (\ b1 -> mempty) a1

 instance Foldable T3' where
   foldr f z (MkT3' a1) = (\ b1 b2 -> b2) a1 z
   foldMap f (MkT3' a1) = (\ b1 -> mempty) a1
 }}}
 So `DerivingFoldable` does not distinguish between GADT and normal
 declarations - respective pairs of instances are identical. At least in
 this case.

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


More information about the ghc-tickets mailing list