@@ -23,6 +23,7 @@ module Database.PostgreSQL.Simple.QueryResults
2323 , convertError
2424 ) where
2525
26+import Control.Applicative (Applicative(..), (<$>))
2627import Control.Exception (SomeException(..), throw)
2728import Data.ByteString (ByteString)
2829import qualified Data.ByteString.Char8 as B
@@ -211,6 +212,14 @@ instance (Result a, Result b, Result c, Result d, Result e, Result f,
211212 return (a,b,c,d,e,f,g,h,i,j)
212213 convertResults fs vs = convertError fs vs 10
213214
215+f <$!> (!x) = f <$> x
216+infixl 4 <$!>
217+
218+instance Result a => QueryResults [a] where
219+ convertResults fs vs = foldr convert' (pure []) (zip fs vs)
220+ where convert' (f,v) as = (:) <$!> convert f v <*> as
221+ {-# INLINE convertResults #-}
222+
214223-- | Throw a 'ConversionFailed' exception, indicating a mismatch
215224-- between the number of columns in the 'Field' and row, and the
216225-- number in the collection to be converted to.
@@ -233,3 +242,4 @@ ellipsis :: ByteString -> ByteString
233242ellipsis bs
234243 | B.length bs > 15 = B.take 10 bs `B.append` "[...]"
235244 | otherwise = bs
245+