vinyl-0.14.3: Extensible Records
Safe HaskellNone
LanguageHaskell2010

Data.Vinyl.Derived

Description

Commonly used Rec instantiations.

Synopsis

Documentation

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

Alias for Field spec

type FieldRec = Rec ElField Source #

A record of named fields.

type AFieldRec (ts :: [(Symbol, Type)]) = 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 :: forall (s :: Symbol) t. ElField '(s, t) -> t Source #

Get the data payload of an ElField.

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

Get the label name of an ElField.

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

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

traverseField :: forall (s :: Symbol) f a b. (KnownSymbol s, Functor f) => (a -> b) -> f (ElField '(s, a)) -> ElField '(s, f b) Source #

Something in the spirit of traverse for ElField whose kind fights the standard library.

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

Lens for an ElField's data payload.

(=:) :: forall (l :: Symbol) v. KnownSymbol l => Label l -> 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 {k} (l :: Symbol) f (v :: k) record (us :: [(Symbol, k)]). (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 :: forall record (l :: Symbol) (us :: [(Symbol, Type)]) v. (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 :: Symbol) v v' record (us :: [(Symbol, Type)]) (us' :: [(Symbol, Type)]). (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 :: Symbol) v record (us :: [(Symbol, Type)]). (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 {k} (l :: Symbol) (v :: k) (v' :: k) record g f (us :: [(Symbol, k)]) (us' :: [(Symbol, k)]). (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 {k} (l :: Symbol) (v :: k) record g f (us :: [(Symbol, k)]). (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 :: Symbol) v v' record g (us :: [(Symbol, Type)]) (us' :: [(Symbol, Type)]). (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 :: Symbol) v record g (us :: [(Symbol, Type)]). (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.

(=:=) :: forall (s :: Symbol) a. KnownSymbol s => Label s -> 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

Instances details
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 #

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 #

type family FieldType (l :: k1) (fs :: [(k1, k)]) :: k where ... Source #

Equations

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

type HasField (record :: ((k, k1) -> Type) -> [(k, k1)] -> Type) (l :: k) (fs :: [(k, k1)]) (fs' :: [(k, k1)]) (v :: k1) (v' :: k1) = (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

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

Defined in Data.Vinyl.Derived

Methods

fromLabel :: Label s' #

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 #

Eq (Label a) Source # 
Instance details

Defined in Data.Vinyl.Derived

Methods

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

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

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

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

Instances

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

Defined in Data.Vinyl.Derived

type AllFields (fs :: [(Symbol, k)]) = (RPureConstrained (KnownField :: (Symbol, k) -> Constraint) fs, RecApplicative fs, RApply fs) Source #

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

rmapf :: forall {k} (fs :: [(Symbol, k)]) f g. AllFields fs => (forall (a :: (Symbol, k)). 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.

type family Unlabeled (ts :: [(k, a)]) :: [a] where ... Source #

Remove the first component (e.g. the label) from a type-level list of pairs.

Equations

Unlabeled ('[] :: [(k, a)]) = '[] :: [a] 
Unlabeled ('(s, x) ': xs :: [(k, a)]) = x ': Unlabeled xs 

class StripFieldNames (ts :: [(Symbol, Type)]) where Source #

Facilities for removing and replacing the type-level label, or column name, part of a record.

Methods

stripNames :: Rec ElField ts -> Rec Identity (Unlabeled ts) Source #

stripNames' :: forall (f :: Type -> Type). Functor f => Rec (f :. ElField) ts -> Rec f (Unlabeled ts) Source #

withNames :: Rec Identity (Unlabeled ts) -> Rec ElField ts Source #

withNames' :: forall (f :: Type -> Type). Functor f => Rec f (Unlabeled ts) -> Rec (f :. ElField) ts Source #

Instances

Instances details
StripFieldNames ('[] :: [(Symbol, Type)]) Source # 
Instance details

Defined in Data.Vinyl.Derived

Methods

stripNames :: Rec ElField ('[] :: [(Symbol, Type)]) -> Rec Identity (Unlabeled ('[] :: [(Symbol, Type)])) Source #

stripNames' :: forall (f :: Type -> Type). Functor f => Rec (f :. ElField) ('[] :: [(Symbol, Type)]) -> Rec f (Unlabeled ('[] :: [(Symbol, Type)])) Source #

withNames :: Rec Identity (Unlabeled ('[] :: [(Symbol, Type)])) -> Rec ElField ('[] :: [(Symbol, Type)]) Source #

withNames' :: forall (f :: Type -> Type). Functor f => Rec f (Unlabeled ('[] :: [(Symbol, Type)])) -> Rec (f :. ElField) ('[] :: [(Symbol, Type)]) Source #

(KnownSymbol s, StripFieldNames ts) => StripFieldNames ('(s, t) ': ts) Source # 
Instance details

Defined in Data.Vinyl.Derived

Methods

stripNames :: Rec ElField ('(s, t) ': ts) -> Rec Identity (Unlabeled ('(s, t) ': ts)) Source #

stripNames' :: forall (f :: Type -> Type). Functor f => Rec (f :. ElField) ('(s, t) ': ts) -> Rec f (Unlabeled ('(s, t) ': ts)) Source #

withNames :: Rec Identity (Unlabeled ('(s, t) ': ts)) -> Rec ElField ('(s, t) ': ts) Source #

withNames' :: forall (f :: Type -> Type). Functor f => Rec f (Unlabeled ('(s, t) ': ts)) -> Rec (f :. ElField) ('(s, t) ': ts) Source #

rpuref :: forall {k} (fs :: [(Symbol, k)]) f. AllFields fs => (forall (a :: (Symbol, k)). KnownField a => f a) -> Rec f fs Source #

Construct a Rec with ElField elements.

(<<$$>>) :: forall {k} (fs :: [(Symbol, k)]) f g. AllFields fs => (forall (a :: (Symbol, k)). KnownField a => f a -> g a) -> Rec f fs -> Rec g fs Source #

Operator synonym for rmapf.

rlabels :: forall {k} (fs :: [(Symbol, k)]). AllFields fs => Rec (Const String :: (Symbol, k) -> Type) fs Source #

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

Specializations for working with an ARec of named fields.