BSD-2-Clause licensed by Edward A. Kmett
Maintained by Edward A. Kmett
This version can be pinned in stack with:constraints-0.10.1@sha256:25190a3401d9371179abc3144ea087148976ebeafdd1b3945bd8a0f799951cb8,2160


Hackage Build Status

This package provides data types and classes for manipulating the ‘ConstraintKinds’ exposed by GHC in 7.4.

Contact Information

Contributions and bug reports are welcome!

Please feel free to contact me through github or on the #haskell IRC channel on

-Edward Kmett


0.10.1 [2018.07.02]

  • Allow building with GHC 8.6.
  • Add three axioms about (+) and (-) to Data.Constraint.Nat.


  • Adapt to the SemigroupMonoid Proposal (introduced in base-4.11):
    • Add a Semigroup instance for Dict
    • Add the appropriate (:=>) instances involving Semigroup, and change the Class () (Monoid a) instance to Class (Semigroup a) (Monoid a) when base is recent enough
    • Add the appropriate Lifting(2) instances involving Semigroup
  • Data.Constraint.Nat now reexports the Div and Mod type families from GHC.TypeLits on base-4.11 or later
  • Fix the type signature of maxCommutes
  • Export the no method of Bottom
  • Add NFData instances for Dict and (:-)


  • Correct an improper use of unsafeCoerce in the internals of Data.Constraint.Nat and Data.Constraint.Symbol
  • Correctly identify the mismatched types when you defer an unsatisfiable equality constraint through Data.Constraint.Deferrable
  • Re-export the (:~~:) defined in base from Data.Constraint.Deferred with GHC 8.2 or later
  • Add several new (:=>) instances for Bits, Identity, Const, Natural, IO, and Word.
  • Modernize some existing Class and (:=>) instances to reflect the fact that Applicative is now a superclass of Monad on recent versions of base.


  • Changes to Data.Constraint:
    • Add strengthen1 and strengthen2
  • Changes to Data.Constraint.Deferrable:
    • Add a Deferrable () instance
    • The Deferrable (a ~ b) instance now shows the TypeReps of a and b when a type mismatch error is thrown
    • Add defer_ and deferEither_, counterparts to defer and deferEither which do not require proxy arguments
    • Enable PolyKinds. This allows the Deferrable (a ~ b instance to be polykinded on all supported versions of GHC except 7.10, where the kinds must be * due to an old GHC bug
    • Introduce a heterogeneous equality type (:~~:), and use it to define a Deferrable (a ~~ b) instance on GHC 8.0 or later
  • Changes to Data.Constraint.Forall:
    • Implement ForallF and ForallT in terms of Forall
    • Add ForallV and InstV (supporting a variable number of parameters)
    • Add a forall combinator
  • Introduce Data.Constraint.Nat and Data.Constraint.Symbol, which contain utilities for working with KnownNat and KnownSymbol constraints, respectively. These modules are only available on GHC 8.0 or later.


  • GHC 8 compatibility
  • transformers 0.5 compatibility
  • binary 0.8 compatibility
  • Dropped support for GHC 7.6 in favor of a nicer Bottom representation.


  • Found a nicer encoding of the initial object in the category of constraints using a nullary constraint.


  • Remove the need for closed type families from the new Forall.


  • Completely redesigned Data.Constraint.Forall. The old design is unsound and can be abused to define unsafeCoerce! The new design requires closed type families, so this module now requires GHC 7.8+


  • Added Data.Constraint.Deferrable.


  • Added Data.Constraint.Lifting.

  • Acknowledge we actually need at least base 4.5

  • Restore support for building on older GHCs

  • Minor documentation fixes.


  • Added mapDict and unmapDict.
  • Added a lot of documentation.


  • Typeable and Data. The Data instance for (:-) is a conservative approximation that avoids having to turn (:-) into a cartesian closed category. If it becomes a pain point for users, I know how to do that, and have done so in other libraries – see hask, but I’m hesitant to bring such heavy machinery to bear and it isn’t clear how to do it in a way that is compatible with those other libraries.


  • Explicit role annotations

  • Fixed build failures.
  • Fixed an unused import warning on older GHCs.


  • Added bottom