@@ -0,0 +1,34 @@
5+ , MultiParamTypeClasses
8+module Squeel.PostgreSQL.Binary2 where
12+import qualified PostgreSQL.Binary.Decoding as Decoding
13+import qualified PostgreSQL.Binary.Encoding as Encoding
15+class ToParam x pg where
16+ toParam :: x -> K Encoding.Encoding pg
17+class ToParams x pgs where
18+ toParams :: x -> NP (K Encoding.Encoding) pgs
20+ :: (IsProductType x xs, AllZip ToParam xs pgs)
21+ => x -> NP (K Encoding.Encoding) pgs
23+ = htrans (Proxy :: Proxy ToParam) (toParam . unI) . unZ . unSOP . from
25+class FromValue pg y where
26+ fromValue :: proxy pg -> Decoding.Value y
27+class FromRow pgs y where
28+ fromRow :: NP proxy pgs -> Decoding.Value y
30+ :: (IsProductType y ys, AllZip FromValue pgs ys)
31+ => NP proxy pgs -> Decoding.Value y
33+ = fmap to . hsequence
34+ . htrans (Proxy :: Proxy FromValue) fromValue . SOP . Z