@@ -72,53 +72,57 @@ instance FromValue ('PGType "timestamptz") UTCTime where
7272instance FromValue ('PGType "interval") DiffTime where
7373 fromValue _ = Decoder.interval_int
7474
75−class ToValue (pg :: PGType) x where
75+class ToValue x (pg :: PGType) where
7676 toValue :: Proxy pg -> Encoder x
77−instance ToValue ('PGType "int2") Int16 where
77+instance ToValue Int16 ('PGType "int2") where
7878 toValue _ = Encoder.int2_int16
79−instance ToValue ('PGType "int4") Int32 where
79+instance ToValue Int32 ('PGType "int4") where
8080 toValue _ = Encoder.int4_int32
81−instance ToValue ('PGType "int8") Int64 where
81+instance ToValue Int64 ('PGType "int8") where
8282 toValue _ = Encoder.int8_int64
83−instance ToValue ('PGType "word2") Word16 where
83+instance ToValue Word16 ('PGType "word2") where
8484 toValue _ = Encoder.int2_word16
85−instance ToValue ('PGType "word4") Word32 where
85+instance ToValue Word32 ('PGType "word4") where
8686 toValue _ = Encoder.int4_word32
87−instance ToValue ('PGType "word8") Word64 where
87+instance ToValue Word64 ('PGType "word8") where
8888 toValue _ = Encoder.int8_word64
89−instance ToValue ('PGType "float4") Float where
89+instance ToValue Float ('PGType "float4") where
9090 toValue _ = Encoder.float4
91−instance ToValue ('PGType "float8") Double where
91+instance ToValue Double ('PGType "float8") where
9292 toValue _ = Encoder.float8
93−instance ToValue ('PGType "bool") Bool where
93+instance ToValue Bool ('PGType "bool") where
9494 toValue _ = Encoder.bool
95−instance ToValue ('PGType "bytea") ByteString where
95+instance ToValue ByteString ('PGType "bytea") where
9696 toValue _ = Encoder.bytea_strict
97−instance ToValue ('PGType "bytea") Lazy.ByteString where
97+instance ToValue Lazy.ByteString ('PGType "bytea") where
9898 toValue _ = Encoder.bytea_lazy
99−instance ToValue ('PGType "text") Text where
99+instance ToValue Text ('PGType "text") where
100100 toValue _ = Encoder.text_strict
101−instance ToValue ('PGType "text") Lazy.Text where
101+instance ToValue Lazy.Text ('PGType "text") where
102102 toValue _ = Encoder.text_lazy
103−instance ToValue ('PGType "char") Char where
103+instance ToValue Char ('PGType "char") where
104104 toValue _ = Encoder.char
105−instance ToValue ('PGType "numeric") Scientific where
105+instance ToValue Scientific ('PGType "numeric") where
106106 toValue _ = Encoder.numeric
107−instance ToValue ('PGType "uuid") UUID where
107+instance ToValue UUID ('PGType "uuid") where
108108 toValue _ = Encoder.uuid
109−instance ToJSON x => ToValue ('PGType "json") x where
109+instance ToJSON x => ToValue x ('PGType "json") where
110110 toValue _ = Encoder.json_bytes . Lazy.toStrict . encode
111−instance ToJSON x => ToValue ('PGType "jsonb") x where
111+instance ToJSON x => ToValue x ('PGType "jsonb") where
112112 toValue _ = Encoder.jsonb_bytes . Lazy.toStrict . encode
113−instance ToValue ('PGType "date") Day where
113+instance ToValue Day ('PGType "date") where
114114 toValue _ = Encoder.date
115−instance ToValue ('PGType "time") TimeOfDay where
115+instance ToValue TimeOfDay ('PGType "time") where
116116 toValue _ = Encoder.time_int
117−instance ToValue ('PGType "timetz") (TimeOfDay, TimeZone) where
117+instance ToValue (TimeOfDay, TimeZone) ('PGType "timetz") where
118118 toValue _ = Encoder.timetz_int
119−instance ToValue ('PGType "timestamp") LocalTime where
119+instance ToValue LocalTime ('PGType "timestamp") where
120120 toValue _ = Encoder.timestamp_int
121−instance ToValue ('PGType "timestamptz") UTCTime where
121+instance ToValue UTCTime ('PGType "timestamptz") where
122122 toValue _ = Encoder.timestamptz_int
123−instance ToValue ('PGType "interval") DiffTime where
123+instance ToValue DiffTime ('PGType "interval") where
124124 toValue _ = Encoder.interval_int
125+
126+type family ToParameters ps xs where
127+ ToParameters '[] '[] = ()
128+ ToParameters (x ': xs) (p ': ps) = (ToValue x p, ToParameters xs ps)