| Copyright | (c) Galois Inc 2014-2015 |
|---|---|
| Maintainer | Joe Hendrix <jhendrix@galois.com> |
| Safe Haskell | Safe |
| Language | Haskell98 |
Data.Parameterized.Classes
Contents
Description
This module declares classes for working with types with the kind
k -> * for any kind k. These are generalizations of the
Data.Functor.Classes types as they work with any kind k, and are
not restricted to *.
- class TestEquality k (f :: k -> *) where
- data (k :~: (a :: k)) (b :: k) :: forall k. k -> k -> * where
- class EqF (f :: k -> *) where
- class PolyEq u v where
- class TestEquality ktp => OrdF (ktp :: k -> *) where
- lexCompareF :: forall (f :: j -> *) (a :: j) (b :: j) (c :: k) (d :: k). OrdF f => f a -> f b -> (a ~ b => OrderingF c d) -> OrderingF c d
- data OrderingF x y where
- joinOrderingF :: forall (a :: j) (b :: j) (c :: k) (d :: k). OrderingF a b -> (a ~ b => OrderingF c d) -> OrderingF c d
- orderingF_refl :: OrderingF x y -> Maybe (x :~: y)
- toOrdering :: OrderingF x y -> Ordering
- fromOrdering :: Ordering -> OrderingF x x
- class ShowF (f :: k -> *) where
- class HashableF (f :: k -> *) where
- class CoercibleF (rtp :: k -> *) where
- type family IndexF (m :: *) :: k -> *
- type family IxValueF (m :: *) :: k -> *
- class IxedF k m where
- class IxedF k m => IxedF' k m where
- class IxedF k m => AtF k m where
- class KnownRepr (f :: k -> *) (ctx :: k) where
- isJust :: Maybe a -> Bool
Equality exports
class TestEquality k (f :: k -> *) where #
This class contains types where you can learn the equality of two types from information contained in terms. Typically, only singleton types should inhabit this class.
Minimal complete definition
Methods
testEquality :: f a -> f b -> Maybe ((:~:) k a b) #
Conditionally prove the equality of a and b.
Instances
| TestEquality Nat NatRepr # | |
| TestEquality Symbol SymbolRepr # | |
| TestEquality k (Nonce k) # | |
| TestEquality k (Nonce k s) # | |
| TestEquality k ((:~:) k a) | Since: 4.7.0.0 |
| TestEquality k (Index k l) # | |
| TestEquality k (Index k ctx) # | |
| TestEquality k (Index k ctx) # | |
| TestEquality k ((:~~:) k1 k a) | Since: 4.10.0.0 |
| TestEquality k f => TestEquality [k] (List k f) # | |
| TestEquality k f => TestEquality (Ctx k) (Assignment k f) # | |
| TestEquality k f => TestEquality (Ctx k) (Assignment k f) # | |
data (k :~: (a :: k)) (b :: k) :: forall k. k -> k -> * where infix 4 #
Propositional equality. If a :~: b is inhabited by some terminating
value, then the type a is the same as the type b. To use this equality
in practice, pattern-match on the a :~: b to get out the Refl constructor;
in the body of the pattern-match, the compiler knows that a ~ b.
Since: 4.7.0.0
Instances
| Category k ((:~:) k) | Since: 4.7.0.0 |
| TestEquality k ((:~:) k a) | Since: 4.7.0.0 |
| NFData2 ((:~:) *) | Since: 1.4.3.0 |
| NFData1 ((:~:) * a) | Since: 1.4.3.0 |
| (~) k a b => Bounded ((:~:) k a b) | Since: 4.7.0.0 |
| (~) k a b => Enum ((:~:) k a b) | Since: 4.7.0.0 |
| Eq ((:~:) k a b) | |
| Ord ((:~:) k a b) | |
| (~) k a b => Read ((:~:) k a b) | Since: 4.7.0.0 |
| Show ((:~:) k a b) | |
| NFData ((:~:) k a b) | Since: 1.4.3.0 |
class EqF (f :: k -> *) where Source #
EqF provides a method eqF for testing whether two parameterized
types are equal.
Unlike TestEquality, this only works when the type arguments are
the same, and does not provide a proof that the types have the same
type when they are equal. Thus this can be implemented over
parameterized types that are unable to provide evidence that their
type arguments are equal.
Minimal complete definition
class PolyEq u v where Source #
A polymorphic equality operator that generalizes TestEquality.
Minimal complete definition
Instances
| PolyEq (NatRepr m) (NatRepr n) Source # | |
| TestEquality k f => PolyEq (Assignment k f x) (Assignment k f y) Source # | |
Ordering generalization
class TestEquality ktp => OrdF (ktp :: k -> *) where Source #
A parameterized type that can be compared on distinct instances.
Minimal complete definition
Methods
compareF :: ktp x -> ktp y -> OrderingF x y Source #
compareF compares two keys with different type parameters. Instances must ensure that keys are only equal if the type parameters are equal.
leqF :: ktp x -> ktp y -> Bool Source #
ltF :: ktp x -> ktp y -> Bool Source #
Instances
| OrdF Nat NatRepr Source # | |
| OrdF Symbol SymbolRepr Source # | |
| OrdF k (Nonce k) Source # | |
| OrdF k (Nonce k s) Source # | |
| OrdF k (Index k l) Source # | |
| OrdF k (Index k ctx) Source # | |
| OrdF k (Index k ctx) Source # | |
| OrdF k f => OrdF [k] (List k f) Source # | |
| OrdF k f => OrdF (Ctx k) (Assignment k f) Source # | |
| OrdF k f => OrdF (Ctx k) (Assignment k f) Source # | |
lexCompareF :: forall (f :: j -> *) (a :: j) (b :: j) (c :: k) (d :: k). OrdF f => f a -> f b -> (a ~ b => OrderingF c d) -> OrderingF c d Source #
Compare two values, and if they are equal compare the next values, otherwise return LTF or GTF
joinOrderingF :: forall (a :: j) (b :: j) (c :: k) (d :: k). OrderingF a b -> (a ~ b => OrderingF c d) -> OrderingF c d Source #
`joinOrderingF x y` first compares on x, returning an equivalent
value if it is not EQF. If it is EQF, it returns y.
Typeclass generalizations
class ShowF (f :: k -> *) where Source #
A parameterized type that can be shown on all instances.
To implement , one should implement an instance ShowF g for all argument types Show
(g tp)tp, then write an empty instance
instance .ShowF g
Methods
withShow :: p f -> q tp -> (Show (f tp) => a) -> a Source #
Provides a show instance for each type.
withShow :: Show (f tp) => p f -> q tp -> (Show (f tp) => a) -> a Source #
Provides a show instance for each type.
Instances
| ShowF Nat NatRepr Source # | |
| ShowF Symbol SymbolRepr Source # | |
| ShowF k (Nonce k) Source # | |
| Show x => ShowF k (Const k x) Source # | |
| ShowF k (Nonce k s) Source # | |
| ShowF k (Index k l) Source # | |
| ShowF k (Index k ctx) Source # | |
| ShowF k (Index k ctx) Source # | |
| ShowF k f => ShowF [k] (List k f) Source # | |
| ShowF k f => ShowF (Ctx k) (Assignment k f) Source # | |
| ShowF k f => ShowF (Ctx k) (Assignment k f) Source # | |
class HashableF (f :: k -> *) where Source #
A parameterized type that is hashable on all instances.
Minimal complete definition
Instances
| HashableF Nat NatRepr Source # | |
| HashableF Symbol SymbolRepr Source # | |
| HashableF k (Nonce k) Source # | |
| Hashable a => HashableF k (Const k a) Source # | |
| HashableF k (Nonce k s) Source # | |
| HashableF k (Index k ctx) Source # | |
| HashableF k (Index k ctx) Source # | |
| HashableF k f => HashableF (Ctx k) (Assignment k f) Source # | |
| HashableF k f => HashableF (Ctx k) (Assignment k f) Source # | |
class CoercibleF (rtp :: k -> *) where Source #
An instance of CoercibleF gives a way to coerce between
all the types of a family. We generally use this to witness
the fact that the type parameter to rtp is a phantom type
by giving an implementation in terms of Data.Coerce.coerce.
Minimal complete definition
Instances
| CoercibleF k (Const k x) Source # | |
Optics generalizations
class IxedF k m where Source #
Parameterized generalization of the lens Ixed class.
Minimal complete definition
class IxedF k m => IxedF' k m where Source #
Parameterized generalization of the lens Ixed class,
but with the guarantee that indexes exist in the container.
Minimal complete definition
Methods
ixF' :: forall (x :: k). IndexF m x -> Lens' m (IxValueF m x) Source #
Given an index into a container, build a lens that points into the given element in the container.
Instances
| IxedF' k (Assignment k f ctx) Source # | |
| IxedF' k (Assignment k f ctx) Source # | |
class IxedF k m => AtF k m where Source #
Parameterized generalization of the lens At class.
Minimal complete definition
Methods
atF :: forall (x :: k). IndexF m x -> Lens' m (Maybe (IxValueF m x)) Source #
Given an index into a container, build a lens that points into
the given position in the container, whether or not it currently
exists. Setting values of atF to a Just value will insert
the value if it does not already exist.
KnownRepr
class KnownRepr (f :: k -> *) (ctx :: k) where Source #
This class is parameterized by a kind k (typically a data
kind), a type constructor f of kind k -> * (typically a GADT of
singleton types indexed by k), and an index parameter ctx of
kind k.
Minimal complete definition
Instances
| KnownNat n => KnownRepr Nat NatRepr n Source # | |
| KnownSymbol s => KnownRepr Symbol SymbolRepr s Source # | |
| KnownRepr [k] (List k f) ([] k) Source # | |
| KnownRepr (Ctx k) (Assignment k f) (EmptyCtx k) Source # | |
| KnownRepr (Ctx k) (Assignment k f) (EmptyCtx k) Source # | |
| (KnownRepr a f s, KnownRepr [a] (List a f) sh) => KnownRepr [a] (List a f) ((:) a s sh) Source # | |
| (KnownRepr (Ctx k) (Assignment k f) ctx, KnownRepr k f bt) => KnownRepr (Ctx k) (Assignment k f) ((::>) k ctx bt) Source # | |
| (KnownRepr (Ctx k) (Assignment k f) ctx, KnownRepr k f bt) => KnownRepr (Ctx k) (Assignment k f) ((::>) k ctx bt) Source # | |