[GHC] #7908: InstanceSigs suggestion not accepted

#7908: InstanceSigs suggestion not accepted -----------------------------+---------------------------------------------- Reporter: heisenbug | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.7 | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: None/Unknown | Blockedby: Blocking: | Related: -----------------------------+---------------------------------------------- Attached testcase compiles, but when uncommenting either of the lines 19, 21 or 23, I get an error: {{{ pr7908.hs:23:12: Method signature does not match class; it should be (>>-) :: forall (c :: k -> *) d. Hidden k c -> (forall (a :: k). c a -> d) -> d In the instance declaration for `Monad' k (Hidden k)' Failed, modules loaded: none. }}} But in fact I basically copied the suggestion into my file! (with slight modification "Hidden k c" --> "Hidden c") This may be because of the rank2 type or because of the polykinds appearing. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7908 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#7908: InstanceSigs suggestion not accepted ---------------------------------+------------------------------------------ Reporter: heisenbug | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.7 Keywords: | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Changes (by simonpj): * cc: dimitris@…, dreixel (added) * difficulty: => Unknown Comment: This is a problem with the notation for kind polymorphism. This works: {{{ instance Monad' (Hidden :: (k -> *) -> *) where return' :: forall (c :: k -> *) (a :: k) . c a -> Hidden c return' = Hide ...etc.. }}} Note the kind signature on `Hidden`. That brings `k` into scope. Without that, `k` is not in scope. And if it isn't in scope, GHC adds an implicit `forall` for the `k`. So if you write {{{ instance Monad Hidden where return' :: forall (c :: k -> *) (a :: k) . c a -> Hidden c return' = Hide }}} what you mean is: {{{ instance Monad Hidden where return' :: forall k. forall (c :: k -> *) (a :: k) . c a -> Hidden c return' = Hide }}} And that is rightly rejected. So there are two problems: * The error message doesn't make it clear what exactly is wrong * Even if it did, the fix (bringing `k` into scope across the whole instance decl) is far from obvious Now that we understand the problem, any suggestions for what would be a better error message, or how to make the solution clearer? -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7908#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC