Copyright | (c) 2011 Edwin Westbrook, Nicolas Frisby, and Paul Brauner |
---|---|
License | BSD3 |
Maintainer | westbrook@galois.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell98 |
A type list contains types as elements. We use GADT proofs terms to
establish membership and append relations. A Data.Type.HList.HList
f
is a vector indexed by a type list, where f :: * -> *
is applied to each
type element.
- data Nil
- data r :> a
- type family r1 :++: r2
- proxyCons :: Proxy r -> f a -> Proxy (r :> a)
- data Member ctx a where
- Member_Base :: Member (ctx :> a) a
- Member_Step :: Member ctx a -> Member (ctx :> b) a
- showsPrecMember :: Bool -> Member ctx a -> ShowS
- weakenMemberL :: Proxy r1 -> Member r2 a -> Member (r1 :++: r2) a
- membersEq :: Member ctx a -> Member ctx b -> Maybe (a :~: b)
- data Append ctx1 ctx2 ctx where
- Append_Base :: Append ctx Nil ctx
- Append_Step :: Append ctx1 ctx2 ctx -> Append ctx1 (ctx2 :> a) (ctx :> a)
- data HList f c where
- empty :: HList f Nil
- singleton :: f a -> HList f (Nil :> a)
- hlistLookup :: Member c a -> HList f c -> f a
- mapHList :: (forall x. f x -> g x) -> HList f c -> HList g c
- mapHList2 :: (forall x. f x -> g x -> h x) -> HList f c -> HList g c -> HList h c
- appendHList :: HList f c1 -> HList f c2 -> HList f (c1 :++: c2)
- mkAppend :: HList f c2 -> Append c1 c2 (c1 :++: c2)
- mkMonoAppend :: Proxy c1 -> HList f c2 -> Append c1 c2 (c1 :++: c2)
- proxiesFromAppend :: Append c1 c2 c -> HList Proxy c2
- splitHList :: (c ~ (c1 :++: c2)) => Proxy c1 -> HList any c2 -> HList f c -> (HList f c1, HList f c2)
- members :: HList f c -> HList (Member c) c
- hlistToList :: HList (Constant a) c -> [a]
- class TypeCtx ctx where
- typeCtxProxies :: HList Proxy ctx
Documentation
TypeCtx ctx => TypeCtx ((:>) ctx a) Source | |
(NuMatchingList args, NuMatching a) => NuMatchingList ((:>) args a) Source | |
type r1 :++: ((:>) r2 a) = (:>) ((:++:) r1 r2) a Source |
data Member ctx a where Source
A Member ctx a
is a "proof" that the type a
is in the type
list ctx
, meaning that ctx
equals
t0 ':>' a ':>' t1 ':>' ... ':>' tn
for some types t0,t1,...,tn
.
Member_Base :: Member (ctx :> a) a | |
Member_Step :: Member ctx a -> Member (ctx :> b) a |
showsPrecMember :: Bool -> Member ctx a -> ShowS Source
data Append ctx1 ctx2 ctx where Source
An Append ctx1 ctx2 ctx
is a "proof" that ctx = ctx1
.:++:
ctx2
Append_Base :: Append ctx Nil ctx | |
Append_Step :: Append ctx1 ctx2 ctx -> Append ctx1 (ctx2 :> a) (ctx :> a) |
A HList f c
is a vector with exactly one element of type f a
for
each type a
in the type list c
.
Show (HList Name c) | |
(NuMatching1 f, NuMatchingList ctx) => NuMatching (HList f ctx) Source |
hlistLookup :: Member c a -> HList f c -> f a Source
mapHList :: (forall x. f x -> g x) -> HList f c -> HList g c Source
Map a function on all elements of a HList
vector.
mapHList2 :: (forall x. f x -> g x -> h x) -> HList f c -> HList g c -> HList h c Source
Map a binary function on all pairs of elements of two HList
vectors.
proxiesFromAppend :: Append c1 c2 c -> HList Proxy c2 Source
splitHList :: (c ~ (c1 :++: c2)) => Proxy c1 -> HList any c2 -> HList f c -> (HList f c1, HList f c2) Source
Split an HList
vector into two pieces. The first argument is a
phantom argument that gives the form of the first list piece.
members :: HList f c -> HList (Member c) c Source
Create a vector of proofs that each type in c
is a Member
of c
.
hlistToList :: HList (Constant a) c -> [a] Source
Convert an HList to a list