[GHC] #15649: Errors about ambiguous untouchable variable when using constraint variable in RankN type

GHC ghc-devs at haskell.org
Sun Sep 16 11:28:23 UTC 2018


#15649: Errors about ambiguous untouchable variable when using constraint variable
in RankN type
-------------------------------------+-------------------------------------
        Reporter:  infinity0         |                Owner:  (none)
            Type:  bug               |               Status:  closed
        Priority:  normal            |            Milestone:  8.6.1
       Component:  Compiler          |              Version:  8.4.3
      Resolution:  duplicate         |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #10651, #14921    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by RyanGlScott):

 * status:  new => closed
 * resolution:   => duplicate
 * related:   => #10651, #14921


Comment:

 This is expected behavior. As simonpj explains in
 https://ghc.haskell.org/trac/ghc/ticket/10651#comment:2, GHC does not (in
 general) unify underneath constraints that might turn into equalities. In
 your program, you have

 {{{#!hs
 (forall ref. r ref => ref -> PSAny r)
 }}}

 In order to prove that `(forall ref. r ref => ref -> PSAny r)` equals
 `(forall ref. r0 ref => ref -> PSAny r0)` (where `r0` is a unification
 variable), it must conclude that `r ~ r0`. But this is not sound in
 general, since `r ref` might later unify with, say, `r ~ Int`, which would
 make `r0 := Int` a valid substitution. Moreover, `r` is not uniquely
 determined anywhere else in the type signature (unlike in `loadAll`, where
 it is determined by the `DynLoad r` argument). Therefore, `r0` is marked
 as untouchable in this type signature. (This is all explained in Section 5
 in the [https://www.microsoft.com/en-us/research/wp-
 content/uploads/2016/02/jfp-outsidein.pdf ​OutsideIn paper].)

 See also #10651 and #14921.

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15649#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list