[GHC] #14661: Cannot derive (newtype I a b = I (F a -> F b) deriving newtype Category) for type family F

GHC ghc-devs at haskell.org
Sat Jan 27 20:45:42 UTC 2018


#14661: Cannot derive (newtype I a b = I (F a -> F b) deriving newtype Category)
for type family F
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:  (none)
            Type:  feature request   |               Status:  closed
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.4.1-alpha1
      Resolution:  wontfix           |             Keywords:
                                     |  DerivingStrategies, deriving,
                                     |  TypeFamilies
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 Iceland_jack):

 Here is an interesting one:

 {{{#!hs
 class ListLike f where
   nil  :: f a
   cons :: a -> f a -> f a
   (·)  :: f a -> f a -> f a

 newtype LL a = LL (forall zz. ListLike zz => zz a)
 }}}

 You can implement (but not derive) `ListLike LL`:

 {{{#!hs
 instance ListLike LL where
   nil :: LL a
   nil = LL nil

   cons :: a -> LL a -> LL a
   cons a (LL as) = LL (cons a as)

   (·) :: LL a -> LL a -> LL a
   LL as · LL bs = LL (as · bs)
 }}}

 I'll add further examples to this
 [https://gist.github.com/Icelandjack/b1185398719f5932b6906396fb67a9f9
 gist].

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


More information about the ghc-tickets mailing list