@@ -1,5 +1,6 @@
1{-# LANGUAGE
1{-# LANGUAGE
3 , FlexibleInstances
4 , FlexibleInstances
5 , MultiParamTypeClasses
6 , MultiParamTypeClasses
@@ -44,14 +45,15 @@ param5 = UnsafeExpression "$5"
45class HasField ident xs x where
46class HasField ident xs x where
46 fieldName :: Proxy ident -> Proxy xs -> Proxy x -> ByteString
47 fieldName :: Proxy ident -> Proxy xs -> Proxy x -> ByteString
48+instance KnownSymbol name
47−instance KnownSymbol name => HasField '[name] ((name ':= x) ': xs) x where
49+ => HasField '[name] ((name ':= x) ': xs) x where
48− fieldName _ _ _ = Char8.pack (symbolVal (Proxy @name))
49−instance HasField ident xs x => HasField ident (y ': xs) x where
50− fieldName _ _ _ = fieldName (Proxy @ident) (Proxy @xs) (Proxy @x)
51−instance (KnownSymbol name, HasField names xs x)
52− => HasField (name ': names) ((name ':= xs) ': xss) x where
53 fieldName _ _ _ = Char8.pack (symbolVal (Proxy @name))
50 fieldName _ _ _ = Char8.pack (symbolVal (Proxy @name))
51+instance HasField ident (x ': xs) y => HasField ident (x' ': x ': xs) y where
52+ fieldName _ _ _ = fieldName (Proxy @ident) (Proxy @(x ': xs)) (Proxy @y)
53+instance (KnownSymbol name, HasField (name' ': names) xs x)
54+ => HasField (name ': name' ': names) ((name ':= xs) ': xss) x where
55+ fieldName _ _ _ = Char8.pack (symbolVal (Proxy @name))
54− <> "." <> fieldName (Proxy @names) (Proxy @xs) (Proxy @x)
56+ <> "." <> fieldName (Proxy @(name' ': names)) (Proxy @xs) (Proxy @x)
57 :: forall ident xs x ps
59 :: forall ident xs x ps
@@ -69,9 +71,9 @@ unalias (AS obj) = obj
71 :: forall ident xs x ps
73 :: forall ident xs x ps
72− . HasField ident xs x
74+ . HasField '[ident] xs x
73 => Aliased (Expression ps xs) (ident ':= x)
75 => Aliased (Expression ps xs) (ident ':= x)
74−column = AS $ column_ (Proxy @ident)
76+column = AS $ column_ (Proxy @'[ident])
76renderAliased
78renderAliased
77 :: KnownSymbol name
79 :: KnownSymbol name
@@ -90,10 +92,10 @@ instance KnownSymbol name => AllAliased '[name ':= x] where
90 renderAllAliased render
92 renderAllAliased render
91 (aliased :& RNil :: Rec (Aliased obj) '[name ':= x]) =
93 (aliased :& RNil :: Rec (Aliased obj) '[name ':= x]) =
92 renderAliased render aliased
94 renderAliased render aliased
93−instance (KnownSymbol name, AllAliased xs)
95+instance (KnownSymbol name, AllAliased (x' ': xs))
94− => AllAliased ((name ':= x) ': xs) where
96+ => AllAliased ((name ':= x) ': (x' ': xs)) where
95 renderAllAliased render
97 renderAllAliased render
96− (x :& xs :: Rec (Aliased obj) ((name ':= x) ': xs)) =
98+ (x :& xs :: Rec (Aliased obj) ((name ':= x) ': (x' : xs))) =
97 renderAliased render x <> ", " <> renderAllAliased render xs
99 renderAliased render x <> ", " <> renderAllAliased render xs
99instance IsString (Expression ps xs 'PGText) where
101instance IsString (Expression ps xs 'PGText) where