Deriving higher-arity instances for newtype family instances fails
{-# 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)'
Trac metadata
| Trac field | Value |
|---|---|
| Version | 6.12.3 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |