Copyright | (c) Galois Inc 2015 |
---|---|
Maintainer | Joe Hendrix <jhendrix@galois.com> |
Safe Haskell | Safe |
Language | Haskell98 |
This module defines type-level lists used for representing the type of variables in a context.
- 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
.
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
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.
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.