@@ -23,6 +23,7 @@ module Database.PostgreSQL.Simple.QueryResults
23 , convertError
23 , convertError
26+import Control.Applicative (Applicative(..), (<$>))
26import Control.Exception (SomeException(..), throw)
27import Control.Exception (SomeException(..), throw)
27import Data.ByteString (ByteString)
28import Data.ByteString (ByteString)
28import qualified Data.ByteString.Char8 as B
29import qualified Data.ByteString.Char8 as B
@@ -211,6 +212,14 @@ instance (Result a, Result b, Result c, Result d, Result e, Result f,
211 return (a,b,c,d,e,f,g,h,i,j)
212 return (a,b,c,d,e,f,g,h,i,j)
212 convertResults fs vs = convertError fs vs 10
213 convertResults fs vs = convertError fs vs 10
215+f <$!> (!x) = f <$> x
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 #-}
214-- | Throw a 'ConversionFailed' exception, indicating a mismatch
223-- | Throw a 'ConversionFailed' exception, indicating a mismatch
215-- between the number of columns in the 'Field' and row, and the
224-- between the number of columns in the 'Field' and row, and the
216-- number in the collection to be converted to.
225-- number in the collection to be converted to.
@@ -233,3 +242,4 @@ ellipsis :: ByteString -> ByteString
233ellipsis bs
242ellipsis bs
234 | B.length bs > 15 = B.take 10 bs `B.append` "[...]"
243 | B.length bs > 15 = B.take 10 bs `B.append` "[...]"
235 | otherwise = bs
244 | otherwise = bs