[GHC] #14877: QuantifiedConstraints: Can't deduce `xx' from `(xx => a, xx)'

GHC ghc-devs at haskell.org
Fri Mar 2 14:49:31 UTC 2018


#14877: QuantifiedConstraints: Can't deduce `xx' from `(xx => a, xx)'
-------------------------------------+-------------------------------------
           Reporter:  Iceland_jack   |             Owner:  (none)
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Compiler       |           Version:  8.2.2
           Keywords:                 |  Operating System:  Unknown/Multiple
  QuantifiedConstraints, wipT2893    |
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 This works with the
 [https://ghc.haskell.org/trac/ghc/ticket/2893#comment:34 latest change to
 the -XQuantifiedConstraints branch].

 {{{#!hs
 {-# Language QuantifiedConstraints, FlexibleInstances,
 MultiParamTypeClasses, AllowAmbiguousTypes, RankNTypes, PolyKinds,
 ConstraintKinds, UndecidableInstances #-}

 class    (forall xx. (xx => a) => Implies xx b) => F a b
 instance (forall xx. (xx => a) => Implies xx b) => F a b

 class    (a => b) => Implies a b
 instance (a => b) => Implies a b
 }}}

 but replacing `Implies xx b` with `(xx => b)` causes it to fail. I don't
 know if the cause of this overlaps with an existing ticket.

 {{{#!hs
 class    (forall xx. (xx => a) => (xx => b)) => F a b
 instance (forall xx. (xx => a) => (xx => b)) => F a b

 -- $ ghci -ignore-dot-ghci /tmp/ASD.hs
 -- GHCi, version 8.5.20180128: http://www.haskell.org/ghc/  :? for help
 -- [1 of 1] Compiling Main             ( /tmp/ASD.hs, interpreted )
 --
 -- /tmp/ASD.hs:4:10: error:
 --     • Could not deduce: xx0
 --         arising from the superclasses of an instance declaration
 --       from the context: forall (xx :: Constraint). (xx => a, xx) => b
 --         bound by the instance declaration at /tmp/ASD.hs:4:10-53
 --       or from: (xx => a, xx)
 --         bound by a quantified context at /tmp/ASD.hs:1:1
 --     • In the instance declaration for ‘F a b’
 --   |
 -- 4 | instance (forall xx. (xx => a) => (xx => b)) => F a b
 --   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 -- Failed, no modules loaded.
 -- Prelude>
 }}}

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


More information about the ghc-tickets mailing list