@@ -19,6 +19,7 @@ A type-level DSL for kinds of PostgreSQL types, constraints, and aliases.
20 , OverloadedStrings
20 , OverloadedStrings
21 , RankNTypes
21 , RankNTypes
22+ , ScopedTypeVariables
22 , StandaloneDeriving
23 , StandaloneDeriving
23 , TypeApplications
24 , TypeApplications
24 , TypeFamilyDependencies
25 , TypeFamilyDependencies
@@ -93,6 +94,10 @@ module Squeal.PostgreSQL.Schema
93 , SameLabels
94 , SameLabels
94 , MapMaybes (..)
95 , MapMaybes (..)
96 -- * Schema
101 -- * Schema
97 , SchemumType (..)
102 , SchemumType (..)
98 , SchemaType
103 , SchemaType
@@ -618,3 +623,17 @@ type family With
618 With '[] schema = schema
623 With '[] schema = schema
619 With (alias ::: rel ': rels) schema =
624 With (alias ::: rel ': rels) schema =
620 alias ::: 'View rel ': With rels schema
625 alias ::: 'View rel ': With rels schema
627+class IsPGlabel (label :: Symbol) expr where label :: expr
628+instance label ~ label'
629+ => IsPGlabel label (PGlabel label') where label = PGlabel
630+data PGlabel (label :: Symbol) = PGlabel
632+renderLabel :: KnownSymbol label => proxy label -> ByteString
633+renderLabel (_ :: proxy label) =
634+ "\'" <> fromString (symbolVal (SOP.Proxy @label)) <> "\'"
637+ :: SOP.All KnownSymbol labels => SOP.NP PGlabel labels -> [ByteString]
638+renderLabels = SOP.hcollapse
639+ . SOP.hcmap (SOP.Proxy @KnownSymbol) (SOP.K . renderLabel)