Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,248
    • Issues 5,248
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 561
    • Merge requests 561
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #14462
Closed
Open
Issue created Nov 14, 2017 by mf825@trac-mf825

deriving on associated data types fails to find constraints

{-# LANGUAGE TypeFamilies, UndecidableInstances #-}

class D a where data DT a
class C a where data CT a

instance (D a, Eq (DT a)) => C (Maybe a) where
  data CT (Maybe a) = CTMaybe (DT a) deriving (Eq)

{-
$ stack --resolver=nightly-2017-10-20 exec -- ghc --version
The Glorious Glasgow Haskell Compilation System, version 8.2.1

$ stack --resolver=nightly-2017-10-20 exec -- ghci Main.hs
GHCi, version 8.2.1: http://www.haskell.org/ghc/  :? for help
(0.00 secs, 0 bytes)
(0.00 secs, 0 bytes)
(0.00 secs, 0 bytes)
(0.00 secs, 0 bytes)
(0.00 secs, 0 bytes)
(0.00 secs, 0 bytes)
(0.00 secs, 0 bytes)
(0.00 secs, 0 bytes)
Loaded GHCi configuration from /home/mf/.ghci
[1 of 1] Compiling Main             ( Main.hs, interpreted )

Main.hs:7:48: error:
    • No instance for (Eq (DT a))
        arising from the first field of ‘CTMaybe’ (type ‘DT a’)
      Possible fix:
        use a standalone 'deriving instance' declaration,
          so you can specify the instance context yourself
    • When deriving the instance for (Eq (CT (Maybe a)))
  |
7 |   data CT (Maybe a) = CTMaybe (DT a) deriving (Eq)
  |                                                ^^
Failed, 0 modules loaded.
(0.03 secs,)
Prelude>


-- if i remove the offending @deriving@ clause above and add this line, everything is fine.
-- use -XFlexibleInstances -XStandaloneDeriving for this.
deriving instance Eq (DT a) => Eq (CT (Maybe a))

-}

checked on linux with ghc8.0.2 and 8.2.1. thanks! and sorry if i've missed a previous report covering this.

Trac metadata
Trac field Value
Version 8.2.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking