Skip to content

QuantifiedConstraints: Can't define class alias

{-# Language TypeInType, MultiParamTypeClasses, TypeFamilies, FlexibleContexts, FunctionalDependencies, AllowAmbiguousTypes, QuantifiedConstraints, GADTs, ConstraintKinds, KindSignatures, RankNTypes, FlexibleInstances, UndecidableInstances, TypeOperators #-}

import Data.Kind

class Reifies s a | s -> a where
  reflect :: proxy s -> a

newtype Lift :: forall k. (Type -> Constraint) -> Type -> k -> Type where
  Lift :: a -> Lift cls a s

data family Def :: (k -> Constraint) -> (k -> Type)

class    (forall s a. Reifies s (Def cls a) => cls (Lift cls a s)) => ReifiableConstraint cls
instance (forall s a. Reifies s (Def cls a) => cls (Lift cls a s)) => ReifiableConstraint cls

gives an error

$ ghci -ignore-dot-ghci Bug.hs
GHCi, version 8.5.20180128: http://www.haskell.org/ghc/  :? for help
[1 of 1] Compiling Main             ( /tmp/Bug.hs, interpreted )

/tmp/Bug.hs:14:10: error:
    • Could not deduce: cls (Lift cls a s)
        arising from the superclasses of an instance declaration
      from the context: forall (s :: k) a.
                        Reifies s (Def cls a) =>
                        cls (Lift cls a s)
        bound by the instance declaration at /tmp/Bug.hs:14:10-93
      or from: Reifies s (Def cls a)
        bound by a quantified context at /tmp/Bug.hs:1:1
    • In the instance declaration for ‘ReifiableConstraint cls’
   |
14 | instance (forall s a. Reifies s (Def cls a) => cls (Lift cls a s)) => ReifiableConstraint cls
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Failed, no modules loaded.
Prelude> 

This is a rare occasion that the class alias trick fails for me so ~+~yay~+~. But is it intended?

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