[GHC] #9948: Recommend class constraint instead of instance constraint
GHC
ghc-devs at haskell.org
Tue Jan 20 15:15:59 UTC 2015
#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 crockeea):
Replying to [comment:5 goldfire]:
> However, we would, of course, still like to find an instance where
possible.
I see your point. So it's good that GHC looks at instances and tries to
find a RHS match. If he constraints are also satisfied, then no errors
should be reported. The case I'm talking about is when there is a matching
instance [on the RHS], but the instance constraints are not satisfied.
{{{
data T a
class Foo b where
foo :: b -> Int
instance (Integral a) => Foo (T a)
f :: T a -> Int
f = foo
}}}
I don't like that GHC behaves differently in the presence of a matching
instance vs when there are no matching instances. One workaround for what
I'm suggesting (that I find myself frequently using) is to comment out all
instances of the class. Then GHC just says `no instance for `Foo a`
arising from the use of `foo`` instead of recommending constraints from
the matching instance.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9948#comment:6>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list