
#11715: There's something fishy going on with Constraint -------------------------------------+------------------------------------- Reporter: bgamari | Owner: Type: bug | Status: new Priority: high | Milestone: 8.0.1 Component: Compiler (Type | Version: 8.0.1-rc1 checker) | Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by goldfire): I haven't looked at the code surrounding this, but here's a plausible story: - {{{* `eqType` Constraint}}} evaluates to `True`, in case you didn't know. This fact is necessary in order to simplify Core more aggressively, as I understand it. - The instance lookup mechanism looks for cached values. (See !TcInteract, line 1306.) An instance for `*` will serve nicely as an instance for `Constraint`. - So once an instance for `*` is found, that one is used for `Constraint` as well. This does not lead to any Core Lint problems (that is, it's perfectly type safe), because of my first bullet point. Of course, `*` and `Constraint` are not equal in Haskell! One long-term solution I have for this is to make `* ~R Constraint` but not `* ~N Constraint`, as we have it now. But roles in kinds are most certainly a story for another day. I do believe that a working solution is easy enough, though: just add a check, using `tcEqType`, in `TcSMonad.findDict`. `tcEqType` is careful ''not'' to relate `*` and `Constraint`. Recall that Core Lint can never check that we're doing this right, sadly. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11715#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler