Frames-beam-0.2.0.0: A library for accessing Postgres tables as in-memory data structures.

Safe HaskellNone
LanguageHaskell2010

Frames.SQL.Beam.Postgres.Vinylize

Description

Typeclass and an instance generator for the typeclass to convert plain Haskell records to their vinyl representation.

Synopsis

Documentation

type family ZipTypes (ns :: [Symbol]) (ys :: [*]) = (zs :: [(Symbol, *)]) | zs -> ns ys Source #

Type family that generates the column types for the vinyl representation.

Instances
type ZipTypes ([] :: [Symbol]) ([] :: [*]) Source # 
Instance details

Defined in Frames.SQL.Beam.Postgres.Vinylize

type ZipTypes ([] :: [Symbol]) ([] :: [*]) = ([] :: [(Symbol, *)])
type ZipTypes (n ': ns) (y ': ys) Source # 
Instance details

Defined in Frames.SQL.Beam.Postgres.Vinylize

type ZipTypes (n ': ns) (y ': ys) = (,) n y ': ZipTypes ns ys

class GenericVinyl a names rs | a -> names rs where Source #

Typeclass for converting a plain Haskell record to it's vinyl representation.

Minimal complete definition

createRecId

Associated Types

type FieldNames a :: [Symbol] Source #

Methods

createRecId :: a -> Rec ElField (ZipTypes names rs) Source #

deriveVinyl :: Name -> DecsQ Source #

Helps generate an instance for GenericVinyl, given a plain Haskell record declaration name. Uses Template Haskell, so if, say, the record is named MyRecord, then first you must invoke deriveGeneric ''MyRecord to get the Sum-of-Products (SOP) representation (imported from generic-sop) of the record in-scope, in the current module. This is followed by invoking deriveVinyl ''MyRecord, which makes use of the SOP representation of the plain record and generates a GenericVinyl instance for the record.