Copyright | (c) Fumiaki Kinoshita 2018 |
---|---|
License | BSD3 |
Maintainer | Fumiaki Kinoshita <fumiexcel@gmail.com> |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- class (Functor f, Profunctor p) => Extensible f p (t :: (k -> *) -> [k] -> *) where
- type ExtensibleConstr t (h :: k -> *) (xs :: [k]) (x :: k) :: Constraint
- pieceAt :: ExtensibleConstr t h xs x => Membership xs x -> Optic' p f (t h xs) (h x)
- piece :: (x ∈ xs, Extensible f p t, ExtensibleConstr t h xs x) => Optic' p f (t h xs) (h x)
- pieceAssoc :: (Associate k v xs, Extensible f p t, ExtensibleConstr t h xs (k :> v)) => Optic' p f (t h xs) (h (k :> v))
- itemAt :: (Wrapper h, Extensible f p t, ExtensibleConstr t h xs x) => Membership xs x -> Optic' p f (t h xs) (Repr h x)
- item :: (Wrapper h, Extensible f p t, x ∈ xs, ExtensibleConstr t h xs x) => proxy x -> Optic' p f (t h xs) (Repr h x)
- itemAssoc :: (Wrapper h, Extensible f p t, Associate k v xs, ExtensibleConstr t h xs (k :> v)) => proxy k -> Optic' p f (t h xs) (Repr h (k :> v))
- data Membership (xs :: [k]) (x :: k)
- mkMembership :: Int -> Q Exp
- getMemberId :: Membership xs x -> Int
- compareMembership :: Membership xs x -> Membership xs y -> Either Ordering (x :~: y)
- leadership :: Membership (y ': xs) x -> ((x :~: y) -> r) -> (Membership xs x -> r) -> r
- class Member xs x where
- membership :: Membership xs x
- remember :: forall xs x r. Membership xs x -> (Member xs x => r) -> r
- type (∈) x xs = Member xs x
- type family FindType (x :: k) (xs :: [k]) :: [Nat] where ...
- 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 Assoc k v = k :> v
- type (>:) = (:>)
- class Associate k v xs | k xs -> v where
- association :: Membership xs (k :> v)
- type family FindAssoc (n :: Nat) (key :: k) (xs :: [Assoc k v]) where ...
- type family Elaborate (key :: k) (xs :: [v]) :: Elaborated k v where ...
- data Elaborated k v
Class
class (Functor f, Profunctor p) => Extensible f p (t :: (k -> *) -> [k] -> *) where Source #
This class allows us to use pieceAt
for both sums and products.
type ExtensibleConstr t (h :: k -> *) (xs :: [k]) (x :: k) :: Constraint Source #
pieceAt :: ExtensibleConstr t h xs x => Membership xs x -> Optic' p f (t h xs) (h x) Source #
Instances
piece :: (x ∈ xs, Extensible f p t, ExtensibleConstr t h xs x) => Optic' p f (t h xs) (h x) Source #
Accessor for an element.
pieceAssoc :: (Associate k v xs, Extensible f p t, ExtensibleConstr t h xs (k :> v)) => Optic' p f (t h xs) (h (k :> v)) Source #
Like piece
, but reckon membership from its key.
itemAt :: (Wrapper h, Extensible f p t, ExtensibleConstr t h xs x) => Membership xs x -> Optic' p f (t h xs) (Repr h x) Source #
Access a specified element through a wrapper.
item :: (Wrapper h, Extensible f p t, x ∈ xs, ExtensibleConstr t h xs x) => proxy x -> Optic' p f (t h xs) (Repr h x) Source #
Access an element through a wrapper.
itemAssoc :: (Wrapper h, Extensible f p t, Associate k v xs, ExtensibleConstr t h xs (k :> v)) => proxy k -> Optic' p f (t h xs) (Repr h (k :> v)) Source #
Access an element specified by the key type through a wrapper.
Membership
data Membership (xs :: [k]) (x :: k) Source #
The position of x
in the type level set xs
.
Instances
mkMembership :: Int -> Q Exp Source #
Generates a Membership
that corresponds to the given ordinal (0-origin).
getMemberId :: Membership xs x -> Int Source #
get the position as an Int
.
compareMembership :: Membership xs x -> Membership xs y -> Either Ordering (x :~: y) Source #
Compare two Membership
s.
leadership :: 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.
Member
class Member xs x where Source #
x
is a member of xs
membership :: Membership xs x Source #
Instances
(Elaborate x (FindType x xs) ~ (Expecting pos :: Elaborated k Nat), KnownNat pos) => Member (xs :: [k]) (x :: k) Source # | |
Defined in Data.Extensible.Internal membership :: Membership xs x Source # |
remember :: forall xs x r. Membership xs x -> (Member xs x => r) -> r Source #
Remember that Member xs x
from Membership
.
Generation
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 Data.Extensible.Class 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 Data.Extensible.Class 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 Data.Extensible.Class 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 Data.Extensible.Class 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.
Association
The kind of key-value pairs
k :> v infix 0 |
Instances
class Associate k v xs | k xs -> v where Source #
is essentially identical to Associate
k v xs(k :> v) ∈ xs
, but the type v
is inferred from k
and xs
.
association :: Membership xs (k :> v) Source #
Instances
(Elaborate k2 (FindAssoc 0 k2 xs) ~ (Expecting (n :> v2) :: Elaborated k1 (Assoc Nat v1)), KnownNat n) => Associate (k2 :: k1) (v2 :: v1) (xs :: [Assoc k1 v1]) Source # | |
Defined in Data.Extensible.Internal association :: Membership xs (k2 :> v2) Source # |
type family FindAssoc (n :: Nat) (key :: k) (xs :: [Assoc k v]) where ... Source #
Find a type associated to the specified key.
Sugar
type family Elaborate (key :: k) (xs :: [v]) :: Elaborated k v where ... Source #
Make the result more readable