Basically, given {-# LANGUAGE PolymorphicKinds, ConstraintKinds, TypeFamilies #-}
(and more, if necessary), does the (~)
type-level operator work on type-level expressions of kind Constraint
? I tried googling the answer, but had no luck.
An inequality constraint can be either active, ε-active, violated, or inactive at a design point. On the other hand, an equality constraint is either active or violated at a design point.
Wikipedia defines optimization as a problem where you maximize or minimize a real function by systematically choosing input values from an allowed set and computing the value of the function.
Linear inequality constraints have the form A·x ≤ b. When A is m-by-n, there are m constraints on a variable x with n components. You supply the m-by-n matrix A and the m-component vector b. Pass linear inequality constraints in the A and b arguments.
The simplest way to handle inequality constraints is to convert them to equality constraints using slack variables and then use the Lagrange theory. but at the expense of introducing r new variables. 0 = or both. (i.e. the constraint is not binding).
Yes, it is possible. Because types of kind Constraint
are finite sets of atomic type constraints, you can test their equality very easily.
The PolyKinds
extension is not necessary, however. Also, there's very few situations when this kind equality would actually be useful, because I don't see a practical way of passing polymorphic constraints as the arguments c1
, c2
to Bla
, so the constraint equality would be a tautology in every case (Show ~ Show
here):
{-# LANGUAGE ConstraintKinds, TypeFamilies #-}
type Bla c1 c2 a = (c1 a, c2 a, c1 ~ c2)
foo :: Bla Show Show a => a -> IO ()
foo = print
main = foo "Bla"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With