git.iko.soy/typeable/postgresql-simple
on master help sign in
Add "instance (Result a, Result b) => Result (Either a b)"

First, we try to convert the field to a value of type "b", if that fails then we try to convert the field to a value of type "a"

commit2172aec89f2b20a0f4b1462c5beee48a94f90c88 authorLeon P Smith <leon@melding-monads.com> dateTue 3 Jan 2012, 19:17 (15 years ago) parent3ff49e3
1 file changed+8
src/Database/PostgreSQL/Simple/Result.hs+8
src/Database/PostgreSQL/Simple/Result.hs+8
@@ -200,6 +200,14 @@ instance Result TimeOfDay where
200200 case makeTimeOfDayValid hours mins (fromIntegral secs) of
201201 Just t -> return (pure t)
202202 _ -> return (returnError ConversionFailed f "could not parse")
203+
204+instance (Result a, Result b) => Result (Either a b) where
205+ convert f dat = case convert f dat of
206+ Right x -> Right (Right x)
207+ Left _ -> case convert f dat of
208+ Right x -> Right (Left x)
209+ Left e -> Left e
210+
203211newtype Compat = Compat Word64
204212
205213mkCompats :: [BuiltinType] -> Compat