Skip to content

QuantifiedConstraints: Can't deduce "(a, b)" from "a" and "b"

{-# Language QuantifiedConstraints, RankNTypes, PolyKinds, ConstraintKinds, UndecidableInstances, GADTs, LiberalTypeSynonyms, TypeOperators, MultiParamTypeClasses, FlexibleInstances #-}

data Dict c where
  Dict :: c => Dict c

infixr |-
class    (a => b) => (a |- b)
instance (a => b) => (a |- b)

type a :- b = Dict (a |- b)

class    ((a, b) => c) => Curried a b c
instance ((a, b) => c) => Curried a b c

curryC :: forall a b c. ((a, b) |- c) :- (a |- b |- c)
curryC = Dict

This fails with

GHCi, version 8.5.20180128: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( /tmp/Test.hs, interpreted )

/tmp/Test.hs:16:10: error:
    • Could not deduce (a, b) arising from a use of ‘Dict’
      from the context: (a, b) |- c
        bound by a quantified context at /tmp/Test.hs:1:1
      or from: a bound by a quantified context at /tmp/Test.hs:1:1
      or from: b bound by a quantified context at /tmp/Test.hs:1:1
      Possible fix:
        add (a, b) to the context of
          the type signature for:
            curryC :: forall (a :: Constraint) (b :: Constraint) (c :: Constraint).
                      ((a, b) |- c) :- (a |- (b |- c))
    • In the expression: Dict
      In an equation for ‘curryC’: curryC = Dict
   |
16 | curryC = Dict
   |          ^^^^
Failed, no modules loaded.

but it works by changing the type of curryC:

curryC :: forall a b c. Curried a b c :- (a |- b |- c)
Trac metadata
Trac field Value
Version 8.5
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information