Safe Haskell | None |
---|---|
Language | Haskell2010 |
Barbies.Constraints
Description
Support for operating on Barbie-types with constrained functions.
Synopsis
- data Dict (c :: k -> Constraint) (a :: k) where
- Dict :: forall {k} (c :: k -> Constraint) (a :: k). c a => Dict c a
- requiringDict :: forall {k} c (a :: k) r. (c a => r) -> Dict c a -> r
- type AllBF (c :: k -> Constraint) (f :: k1 -> k) (b :: (k1 -> Type) -> Type) = AllB (ClassF c f) b
- class c (f a) => ClassF (c :: k -> Constraint) (f :: k1 -> k) (a :: k1)
- class c (f a) (g a) => ClassFG (c :: k -> k1 -> Constraint) (f :: k2 -> k) (g :: k2 -> k1) (a :: k2)
- class (c a, d a) => ((c :: k -> Constraint) & (d :: k -> Constraint)) (a :: k)
Instance dictionaries
data Dict (c :: k -> Constraint) (a :: k) where Source #
is evidence that there exists an instance of Dict
c ac a
.
It is essentially equivalent to Dict (c a)
from the
constraints package,
but because of its kind, it allows us to define things like
.Dict
Show
Constructors
Dict :: forall {k} (c :: k -> Constraint) (a :: k). c a => Dict c a |
requiringDict :: forall {k} c (a :: k) r. (c a => r) -> Dict c a -> r Source #
Turn a constrained-function into an unconstrained one that uses the packed instance dictionary instead.
Getting constraints
type AllBF (c :: k -> Constraint) (f :: k1 -> k) (b :: (k1 -> Type) -> Type) = AllB (ClassF c f) b Source #
class c (f a) => ClassF (c :: k -> Constraint) (f :: k1 -> k) (a :: k1) Source #
ClassF
has one universal instance that makes
equivalent to ClassF
c f ac (f a)
. However, we have
'ClassF c f :: k -> Constraint
This is useful since it allows to define constraint-constructors like
ClassF
Monoid
Maybe
Instances
c (f a) => ClassF (c :: k1 -> Constraint) (f :: k2 -> k1) (a :: k2) Source # | |
Defined in Barbies.Internal.Dicts |
class c (f a) (g a) => ClassFG (c :: k -> k1 -> Constraint) (f :: k2 -> k) (g :: k2 -> k1) (a :: k2) Source #
Like ClassF
but for binary relations.
Instances
c (f a) (g a) => ClassFG (c :: k1 -> k2 -> Constraint) (f :: k3 -> k1) (g :: k3 -> k2) (a :: k3) Source # | |
Defined in Barbies.Internal.Dicts |
Helpers
class (c a, d a) => ((c :: k -> Constraint) & (d :: k -> Constraint)) (a :: k) Source #
Instances
(c a, d a) => ((c :: k -> Constraint) & (d :: k -> Constraint)) (a :: k) Source # | |
Defined in Barbies.Internal.ConstraintsB |