
#12120: GHC accepts invalid Haskell: `class Eq (a Int) => C a where` -------------------------------------+------------------------------------- Reporter: thomie | Owner: Type: bug | Status: new Priority: lowest | Milestone: Component: Compiler | Version: 8.0.1 Keywords: report-impact | Operating System: Unknown/Multiple Architecture: | Type of failure: Documentation Unknown/Multiple | bug Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- From the Haskell 2010 report [https://www.haskell.org/onlinereport/haskell2010/haskellch4.html 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) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12120 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler