Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data Membership (xs :: [k]) (x :: k)
- getMemberId :: Membership xs x -> Int
- mkMembership :: Int -> Q Exp
- leadership :: Membership (x ': xs) x
- nextMembership :: Membership xs y -> Membership (x ': xs) y
- testMembership :: Membership (y ': xs) x -> ((x :~: y) -> r) -> (Membership xs x -> r) -> r
- compareMembership :: Membership xs x -> Membership xs y -> Either Ordering (x :~: y)
- impossibleMembership :: Membership '[] x -> r
- reifyMembership :: Int -> (forall x. Membership xs x -> r) -> r
- class Member xs x
- data Assoc k v = k :> v
- type (>:) = '(:>)
- class Lookup xs k v | k xs -> v where
- association :: Membership xs (k :> v)
- type family KeyOf (kv :: Assoc k v) :: k where ...
- class pk (KeyOf kv) => KeyIs pk kv
- proxyKeyOf :: proxy kv -> Proxy (KeyOf kv)
- stringKeyOf :: (IsString a, KnownSymbol (KeyOf kv)) => proxy kv -> a
- type family TargetOf (kv :: Assoc k v) :: v where ...
- proxyTargetOf :: proxy kv -> Proxy (TargetOf kv)
- class pv (TargetOf kv) => TargetIs pv kv
- class (pk (KeyOf kv), pv (TargetOf kv)) => KeyTargetAre pk pv kv
- class Generate (xs :: [k]) where
- henumerate :: (forall x. Membership xs x -> r -> r) -> r -> r
- hcount :: proxy xs -> Int
- hgenerateList :: Applicative f => (forall x. Membership xs x -> f (h x)) -> f (HList h xs)
- class (ForallF c xs, Generate xs) => Forall (c :: k -> Constraint) (xs :: [k]) where
- henumerateFor :: proxy c -> proxy' xs -> (forall x. c x => Membership xs x -> r -> r) -> r -> r
- hgenerateListFor :: Applicative f => proxy c -> (forall x. c x => Membership xs x -> f (h x)) -> f (HList h xs)
- type family ForallF (c :: k -> Constraint) (xs :: [k]) :: Constraint where ...
- data Proxy (t :: k) = Proxy
Membership
data Membership (xs :: [k]) (x :: k) Source #
A witness that of x
is a member of a type level set xs
.
Instances
getMemberId :: Membership xs x -> Int Source #
get the position as an Int
.
mkMembership :: Int -> Q Exp Source #
Generates a Membership
that corresponds to the given ordinal (0-origin).
leadership :: Membership (x ': xs) x Source #
This Membership
points to the first element
nextMembership :: Membership xs y -> Membership (x ': xs) y Source #
The next membership
testMembership :: Membership (y ': xs) x -> ((x :~: y) -> r) -> (Membership xs x -> r) -> r Source #
Embodies a type equivalence to ensure that the Membership
points the first element.
compareMembership :: Membership xs x -> Membership xs y -> Either Ordering (x :~: y) Source #
Compare two Membership
s.
impossibleMembership :: Membership '[] x -> r Source #
There is no Membership
of an empty list.
reifyMembership :: Int -> (forall x. Membership xs x -> r) -> r Source #
Make up a Membership
from an integer.
x
is a member of xs
Instances
(Elaborate x (FindType x xs) ~ ('Expecting pos :: Elaborated k Nat), KnownNat pos) => Member (xs :: [k]) (x :: k) Source # | |
Defined in Type.Membership.Internal membership :: Membership xs x Source # |
Association
class Lookup xs k v | k xs -> v where Source #
is essentially identical to Lookup
xs k v(k :> v) ∈ xs
, but the type v
is inferred from k
and xs
.
association :: Membership xs (k :> v) Source #
Instances
(Elaborate k3 (FindAssoc 0 k3 xs) ~ ('Expecting (n :> v) :: Elaborated k1 (Assoc Nat k2)), KnownNat n) => Lookup (xs :: [Assoc k1 k2]) (k3 :: k1) (v :: k2) Source # | |
Defined in Type.Membership.Internal association :: Membership xs (k3 :> v) Source # |
class pk (KeyOf kv) => KeyIs pk kv Source #
Constraint applied to KeyOf
Instances
pk k2 => KeyIs (pk :: k1 -> Constraint) (k2 :> v2 :: Assoc k1 v1) Source # | |
Defined in Type.Membership |
proxyKeyOf :: proxy kv -> Proxy (KeyOf kv) Source #
stringKeyOf :: (IsString a, KnownSymbol (KeyOf kv)) => proxy kv -> a Source #
class pv (TargetOf kv) => TargetIs pv kv Source #
Constraint applied to TargetOf
Instances
pv v2 => TargetIs (pv :: v1 -> Constraint) (k2 :> v2 :: Assoc k1 v1) Source # | |
Defined in Type.Membership |
class (pk (KeyOf kv), pv (TargetOf kv)) => KeyTargetAre pk pv kv Source #
Combined constraint for Assoc
Instances
(pk k2, pv v2) => KeyTargetAre (pk :: k1 -> Constraint) (pv :: v1 -> Constraint) (k2 :> v2 :: Assoc k1 v1) Source # | |
Defined in Type.Membership |
Enumeration
class Generate (xs :: [k]) where Source #
Every type-level list is an instance of Generate
.
henumerate :: (forall x. Membership xs x -> r -> r) -> r -> r Source #
Enumerate all possible Membership
s of xs
.
hcount :: proxy xs -> Int Source #
Count the number of memberships.
hgenerateList :: Applicative f => (forall x. Membership xs x -> f (h x)) -> f (HList h xs) Source #
Enumerate Membership
s and construct an HList
.
Instances
Generate ('[] :: [k]) Source # | |
Defined in Type.Membership henumerate :: (forall (x :: k0). Membership '[] x -> r -> r) -> r -> r Source # hcount :: proxy '[] -> Int Source # hgenerateList :: Applicative f => (forall (x :: k0). Membership '[] x -> f (h x)) -> f (HList h '[]) Source # | |
Generate xs => Generate (x ': xs :: [k]) Source # | |
Defined in Type.Membership henumerate :: (forall (x0 :: k0). Membership (x ': xs) x0 -> r -> r) -> r -> r Source # hcount :: proxy (x ': xs) -> Int Source # hgenerateList :: Applicative f => (forall (x0 :: k0). Membership (x ': xs) x0 -> f (h x0)) -> f (HList h (x ': xs)) Source # |
class (ForallF c xs, Generate xs) => Forall (c :: k -> Constraint) (xs :: [k]) where Source #
Every element in xs
satisfies c
henumerateFor :: proxy c -> proxy' xs -> (forall x. c x => Membership xs x -> r -> r) -> r -> r Source #
Enumerate all possible Membership
s of xs
with an additional context.
hgenerateListFor :: Applicative f => proxy c -> (forall x. c x => Membership xs x -> f (h x)) -> f (HList h xs) Source #
Instances
Forall (c :: k -> Constraint) ('[] :: [k]) Source # | |
Defined in Type.Membership henumerateFor :: proxy c -> proxy' '[] -> (forall (x :: k0). c x => Membership '[] x -> r -> r) -> r -> r Source # hgenerateListFor :: Applicative f => proxy c -> (forall (x :: k0). c x => Membership '[] x -> f (h x)) -> f (HList h '[]) Source # | |
(c x, Forall c xs) => Forall (c :: a -> Constraint) (x ': xs :: [a]) Source # | |
Defined in Type.Membership henumerateFor :: proxy c -> proxy' (x ': xs) -> (forall (x0 :: k). c x0 => Membership (x ': xs) x0 -> r -> r) -> r -> r Source # hgenerateListFor :: Applicative f => proxy c -> (forall (x0 :: k). c x0 => Membership (x ': xs) x0 -> f (h x0)) -> f (HList h (x ': xs)) Source # |
type family ForallF (c :: k -> Constraint) (xs :: [k]) :: Constraint where ... Source #
HACK: Without this, the constraints are not propagated well.
Reexports
Proxy
is a type that holds no data, but has a phantom parameter of
arbitrary type (or even kind). Its use is to provide type information, even
though there is no value available of that type (or it may be too costly to
create one).
Historically,
is a safer alternative to the
Proxy
:: Proxy
a
idiom.undefined
:: a
>>>
Proxy :: Proxy (Void, Int -> Int)
Proxy
Proxy can even hold types of higher kinds,
>>>
Proxy :: Proxy Either
Proxy
>>>
Proxy :: Proxy Functor
Proxy
>>>
Proxy :: Proxy complicatedStructure
Proxy
Instances
Generic1 (Proxy :: k -> Type) | Since: base-4.6.0.0 |
Monad (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Functor (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Applicative (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Foldable (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Defined in Data.Foldable fold :: Monoid m => Proxy m -> m # foldMap :: Monoid m => (a -> m) -> Proxy a -> m # foldMap' :: Monoid m => (a -> m) -> Proxy a -> m # foldr :: (a -> b -> b) -> b -> Proxy a -> b # foldr' :: (a -> b -> b) -> b -> Proxy a -> b # foldl :: (b -> a -> b) -> b -> Proxy a -> b # foldl' :: (b -> a -> b) -> b -> Proxy a -> b # foldr1 :: (a -> a -> a) -> Proxy a -> a # foldl1 :: (a -> a -> a) -> Proxy a -> a # elem :: Eq a => a -> Proxy a -> Bool # maximum :: Ord a => Proxy a -> a # minimum :: Ord a => Proxy a -> a # | |
Traversable (Proxy :: Type -> Type) | Since: base-4.7.0.0 |
Alternative (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
MonadPlus (Proxy :: Type -> Type) | Since: base-4.9.0.0 |
NFData1 (Proxy :: Type -> Type) | Since: deepseq-1.4.3.0 |
Defined in Control.DeepSeq | |
Hashable1 (Proxy :: Type -> Type) | |
Defined in Data.Hashable.Class | |
Bounded (Proxy t) | Since: base-4.7.0.0 |
Enum (Proxy s) | Since: base-4.7.0.0 |
Eq (Proxy s) | Since: base-4.7.0.0 |
Ord (Proxy s) | Since: base-4.7.0.0 |
Read (Proxy t) | Since: base-4.7.0.0 |
Show (Proxy s) | Since: base-4.7.0.0 |
Ix (Proxy s) | Since: base-4.7.0.0 |
Defined in Data.Proxy | |
Generic (Proxy t) | Since: base-4.6.0.0 |
Semigroup (Proxy s) | Since: base-4.9.0.0 |
Monoid (Proxy s) | Since: base-4.7.0.0 |
NFData (Proxy a) | Since: deepseq-1.4.0.0 |
Defined in Control.DeepSeq | |
Hashable (Proxy a) | |
Defined in Data.Hashable.Class | |
type Rep1 (Proxy :: k -> Type) | |
type Rep (Proxy t) | |