vinyl-0.4.3: Extensible Records

Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Vinyl.Core

Synopsis

Documentation

data Rec el f rrs where Source

A record is parameterized by a universe u, list of rows rs, a large elimination el, and a type constructor f to be applied to the interpretation el r of each of those r.

Constructors

RNil :: Rec el f [] 
(:&) :: !(f (el $ r)) -> !(Rec el f rs) -> Rec el f (r : rs) infixr 9 

Instances

(Eq (f (($) * k el r)), Eq (Rec k el f rs)) => Eq (Rec k el f ((:) k r rs)) 
Eq (Rec k el f ([] k)) 
(Storable (($) * k el r), Storable (Rec k el Identity rs)) => Storable (Rec k el Identity ((:) k r rs)) 
Storable (Rec k el Identity ([] k)) 
(Monoid (($) * k el r), Monoid (Rec k el f rs), Applicative f) => Monoid (Rec k el f ((:) k r rs)) 
Monoid (Rec k el f ([] k)) 
FoldRec (Rec k el f ([] k)) a 
((~) * t (($) * k el r), FoldRec (Rec k el f rs) (f t)) => FoldRec (Rec k el f ((:) k r rs)) (f t) 

(=:) :: Applicative f => sing k -> (el $ k) -> Rec el f `[k]` Source

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

(<-:) :: sing r -> f (el $ r) -> Rec el f `[r]` infixr 6 Source

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

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

withUniverse :: (forall x. el x) -> Rec el f rs -> Rec el f rs Source

Records constructed using the above combinators will often be polymorphic in their interpreter el. To avoid providing a type annotation, one can provide their interpreters with a singleton tag and pass that in.