[GHC] #2850: GeneralizedNewtypeDeriving + TypeFamilies doesn't work

GHC trac at galois.com
Sun Dec 7 22:43:19 EST 2008


#2850: GeneralizedNewtypeDeriving + TypeFamilies doesn't work
-----------------------------+----------------------------------------------
Reporter:  ajd               |          Owner:                  
    Type:  feature request   |         Status:  new             
Priority:  normal            |      Component:  Compiler        
 Version:  6.10.1            |       Severity:  normal          
Keywords:                    |       Testcase:                  
      Os:  Unknown/Multiple  |   Architecture:  Unknown/Multiple
-----------------------------+----------------------------------------------
 It would be nice if we could do stuff like this:

 {{{
 {-# LANGUAGE GeneralizedNewtypeDeriving, TypeFamilies, FlexibleContexts,
 FlexibleInstances #-}
 class K a where
   bar :: a -> a

 class K (B a) => M a where
   data B a :: *
   foo :: B a -> B a

 instance M Bool where
   data B Bool = B1Bool Bool | B2Bool Bool
   foo = id

 instance K (B Bool) where
   bar = id

 instance M Int where
   newtype B Int = BInt (B Bool) deriving K
   foo = id
 }}}

 which currently gives the error

 {{{
 foo.hs:17:41:
     Can't make a derived instance of `K (B Int)'
       (even with cunning newtype deriving:
        the newtype may be recursive)
     In the newtype instance declaration for `B'
 }}}

 However, the newtype is not recursive, it is just an associated datatype
 from another class, so it seems like this ought to work.

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


More information about the Glasgow-haskell-bugs mailing list