HList-0.5.1.0: Heterogeneous lists
Safe HaskellNone
LanguageHaskell2010

Data.HList.Record

Description

The HList library

(C) 2004-2006, Oleg Kiselyov, Ralf Laemmel, Keean Schupke

Extensible records

The three-ish models of labels that go with this module;

These used to work:

Synopsis

labels used for doctests

>>> let x = Label :: Label "x"
>>> let y = Label :: Label "y"
>>> let z = Label :: Label "z"

Records

Labels

Record types as label-value pairs, where label is purely phantom. Thus the run-time representation of a field is the same as that of its value, and the record, at run-time, is indistinguishable from the HList of field values. At run-time, all information about the labels is erased.

The type from Data.Tagged is used.

(.=.) :: Label l -> v -> Tagged l v infixr 4 Source #

Create a value with the given label. Analagous to a data constructor such as Just, Left, or Right. Higher fixity than record-modification operations like (.*.), (.-.), etc. to support expression like the below w/o parentheses:

>>> x .=. "v1" .*. y .=. '2' .*. emptyRecord
Record{x="v1",y='2'}

Record

newtype Record (r :: [*]) Source #

Constructors

Record (HList r) 

Instances

Instances details
Relabeled Record Source # 
Instance details

Defined in Data.HList.Record

Methods

