Skip to content

GitLab

  • Menu
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 4,863
    • Issues 4,863
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 455
    • Merge requests 455
  • 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 Compiler
  • GHCGHC
  • Issues
  • #12120
Closed
Open
Created May 26, 2016 by Thomas Miedema@thomie

GHC accepts invalid Haskell: `class Eq (a Int) => C a where`

From the Haskell 2010 report chapter 4,

  • Class and instance declarations:
| 	class [scontext =>] ...
| 	instance [scontext =>] ...
  • Normal type signatures:
	vars :: [context =>] ...

Notice the difference between scontext (//with// s) and context (without s).

scontext 	→ 	simpleclass
	| 	( simpleclass1 , … , simpleclassn ) 	    (n ≥ 0)
simpleclass 	→ 	qtycls tyvar
context 	→ 	class
	| 	( class1 , … , classn ) 	    (n ≥ 0)
class 	→ 	qtycls tyvar
	| 	qtycls ( tyvar atype1 … atypen ) 	    (n ≥ 1)

GHC seems to ignore this difference, and happily accepts class Eq (a Int) => C a where. Hugs (Version: September 2006) reports for that same example:

Illegal Haskell 98 class constraint in class declaration
*** Constraint : Eq (a Int)
Trac metadata
Trac field Value
Version 8.0.1
Type Bug
TypeOfFailure OtherFailure
Priority lowest
Resolution Unresolved
Component Compiler
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