Portability | non-portable |
---|---|
Stability | experimental |
Maintainer | Edward Kmett <ekmett@gmail.com> |
Safe Haskell | Trustworthy |
- data Constraint
- data Dict where
- newtype a :- b = Sub (a => Dict b)
- (\\) :: a => (b => r) -> (a :- b) -> r
- weaken1 :: (a, b) :- a
- weaken2 :: (a, b) :- b
- contract :: a :- (a, a)
- (&&&) :: (a :- b) -> (a :- c) -> a :- (b, c)
- (***) :: (a :- b) -> (c :- d) -> (a, c) :- (b, d)
- trans :: (b :- c) -> (a :- b) -> a :- c
- refl :: a :- a
- top :: a :- ()
- bottom :: (() ~ Bool) :- c
- class Class b h | h -> b where
- class b :=> h | h -> b where
Constraints
data Constraint
Dictionary
Capture a dictionary for a given constraint
Entailment
(\\) :: a => (b => r) -> (a :- b) -> rSource
Given that a :- b
, derive something that needs a context b
, using the context a
(&&&) :: (a :- b) -> (a :- c) -> a :- (b, c)Source
Constraint product
trans weaken1 (f &&& g) = f trans weaken2 (f &&& g) = g
(***) :: (a :- b) -> (c :- d) -> (a, c) :- (b, d)Source
due to the hack for the kind of (,) in the current version of GHC we can't actually make instances for (,) :: Constraint -> Constraint -> Constraint
trans :: (b :- c) -> (a :- b) -> a :- cSource
Transitivity of entailment
If we view '(:-)' as a Constraint-indexed category, then this is '(.)'
Reflexivity of entailment
If we view '(:-)' as a Constraint-indexed category, then this is id
Every constraint implies truth
These are the terminal arrows of the category, and () is the terminal object.
bottom :: (() ~ Bool) :- cSource
A bad type coercion lets you derive any type you want.
These are the initial arrows of the category and (() ~ Bool) is the initial object
This demonstrates the law of classical logical ex falso quodlibet
Reflection
class Class b h | h -> b whereSource
Reify the relationship between a class and its superclass constraints as a class
Class () () | |
Class () (Bounded a) | |
Class () (Enum a) | |
Class () (Eq a) | |
Class () (Monad f) | |
Class () (Functor f) | |
Class () (Num a) | |
Class () (Read a) | |
Class () (Show a) | |
Class () (Monoid a) | |
Class () (:=> b a) | |
Class () (Class b a) | |
Class (Eq a) (Ord a) | |
Class (Fractional a) (Floating a) | |
Class (Monad f) (MonadPlus f) | |
Class (Functor f) (Applicative f) | |
Class (Num a) (Fractional a) | |
Class (Applicative f) (Alternative f) | |
Class (Num a, Ord a) (Real a) | |
Class (Real a, Fractional a) (RealFrac a) | |
Class (Real a, Enum a) (Integral a) | |
Class (RealFrac a, Floating a) (RealFloat a) |
class b :=> h | h -> b whereSource
Reify the relationship between an instance head and its body as a class