extensible-0.6: Extensible, efficient, optics-friendly data types and effects

Copyright(c) Fumiaki Kinoshita 2018
LicenseBSD3
MaintainerFumiaki Kinoshita <fumiexcel@gmail.com>
Safe HaskellNone
LanguageHaskell2010

Data.Extensible.Class

Contents

Description

 
Synopsis

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.

Associated Types

type ExtensibleConstr t (xs :: [k]) (h :: k -> *) (x :: k) :: Constraint Source #

Methods

pieceAt :: ExtensibleConstr t xs h x => Membership xs x -> Optic' p f (t xs h) (h x) Source #

Instances
(Applicative f, Choice p) => Extensible f p ((:/) :: [k] -> (k -> Type) -> Type) Source # 
Instance details

Defined in Data.Extensible.Sum

Associated Types

type ExtensibleConstr (:/) xs h x :: Constraint Source #

Methods

pieceAt :: ExtensibleConstr (:/) xs h x => Membership xs x -> Optic' p f (xs :/ h) (h x) Source #

(Corepresentable p, Comonad (Corep p), Functor f) => Extensible f p ((:&) :: [k] -> (k -> Type) -> Type) Source # 
Instance details

Defined in Data.Extensible.Struct

Associated Types

type ExtensibleConstr (:&) xs h x :: Constraint Source #

Methods

pieceAt :: ExtensibleConstr (:&) xs h x => Membership xs x -> Optic' p f (xs :& h) (h x) Source #

(Functor f, Profunctor p) => Extensible f p (Inextensible :: [k] -> (k -> Type) -> Type) Source # 
Instance details

Defined in Data.Extensible.Field

Associated Types

type ExtensibleConstr Inextensible xs h x :: Constraint Source #

Methods

pieceAt :: ExtensibleConstr Inextensible xs h x => Membership xs x -> Optic' p f (Inextensible xs h) (h x) Source #

(Corepresentable p, Comonad (Corep p), Functor f) => Extensible f p (BitProd r :: [k] -> (k -> Type) -> Type) Source # 
Instance details

Defined in Data.Extensible.Bits

Associated Types

type ExtensibleConstr (BitProd r) xs h x :: Constraint Source #

Methods

pieceAt :: ExtensibleConstr (BitProd r) xs h x => Membership xs x -> Optic' p f (BitProd r xs h) (h x) Source #

piece :: (x xs, Extensible f p t, ExtensibleConstr t xs h x) => Optic' p f (t xs h) (h x) Source #

Accessor for an element.

pieceAssoc :: (Lookup xs k v, Extensible f p t, ExtensibleConstr t xs h (k :> v)) => Optic' p f (t xs h) (h (k :> v)) Source #

Like piece, but reckon membership from its key.

itemAt :: (Wrapper h, Extensible f p t, ExtensibleConstr t xs h x) => Membership xs x -> Optic' p f (t xs h) (Repr h x) Source #

Access a specified element through a wrapper.

item :: (Wrapper h, Extensible f p t, x xs, ExtensibleConstr t xs h x) => proxy x -> Optic' p f (t xs h) (Repr h x) Source #

Access an element through a wrapper.

itemAssoc :: (Wrapper h, Extensible f p t, Lookup xs k v, ExtensibleConstr t xs h (k :> v)) => proxy k -> Optic' p f (t xs h) (Repr h (k :> v)) Source #

Access an element specified by the key type through a wrapper.

itemKey :: forall k v xs h f p t. (Wrapper h, Extensible f p t, Lookup xs k v, ExtensibleConstr t xs h (k :> v)) => Optic' p f (t xs h) (Repr h (k :> v)) Source #

Access an element specified by the key type through a wrapper.

Membership

data Membership (xs :: [k]) (x :: k) :: forall k. [k] -> k -> Type #

A witness that of x is a member of a type level set xs.

Instances
Eq (Membership xs x) 
Instance details

Defined in Type.Membership.Internal

Methods

(==) :: Membership xs x -> Membership xs x -> Bool #

(/=) :: Membership xs x -> Membership xs x -> Bool #

Ord (Membership xs x) 
Instance details

Defined in Type.Membership.Internal

Methods

compare :: Membership xs x -> Membership xs x -> Ordering #

(<) :: Membership xs x -> Membership xs x -> Bool #

(<=) :: Membership xs x -> Membership xs x -> Bool #

(>) :: Membership xs x -> Membership xs x -> Bool #

(>=) :: Membership xs x -> Membership xs x -> Bool #

max :: Membership xs x -> Membership xs x -> Membership xs x #

min :: Membership xs x -> Membership xs x -> Membership xs x #

Show (Membership xs x) 
Instance details

Defined in Type.Membership.Internal

Methods

showsPrec :: Int -> Membership xs x -> ShowS #

show :: Membership xs x -> String #

showList :: [Membership xs x] -> ShowS #

Semigroup (Membership xs x) 
Instance details

