Skip to content

Cannot use monokinded class as superclass for polykinded one.

For example, base has

type Eq1 :: (Type -> Type) -> Constraint
class Eq1 f where
  liftEq :: (a -> b -> Bool) -> f a -> f b -> Bool

Imagine, I want to write a class providing a stronger comparison function

type EqP :: (k -> Type) -> Constraint
class EqP f where
  eqp :: f a -> f b -> Bool

instances for EqP could include StableName, or ordinal numbers:

data Fin :: Peano -> Type where
  FZ :: Fin (S n)
  FS :: Fin n -> Fin (S n)

eqpFin :: Fin n -> Fin m -> Bool
eqpFin FZ     FZ     = True
eqpFin (FS n) (FS m) = eqpFin n m
eqpFin _      _      = False

It would be great to say that Eq1 f => EqP f. That won't work though: that is ill-kinded. I imagine writing

class (k ~ Type => Eq1 f) => EqP (f :: k -> Type) where

but that doesn't work either, and I think there cannot be kind equalities anymore anyway.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information