#4185: Deriving higher-arity instances for newtype family instances fails
---------------------------------+------------------------------------------
Reporter: LouisWasserman | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler
Version: 6.12.3 | Keywords:
Os: Unknown/Multiple | Testcase:
Architecture: Unknown/Multiple | Failure: None/Unknown
---------------------------------+------------------------------------------
{{{
{-# LANGUAGE TypeFamilies, GeneralizedNewtypeDeriving #-}
module Baz where
class Bar f where
bar :: f a -> Int
data family Foo k :: * -> *
instance Bar Maybe where
bar Nothing = 0
bar Just{} = 1
newtype instance Foo Int a = FooInt (Maybe a) deriving (Bar)
}}}
fails with
{{{
Baz.hs:13:56:
Derived instance `Bar (Foo Int)'
requires illegal partial application of data type family Foo
In the newtype instance declaration for `Foo'
}}}
Attempting to use StandaloneDeriving:
{{{
{-# LANGUAGE StandaloneDeriving, TypeFamilies, GeneralizedNewtypeDeriving
#-}
module Baz where
class Bar f where
bar :: f a -> Int
data family Foo k :: * -> *
instance Bar Maybe where
bar Nothing = 0
bar Just{} = 1
newtype instance Foo Int a = FooInt (Maybe a)
deriving instance Bar (Foo Int)
}}}
gives the super-weird error
{{{
Baz.hs:15:0:
No family instance for `Foo Int'
In the stand-alone deriving instance for `Bar (Foo Int)'
}}}
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4185>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs