
#9948: Recommend class constraint instead of instance constraint -------------------------------------+------------------------------------- Reporter: crockeea | Owner: Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.4 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by rwbarton): I can see why you might want this behavior in some cases, but would you really want {{{ isPalindrome :: [a] -> Bool isPalindrome xs = xs == reverse xs }}} to suggest adding an `Eq [a]` constraint (that's not even valid Haskell 98!), or some function to dump a data structure to suggest adding a `Show [(Int, Maybe a)]` constraint? Whatever constraint GHC suggests, it won't be the appropriate one in every situation. The current behavior is the most obvious one to me (the suggested constraint is the same one that appears in the type that GHC would infer in the absence of a type signature). I'm also a bit confused by the workaround that you mentioned; if you know that `Foo` is the class containing `foo` (which you must to comment out its instances) then don't you already know what constraint to add? Is it very difficult in your use cases to work out what the parameter to the class should be? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9948#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler