vinyl-0.2.1: Extensible Records

Safe HaskellNone

Data.Vinyl.Rec

Synopsis

Documentation

data Rec whereSource

A record is parameterized by a list of fields and a functor to be applied to each of those fields.

Constructors

RNil :: Rec `[]` f 
:& :: f t -> Rec rs f -> Rec ((sy ::: t) : rs) f 

Instances

(Storable t, Storable (PlainRec rs)) => Storable (PlainRec (: * (::: sy t) rs)) 
Storable (PlainRec ([] *)) 
Dist (Rec rs)

Records may be distributed to accumulate the effects of their fields.

(Eq (g t), Eq (Rec fs g)) => Eq (Rec (: * (::: s t) fs) g) 
Eq (Rec ([] *) f) 
(SingI Symbol sy, Show (g t), Show (Rec fs g)) => Show (Rec (: * (::: sy t) fs) g) 
Show (Rec ([] *) f) 
(Monoid t, Monoid (Rec fs g), Applicative g) => Monoid (Rec (: * (::: s t) fs) g) 
Monoid (Rec ([] *) f) 
FoldRec (Rec ([] *) f) a 
FoldRec (Rec fs g) (g t) => FoldRec (Rec (: * (::: s t) fs) g) (g t) 
Apply (* -> *) (~> *) (Rec rs)

Records can be applied to each other.

(~ * y (::: sy t), IElem * y xs, <: (Rec xs f) (Rec ys f)) => (Rec xs f) <: (Rec (: * y ys) f) 
(Rec xs f) <: (Rec ([] *) f) 

type PlainRec rs = Rec rs IdentitySource

Fields of plain records are in the Identity functor.

(=:) :: Applicative f => (sy ::: t) -> t -> Rec `[sy ::: t]` fSource

Shorthand for a record with a single field. Lifts the field's value into the chosen functor automatically.

(<+>) :: Rec as f -> Rec bs f -> Rec (as ++ bs) fSource

Append for records.

(<-:) :: Applicative f => (sy ::: t) -> f t -> Rec `[sy ::: t]` fSource

Shorthand for a record with a single field of an Applicative type. This is useful for Applicative or Monadic intialization of records as in the idiom:

 dist $ myField <-: someIO <+> yourField <-: otherIO

type family as (++) bs :: [*]Source

Append for type-level lists.

fixRecord :: (forall f. Applicative f => Rec rs f) -> PlainRec rsSource

Fixes a polymorphic record into the Identity functor.