git.iko.soy/typeable/postgresql-simple
on master help sign in
Added the FieldParser synonym and renamed fieldWith
commitda0481b789453b17e7bf6bf17338579a960d7cb5 authorLeon P Smith <leon@melding-monads.com> dateMon 23 Jul 2012, 04:38 (14 years ago) parente16b757
2 files changed+8−5
src/Database/PostgreSQL/Simple/FromField.hs+4−1 src/Database/PostgreSQL/Simple/FromRow.hs+4−4
src/Database/PostgreSQL/Simple/FromField.hs+4−1
@@ -27,6 +27,7 @@
2727module Database.PostgreSQL.Simple.FromField
2828 (
2929 FromField(..)
30+ , FieldParser
3031 , ResultError(..)
3132 , returnError
3233
@@ -95,9 +96,11 @@ instance Exception ResultError
9596left :: Exception a => a -> Ok b
9697left = Errors . (:[]) . SomeException
9798
99+type FieldParser a = Field -> Maybe ByteString -> Ok a
100+
98101-- | A type that may be converted from a SQL type.
99102class FromField a where
100− fromField :: Field -> Maybe ByteString -> Ok a
103+ fromField :: FieldParser a
101104 -- ^ Convert a SQL value to a Haskell value.
102105 --
103106 -- Returns a list of exceptions if the conversion fails. In the case of
src/Database/PostgreSQL/Simple/FromRow.hs+4−4
@@ -20,7 +20,7 @@ module Database.PostgreSQL.Simple.FromRow
2020 ( FromRow(..)
2121 , RowParser
2222 , field
23− , field'
23+ , fieldWith
2424 , numFieldsRemaining
2525 ) where
2626
@@ -65,8 +65,8 @@ import Data.Vector ((!))
6565class FromRow a where
6666 fromRow :: RowParser a
6767
68−field' :: (Field -> Maybe ByteString -> Ok a) -> RowParser a
69−field' fieldP = RP $ do
68+fieldWith :: FieldParser a -> RowParser a
69+fieldWith fieldP = RP $ do
7070 let unCol (PQ.Col x) = fromIntegral x :: Int
7171 Row{..} <- ask
7272 column <- lift get
@@ -91,7 +91,7 @@ field' fieldP = RP $ do
9191 lift (lift (fieldP field (getvalue result row column)))
9292
9393field :: FromField a => RowParser a
94−field = field' fromField
94+field = fieldWith fromField
9595
9696ellipsis :: ByteString -> ByteString
9797ellipsis bs