class (i ~ RIndex r rs, NatToInt i) => RecElem (record :: (k -> Type) -> [k] -> Type) (r :: k) (r' :: k) (rs :: [k]) (rs' :: [k]) (i :: Nat) | r r' rs i -> rs' whereThe presence of a field in a record is witnessed by a lens into
its value. The fifth parameter to RecElem, i, is there to help
the constraint solver realize that this is a decidable predicate
with respect to the judgemental equality in k.
Associated types
type family RecElemFCtx (record :: (k -> Type) -> [k] -> Type) (f :: k -> Type) :: ConstraintAn opportunity for instances to generate constraints based on the functor parameter of records passed to class methods.
Methods
rlensC :: (Functor g, RecElemFCtx record f) => (f r -> g (f r')) -> record f rs -> g (record f rs')We can get a lens for getting and setting the value of a field which is in a record. As a convenience, we take a proxy argument to fix the particular field being viewed. These lenses are compatible with the
lenslibrary. Morally:rlensC :: Lens' (Rec f rs) (Rec f rs') (f r) (f r')rgetC :: (RecElemFCtx record f, r ~ r') => record f rs -> f rFor Vinyl users who are not using the
lenspackage, we provide a getter.rputC :: RecElemFCtx record f => f r' -> record f rs -> record f rs'For Vinyl users who are not using the
lenspackage, we also provide a setter. In general, it will be unambiguous what field is being written to, and so we do not take a proxy argument here.
Instances6RecElem
RecElem ARec t t' (t ': ts) (t' ': ts) 'ZDefined in vinyl-0.14.3 · Data.Vinyl.ARec.InternalRecElem Rec r r' (r ': rs) (r' ': rs) 'ZDefined in vinyl-0.14.3 · Data.Vinyl.Lens(RIndex r (s ': rs) ~ 'S i, RecElem Rec r r' rs rs' i) => RecElem Rec r r' (s ': rs) (s ': rs') ('S i)Defined in vinyl-0.14.3 · Data.Vinyl.Lens(RIndex t (s ': ts) ~ 'S i, NatToInt i, RecElem ARec t t' ts ts' i) => RecElem ARec t t' (s ': ts) (s ': ts') ('S i)Defined in vinyl-0.14.3 · Data.Vinyl.ARec.Internal(i ~ RIndex t ts, NatToInt i, FieldOffset ElField ts t, Storable (Rec ElField ts), AllConstrained (FieldOffset ElField ts) ts) => RecElem SRec t t ts ts iDefined in vinyl-0.14.3 · Data.Vinyl.SRec(i ~ RIndex t ts, NatToInt i, FieldOffset ElField ts t, Storable (Rec ElField ts), AllConstrained (FieldOffset ElField ts) ts) => RecElem (SRec2 ElField) t t ts ts iDefined in vinyl-0.14.3 · Data.Vinyl.SRec