[GHC] #7019: Wrong error message when using forall in constraints
GHC
cvs-ghc at haskell.org
Fri Jun 29 18:36:42 CEST 2012
#7019: Wrong error message when using forall in constraints
---------------------------------+------------------------------------------
Reporter: sjoerd_visscher | Owner: simonpj
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.4.1
Keywords: | Os: Unknown/Multiple
Architecture: Unknown/Multiple | Failure: None/Unknown
Difficulty: Unknown | Testcase:
Blockedby: | Blocking:
Related: |
---------------------------------+------------------------------------------
Comment(by simonpj):
GHC does not support polymorphic constraints to the left of an arrow. The
!StackOverflow thread you point to contains this program:
{{{
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE UndecidableInstances #-}
module T7019a where
class Context c where
func1 :: c -> String
class (forall b. Context (Associated a b)) -- URK!
=> Class a where
data Associated a :: * -> *
newtype ClassTest = ClassTest { runClassTest :: String }
instance (forall b. Context (Associated ClassTest b)) -- URK!
=> Class ClassTest where
data Associated ClassTest b = ClassTestAssoc b (b -> ClassTest)
instance Context (Associated ClassTest b) where
func1 (ClassTestAssoc b strFunc) = runClassTest $ strFunc b
main = putStr . func1 $ ClassTestAssoc 37 (ClassTest . show)
}}}
I'm astonished that this program typechecks. It certainly shouldn't. We
have not begun to think about constraints like `(forall b. (Associated
ClassTest b))` I'm afraid.
Actually, your Monoid example makes a lot more sense, but can't you just
have a top-level instance
{{{
instance Monoid (Free a) where ...(not sure)....
}}}
in which case you are fine.
Wanting foralls on the left of an arrow is not stupid. See #5927, #2893,
#2456. But it's not going to happen soon, because I don't know how to
specify or implement it. (Which is not to say that someone else may not
be able to crack it.)
Meanwhile, these programs should be rejected, and I'll add the tests so
that they are.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7019#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list