on dev help sign in
move decoder instance code for composite
commit5677306b938befe2e61b12d0a62b1ceb702575c7 authorEitan Chatav <eitan.chatav@gmail.com> dateWed 11 Apr 2018, 09:13 (9 years ago) parent7b65fb1
1 file changed+8−9
squeal-postgresql/src/Squeal/PostgreSQL/Binary.hs+8−9
squeal-postgresql/src/Squeal/PostgreSQL/Binary.hs+8−9
@@ -203,6 +203,14 @@ instance FromValue pg y => FromValue ('PGfixarray n pg) (Vector (Maybe y)) where
203203 fromValue _ = Decoding.array
204204 (Decoding.dimensionArray Vector.replicateM
205205 (Decoding.nullableValueArray (fromValue (Proxy @pg))))
206+instance
207+ ( SListI fields
208+ , IsMaybes ys
209+ , IsProductType y (Maybes ys)
210+ , AllZip FromAliasedValue fields ys
211+ , SameFields (DatatypeInfoOf y) fields
212+ ) => FromValue ('PGcomposite fields) y where
213+ fromValue = fmap (to . SOP . Z . maybes) . composite . decoders
206214
207215class IsMaybes (xs :: [Type]) where
208216 type family Maybes xs = (mxs :: [Type]) | mxs -> xs
@@ -221,15 +229,6 @@ class FromAliasedValue (pg :: (Symbol,PGType)) (y :: Type) where
221229instance FromValue pg y => FromAliasedValue (alias ::: pg) y where
222230 fromAliasedValue _ = fromValue (Proxy @pg)
223231
224−instance
225− ( SListI fields
226− , IsMaybes ys
227− , IsProductType y (Maybes ys)
228− , AllZip FromAliasedValue fields ys
229− , SameFields (DatatypeInfoOf y) fields
230− ) => FromValue ('PGcomposite fields) y where
231− fromValue = fmap (to . SOP . Z . maybes) . composite . decoders
232−
233232decoders
234233 :: forall pgs ys proxy
235234 . AllZip FromAliasedValue pgs ys