Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,391
    • Issues 4,391
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 373
    • Merge Requests 373
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #4185

Closed
Open
Opened Jul 12, 2010 by LouisWasserman@trac-LouisWasserman

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
Assignee
Assign to
7.6.2
Milestone
7.6.2
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#4185