Constraint kinds
also: constraintkinds, constraint synonym
The extension that gives constraints their own kind, so the thing left of the arrow becomes a first-class type that can be named, parameterised, and computed by a type family. It is how a container class expresses whatever its elements require without fixing it in the class head.
With ConstraintKinds, the thing to the left of becomes a first-class type of kind Constraint, so constraints can be named, parameterised, and abstracted over like any other type.
A constraint synonym, and a constraint computed by a type family.
{-# LANGUAGE ConstraintKinds, TypeFamilies #-}type Serialisable a = (Show a, Read a, Eq a) -- one name for threetype family Elem c :: Constraint whereElem [a] = Ord aElem (Set a) = Ord a-- and a constraint as a class parameterclass HasDict (c :: Constraint) where withDict :: (c => r) -> r
What it buys is a way out of the combinatorial growth of constraint lists, and the ability to let an instance decide what its own constraint is, which is how container classes express “whatever this container needs of its elements” without fixing it in the class head.
Kinds and types are the same thing here, which is what makes it work: Constraint is just another kind alongside , so everything the type system already does with types applies to constraints unchanged.
see also
read more