relabeled :: forall p f (s :: [Type]) (t :: [Type]) (a :: [Type]) (b :: [Type]). (HMapTaggedFn (RecordValuesR s) a, HMapTaggedFn (RecordValuesR b) t, SameLengths '[s, a, t, b], RecordValuesR t ~ RecordValuesR b, RecordValuesR s ~ RecordValuesR a, RecordValues b, RecordValues s, Profunctor p, Functor f) => p (Record a) (f (Record b)) -> p (Record s) (f (Record t)) Source #

TypeIndexed Record TIP Source # 
Instance details

Defined in Data.HList.TIC

Methods

typeIndexed :: forall p f (s :: [Type]) (t :: [Type]) (a :: [Type]) (b :: [Type]). (TypeIndexedCxt s t a b, Profunctor p, Functor f) => p (TIP (TagR a)) (f (TIP (TagR b))) -> p (Record s) (f (Record t)) Source #

(HZipRecord x y xy, SameLengths '[x, y, xy]) => HZip Record x y xy Source #
>>> let x :: Record '[Tagged "x" Int]; x = undefined
>>> let y :: Record '[Tagged "x" Char]; y = undefined
>>> :t hZip x y
hZip x y :: Record '[Tagged "x" (Int, Char)]
Instance details

Defined in Data.HList.Record

Methods

hZip :: Record x -> Record y -> Record xy Source #

(HZipRecord x y xy, SameLengths '[x, y, xy]) => HUnzip Record x y xy Source # 
Instance details

Defined in Data.HList.Record

Methods

hUnzip :: Record xy -> (Record x, Record y) Source #

HMapAux HList (HFmap f) x y => HMapAux Record f x y Source # 
Instance details

Defined in Data.HList.Record

Methods

hMapAux :: f -> Record x -> Record y Source #

H2ProjectByLabels '[Label l] v t1 v' => HDeleteAtLabel Record (l :: k) v v' Source # 
Instance details

Defined in Data.HList.Record

Methods

hDeleteAtLabel :: Label l -> Record v -> Record v' Source #

(H2ProjectByLabels (LabelsOf a) s a_ _s_minus_a, HRLabelSet a_, HRLabelSet a, HRearrange (LabelsOf a) a_ a, HLeftUnion b s bs, HRLabelSet bs, HRearrange (LabelsOf t) bs t, HRLabelSet t) => Projected Record s t a b Source #
Lens rs rt ra rb

where rs ~ Record s, rt ~ Record t, ra ~ Record a, rb ~ Record b

Instance details

Defined in Data.HList.Labelable

Methods

projected :: forall (ty :: LabeledOpticType) p f. (ty ~ LabelableTy Record, LabeledOpticP ty p, LabeledOpticF ty f) => p (Record a) (f (Record b)) -> p (Record s) (f (Record t)) Source #

(HUpdateAtLabel2 l v r r', HasField l (Record r') v) => HUpdateAtLabel Record (l :: k) v r r' Source # 
Instance details

Defined in Data.HList.Record

Methods

hUpdateAtLabel :: Label l -> v -> Record r -> Record r' Source #

HLens x Record s t a b => Labelable (x :: k) Record s t a b Source #

make a Lens (Record s) (Record t) a b

Instance details

Defined in Data.HList.Labelable

Associated Types

type LabelableTy Record :: LabeledOpticType Source #

Methods

hLens' :: Label x -> LabeledOptic x Record s t a b Source #

(t ~ (Any :: Type), Fail (FieldNotFound l ())) => HasField (l :: k) (Record ('[] :: [Type])) t Source #

XXX

Instance details

Defined in Data.HList.Record

Methods

hLookupByLabel :: Label l -> Record '[] -> t Source #

(HEqK l l1 b, HasField' b l (Tagged l1 v1 ': r) v) => HasField (l :: k1) (Record (Tagged l1 v1 ': r)) v Source # 
Instance details

Defined in Data.HList.Record

Methods

hLookupByLabel :: Label l -> Record (Tagged l1 v1 ': r) -> v Source #

HRLabelSet (t ': r) => HExtend t (Record r) Source # 
Instance details

Defined in Data.HList.Record

Associated Types

type HExtendR t (Record r) Source #

Methods

(.*.) :: t -> Record r -> HExtendR t (Record r) Source #

(HReverse l lRev, HMapTaggedFn lRev l') => HBuild' l (Record l') Source #

This instance allows creating a Record with

hBuild 3 a :: Record '[Tagged "x" Int, Tagged "y" Char]
Instance details

Defined in Data.HList.Record

Methods

hBuild' :: HList l -> Record l' Source #

(HLeftUnion lv x lvx, HRLabelSet x, HLabelSet (LabelsOf x), HRearrange (LabelsOf x) lvx x) => HUpdateMany lv (Record x) Source #

implementation in terms of .<++.

Instance details

Defined in Data.HList.RecordU

Methods

hUpdateMany :: Record lv -> Record x -> Record x Source #

(HasField l (Record r) u, HasFieldPath needJust ls u v) => HasFieldPath needJust (Label l ': ls) (Record r) v Source # 
Instance details

Defined in Data.HList.Dredge

Methods

hLookupByLabelPath1 :: Proxy needJust -> Label (Label l ': ls) -> Record r -> v Source #

Bounded (HList r) => Bounded (Record r) Source # 
Instance details

Defined in Data.HList.Record

Methods

minBound :: Record r #

maxBound :: Record r #

Eq (HList r) => Eq (Record r) Source # 
Instance details

Defined in Data.HList.Record

Methods

(==) :: Record r -> Record r -> Bool #

(/=) :: Record r -> Record r -> Bool #

DataRecordCxt a => Data (Record a) Source # 
Instance details

Defined in Data.HList.Data

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Record a -> c (Record a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Record a) #

toConstr :: Record a -> Constr #

dataTypeOf :: Record a -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Record a)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Record a)) #

gmapT :: (forall b. Data b => b -> b) -> Record a -> Record a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Record a -> r #

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Record a -> r #

gmapQ :: (forall d. Data d => d -> u) -> Record a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Record a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Record a -> m (Record a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Record a -> m (Record a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Record a -> m (Record a) #

Ord (HList r) => Ord (Record r) Source # 
Instance details

Defined in Data.HList.Record

Methods

compare :: Record r -> Record r -> Ordering #

(<) :: Record r -> Record r -> Bool #

(<=) :: Record r -> Record r -> Bool #

(>) :: Record r -> Record r -> Bool #

(>=) :: Record r -> Record r -> Bool #

max :: Record r -> Record r -> Record r #

min :: Record r -> Record r -> Record r #

(HMapCxt HList ReadComponent (AddProxy rs) bs, ApplyAB ReadComponent (Proxy r) readP_r, HProxies rs, HSequence ReadP (readP_r ': bs) (r ': rs), r ~ Tagged l v, ShowLabel l, Read v, HSequence ReadP bs rs) => Read (Record (r ': rs)) Source # 
Instance details

Defined in Data.HList.Record

Methods

readsPrec :: Int -> ReadS (Record (r ': rs)) #

readList :: ReadS [Record (r ': rs)] #

readPrec :: ReadPrec (Record (r ': rs)) #

readListPrec :: ReadPrec [Record (r ': rs)] #

ShowComponents r => Show (Record r) Source # 
Instance details

Defined in Data.HList.Record

Methods

showsPrec :: Int -> Record r -> ShowS #

show :: Record r -> String #

showList :: [Record r] -> ShowS #

Ix (HList r) => Ix (Record r) Source # 
Instance details

Defined in Data.HList.Record

Methods

range :: (Record r, Record r) -> [Record r] #

index :: (Record r, Record r) -> Record r -> Int #

unsafeIndex :: (Record r, Record r) -> Record r -> Int #

inRange :: (Record r, Record r) -> Record r -> Bool #

rangeSize :: (Record r, Record r) -> Int #

unsafeRangeSize :: (Record r, Record r) -> Int #

Semigroup (HList r) => Semigroup (Record r) Source # 
Instance details

Defined in Data.HList.Record

Methods

(<>) :: Record r -> Record r -> Record r #

sconcat :: NonEmpty (Record r) -> Record r #

stimes :: Integral b => b -> Record r -> Record r #

Monoid (HList r) => Monoid (Record r) Source # 
Instance details

Defined in Data.HList.Record

Methods

mempty :: Record r #

mappend :: Record r -> Record r -> Record r #

mconcat :: [Record r] -> Record r #

TypeRepsList (HList xs) => TypeRepsList (Record xs) Source # 
Instance details

Defined in Data.HList.Data

Methods

typeRepsList :: Record xs -> [TypeRep] Source #

(la ~ LabelsOf a, lt ~ LabelsOf t, HRearrange la s a, HRearrange lt b t, HLabelSet la, HLabelSet lt) => Rearranged Record (s :: [Type]) (t :: [Type]) (a :: [Type]) (b :: [Type]) Source #
Iso (Record s) (Record t) (Record a) (Record b)

where s is a permutation of a, b is a permutation of t. In practice sameLabels and sameLength are likely needed on both sides of rearranged, to avoid ambiguous types.

An alternative implementation:

rearranged x = iso hRearrange' hRearrange' x
Instance details

Defined in Data.HList.Record

Methods

rearranged :: (Profunctor p, Functor f) => p (Record a) (f (Record b)) -> p (Record s) (f (Record t)) Source #

(HRLabelSet (HAppendListR r1 r2), HAppend (HList r1) (HList r2)) => HAppend (Record r1) (Record r2) Source #
(.*.)
Add a field to a record. Analagous to (++) for lists.
record .*. field1
       .*. field2
Instance details

Defined in Data.HList.Record

Methods

hAppend :: Record r1 -> Record r2 -> HAppendR (Record r1) (Record r2) Source #

H2ProjectByLabels (LabelsOf r2) r1 r2 rout => SubType (Record r1 :: Type) (Record r2 :: Type) Source #

Subtyping for records

Instance details

Defined in Data.HList.Record

type LabelableTy Record Source # 
Instance details

Defined in Data.HList.Labelable

type HExtendR t (Record r) Source # 
Instance details

Defined in Data.HList.Record

type HExtendR t (Record r) = Record (t ': r)
type HAppendR (Record r1 :: Type) (Record r2 :: Type) Source # 
Instance details

Defined in Data.HList.Record

type HAppendR (Record r1 :: Type) (Record r2 :: Type) = Record (HAppendListR r1 r2)

mkRecord :: HRLabelSet r => HList r -> Record r Source #

Build a record

emptyRecord :: Record '[] Source #

Build an empty record

hEndR :: Record a -> Record a Source #

serves the same purpose as hEnd

hEndP :: Proxy (xs :: [k]) -> Proxy xs Source #

hEndP $ hBuild label1 label2

is one way to make a Proxy of labels (for use with asLabelsOf for example). Another way is

label1 .*. label2 .*. emptyProxy

hListRecord :: forall p f (r1 :: [Type]) (r2 :: [Type]). (Profunctor p, Functor f, HLabelSet (LabelsOf r1), HAllTaggedLV r1) => p (Record r1) (f (Record r2)) -> p (HList r1) (f (HList r2)) Source #

HRLabelSet t => Iso (HList s) (HList t) (Record s) (Record t)

hListRecord' :: forall p f (r :: [Type]). (Profunctor p, Functor f, HLabelSet (LabelsOf r), HAllTaggedLV r) => p (Record r) (f (Record r)) -> p (HList r) (f (HList r)) Source #

Iso' (HList s) (Record s)

Getting Labels

type family LabelsOf (ls :: [*]) :: [*] Source #

Construct the (phantom) list of labels of a record, or list of Label.

Instances

Instances details
type LabelsOf ('[] :: [Type]) Source # 
Instance details

Defined in Data.HList.Record

type LabelsOf ('[] :: [Type]) = '[] :: [Type]
type LabelsOf (Tagged l v ': r) Source # 
Instance details

Defined in Data.HList.Record

type LabelsOf (Tagged l v ': r) = Label l ': LabelsOf r
type LabelsOf (Label l ': r) Source # 
Instance details

Defined in Data.HList.Record

type LabelsOf (Label l ': r) = Label l ': LabelsOf r

labelsOf :: hlistOrRecord l -> Proxy (LabelsOf l) Source #

asLabelsOf :: (HAllTaggedLV x, SameLabels x y, SameLength x y) => r x -> s y -> r x Source #

similar to asTypeOf:

>>> let s0 = Proxy :: Proxy '["x", "y"]
>>> let s1 = Proxy :: Proxy '[Label "x", Label "y"]
>>> let s2 = Proxy :: Proxy '[Tagged "x" Int, Tagged "y" Char]
>>> let f0 r = () where _ = r `asLabelsOf` s0
>>> let f1 r = () where _ = r `asLabelsOf` s1
>>> let f2 r = () where _ = r `asLabelsOf` s2
>>> :t f0
f0 :: r '[Tagged "x" v, Tagged "y" v1] -> ()
>>> :t f1
f1 :: r '[Tagged "x" v, Tagged "y" v1] -> ()
>>> :t f2
f2 :: r '[Tagged "x" v, Tagged "y" v1] -> ()

Getting Values

class SameLength r (RecordValuesR r) => RecordValues (r :: [*]) where Source #

Construct the HList of values of the record.

Associated Types

type RecordValuesR r :: [*] Source #

Instances

Instances details
RecordValues ('[] :: [Type]) Source # 
Instance details

Defined in Data.HList.Record

Associated Types

type RecordValuesR '[] :: [Type] Source #

(SameLength' r (RecordValuesR r), SameLength' (RecordValuesR r) r, RecordValues r) => RecordValues (Tagged l v ': r) Source # 
Instance details

Defined in Data.HList.Record

Associated Types

type RecordValuesR (Tagged l v ': r) :: [Type] Source #

Methods

recordValues' :: HList (Tagged l v ': r) -> HList (RecordValuesR (Tagged l v ': r)) Source #

unlabeled0 :: forall f p (x :: [Type]) (y :: [Type]). (Functor f, Profunctor p, SameLabels x y, HMapAux HList TaggedFn (RecordValuesR y) y, RecordValues x, RecordValues y) => p (HList (RecordValuesR x)) (f (HList (RecordValuesR y))) -> p (Record x) (f (Record y)) Source #

Iso (Record s) (Record t) (HList a) (HList b)
view unlabeled == recordValues

unlabeled :: (Unlabeled x y, Profunctor p, Functor f) => (HList (RecordValuesR x) `p` f (HList (RecordValuesR y))) -> Record x `p` f (Record y) Source #

unlabeled' :: (Unlabeled' x, Profunctor p, Functor f) => (HList (RecordValuesR x) `p` f (HList (RecordValuesR x))) -> Record x `p` f (Record x) Source #

Unlabeled' x => Iso' (Record x) (HList (RecordValuesR x))

Operations

Show

A corresponding Show instance exists as

show x = "Record {" ++ showComponents "" x ++ "}"

class ShowComponents l where Source #

Instances

Instances details
ShowComponents ('[] :: [Type]) Source # 
Instance details

Defined in Data.HList.Record

(ShowLabel l, Show v, ShowComponents r) => ShowComponents (Tagged l v ': r) Source # 
Instance details

Defined in Data.HList.Record

Methods

showComponents :: String -> HList (Tagged l v ': r) -> String Source #

class ShowLabel l where Source #

Methods

showLabel :: Label l -> String Source #

Instances

Instances details
KnownNat x => ShowLabel (x :: Nat) Source # 
Instance details

Defined in Data.HList.Label6

Methods

showLabel :: Label x -> String Source #

KnownSymbol x => ShowLabel (x :: Symbol) Source # 
Instance details

Defined in Data.HList.Label6

Methods

showLabel :: Label x -> String Source #

Typeable x => ShowLabel (x :: Type) Source #

Equality on labels

Show label

Instance details

Defined in Data.HList.Label5

Methods

showLabel :: Label x -> String Source #

Show desc => ShowLabel (Lbl x ns desc :: Type) Source #

Equality on labels (descriptions are ignored) Use generic instance

Show label

Instance details

Defined in Data.HList.Label3

Methods

showLabel :: Label (Lbl x ns desc) -> String Source #

Extension

hExtend, hAppend

(.*.) :: HExtend e l => e -> l -> HExtendR e l infixr 2 Source #

Delete

hDeleteAtLabel label record

(.-.) :: HDeleteAtLabel r l xs xs' => r xs -> Label l -> r xs' infixl 2 Source #

Remove a field from a record. At the same level as other record modification options (.*.). Analagous to (\\) in lists.

record1 .-. label1
label1 .=. value1 .*.
label2 .=. value2 .-.
label2 .*.
emptyRecord
label1 .=. value1 .-.
label1 .*.
label2 .=. value2 .*.
emptyRecord
record1 .*. label1 .=. record2 .!. label1
        .*. label2 .=. record2 .!. label2
        .-. label1

class HDeleteLabels ks r r' | ks r -> r' where Source #

Methods

hDeleteLabels Source #

Arguments

:: proxy (ks :: [*])

as provided by labelsOf

-> Record r 
-> Record r' 

Instances

Instances details
HDeleteLabels ks ('[] :: [Type]) ('[] :: [Type]) Source # 
Instance details

Defined in Data.HList.Record

Methods

hDeleteLabels :: proxy ks -> Record '[] -> Record '[] Source #

(HMember (Label l) ks b, HCond b (Record r2) (Record (Tagged l v ': r2)) (Record r3), HDeleteLabels ks r1 r2) => HDeleteLabels ks (Tagged l v ': r1) r3 Source # 
Instance details

Defined in Data.HList.Record

Methods

hDeleteLabels :: proxy ks -> Record (Tagged l v ': r1) -> Record r3 Source #

Lookup/update

Lens-based setters/getters are popular. hLens packages up hUpdateAtLabel and hLookupByLabel.

Refer to examples/lens.hs and examples/labelable.hs for examples.

class HLensCxt x r s t a b => HLens x r s t a b | x s b -> t, x t a -> s, x s -> a, x t -> b where Source #

Methods

hLens :: Label x -> forall f. Functor f => (a -> f b) -> r s -> f (r t) Source #

hLens :: Label x -> Lens (r s) (r t) a b

Instances

Instances details
HLensCxt r x s t a b => HLens (r :: k) x s t a b Source # 
Instance details

Defined in Data.HList.Record

Methods

hLens :: Label r -> forall (f :: Type -> Type). Functor f => (a -> f b) -> x s -> f (x t) Source #

Lookup

class HasField (l :: k) r v | l r -> v where Source #

This is a baseline implementation. We use a helper class, HasField, to abstract from the implementation.

Because hLookupByLabel is so frequent and important, we implement it separately, more efficiently. The algorithm is familiar assq, only the comparison operation is done at compile-time

Methods

hLookupByLabel :: Label l -> r -> v Source #

Instances

Instances details
(t ~ (Any :: Type), Fail (FieldNotFound l ())) => HasField (l :: k) (Record ('[] :: [Type])) t Source #

XXX

Instance details

Defined in Data.HList.Record

Methods

hLookupByLabel :: Label l -> Record '[] -> t Source #

(HEqK l l1 b, HasField' b l (Tagged l1 v1 ': r) v) => HasField (l :: k1) (Record (Tagged l1 v1 ': r)) v Source # 
Instance details

Defined in Data.HList.Record

Methods

hLookupByLabel :: Label l -> Record (Tagged l1 v1 ': r) -> v Source #

(IArray UArray v, v ~ GetElemTy ls, HFindLabel l ls n, HNat2Integral n) => HasField (l :: k) (RecordU ls) v Source # 
Instance details

Defined in Data.HList.RecordU

Methods

hLookupByLabel :: Label l -> RecordU ls -> v Source #

(HFindLabel l r n, HLookupByHNatUS n u (Tagged l v), HasField l (Record r) v, RecordUSCxt r u) => HasField (l :: k) (RecordUS r) v Source #

works expected. See examples attached to bad.

Instance details

Defined in Data.HList.RecordU

Methods

hLookupByLabel :: Label l -> RecordUS r -> v Source #

(HasField x (Record vs) a, HFindLabel x vs n, HNat2Integral n) => HasField (x :: k) (Variant vs) (Maybe a) Source # 
Instance details

Defined in Data.HList.Variant

Methods

hLookupByLabel :: Label x -> Variant vs -> Maybe a Source #

(e ~ e', HasField e (Record l) e') => HasField (e :: Type) (TIP l) e' Source # 
Instance details

Defined in Data.HList.TIP

Methods

hLookupByLabel :: Label e -> TIP l -> e' Source #

HasField o (Variant l) (Maybe o) => HasField (o :: Type) (TIC l) (Maybe o) Source #

Public destructor (or, open union's projection function)

Instance details

Defined in Data.HList.TIC

Methods

hLookupByLabel :: Label o -> TIC l -> Maybe o Source #

class HasFieldM (l :: k) r (v :: Maybe *) | l r -> v where Source #

a version of HasField hLookupByLabel .!. that returns a default value when the label is not in the record:

>>> let r = x .=. "the x value" .*. emptyRecord
>>> hLookupByLabelM y r ()
()
>>> hLookupByLabelM x r ()
"the x value"

Methods

hLookupByLabelM Source #

Arguments

:: Label l 
-> r

Record (or Variant,TIP,TIC)

-> t

default value

-> DemoteMaybe t v 

Instances

Instances details
(HMemberM (Label l) (LabelsOf xs) b, HasFieldM1 b l (r xs) v) => HasFieldM (l :: k) (r xs) v Source # 
Instance details

Defined in Data.HList.Record

Methods

hLookupByLabelM :: Label l -> r xs -> t -> DemoteMaybe t v Source #

(.!.) :: HasField l r v => r -> Label l -> v infixr 9 Source #

Lookup a value in a record by its label. Analagous to (!!), the list indexing operation. Highest fixity, like (!!).

>>> :{
let record1 = x .=. 3 .*.
              y .=. 'y' .*.
              emptyRecord
:}
>>> record1 .!. x
3
>>> record1 .!. y
'y'
>>> :{
let r2 = y .=. record1 .!. x .*.
         z .=. record1 .!. y .*.
         emptyRecord
:}
>>> r2
Record{y=3,z='y'}

Note that labels made following Data.HList.Labelable allow using "Control.Lens.^." instead.

Update

(.@.) :: forall k record (l :: k) v (r :: [Type]) (r' :: [Type]). (HUpdateAtLabel record l v r r', SameLength' r r', SameLength' r' r) => Tagged l v -> record r -> record r' infixr 2 Source #

Update a field with a particular value. Same fixity as (.*.) so that extensions and updates can be chained. There is no real list analogue, since there is no Prelude defined update.

label1 .=. value1 .@. record1

class HUpdateAtLabel record (l :: k) (v :: *) (r :: [*]) (r' :: [*]) | l v r -> r', l r' -> v where Source #

hUpdateAtLabel label value record

Methods

hUpdateAtLabel :: SameLength r r' => Label l -> v -> record r -> record r' Source #

Instances

Instances details
(HUpdateAtLabel2 l v r r', HasField l (Record r') v) => HUpdateAtLabel Record (l :: k) v r r' Source # 
Instance details

Defined in Data.HList.Record

Methods

hUpdateAtLabel :: Label l -> v -> Record r -> Record r' Source #

HUpdateVariantAtLabelCxt l e v v' n _e => HUpdateAtLabel Variant (l :: k) e v v' Source #
hUpdateAtLabel x e' (mkVariant x e proxy) == mkVariant x e' proxy
hUpdateAtLabel y e' (mkVariant x e proxy) == mkVariant x e  proxy
Instance details

Defined in Data.HList.Variant

Methods

hUpdateAtLabel :: Label l -> e -> Variant v -> Variant v' Source #

(r ~ r', v ~ GetElemTy r, HFindLabel l r n, HNat2Integral n, IArray UArray v, HasField l (Record r') v) => HUpdateAtLabel RecordU (l :: k) v r r' Source # 
Instance details

Defined in Data.HList.RecordU

Methods

hUpdateAtLabel :: Label l -> v -> RecordU r -> RecordU r' Source #

(HUpdateAtLabel Record e' e r r', HTypeIndexed r', e ~ e') => HUpdateAtLabel TIP (e' :: Type) e r r' Source # 
Instance details

Defined in Data.HList.TIP

Methods

hUpdateAtLabel :: Label e' -> e -> TIP r -> TIP r' Source #

type-preserving versions

Note: these restrict the resulting record type to be the same as in input record type, which can help reduce the number of type annotations needed

(.<.) :: forall k record (l :: k) v (r :: [Type]). (HUpdateAtLabel record l v r r, SameLength' r r) => Tagged l v -> record r -> record r infixr 2 Source #

The same as .@., except type preserving. It has the same fixity as (.@.).

type HTPupdateAtLabel record l v r = (HUpdateAtLabel record l v r r, SameLength' r r) Source #

hTPupdateAtLabel :: HTPupdateAtLabel record l v r => Label l -> v -> record r -> record r Source #

We could also say:

hTPupdateAtLabel l v r = hUpdateAtLabel l v r `asTypeOf` r

Then we were taking a dependency on Haskell's type equivalence. This would also constrain the actual implementation of hUpdateAtLabel.

A variation on hUpdateAtLabel: type-preserving update.

Rename Label

hRenameLabel :: forall k1 k2 r (l1 :: k1) (v1 :: [Type]) (v' :: [Type]) v2 (l2 :: k2). (HDeleteAtLabel r l1 v1 v', HasField l1 (r v1) v2, HExtend (Tagged l2 v2) (r v')) => Label l1 -> Label l2 -> r v1 -> HExtendR (Tagged l2 v2) (r v') Source #

Rename the label of record

>>> hRenameLabel x y (x .=. () .*. emptyRecord)
Record{y=()}

Projection

type family Labels (xs :: [k]) :: * Source #

A helper to make the Proxy needed by hProjectByLabels, and similar functions which accept a list of kind [*].

For example:

(rin,rout) = hProjectByLabels2 (Proxy :: Labels ["x","y"]) r

behaves like

rin = r .!. (Label :: Label "x") .*.
      r .!. (Label :: Label "y") .*.
      emptyRecord

rout = r .-. (Label :: Label "x") .-. (Label :: Label "y")

Instances

Instances details
type Labels (xs :: [k]) Source # 
Instance details

Defined in Data.HList.Record

type Labels (xs :: [k])

It is also an important operation: the basis of many deconstructors -- so we try to implement it efficiently.

hProjectByLabels :: (HRLabelSet a, H2ProjectByLabels ls t a b) => proxy ls -> Record t -> Record a Source #

hProjectByLabels ls r returns r with only the labels in ls remaining

hProjectByLabels' :: forall (l :: [Type]) (r :: [Type]) (t :: [Type]) (b :: [Type]). (HRearrange3 (LabelsOf l) r l, SameLength' (LabelsOf l) r, SameLength' r (LabelsOf l), SameLength' r l, SameLength' l r, HLabelSet (LabelsOf l), HLabelSet (LabelsOf r), HAllTaggedLV r, H2ProjectByLabels (LabelsOf l) t r b) => Record t -> Record l Source #

a lens for projection

see Data.HList.Labelable.Projected

Unions

Left

class HLeftUnion r r' r'' | r r' -> r'' where Source #

Methods

hLeftUnion :: Record r -> Record r' -> Record r'' Source #

Instances

Instances details
(HDeleteLabels (LabelsOf l) r r', HAppend (Record l) (Record r'), HAppendR (Record l) (Record r') ~ Record lr) => HLeftUnion l r lr Source # 
Instance details

Defined in Data.HList.Record

Methods

hLeftUnion :: Record l -> Record r -> Record lr Source #

(.<++.) :: HLeftUnion r r' r'' => Record r -> Record r' -> Record r'' infixl 1 Source #

Similar to list append, so give this slightly lower fixity than (.*.), so we can write:

field1 .=. value .*. record1 .<++. record2

Symmetric

Compute the symmetric union of two records r1 and r2 and return the pair of records injected into the union (ru1, ru2).

To be more precise, we compute the symmetric union type ru of two record types r1 and r2. The emphasis on types is important.

The two records (ru1,ru2) in the result of unionSR have the same type ru, but they are generally different values. Here the simple example: suppose

 r1 = (Label .=. True)  .*. emptyRecord
 r2 = (Label .=. False) .*. emptyRecord

Then unionSR r1 r2 will return (r1,r2). Both components of the result are different records of the same type.

To project from the union ru, use hProjectByLabels. It is possible to project from the union obtaining a record that was not used at all when creating the union.

We do assure however that if unionSR r1 r2 gave (r1u,r2u), then projecting r1u onto the type of r1 gives the value identical to r1. Ditto for r2.

class UnionSymRec r1 r2 ru | r1 r2 -> ru where Source #

Methods

unionSR :: Record r1 -> Record r2 -> (Record ru, Record ru) Source #

Instances

Instances details
r1 ~ r1' => UnionSymRec r1 ('[] :: [Type]) r1' Source # 
Instance details

Defined in Data.HList.Record

Methods

unionSR :: Record r1 -> Record '[] -> (Record r1', Record r1') Source #

(HMemberLabel l r1 b, UnionSymRec' b r1 (Tagged l v) r2' ru) => UnionSymRec r1 (Tagged l v ': r2') ru Source # 
Instance details

Defined in Data.HList.Record

Methods

unionSR :: Record r1 -> Record (Tagged l v ': r2') -> (Record ru, Record ru) Source #

Reorder Labels

hRearrange :: (HLabelSet ls, HRearrange ls r r') => Proxy ls -> Record r -> Record r' Source #

Rearranges a record by labels. Returns the record r, rearranged such that the labels are in the order given by ls. (LabelsOf r) must be a permutation of ls.

hRearrange' :: forall (l :: [Type]) (r :: [Type]). (HLabelSet (LabelsOf l), HRearrange3 (LabelsOf l) r l, SameLength' (LabelsOf l) r, SameLength' r (LabelsOf l), SameLength' r l, SameLength' l r) => Record r -> Record l Source #

hRearrange' is hRearrange where ordering specified by the Proxy argument is determined by the result type.

With built-in haskell records, these e1 and e2 have the same type:

data R = R { x, y :: Int }
e1 = R{ x = 1, y = 2}
e2 = R{ y = 2, x = 1}

hRearrange' can be used to allow either ordering to be accepted:

h1, h2 :: Record [ Tagged "x" Int, Tagged "y" Int ]
h1 = hRearrange' $
    x .=. 1 .*.
    y .=. 2 .*.
    emptyRecord

h2 = hRearrange' $
    y .=. 2 .*.
    x .=. 1 .*.
    emptyRecord

isos using hRearrange

class Rearranged r s t a b where Source #

Methods

rearranged :: (Profunctor p, Functor f) => (r a `p` f (r b)) -> r s `p` f (r t) Source #

Instances

Instances details
(la ~ LabelsOf a, lt ~ LabelsOf t, HRearrange la s a, HRearrange lt b t, HLabelSet la, HLabelSet lt) => Rearranged Record (s :: [Type]) (t :: [Type]) (a :: [Type]) (b :: [Type]) Source #
Iso (Record s) (Record t) (Record a) (Record b)

where s is a permutation of a, b is a permutation of t. In practice sameLabels and sameLength are likely needed on both sides of rearranged, to avoid ambiguous types.

An alternative implementation:

rearranged x = iso hRearrange' hRearrange' x
Instance details

Defined in Data.HList.Record

Methods

rearranged :: (Profunctor p, Functor f) => p (Record a) (f (Record b)) -> p (Record s) (f (Record t)) Source #

(SameLength s a, ExtendsVariant s a, SameLength b t, ExtendsVariant b t) => Rearranged Variant (s :: [Type]) (t :: [Type]) (a :: [Type]) (b :: [Type]) Source # 
Instance details

Defined in Data.HList.Variant

Methods

rearranged :: (Profunctor p, Functor f) => p (Variant a) (f (Variant b)) -> p (Variant s) (f (Variant t)) Source #

rearranged' :: forall k r (t :: k) (b :: k) p f. (Rearranged r t t b b, Profunctor p, Functor f) => p (r b) (f (r b)) -> p (r t) (f (r t)) Source #

Iso' (r s) (r a)

where s is a permutation of a

Apply a function to all values

hMapR :: forall (x :: [Type]) (y :: [Type]) f. (SameLength' x y, SameLength' y x, HMapAux HList (HFmap f) x y) => f -> Record x -> Record y Source #

map over the values of a record. This is a shortcut for

\ f (Record a) -> Record (hMap (HFmap f) a)
Example

suppose we have a function that should be applied to every element of a record:

>>> let circSucc_ x | x == maxBound = minBound | otherwise = succ x
>>> :t circSucc_
circSucc_ :: (Bounded a, Enum a, Eq a) => a -> a

Use a shortcut (Fun) to create a value that has an appropriate ApplyAB instance:

>>> let circSucc = Fun circSucc_ :: Fun '[Eq,Enum,Bounded] '()

Confirm that we got Fun right:

>>> :t applyAB circSucc
applyAB circSucc :: (Bounded b, Enum b, Eq b) => b -> b
>>> applyAB circSucc True
False

define the actual record:

>>> let r = x .=. 'a' .*. y .=. False .*. emptyRecord
>>> r
Record{x='a',y=False}
>>> hMapR circSucc r
Record{x='b',y=True}

newtype HMapR f Source #

Constructors

HMapR f 

Instances

Instances details
(HMapCxt Record f x y, rx ~ Record x, ry ~ Record y) => ApplyAB (HMapR f) rx ry Source # 
Instance details

Defined in Data.HList.Record

Methods

applyAB :: HMapR f -> rx -> ry Source #

cast labels

class Relabeled r where Source #

Iso (Record s) (Record t) (Record a) (Record b), such that relabeled = unlabeled . from unlabeled

in other words, pretend a record has different labels, but the same values.

Methods

relabeled :: forall p f s t a b. (HMapTaggedFn (RecordValuesR s) a, HMapTaggedFn (RecordValuesR b) t, SameLengths '[s, a, t, b], RecordValuesR t ~ RecordValuesR b, RecordValuesR s ~ RecordValuesR a, RecordValues b, RecordValues s, Profunctor p, Functor f) => (r a `p` f (r b)) -> r s `p` f (r t) Source #

Instances

Instances details
Relabeled Record Source # 
Instance details

Defined in Data.HList.Record

Methods

relabeled :: forall p f (s :: [Type]) (t :: [Type]) (a :: [Type]) (b :: [Type]). (HMapTaggedFn (RecordValuesR s) a, HMapTaggedFn (RecordValuesR b) t, SameLengths '[s, a, t, b], RecordValuesR t ~ RecordValuesR b, RecordValuesR s ~ RecordValuesR a, RecordValues b, RecordValues s, Profunctor p, Functor f) => p (Record a) (f (Record b)) -> p (Record s) (f (Record t)) Source #

Relabeled Variant Source # 
Instance details

Defined in Data.HList.Variant

Methods

relabeled :: forall p f (s :: [Type]) (t :: [Type]) (a :: [Type]) (b :: [Type]). (HMapTaggedFn (RecordValuesR s) a, HMapTaggedFn (RecordValuesR b) t, SameLengths '[s, a, t, b], RecordValuesR t ~ RecordValuesR b, RecordValuesR s ~ RecordValuesR a, RecordValues b, RecordValues s, Profunctor p, Functor f) => p (Variant a) (f (Variant b)) -> p (Variant s) (f (Variant t)) Source #

relabeled' :: forall r (t :: [Type]) (b :: [Type]) p f. (Relabeled r, HMapAux HList TaggedFn (RecordValuesR t) b, HMapAux HList TaggedFn (RecordValuesR b) t, RecordValues b, RecordValues t, SameLength' (RecordValuesR t) b, SameLength' (RecordValuesR b) t, SameLength' t (RecordValuesR b), SameLength' t b, SameLength' b (RecordValuesR t), SameLength' b t, Profunctor p, Functor f, RecordValuesR t ~ RecordValuesR b) => p (r b) (f (r b)) -> p (r t) (f (r t)) Source #

Iso' (Record s) (Record a)

such that RecordValuesR s ~ RecordValuesR a

Hints for type errors

data DuplicatedLabel l Source #

Property of a proper label set for a record: no duplication of labels, and every element of the list is Tagged label value

type ExtraField x = ErrText "extra field" :<>: ErrShowType x Source #

type FieldNotFound key collection = (ErrText "key" :<>: ErrShowType key) :$$: (ErrText "could not be found in" :<>: ErrShowType collection) Source #

Unclassified

Probably internals, that may not be useful

zipTagged :: (MapLabel ts ~ lts, HZip Proxy lts vs tvs) => Proxy ts -> proxy vs -> Proxy tvs Source #

Missing from ghc-7.6, because HZip Proxy instances interfere with HZip HList instances.

a variation on hZip for Proxy, where the list of labels does not have to include Label (as in ts')

>>> let ts = Proxy :: Proxy ["x","y"]
>>> let ts' = Proxy :: Proxy [Label "x",Label "y"]
>>> let vs = Proxy :: Proxy [Int,Char]
>>> :t zipTagged ts Proxy
zipTagged ts Proxy :: Proxy '[Tagged "x" y, Tagged "y" y1]
>>> :t zipTagged ts vs
zipTagged ts vs :: Proxy '[Tagged "x" Int, Tagged "y" Char]

And and the case when hZip does the same thing:

>>> :t zipTagged ts' vs
zipTagged ts' vs :: Proxy '[Tagged "x" Int, Tagged "y" Char]
>>> :t hZip ts' vs
hZip ts' vs :: Proxy '[Tagged "x" Int, Tagged "y" Char]

class HasField' (b :: Bool) (l :: k) (r :: [*]) v | b l r -> v where Source #

Methods

hLookupByLabel' :: Proxy b -> Label l -> HList r -> v Source #

Instances

Instances details
HasField l (Record r) v => HasField' 'False (l :: k) (fld ': r) v Source # 
Instance details

Defined in Data.HList.Record

Methods

hLookupByLabel' :: Proxy 'False -> Label l -> HList (fld ': r) -> v Source #

HasField' 'True (l :: k) (Tagged l v ': r) v Source # 
Instance details

Defined in Data.HList.Record

Methods

hLookupByLabel' :: Proxy 'True -> Label l -> HList (Tagged l v ': r) -> v Source #

type family DemoteMaybe (d :: *) (v :: Maybe *) :: * Source #

Instances

Instances details
type DemoteMaybe d ('Nothing :: Maybe Type) Source # 
Instance details

Defined in Data.HList.Record

type DemoteMaybe d ('Nothing :: Maybe Type) = d
type DemoteMaybe d ('Just a) Source # 
Instance details

Defined in Data.HList.Record

type DemoteMaybe d ('Just a) = a

class HasFieldM1 (b :: Maybe [*]) (l :: k) r v | b l r -> v where Source #

Methods

hLookupByLabelM1 :: Proxy b -> Label l -> r -> t -> DemoteMaybe t v Source #

Instances

Instances details
HasFieldM1 ('Nothing :: Maybe [Type]) (l :: k) r ('Nothing :: Maybe Type) Source # 
Instance details

Defined in Data.HList.Record

Methods

hLookupByLabelM1 :: Proxy 'Nothing -> Label l -> r -> t -> DemoteMaybe t 'Nothing Source #

HasField l r v => HasFieldM1 ('Just b) (l :: k) r ('Just v) Source # 
Instance details

Defined in Data.HList.Record

Methods

hLookupByLabelM1 :: Proxy ('Just b) -> Label l -> r -> t -> DemoteMaybe t ('Just v) Source #

class H2ProjectByLabels (ls :: [*]) r rin rout | ls r -> rin rout where Source #

Invariant:

r === rin `disjoint-union` rout
labels rin === ls
    where (rin,rout) = hProjectByLabels ls r

Methods

h2projectByLabels :: proxy ls -> HList r -> (HList rin, HList rout) Source #

Instances

Instances details
H2ProjectByLabels ('[] :: [Type]) r ('[] :: [Type]) r Source # 
Instance details

Defined in Data.HList.Record

Methods

h2projectByLabels :: proxy '[] -> HList r -> (HList '[], HList r) Source #

H2ProjectByLabels (l ': ls) ('[] :: [Type]) ('[] :: [Type]) ('[] :: [Type]) Source # 
Instance details

Defined in Data.HList.Record

Methods

h2projectByLabels :: proxy (l ': ls) -> HList '[] -> (HList '[], HList '[]) Source #

(HMemberM (Label l1) (l ': ls) b, H2ProjectByLabels' b (l ': ls) (Tagged l1 v1 ': r1) rin rout) => H2ProjectByLabels (l ': ls) (Tagged l1 v1 ': r1) rin rout Source # 
Instance details

Defined in Data.HList.Record

Methods

h2projectByLabels :: proxy (l ': ls) -> HList (Tagged l1 v1 ': r1) -> (HList rin, HList rout) Source #

class H2ProjectByLabels' (b :: Maybe [*]) (ls :: [*]) r rin rout | b ls r -> rin rout where Source #

Methods

h2projectByLabels' :: Proxy b -> proxy ls -> HList r -> (HList rin, HList rout) Source #

Instances

Instances details
H2ProjectByLabels ls r rin rout => H2ProjectByLabels' ('Nothing :: Maybe [Type]) ls (f ': r) rin (f ': rout) Source #

if ls above has labels not in the record, we get labels (rin isSubsetOf ls).

Instance details

Defined in Data.HList.Record

Methods

h2projectByLabels' :: Proxy 'Nothing -> proxy ls -> HList (f ': r) -> (HList rin, HList (f ': rout)) Source #

H2ProjectByLabels ls1 r rin rout => H2ProjectByLabels' ('Just ls1) ls (f ': r) (f ': rin) rout Source # 
Instance details

Defined in Data.HList.Record

Methods

h2projectByLabels' :: Proxy ('Just ls1) -> proxy ls -> HList (f ': r) -> (HList (f ': rin), HList rout) Source #

class HLabelSet ls Source #

Relation between HLabelSet and HRLabelSet

instance HLabelSet (LabelsOf ps) => HRLabelSet ps

see also HSet

Instances

Instances details
HLabelSet ('[] :: [k]) Source # 
Instance details

Defined in Data.HList.Record

HLabelSet ('[x] :: [k]) Source # 
Instance details

Defined in Data.HList.Record

(HEqK l1 l2 leq, HLabelSet' l1 l2 leq r) => HLabelSet (l1 ': (l2 ': r) :: [a]) Source # 
Instance details

Defined in Data.HList.Record

class HLabelSet' l1 l2 (leq :: Bool) r Source #

Instances

Instances details
Fail (DuplicatedLabel l1) => HLabelSet' (l1 :: k1) (l2 :: k2) 'True (r :: k3) Source # 
Instance details

Defined in Data.HList.Record

(HLabelSet (l2 ': r), HLabelSet (l1 ': r)) => HLabelSet' (l1 :: k) (l2 :: k) 'False (r :: [k]) Source # 
Instance details

Defined in Data.HList.Record

class (HLabelSet (LabelsOf ps), HAllTaggedLV ps) => HRLabelSet (ps :: [*]) Source #

Instances

Instances details
(HLabelSet (LabelsOf ps), HAllTaggedLV ps) => HRLabelSet ps Source # 
Instance details

Defined in Data.HList.Record

class HAllTaggedLV (ps :: [*]) Source #

The Record, Variant, TIP, TIC type constructors only make sense when they are applied to an instance of this class

Instances

Instances details
HAllTaggedLV ('[] :: [Type]) Source # 
Instance details

Defined in Data.HList.FakePrelude

(HAllTaggedLV xs, x ~ Tagged t v) => HAllTaggedLV (x ': xs) Source # 
Instance details

Defined in Data.HList.FakePrelude

class (HRearrange3 ls r r', LabelsOf r' ~ ls, SameLength ls r, SameLength r r') => HRearrange (ls :: [*]) r r' | ls r -> r', r' -> ls where Source #

Helper class for hRearrange

Methods

hRearrange2 :: proxy ls -> HList r -> HList r' Source #

Instances

Instances details
(HRearrange3 ls r r', LabelsOf r' ~ ls, SameLength ls r, SameLength r r') => HRearrange ls r r' Source # 
Instance details

Defined in Data.HList.Record

Methods

hRearrange2 :: proxy ls -> HList r -> HList r' Source #

class HRearrange3 (ls :: [*]) r r' | ls r -> r' where Source #

same as HRearrange, except no backwards FD

Methods

hRearrange3 :: proxy ls -> HList r -> HList r' Source #

Instances

Instances details
HRearrange3 ('[] :: [Type]) ('[] :: [Type]) ('[] :: [Type]) Source # 
Instance details

Defined in Data.HList.Record

Methods

hRearrange3 :: proxy '[] -> HList '[] -> HList '[] Source #

Fail (ExtraField l) => HRearrange3 ('[] :: [Type]) (Tagged l v ': a) ('[] :: [Type]) Source #

For improved error messages

Instance details

Defined in Data.HList.Record

Methods

hRearrange3 :: proxy '[] -> HList (Tagged l v ': a) -> HList '[] Source #

(H2ProjectByLabels '[l] r rin rout, HRearrange4 l ls rin rout r', l ~ Label ll) => HRearrange3 (l ': ls) r r' Source # 
Instance details

Defined in Data.HList.Record

Methods

hRearrange3 :: proxy (l ': ls) -> HList r -> HList r' Source #

class HRearrange4 (l :: *) (ls :: [*]) rin rout r' | l ls rin rout -> r' where Source #

Helper class 2 for hRearrange

Methods

hRearrange4 :: proxy l -> Proxy ls -> HList rin -> HList rout -> HList r' Source #

Instances

Instances details
Fail (FieldNotFound l ()) => HRearrange4 l ls ('[] :: [Type]) rout ('[] :: [Type]) Source #

For improved error messages. XXX FieldNotFound

Instance details

Defined in Data.HList.Record

Methods

hRearrange4 :: proxy l -> Proxy ls -> HList '[] -> HList rout -> HList '[] Source #

(HRearrange3 ls rout r', r'' ~ (Tagged l v ': r'), ll ~ Label l) => HRearrange4 ll ls '[Tagged l v] rout r'' Source # 
Instance details

Defined in Data.HList.Record

Methods

hRearrange4 :: proxy ll -> Proxy ls -> HList '[Tagged l v] -> HList rout -> HList r'' Source #

class UnionSymRec' (b :: Bool) r1 f2 r2' ru | b r1 f2 r2' -> ru where Source #

Methods

unionSR' :: Proxy b -> Record r1 -> f2 -> Record r2' -> (Record ru, Record ru) Source #

Instances

Instances details
(UnionSymRec r1 r2' ru, HExtend f2 (Record ru), Record f2ru ~ HExtendR f2 (Record ru)) => UnionSymRec' 'False r1 f2 r2' f2ru Source # 
Instance details

Defined in Data.HList.Record

Methods

unionSR' :: Proxy 'False -> Record r1 -> f2 -> Record r2' -> (Record f2ru, Record f2ru) Source #

(UnionSymRec r1 r2' ru, HTPupdateAtLabel Record l2 v2 ru, f2 ~ Tagged l2 v2) => UnionSymRec' 'True r1 f2 r2' ru Source #

Field f2 is already in r1, so it will be in the union of r1 with the rest of r2.

To inject (HCons f2 r2) in that union, we should replace the field f2

Instance details

Defined in Data.HList.Record

Methods

unionSR' :: Proxy 'True -> Record r1 -> f2 -> Record r2' -> (Record ru, Record ru) Source #

type HFindLabel (l :: k) (ls :: [*]) (n :: HNat) = HFind l (UnLabel l (LabelsOf ls)) n Source #

A version of HFind where the ls type variable is a list of Tagged or Label. This is a bit indirect, and ideally LabelsOf could have kind [*] -> [k].

labelLVPair :: Tagged l v -> Label l Source #

Label accessor

newLVPair :: Label l -> v -> Tagged l v Source #

type family UnLabel (proxy :: k) (ls :: [*]) :: [k] Source #

remove the Label type constructor. The proxy argument is supplied to make it easier to fix the kind variable k.

Instances

Instances details
type UnLabel (proxy :: k) ('[] :: [Type]) Source # 
Instance details

Defined in Data.HList.Record

type UnLabel (proxy :: k) ('[] :: [Type]) = '[] :: [k]
type UnLabel (proxy :: a) (Label x ': xs) Source # 
Instance details

Defined in Data.HList.Record

type UnLabel (proxy :: a) (Label x ': xs) = x ': UnLabel proxy xs

type HMemberLabel l r b = HMember l (UnLabel l (LabelsOf r)) b Source #

data TaggedFn Source #

Constructors

TaggedFn 

Instances

Instances details
tx ~ Tagged t x => ApplyAB TaggedFn x tx Source # 
Instance details

Defined in Data.HList.Record

Methods

applyAB :: TaggedFn -> x -> tx Source #

data ReadComponent Source #

Instances

Instances details
(Read v, ShowLabel l, x ~ Tagged l v, ReadP x ~ y) => ApplyAB ReadComponent (Proxy x) y Source # 
Instance details

Defined in Data.HList.Record

Methods

applyAB :: ReadComponent -> Proxy x -> y Source #

type HLensCxt x r s t a b = (HasField x (r s) a, HUpdateAtLabel r x b s t, HasField x (r t) b, HUpdateAtLabel r x a t s, SameLength s t, SameLabels s t) Source #

constraints needed to implement HLens

zip

use the more general HZip class instead

class HZipRecord x y xy | x y -> xy, xy -> x y where Source #

Methods

hZipRecord :: Record x -> Record y -> Record xy Source #

hUnzipRecord :: Record xy -> (Record x, Record y) Source #

Instances

Instances details
HZipRecord ('[] :: [Type]) ('[] :: [Type]) ('[] :: [Type]) Source # 
Instance details

Defined in Data.HList.Record

Methods

hZipRecord :: Record '[] -> Record '[] -> Record '[] Source #

hUnzipRecord :: Record '[] -> (Record '[], Record '[]) Source #

HZipRecord as bs abss => HZipRecord (Tagged x a ': as) (Tagged x b ': bs) (Tagged x (a, b) ': abss) Source # 
Instance details

Defined in Data.HList.Record

Methods

hZipRecord :: Record (Tagged x a ': as) -> Record (Tagged x b ': bs) -> Record (Tagged x (a, b) ': abss) Source #

hUnzipRecord :: Record (Tagged x (a, b) ': abss) -> (Record (Tagged x a ': as), Record (Tagged x b ': bs)) Source #

alternative implementation

hZipRecord2 :: forall (x :: [Type]) (y1 :: [Type]) (y2 :: [Type]). (SameLabels x y1, SameLabels x y2, HAllTaggedLV x, HMapAux HList TaggedFn (RecordValuesR x) x, HZipList (RecordValuesR y1) (RecordValuesR y2) (RecordValuesR x), RecordValues x, RecordValues y1, RecordValues y2, SameLength' x y1, SameLength' x y2, SameLength' y2 x, SameLength' y1 x) => Record y1 -> Record y2 -> Record x Source #

instead of explicit recursion above, we could define HZipRecord in terms of HZipList. While all types are inferred, this implementation is probably slower, so explicit recursion is used in the HZip Record instance.

Orphan instances

(HRevAppR l ('[] :: [Type]) ~ lRev, HExtendRs lRev (Proxy ('[] :: [Type])) ~ Proxy l1, l' ~ l1) => HBuild' l (Proxy l') Source #

see hEndP

Instance details

Methods

hBuild' :: HList l -> Proxy l' Source #