Defined in Type.Membership.Internal

Methods

(<>) :: Membership xs x -> Membership xs x -> Membership xs x #

sconcat :: NonEmpty (Membership xs x) -> Membership xs x #

stimes :: Integral b => b -> Membership xs x -> Membership xs x #

Lift (Membership xs x) 
Instance details

Defined in Type.Membership.Internal

Methods

lift :: Membership xs x -> Q Exp #

Hashable (Membership xs x) 
Instance details

Defined in Type.Membership.Internal

Methods

hashWithSalt :: Int -> Membership xs x -> Int #

hash :: Membership xs x -> Int #

NFData (Membership xs x) 
Instance details

Defined in Type.Membership.Internal

Methods

rnf :: Membership xs x -> () #

Pretty (Membership xs x) 
Instance details

Defined in Type.Membership.Internal

Methods

pretty :: Membership xs x -> Doc ann #

prettyList :: [Membership xs x] -> Doc ann #

mkMembership :: Int -> Q Exp #

Generates a Membership that corresponds to the given ordinal (0-origin).

getMemberId :: Membership xs x -> Int #

get the position as an Int.

compareMembership :: Membership xs x -> Membership xs y -> Either Ordering (x :~: y) #

Compare two Memberships.

leadership :: Membership (x ': xs) x #

This Membership points to the first element

Member

class Member (xs :: [k]) (x :: k) where #

x is a member of xs

Methods

membership :: Membership xs x #

Instances
(Elaborate x (FindType x xs) ~ (Expecting pos :: Elaborated k Nat), KnownNat pos) => Member (xs :: [k]) (x :: k) 
Instance details

Defined in Type.Membership.Internal

Methods

membership :: Membership xs x #

type (∈) (x :: k) (xs :: [k]) = Member xs x #

Unicode flipped alias for Member

type family FindType (x :: k) (xs :: [k]) :: [Nat] where ... #

FindType types

Equations

FindType (x :: k) (x ': xs :: [k]) = 0 ': MapSucc (FindType x xs) 
FindType (x :: k) (y ': ys :: [k]) = MapSucc (FindType x ys) 
FindType (x :: k) ([] :: [k]) = ([] :: [Nat]) 

Generation

class Generate (xs :: [k]) where #

Every type-level list is an instance of Generate.

Methods

henumerate :: (forall (x :: k). Membership xs x -> r -> r) -> r -> r #

Enumerate all possible Memberships of xs.

hcount :: proxy xs -> Int #

Count the number of memberships.

hgenerateList :: Applicative f => (forall (x :: k). Membership xs x -> f (h x)) -> f (HList h xs) #

Enumerate Memberships and construct an HList.

Instances
Generate ([] :: [k]) 
Instance details

Defined in Type.Membership

Methods

henumerate :: (forall (x :: k0). Membership [] x -> r -> r) -> r -> r #

hcount :: proxy [] -> Int #

hgenerateList :: Applicative f => (forall (x :: k0). Membership [] x -> f (h x)) -> f (HList h []) #

Generate xs => Generate (x ': xs :: [k]) 
Instance details

Defined in Type.Membership

Methods

henumerate :: (forall (x0 :: k0). Membership (x ': xs) x0 -> r -> r) -> r -> r #

hcount :: proxy (x ': xs) -> Int #

hgenerateList :: Applicative f => (forall (x0 :: k0). Membership (x ': xs) x0 -> f (h x0)) -> f (HList h (x ': xs)) #

class (ForallF c xs, Generate xs) => Forall (c :: k -> Constraint) (xs :: [k]) where #

Every element in xs satisfies c

Methods

henumerateFor :: proxy c -> proxy' xs -> (forall (x :: k). c x => Membership xs x -> r -> r) -> r -> r #

Enumerate all possible Memberships of xs with an additional context.

hgenerateListFor :: Applicative f => proxy c -> (forall (x :: k). c x => Membership xs x -> f (h x)) -> f (HList h xs) #

Instances
Forall (c :: k -> Constraint) ([] :: [k]) 
Instance details

Defined in Type.Membership

Methods

henumerateFor :: proxy c -> proxy' [] -> (forall (x :: k0). c x => Membership [] x -> r -> r) -> r -> r #

hgenerateListFor :: Applicative f => proxy c -> (forall (x :: k0). c x => Membership [] x -> f (h x)) -> f (HList h []) #

(c x, Forall c xs) => Forall (c :: a -> Constraint) (x ': xs :: [a]) 
Instance details

Defined in Type.Membership

Methods

henumerateFor :: proxy c -> proxy' (x ': xs) -> (forall (x0 :: k). c x0 => Membership (x ': xs) x0 -> r -> r) -> r -> r #

hgenerateListFor :: Applicative f => proxy c -> (forall (x0 :: k). c x0 => Membership (x ': xs) x0 -> f (h x0)) -> f (HList h (x ': xs)) #

type family ForallF (c :: k -> Constraint) (xs :: [k]) :: Constraint where ... #

HACK: Without this, the constraints are not propagated well.

Equations

ForallF (c :: k -> Constraint) ([] :: [k]) = () 
ForallF (c :: k -> Constraint) (x ': xs :: [k]) = (c x, Forall c xs) 

Association

data Assoc k v #

The kind of key-value pairs

Constructors

k :> v infix 0 
Instances
MonadCont (Eff (ContDef r (Eff xs) ': xs)) Source # 
Instance details

Defined in Data.Extensible.Effect.Default

Methods

callCC :: ((a -> Eff (ContDef r (Eff xs) ': xs) b) -> Eff (ContDef r (Eff xs) ': xs) a) -> Eff (ContDef r (Eff xs) ': xs) a #

Wrapper h => Wrapper (Field h :: Assoc k v -> Type) Source # 
Instance details

Defined in Data.Extensible.Field

Associated Types

type Repr (Field h) v :: Type Source #

Methods

_Wrapper :: (Functor f, Profunctor p) => Optic' p f (Field h v0) (Repr (Field h) v0) Source #

wrap :: Repr (Field h) v0 -> Field h v0 Source #

unwrap :: Field h v0 -> Repr (Field h) v0 Source #

Forall (KeyTargetAre KnownSymbol (Instance1 ToJSON h)) xs => ToJSON (xs :& Nullable (Field h :: Assoc Symbol v -> Type)) Source # 
Instance details

Defined in Data.Extensible.Dictionary

Methods

toJSON :: (xs :& Nullable (Field h)) -> Value #

toEncoding :: (xs :& Nullable (Field h)) -> Encoding #

toJSONList :: [xs :& Nullable (Field h)] -> Value #

toEncodingList :: [xs :& Nullable (Field h)] -> Encoding #

Forall (KeyTargetAre KnownSymbol (Instance1 ToJSON h)) xs => ToJSON (xs :& (Field h :: Assoc Symbol v -> Type)) Source # 
Instance details

Defined in Data.Extensible.Dictionary

Methods

toJSON :: (xs :& Field h) -> Value #

toEncoding :: (xs :& Field h) -> Encoding #

toJSONList :: [xs :& Field h] -> Value #

toEncodingList :: [xs :& Field h] -> Encoding #

Forall (KeyTargetAre KnownSymbol (Instance1 FromJSON h)) xs => FromJSON (xs :& Nullable (Field h :: Assoc Symbol v -> Type)) Source # 
Instance details

Defined in Data.Extensible.Dictionary

Forall (KeyTargetAre KnownSymbol (Instance1 FromJSON h)) xs => FromJSON (xs :& (Field h :: Assoc Symbol v -> Type)) Source #

parseJSON Null is called for missing fields.

Instance details

Defined in Data.Extensible.Dictionary

Methods

parseJSON :: Value -> Parser (xs :& Field h) #

parseJSONList :: Value -> Parser [xs :& Field h] #

Forall (KeyTargetAre KnownSymbol (Instance1 FromField h)) xs => FromNamedRecord (xs :& (Field h :: Assoc Symbol v -> Type)) Source # 
Instance details

Defined in Data.Extensible.Dictionary

Forall (KeyTargetAre KnownSymbol (Instance1 ToField h)) xs => ToNamedRecord (xs :& (Field h :: Assoc Symbol v -> Type)) Source # 
Instance details

Defined in Data.Extensible.Dictionary

Methods

toNamedRecord :: (xs :& Field h) -> NamedRecord #

type Repr (Field h :: Assoc k v -> Type) (kv :: Assoc k v) Source # 
Instance details

Defined in Data.Extensible.Field

type Repr (Field h :: Assoc k v -> Type) (kv :: Assoc k v) = Repr h (TargetOf kv)

type (>:) = ((:>) :: k -> v -> Assoc k v) #

A synonym for (:>)

class Lookup (xs :: [Assoc k v]) (k1 :: k) (v1 :: v) | k1 xs -> v1 where #

Lookup xs k v is essentially identical to (k :> v) ∈ xs , but the type v is inferred from k and xs.

Methods

association :: Membership xs (k1 :> v1) #

Instances
(Elaborate k2 (FindAssoc 0 k2 xs) ~ (Expecting (n :> v2) :: Elaborated k1 (Assoc Nat v1)), KnownNat n) => Lookup (xs :: [Assoc k1 v1]) (k2 :: k1) (v2 :: v1) 
Instance details

Defined in Type.Membership.Internal

Methods

association :: Membership xs (k2 :> v2) #

type Associate k v xs = Lookup xs k v Source #

Deprecated: Use Lookup instead

Misc

type family Head (xs :: [k]) :: k where ... Source #

First element

Equations

Head (x ': xs) = x 

type family Last (x :: [k]) :: k where ... Source #

Last element

Equations

Last '[x] = x 
Last (x ': xs) = Last xs