[GHC] #5927: A type-level "implies" constraint on Constraints

GHC ghc-devs at haskell.org
Tue Feb 27 16:51:46 UTC 2018


#5927: A type-level "implies" constraint on Constraints
-------------------------------------+-------------------------------------
        Reporter:  illissius         |                Owner:  (none)
            Type:  feature request   |               Status:  closed
        Priority:  normal            |            Milestone:
       Component:  Compiler (Type    |              Version:  7.4.1
  checker)                           |             Keywords:
      Resolution:  duplicate         |  QuantifiedConstraints
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:  #2893             |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by simonpj):

 Hmm. This is interesting.  We have
 {{{
 $dmshowsPrec :: Show a => Int -> a -> ShowS
 }}}
 and the implied instance decl is
 {{{
 instance (forall a. c a => Show a) => Show (Exists c) where
   show (Exists a) = show a
   showsPrec = $dmshowsPrec
 }}}
 From the RHS of `showsPred` we get `[W] Show (Exists c)`.   And ''alas''
 we try to solve that from the quantified constraint (which takes
 precedence over top-level instances), by instantiating `a` to `(Exists
 c)`.  So we get
 {{{
   [W} c (Exists c)
 }}}
 which we can't solve.

 This would happen on any recursive invocation of a method at the same
 type.

 It's not clear what we want here.   The quantified constraint claims to
 provide an instance ''for every type a'' which is jolly suspicious.

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


More information about the ghc-tickets mailing list