@@ -72,53 +72,57 @@ instance FromValue ('PGType "timestamptz") UTCTime where
72instance FromValue ('PGType "interval") DiffTime where
72instance FromValue ('PGType "interval") DiffTime where
73 fromValue _ = Decoder.interval_int
73 fromValue _ = Decoder.interval_int
75−class ToValue (pg :: PGType) x where
75+class ToValue x (pg :: PGType) where
76 toValue :: Proxy pg -> Encoder x
76 toValue :: Proxy pg -> Encoder x
77−instance ToValue ('PGType "int2") Int16 where
77+instance ToValue Int16 ('PGType "int2") where
78 toValue _ = Encoder.int2_int16
78 toValue _ = Encoder.int2_int16
79−instance ToValue ('PGType "int4") Int32 where
79+instance ToValue Int32 ('PGType "int4") where
80 toValue _ = Encoder.int4_int32
80 toValue _ = Encoder.int4_int32
81−instance ToValue ('PGType "int8") Int64 where
81+instance ToValue Int64 ('PGType "int8") where
82 toValue _ = Encoder.int8_int64
82 toValue _ = Encoder.int8_int64
83−instance ToValue ('PGType "word2") Word16 where
83+instance ToValue Word16 ('PGType "word2") where
84 toValue _ = Encoder.int2_word16
84 toValue _ = Encoder.int2_word16
85−instance ToValue ('PGType "word4") Word32 where
85+instance ToValue Word32 ('PGType "word4") where
86 toValue _ = Encoder.int4_word32
86 toValue _ = Encoder.int4_word32
87−instance ToValue ('PGType "word8") Word64 where
87+instance ToValue Word64 ('PGType "word8") where
88 toValue _ = Encoder.int8_word64
88 toValue _ = Encoder.int8_word64
89−instance ToValue ('PGType "float4") Float where
89+instance ToValue Float ('PGType "float4") where
90 toValue _ = Encoder.float4
90 toValue _ = Encoder.float4
91−instance ToValue ('PGType "float8") Double where
91+instance ToValue Double ('PGType "float8") where
92 toValue _ = Encoder.float8
92 toValue _ = Encoder.float8
93−instance ToValue ('PGType "bool") Bool where
93+instance ToValue Bool ('PGType "bool") where
94 toValue _ = Encoder.bool
94 toValue _ = Encoder.bool
95−instance ToValue ('PGType "bytea") ByteString where
95+instance ToValue ByteString ('PGType "bytea") where
96 toValue _ = Encoder.bytea_strict
96 toValue _ = Encoder.bytea_strict
97−instance ToValue ('PGType "bytea") Lazy.ByteString where
97+instance ToValue Lazy.ByteString ('PGType "bytea") where
98 toValue _ = Encoder.bytea_lazy
98 toValue _ = Encoder.bytea_lazy
99−instance ToValue ('PGType "text") Text where
99+instance ToValue Text ('PGType "text") where
100 toValue _ = Encoder.text_strict
100 toValue _ = Encoder.text_strict
101−instance ToValue ('PGType "text") Lazy.Text where
101+instance ToValue Lazy.Text ('PGType "text") where
102 toValue _ = Encoder.text_lazy
102 toValue _ = Encoder.text_lazy
103−instance ToValue ('PGType "char") Char where
103+instance ToValue Char ('PGType "char") where
104 toValue _ = Encoder.char
104 toValue _ = Encoder.char
105−instance ToValue ('PGType "numeric") Scientific where
105+instance ToValue Scientific ('PGType "numeric") where
106 toValue _ = Encoder.numeric
106 toValue _ = Encoder.numeric
107−instance ToValue ('PGType "uuid") UUID where
107+instance ToValue UUID ('PGType "uuid") where
108 toValue _ = Encoder.uuid
108 toValue _ = Encoder.uuid
109−instance ToJSON x => ToValue ('PGType "json") x where
109+instance ToJSON x => ToValue x ('PGType "json") where
110 toValue _ = Encoder.json_bytes . Lazy.toStrict . encode
110 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
112 toValue _ = Encoder.jsonb_bytes . Lazy.toStrict . encode
112 toValue _ = Encoder.jsonb_bytes . Lazy.toStrict . encode
113−instance ToValue ('PGType "date") Day where
113+instance ToValue Day ('PGType "date") where
114 toValue _ = Encoder.date
114 toValue _ = Encoder.date
115−instance ToValue ('PGType "time") TimeOfDay where
115+instance ToValue TimeOfDay ('PGType "time") where
116 toValue _ = Encoder.time_int
116 toValue _ = Encoder.time_int
117−instance ToValue ('PGType "timetz") (TimeOfDay, TimeZone) where
117+instance ToValue (TimeOfDay, TimeZone) ('PGType "timetz") where
118 toValue _ = Encoder.timetz_int
118 toValue _ = Encoder.timetz_int
119−instance ToValue ('PGType "timestamp") LocalTime where
119+instance ToValue LocalTime ('PGType "timestamp") where
120 toValue _ = Encoder.timestamp_int
120 toValue _ = Encoder.timestamp_int
121−instance ToValue ('PGType "timestamptz") UTCTime where
121+instance ToValue UTCTime ('PGType "timestamptz") where
122 toValue _ = Encoder.timestamptz_int
122 toValue _ = Encoder.timestamptz_int
123−instance ToValue ('PGType "interval") DiffTime where
123+instance ToValue DiffTime ('PGType "interval") where
124 toValue _ = Encoder.interval_int
124 toValue _ = Encoder.interval_int
126+type family ToParameters ps xs where
127+ ToParameters '[] '[] = ()
128+ ToParameters (x ': xs) (p ': ps) = (ToValue x p, ToParameters xs ps)