Higher kinded empty constraint

62 Views Asked by At

I want to have an empty constraint at a higher kind.

Suppose I have the following class:

class Category k where
  type Obj k :: * -> Constraint
  id  :: Obj k a => a `k` a
  (.) :: (Obj k a, Obj k b, Obj k c) => b `k` c -> a `k` b -> a `k` c

Now I want to make an instance for functions such that it doesn't constrain the elements in any way. What do I give as an instance for Obj?

instance Category (->) where
  type Obj (->) = ?
  id    = \a -> a
  f . g = \a -> f (g a)
1

There are 1 best solutions below

1
On BEST ANSWER

You'll need to give it an explicit additional argument in the class declaration.

class Category k where
  type Obj k a :: Constraint

Then it's easy to define the instances using the lower-kinded () empty constraint.

instance Category (->) where
  type Obj (->) a = ()