Copyright | (c) Galois Inc 2015 |
---|---|
Maintainer | Joe Hendrix <jhendrix@galois.com> |
Safe Haskell | Safe |
Language | Haskell98 |
Data.Parameterized.Ctx
Contents
Description
This module defines type-level lists used for representing the type of variables in a context.
Synopsis
- data Ctx k
- type EmptyCtx = EmptyCtx
- type SingleCtx x = EmptyCtx ::> x
- type (::>) (c :: Ctx k) (a :: k) = c ::> a
- type family (x :: Ctx k) <+> (y :: Ctx k) :: Ctx k where ...
- type family CtxSize (a :: Ctx k) :: Nat where ...
- type CtxLookup (n :: Nat) (ctx :: Ctx k) = CtxLookupRight (FromLeft ctx n) ctx
- type CtxUpdate (n :: Nat) (x :: k) (ctx :: Ctx k) = CtxUpdateRight (FromLeft ctx n) x ctx
- type family CtxLookupRight (n :: Nat) (ctx :: Ctx k) :: k where ...
- type family CtxUpdateRight (n :: Nat) (x :: k) (ctx :: Ctx k) :: Ctx k where ...
- type family CheckIx (ctx :: Ctx k) (n :: Nat) (b :: Bool) :: Constraint where ...
- type ValidIx (n :: Nat) (ctx :: Ctx k) = CheckIx ctx n ((n + 1) <=? CtxSize ctx)
- type FromLeft ctx n = (CtxSize ctx - 1) - n
Documentation
Kind
comprises lists of types of kind Ctx
kk
.
Instances
TraversableFC (Assignment :: (k -> Type) -> Ctx k -> *) Source # | |
Defined in Data.Parameterized.Context.Unsafe Methods traverseFC :: Applicative m => (forall (x :: k0). f x -> m (g x)) -> forall (x :: l). Assignment f x -> m (Assignment g x) Source # | |
TraversableFC (Assignment :: (k -> Type) -> Ctx k -> *) Source # | |
Defined in Data.Parameterized.Context.Safe Methods traverseFC :: Applicative m => (forall (x :: k0). f x -> m (g x)) -> forall (x :: l). Assignment f x -> m (Assignment g x) Source # | |
FoldableFC (Assignment :: (k -> Type) -> Ctx k -> *) Source # | |
Defined in Data.Parameterized.Context.Unsafe Methods foldMapFC :: Monoid m => (forall (x :: k0). f x -> m) -> forall (x :: l). Assignment f x -> m Source # foldrFC :: (forall (x :: k0). f x -> b -> b) -> forall (x :: l). b -> Assignment f x -> b Source # foldlFC :: (forall (x :: k0). b -> f x -> b) -> forall (x :: l). b -> Assignment f x -> b Source # foldrFC' :: (forall (x :: k0). f x -> b -> b) -> forall (x :: l). b -> Assignment f x -> b Source # foldlFC' :: (forall (x :: k0). b -> f x -> b) -> forall (x :: l). b -> Assignment f x -> b Source # toListFC :: (forall (x :: k0). f x -> a) -> forall (x :: l). Assignment f x -> [a] Source # | |
FoldableFC (Assignment :: (k -> Type) -> Ctx k -> *) Source # | |
Defined in Data.Parameterized.Context.Safe Methods foldMapFC :: Monoid m => (forall (x :: k0). f x -> m) -> forall (x :: l). Assignment f x -> m Source # foldrFC :: (forall (x :: k0). f x -> b -> b) -> forall (x :: l). b -> Assignment f x -> b Source # foldlFC :: (forall (x :: k0). b -> f x -> b) -> forall (x :: l). b -> Assignment f x -> b Source # foldrFC' :: (forall (x :: k0). f x -> b -> b) -> forall (x :: l). b -> Assignment f x -> b Source # foldlFC' :: (forall (x :: k0). b -> f x -> b) -> forall (x :: l). b -> Assignment f x -> b Source # toListFC :: (forall (x :: k0). f x -> a) -> forall (x :: l). Assignment f x -> [a] Source # | |
OrdFC (Assignment :: (k -> Type) -> Ctx k -> *) Source # | |
Defined in Data.Parameterized.Context.Unsafe Methods compareFC :: (forall (x :: k0) (y :: k0). f x -> f y -> OrderingF x y) -> forall (x :: l) (y :: l). Assignment f x -> Assignment f y -> OrderingF x y Source # | |
OrdFC (Assignment :: (k -> Type) -> Ctx k -> *) Source # | |
Defined in Data.Parameterized.Context.Safe Methods compareFC :: (forall (x :: k0) (y :: k0). f x -> f y -> OrderingF x y) -> forall (x :: l) (y :: l). Assignment f x -> Assignment f y -> OrderingF x y Source # | |
TestEqualityFC (Assignment :: (k -> Type) -> Ctx k -> *) Source # | |
Defined in Data.Parameterized.Context.Unsafe Methods testEqualityFC :: (forall (x :: k0) (y :: k0). f x -> f y -> Maybe (x :~: y)) -> forall (x :: l) (y :: l). Assignment f x -> Assignment f y -> Maybe (x :~: y) Source # | |
TestEqualityFC (Assignment :: (k -> Type) -> Ctx k -> *) Source # | |
Defined in Data.Parameterized.Context.Safe Methods testEqualityFC :: (forall (x :: k0) (y :: k0). f x -> f y -> Maybe (x :~: y)) -> forall (x :: l) (y :: l). Assignment f x -> Assignment f y -> Maybe (x :~: y) Source # | |
FunctorFC (Assignment :: (k -> Type) -> Ctx k -> *) Source # | |
Defined in Data.Parameterized.Context.Unsafe Methods fmapFC :: (forall (x :: k0). f x -> g x) -> forall (x :: l). Assignment f x -> Assignment g x Source # | |
FunctorFC (Assignment :: (k -> Type) -> Ctx k -> *) Source # | |
Defined in Data.Parameterized.Context.Safe Methods fmapFC :: (forall (x :: k0). f x -> g x) -> forall (x :: l). Assignment f x -> Assignment g x Source # | |
Category (Diff :: Ctx k -> Ctx k -> *) # | |
Category (Diff :: Ctx k -> Ctx k -> *) # | |
TestEquality f => TestEquality (Assignment f :: Ctx k -> *) # | |
Defined in Data.Parameterized.Context.Unsafe Methods testEquality :: Assignment f a -> Assignment f b -> Maybe (a :~: b) # | |
TestEquality f => TestEquality (Assignment f :: Ctx k -> *) # | |
Defined in Data.Parameterized.Context.Safe Methods testEquality :: Assignment f a -> Assignment f b -> Maybe (a :~: b) # | |
HashableF f => HashableF (Assignment f :: Ctx k -> *) Source # | |
Defined in Data.Parameterized.Context.Unsafe Methods hashWithSaltF :: Int -> Assignment f tp -> Int Source # hashF :: Assignment f tp -> Int Source # | |
HashableF f => HashableF (Assignment f :: Ctx k -> *) Source # | |
Defined in Data.Parameterized.Context.Safe Methods hashWithSaltF :: Int -> Assignment f tp -> Int Source # hashF :: Assignment f tp -> Int Source # | |
ShowF f => ShowF (Assignment f :: Ctx k -> *) Source # | |
Defined in Data.Parameterized.Context.Unsafe Methods withShow :: p (Assignment f) -> q tp -> (Show (Assignment f tp) -> a) -> a Source # showF :: Assignment f tp -> String Source # showsPrecF :: Int -> Assignment f tp -> String -> String Source # | |
ShowF f => ShowF (Assignment f :: Ctx k -> *) Source # | |
Defined in Data.Parameterized.Context.Safe Methods withShow :: p (Assignment f) -> q tp -> (Show (Assignment f tp) -> a) -> a Source # showF :: Assignment f tp -> String Source # showsPrecF :: Int -> Assignment f tp -> String -> String Source # | |
OrdF f => OrdF (Assignment f :: Ctx k -> *) Source # | |
Defined in Data.Parameterized.Context.Unsafe Methods compareF :: Assignment f x -> Assignment f y -> OrderingF x y Source # leqF :: Assignment f x -> Assignment f y -> Bool Source # ltF :: Assignment f x -> Assignment f y -> Bool Source # geqF :: Assignment f x -> Assignment f y -> Bool Source # gtF :: Assignment f x -> Assignment f y -> Bool Source # | |
OrdF f => OrdF (Assignment f :: Ctx k -> *) Source # | |
Defined in Data.Parameterized.Context.Safe Methods compareF :: Assignment f x -> Assignment f y -> OrderingF x y Source # leqF :: Assignment f x -> Assignment f y -> Bool Source # ltF :: Assignment f x -> Assignment f y -> Bool Source # geqF :: Assignment f x -> Assignment f y -> Bool Source # gtF :: Assignment f x -> Assignment f y -> Bool Source # | |
KnownRepr (Assignment f :: Ctx k -> *) (EmptyCtx :: Ctx k) Source # | |
Defined in Data.Parameterized.Context.Unsafe Methods knownRepr :: Assignment f EmptyCtx Source # | |
KnownRepr (Assignment f :: Ctx k -> *) (EmptyCtx :: Ctx k) Source # | |
Defined in Data.Parameterized.Context.Safe Methods knownRepr :: Assignment f EmptyCtx Source # | |
(KnownRepr (Assignment f) ctx, KnownRepr f bt) => KnownRepr (Assignment f :: Ctx k -> *) (ctx ::> bt :: Ctx k) Source # | |
Defined in Data.Parameterized.Context.Unsafe Methods knownRepr :: Assignment f (ctx ::> bt) Source # | |
(KnownRepr (Assignment f) ctx, KnownRepr f bt) => KnownRepr (Assignment f :: Ctx k -> *) (ctx ::> bt :: Ctx k) Source # | |
Defined in Data.Parameterized.Context.Safe Methods knownRepr :: Assignment f (ctx ::> bt) Source # |
type family (x :: Ctx k) <+> (y :: Ctx k) :: Ctx k where ... Source #
Append two type-level contexts.
Type context manipulation
type family CtxSize (a :: Ctx k) :: Nat where ... Source #
This type family computes the number of elements in a Ctx
type CtxLookup (n :: Nat) (ctx :: Ctx k) = CtxLookupRight (FromLeft ctx n) ctx Source #
Lookup the value in a context by number, from the left. Produce a type error if the index is out of range.
type CtxUpdate (n :: Nat) (x :: k) (ctx :: Ctx k) = CtxUpdateRight (FromLeft ctx n) x ctx Source #
Update the value in a context by number, from the left. If the index is out of range, the context is unchanged.
type family CtxLookupRight (n :: Nat) (ctx :: Ctx k) :: k where ... Source #
Lookup the value in a context by number, from the right
Equations
CtxLookupRight 0 (ctx ::> r) = r | |
CtxLookupRight n (ctx ::> r) = CtxLookupRight (n - 1) ctx |
type family CtxUpdateRight (n :: Nat) (x :: k) (ctx :: Ctx k) :: Ctx k where ... Source #
Update the value in a context by number, from the right. If the index is out of range, the context is unchanged.
Equations
CtxUpdateRight n x EmptyCtx = EmptyCtx | |
CtxUpdateRight 0 x (ctx ::> old) = ctx ::> x | |
CtxUpdateRight n x (ctx ::> y) = CtxUpdateRight (n - 1) x ctx ::> y |
type family CheckIx (ctx :: Ctx k) (n :: Nat) (b :: Bool) :: Constraint where ... Source #
Helper type family used to generate descriptive error messages when
an index is larger than the length of the Ctx
being indexed.