[GHC] #7854: Constrained method type accepted in Haskell 98 mode

#7854: Constrained method type accepted in Haskell 98 mode -----------------------------+---------------------------------------------- Reporter: refold | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.6.3 | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: None/Unknown | Blockedby: Blocking: | Related: -----------------------------+---------------------------------------------- If I understand [http://www.haskell.org/ghc/docs/7.6.2/html/users_guide /type-class-extensions.html#class-method-types this paragraph] of the GHC manual correctly, the following code should be rejected in Haskell 98 mode: {{{ {-# LANGUAGE Haskell98 #-} module Main where class Compare a where comp :: Eq a => a -> a -> Bool }}} However, it compiles fine for me both with 7.4.2 and 7.6.1. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7854 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7854: Constrained method type accepted in Haskell 98 mode -----------------------------+---------------------------------------------- Reporter: refold | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.6.3 | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: None/Unknown | Blockedby: Blocking: | Related: -----------------------------+---------------------------------------------- Comment(by refold): Also accepted by 7.0.4 and 7.2.1, but rejected by 6.12.1. However, it complains about `-XFlexibleContexts`, not `-XConstrainedClassMethods`: {{{ [1 of 1] Compiling Main ( Test.hs, interpreted ) Test.hs:3:0: All of the type variables in the constraint `Eq a' are already in scope (at least one must be universally quantified here) (Use -XFlexibleContexts to lift this restriction) When checking the class method: comp :: (Eq a) => a -> a -> Bool In the class declaration for `Compare' Failed, modules loaded: none. }}} -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7854#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7854: Constrained method type accepted in Haskell 98 mode -----------------------------+---------------------------------------------- Reporter: refold | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.6.3 | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: None/Unknown | Blockedby: Blocking: | Related: -----------------------------+---------------------------------------------- Comment(by refold): Interestingly, the example from the manual seems to be always excepted if `MultiParamTypeClasses` are enabled: {{{ class Seq s a where fromList :: [a] -> s a elem :: Eq a => a -> s a -> Bool }}} -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7854#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7854: Constrained method type accepted in Haskell 98 mode -----------------------------+---------------------------------------------- Reporter: refold | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.6.3 | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: None/Unknown | Blockedby: Blocking: | Related: -----------------------------+---------------------------------------------- Comment(by refold): Replying to [comment:2 refold]:
seems to be always excepted
s/excepted/accepted/ -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7854#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7854: Constrained method type accepted in Haskell 98 mode ---------------------------------+------------------------------------------ Reporter: refold | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.6.3 Keywords: | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Changes (by simonpj): * difficulty: => Unknown Comment: You are absolutely right. See the H98 report [http://www.haskell.org/onlinereport/decls.html]. In 4.3.1. it says "the cxi may not constrain u", where u is the class variable, and cx is the context of a class method signature. But (a) it's a bit fiddly to fix, (b) it's not clear what exactly it means for multi-parameter type classes, and more seriously it might break some existing programs which are inadvertently straying from H98 definition. So I'm rather inclined to let sleeping dogs lie. Simon -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7854#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC