vinyl-0.9.0: Extensible Records

Safe HaskellNone
LanguageHaskell2010

Data.Vinyl.Derived

Contents

Description

Commonly used Rec instantiations.

Synopsis

Documentation

type (:::) a b = '(a, b) Source #

Alias for Field spec

type FieldRec = Rec ElField Source #

A record of named fields.

type AFieldRec ts = ARec ElField ts Source #

An ARec of named fields to provide constant-time field access.

type HList = Rec Identity Source #

Heterogeneous list whose elements are evaluated during list construction.

type LazyHList = Rec Thunk Source #

Heterogeneous list whose elements are left as-is during list construction (cf. HList).

getField :: ElField '(s, t) -> t Source #

Get the data payload of an ElField.

getLabel :: forall s t. ElField '(s, t) -> String Source #

Get the label name of an ElField.

fieldMap :: (a -> b) -> ElField '(s, a) -> ElField '(s, b) Source #

ElField is isomorphic to a functor something like Compose ElField ('(,) s).

rfield :: Functor f => (a -> f b) -> ElField '(s, a) -> f (ElField '(s, b)) Source #

Lens for an ElField's data payload.

(=:) :: KnownSymbol l => Label (l :: Symbol) -> (v :: *) -> ElField (l ::: v) infix 8 Source #

Operator for creating an ElField. With the -XOverloadedLabels extension, this permits usage such as, #foo =: 23 to produce a value of type ElField ("foo" ::: Int).

rgetf :: forall l f v record us. (HasField record l us us v v, RecElemFCtx record f) => Label l -> record f us -> f (l ::: v) Source #

Get a named field from a record.

rvalf :: (HasField record l us us v v, RecElemFCtx record ElField) => Label l -> record ElField us -> v Source #

Get the value associated with a named field from a record.

rputf' :: forall l v v' record us us'. (HasField record l us us' v v', KnownSymbol l, RecElemFCtx record ElField) => Label l -> v' -> record ElField us -> record ElField us' Source #

Set a named field. rputf' #foo 23 sets the field named #foo to 23.

rputf :: forall l v record us. (HasField record l us us v v, KnownSymbol l, RecElemFCtx record ElField) => Label l -> v -> record ElField us -> record ElField us Source #

Set a named field without changing its type. rputf #foo 23 sets the field named #foo to 23.

rlensfL' :: forall l v v' record g f us us'. (Functor g, HasField record l us us' v v', RecElemFCtx record f) => Label l -> (f (l ::: v) -> g (f (l ::: v'))) -> record f us -> g (record f us') Source #

A lens into a Rec identified by a Label.

rlensfL :: forall l v record g f us. (Functor g, HasField record l us us v v, RecElemFCtx record f) => Label l -> (f (l ::: v) -> g (f (l ::: v))) -> record f us -> g (record f us) Source #

A type-preserving lens into a Rec identified by a Label.

rlensf' :: forall l v v' record g us us'. (Functor g, HasField record l us us' v v', RecElemFCtx record ElField) => Label l -> (v -> g v') -> record ElField us -> g (record ElField us') Source #

A lens into the payload value of a Rec field identified by a Label.

rlensf :: forall l v record g us. (Functor g, HasField record l us us v v, RecElemFCtx record ElField) => Label l -> (v -> g v) -> record ElField us -> g (record ElField us) Source #

A type-preserving lens into the payload value of a Rec field identified by a Label.

(=:=) :: KnownSymbol s => Label (s :: Symbol) -> a -> FieldRec '['(s, a)] Source #

Shorthand for a FieldRec with a single field.

data SField (field :: k) Source #

A proxy for field types.

Constructors

SField 
Instances
Eq (SField a) Source # 
Instance details

Defined in Data.Vinyl.Derived

Methods

(==) :: SField a -> SField a -> Bool #

(/=) :: SField a -> SField a -> Bool #

Ord (SField a) Source # 
Instance details

Defined in Data.Vinyl.Derived

Methods

compare :: SField a -> SField a -> Ordering #

(<) :: SField a -> SField a -> Bool #

(<=) :: SField a -> SField a -> Bool #

(>) :: SField a -> SField a -> Bool #

(>=) :: SField a -> SField a -> Bool #

max :: SField a -> SField a -> SField a #

min :: SField a -> SField a -> SField a #

KnownSymbol s => Show (SField ((,) s t)) Source # 
Instance details

Defined in Data.Vinyl.Derived

Methods

showsPrec :: Int -> SField (s, t) -> ShowS #

show :: SField (s, t) -> String #

showList :: [SField (s, t)] -> ShowS #

type family FieldType l fs where ... Source #

Equations

FieldType l '[] = TypeError ((Text "Cannot find label " :<>: ShowType l) :<>: Text " in fields") 
FieldType l ((l ::: v) ': fs) = v 
FieldType l ((l' ::: v') ': fs) = FieldType l fs 

type HasField record l fs fs' v v' = (RecElem record (l ::: v) (l ::: v') fs fs' (RIndex (l ::: v) fs), FieldType l fs ~ v, FieldType l fs' ~ v') Source #

Constraint that a label is associated with a particular type in a record.

data Label (a :: Symbol) Source #

Proxy for label type

Constructors

Label 
Instances
s ~ s' => IsLabel s (Label s') Source # 
Instance details

Defined in Data.Vinyl.Derived

Methods

fromLabel :: Label s' #

Eq (Label a) Source # 
Instance details

Defined in Data.Vinyl.Derived

Methods

(==) :: Label a -> Label a -> Bool #

(/=) :: Label a -> Label a -> Bool #

Show (Label a) Source # 
Instance details

Defined in Data.Vinyl.Derived

Methods

showsPrec :: Int -> Label a -> ShowS #

show :: Label a -> String #

showList :: [Label a] -> ShowS #

class (KnownSymbol (Fst a), a ~ '(Fst a, Snd a)) => KnownField a Source #

Defines a constraint that lets us extract the label from an ElField. Used in rmapf and rpuref.

Instances
KnownSymbol l => KnownField (l ::: v :: (Symbol, k)) Source # 
Instance details

Defined in Data.Vinyl.Derived

type AllFields fs = (RPureConstrained KnownField fs, RecApplicative fs, RApply fs) Source #

Shorthand for working with records of fields as in rmapf and rpuref.

rmapf :: AllFields fs => (forall a. KnownField a => f a -> g a) -> Rec f fs -> Rec g fs Source #

Map a function between functors across a Rec taking advantage of knowledge that each element is an ElField.

rpuref :: AllFields fs => (forall a. KnownField a => f a) -> Rec f fs Source #

Construct a Rec with ElField elements.

(<<$$>>) :: AllFields fs => (forall a. KnownField a => f a -> g a) -> Rec f fs -> Rec g fs Source #

Operator synonym for rmapf.

rlabels :: AllFields fs => Rec (Const String) fs Source #

Produce a Rec of the labels of a Rec of ElFields.

Specializations for working with an ARec of named fields.