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

GHC ghc-devs at haskell.org
Sun Sep 16 16:18:07 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:                    |
-------------------------------------+-------------------------------------

Comment (by infinity0):

 OK, thanks for explaining. Looks like adding a `Proxy r` as mentioned on
 #10651 also works here, and you don't need `AllowAmbiguousTypes` or
 `TypeApplications`. It might be good to have the error message (r0 is
 untouchable etc) mention this workaround.

 (I had known of the trick of giving a ghost parameter in other similar
 cases with ambiguous types, but here `r` is of kind `* -> Constraint` so
 that doesn't work and one *has* to use `Proxy` here.)

 {{{#!haskell
 loadAll2
   :: forall a r . (DynPS r a)
   => (forall ref. r ref => ref -> PSAny r)
   -> Proxy r -> a -> Maybe a
 loadAll2 loader _ r = loadAll (DynLoad' loader :: DynLoad' r) r

 testCallable2 :: IO (Maybe ())
 testCallable2 = return $ loadAll2 undefined (Proxy :: Proxy Unconstrained)
 ()
 }}}

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


More information about the ghc-tickets mailing list