on dev help sign in
FromValues
commitb997bc66d788f09371723fcce45c9916cdbbefd5 authorEitan Chatav <eitan.chatav@gmail.com> dateFri 16 Jun 2017, 15:53 (9 years ago) parentd23d95c
1 file changed+9
squeel-postgresql/src/Squeel/PostgreSQL/Value.hs+9
squeel-postgresql/src/Squeel/PostgreSQL/Value.hs+9
@@ -81,6 +81,15 @@ instance FromValue 'PGTimestampTZ UTCTime where
8181instance FromValue 'PGInterval DiffTime where
8282 fromValue _ = Decoder.interval_int
8383
84+class FromValues pgs xs where
85+ decodeValues :: Proxy# pgs -> Rec (Const ByteString) xs -> Rec (Either Text) xs
86+instance FromValues '[] '[] where decodeValues _ _ = RNil
87+instance (FromValue pg x, FromValues pgs xs)
88+ => FromValues (pg ': pgs) (x ': xs) where
89+ decodeValues _ (Const result :& results) =
90+ decodeValue (proxy# :: Proxy# pg) result
91+ :& decodeValues (proxy# :: Proxy# pgs) results
92+
8493class ToValue x (pg :: PGType) where
8594 toValue :: Proxy# pg -> Encoder x
8695instance ToValue Int16 'PGInt2 where