[GHC] #12245: Deriving Data at higher kinds

GHC ghc-devs at haskell.org
Wed Jun 29 10:19:24 UTC 2016


#12245: Deriving Data at higher kinds
-------------------------------------+-------------------------------------
           Reporter:  simonpj        |             Owner:
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.0.1
           Keywords:                 |  Operating System:  Unknown/Multiple
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Here's what
 [https://mail.haskell.org/pipermail/generics/2016-June/000564.html Lennart
 Spitzner wanted to do]:
 {{{
 > {-# LANGUAGE StandaloneDeriving #-}
 > {-# LANGUAGE DeriveDataTypeable #-}
 > {-# LANGUAGE FlexibleInstances #-}
 >
 > import Data.Data ( Data )
 >
 > data Foo f = Foo (f Bool) (f Int)
 >
 > deriving instance Data (Foo [])
 > deriving instance Data (Foo Maybe)
 }}}
 Of course you can't derive `Data` for `Foo` because we don't know what `f`
 is, so Lennart is making multiple instances, one for each instance of `f`.
 It's a bit clumsy. What we would really like is
 {{{
 deriving instance (forall a. Data  => Data (f a)) => Data (Foo f)
 }}}
 but we don't have higher order instances yet!  So Lennart is manually
 making two instances.

 This should work, but he gets
 {{{
 > Main.hs: line 45, column 1:
 >   Multiple declarations of ā€˜$cr2Cā€™
 >     Declared at: Main.hs:44:1
 >                  Main.hs:45:1
 > Main.hs: line 45, column 1:
 >   Multiple declarations of ā€˜$tr2Dā€™
 >     Declared at: Main.hs:44:1
 >                  Main.hs:45:1
 }}}

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


More information about the ghc-tickets mailing list