@@ -82,7 +82,9 @@ data ResultError = Incompatible { errSQLType :: String
8282
8383instance Exception ResultError
8484
85−left :: Exception a => a -> Either SomeException b
85+type Status = Either SomeException
86+
87+left :: Exception a => a -> Status b
8688left = Left . SomeException
8789
8890-- | A type that may be converted from a SQL type.
@@ -151,7 +153,7 @@ instance Result LB.ByteString where
151153 convert f dat = LB.fromChunks . (:[]) <$> convert f dat
152154
153155unescapeBytea :: Field -> SB.ByteString
154− -> Either SomeException (Binary SB.ByteString)
156+ -> Status (Binary SB.ByteString)
155157unescapeBytea f str = case unsafePerformIO (PQ.unescapeBytea str) of
156158 Nothing -> returnError ConversionFailed f "unescapeBytea failed"
157159 Just str -> pure (Binary str)
@@ -224,8 +226,8 @@ okInt = ok64
224226#endif
225227
226228doConvert :: forall a . (Typeable a)
227− => Field -> Compat -> (ByteString -> Either SomeException a)
228− -> Maybe ByteString -> Either SomeException a
229+ => Field -> Compat -> (ByteString -> Status a)
230+ -> Maybe ByteString -> Status a
229231doConvert f types cvt (Just bs)
230232 | Just typ <- oid2builtin (typeOid f)
231233 , mkCompat typ `compat` types = cvt bs
@@ -235,27 +237,27 @@ doConvert f _ _ _ = returnError UnexpectedNull f ""
235237
236238returnError :: forall a err . (Typeable a, Exception err)
237239 => (String -> String -> String -> err)
238− -> Field -> String -> Either SomeException a
240+ -> Field -> String -> Status a
239241returnError mkErr f = left . mkErr (B.unpack (typename f))
240242 (show (typeOf (undefined :: a)))
241243
242244atto :: forall a. (Typeable a)
243245 => Compat -> Parser a -> Field -> Maybe ByteString
244− -> Either SomeException a
246+ -> Status a
245247atto types p0 f dat = doConvert f types (go p0) dat
246248 where
247− go :: Parser a -> ByteString -> Either SomeException a
249+ go :: Parser a -> ByteString -> Status a
248250 go p s =
249251 case parseOnly p s of
250252 Left err -> returnError ConversionFailed f err
251253 Right v -> Right v
252254
253255atto' :: forall a. (Typeable a)
254− => Compat -> Parser (Either SomeException a) -> Field -> Maybe ByteString
255− -> Either SomeException a
256+ => Compat -> Parser (Status a) -> Field -> Maybe ByteString
257+ -> Status a
256258atto' types p0 f dat = doConvert f types (go p0) dat
257259 where
258− go :: Parser (Either SomeException a) -> ByteString -> Either SomeException a
260+ go :: Parser (Status a) -> ByteString -> Status a
259261 go p s =
260262 case parseOnly p s of
261263 Left err -> returnError ConversionFailed f err