vinyl-plus-0.1.1: Vinyl records utilities

Safe HaskellNone
LanguageHaskell2010

Data.Vinyl.Optic.Plain.Class

Synopsis

Documentation

class (i ~ RIndex r rs) => RElem r rs i where Source

This is a drop-in replacement for the RElem class from Data.Vinyl.Lens. The functions it provides work on CoRecs instead of Recs. It also provides a lifting function clift, which has no equivalent operation on Recs. If CoRec were merged into vinyl, this typeclass could be eliminated, and its methods could be added to RElem.

Methods

cprism :: (Choice p, Applicative g) => proxy r -> p (f r) (g (f r)) -> p (CoRec f rs) (g (CoRec f rs)) Source

We can get a prism for getting and setting values in a CoRec. Morally,

cprism :: Prism' (CoRec f rs) (f r)

cget :: proxy r -> CoRec f rs -> Maybe (f r) Source

Get a value from a CoRec. Note that, unlike rget, this function may not find the requested element, so the result is wrapped in Maybe.

cmodify :: (f r -> f r) -> CoRec f rs -> CoRec f rs Source

If the element in the CoRec is of a certain type, modify it. Otherwise, leave the CoRec unchanged.

cput :: f r -> CoRec f rs -> CoRec f rs Source

If the element in the CoRec is of a certain type, replace it. This function is provided for symmetry with rput, but it is not typically useful. Usually, clift is more useful.

clift :: f r -> CoRec f rs Source

Lift an element into a CoRec.

Instances

(~) k r s => RElem k r ((:) k s rs) Z Source 
((~) Nat (RIndex k r ((:) k s rs)) (S i), RElem k r rs i) => RElem k r ((:) k s rs) (S i) Source 

class (is ~ RImage sub super) => RSubset sub super is where Source

Methods

ccast :: CoRec f sub -> CoRec f super Source

Upcast a CoRec to another CoRec that could be inhabited by additional types.

Instances

RSubset k ([] k) super ([] Nat) Source 
(RElem k r super i, RSubset k sub super is) => RSubset k ((:) k r sub) super ((:) Nat i is) Source 

type REquivalent rs ss is js = (RSubset rs ss is, RSubset ss rs js) Source

Two record types are equivalent when they are subtypes of each other.

type RElem' r rs = RElem r rs (RIndex r rs) Source

A shorthand for RElem which supplies its index.

type (∈) r rs = RElem' r rs Source

An infix operator for 'RMember\''.

type RSubset' rs ss = RSubset rs ss (RImage rs ss) Source

A shorthand for RSubset which supplies its image.

type (⊆) rs ss = RSubset' rs ss Source

An infix operator for 'RSubset\''

type REquivalent' rs ss = REquivalent rs ss (RImage rs ss) (RImage ss rs) Source

A shorthand for REquivalent which supplies its images.

type (≅) rs ss = REquivalent' rs ss Source

An infix operator for 'REquivalent\''

type (<:) rs ss = rs ss Source

A non-unicode equivalent of (⊆).

type (:~:) rs ss = rs ss Source

A non-unicode equivalent of (≅).