diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,27 @@
+# hpqtypes-1.4.0 (2015-02-26)
+* add support for QuickCheck 2.7
+* add support for notifications
+* remove SpaceMonoid, use Monoid and IsString instead
+* use data-default-class package for default values
+* drop Single, use Identity functor instead
+* remove someSQL from IsSQL class
+* remove foldlM/foldrM from MonadDB and make QueryResult instance of Foldable instead
+* add support for a type representing cartesian product of rows for more composability
+* do not wrap exceptions thrown from DBT in DBException unless explicitly requested
+* provide custom Show instance for Interval
+* add ToSQL instance for Int
+
+# hpqtypes-1.3.2 (2015-01-27)
+* replace wrong package uploaded to hackage
+
+# hpqtypes-1.3.1 (2015-01-26)
+* add support for XML type
+
+# hpqtypes-1.3.0 (2015-01-09)
+* composite: make {from,to}Composite functions pure
+
+# hpqtypes-1.2.5 (2015-01-04)
+* add support for monad-control >= 1.0.0.1
+
+# hpqtypes-1.2.4 (2014-12-08)
+* add IsString instance for Savepoint newtype
diff --git a/LICENSE b/LICENSE
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2013, Scrive
+Copyright (c) 2013-2015, Scrive
 
 All rights reserved.
 
diff --git a/examples/Catalog.hs b/examples/Catalog.hs
--- a/examples/Catalog.hs
+++ b/examples/Catalog.hs
@@ -9,7 +9,7 @@
 import Data.Function
 import Data.Int
 import Data.Monoid
-import Data.Monoid.Space
+import Data.Monoid.Utils
 import Database.PostgreSQL.PQTypes
 import Database.PostgreSQL.PQTypes.Internal.Utils (mread)
 import System.Console.Readline
@@ -20,18 +20,12 @@
 printLn :: MonadBase IO m => String -> m ()
 printLn = liftBase . putStrLn
 
--- | Run 'DBT' over 'IO'.
-runDB :: ConnectionSource -> DBT IO a -> IO a
-runDB cs = runDBT cs defaultTransactionSettings
-
 -- | Get connection string from command line argument.
 getConnSettings :: IO ConnectionSettings
 getConnSettings = do
   args <- getArgs
   case args of
-    [conninfo] -> return defaultSettings {
-      csConnInfo = BS.pack conninfo
-    }
+    [conninfo] -> return def { csConnInfo = BS.pack conninfo }
     _ -> do
       prog <- getProgName
       error $ "Usage:" <+> prog <+> "<connection info>"
@@ -52,7 +46,7 @@
   pqFormat _ = "%book_"
 
 instance CompositeFromSQL Book where
-  toComposite (bid, name, year) = return Book {
+  toComposite (bid, name, year) = Book {
     bookID = bid
   , bookName = name
   , bookYear = year
@@ -62,7 +56,7 @@
 withCatalog cs = bracket_ createStructure dropStructure
   where
     -- | Create needed tables and types.
-    createStructure = runDB (defaultSource cs) $ do
+    createStructure = runDBT (simpleSource cs) def $ do
       printLn "Creating tables..."
       runSQL_ $ mconcat [
           "CREATE TABLE authors_ ("
@@ -89,7 +83,7 @@
         , ")"
         ]
     -- | Drop previously created database structures.
-    dropStructure = runDB (defaultSource cs) $ do
+    dropStructure = runDBT (simpleSource cs) def $ do
       printLn "Dropping tables..."
       runSQL_ "DROP TYPE book_"
       runSQL_ "DROP TABLE books_"
@@ -100,24 +94,23 @@
 processCommand :: ConnectionSource -> String -> IO ()
 processCommand cs cmd = case parse cmd of
   -- | Display authors.
-  ("authors", "") -> runDB cs $ do
+  ("authors", "") -> runDBT cs def $ do
     runSQL_ "SELECT * FROM authors_ ORDER BY name"
-    foldlM (\_ (aid::Int64, name) -> printLn $ show aid <> ":" <+> name) ()
+    mapDB_ $ \(aid::Int64, name) -> printLn $ show aid <> ":" <+> name
   -- | Display books.
-  ("books", "") -> runDB cs $ do
+  ("books", "") -> runDBT cs def $ do
     runSQL_ "SELECT a.name, ARRAY(SELECT (b.id, b.name, b.year)::book_ FROM books_ b WHERE b.author_id = a.id) FROM authors_ a ORDER BY a.name"
-    foldlM (\_ (author, CompositeArray1 (books::[Book])) -> do
+    mapDB_ $ \(author, CompositeArray1 (books::[Book])) -> do
       printLn $ author <> ":"
       forM_ books $ \book -> printLn $ "*" <+> show book
-      ) ()
   -- | Insert an author.
   ("insert_author", mname) -> case mread mname of
-    Just (name::String) -> runDB cs . runQuery_ $
+    Just (name::String) -> runDBT cs def . runQuery_ $
       "INSERT INTO authors_ (name) VALUES (" <?> name <+> ")"
     Nothing -> printLn $ "Invalid name"
   -- | Insert a book.
   ("insert_book", mbook) -> case mread mbook of
-    Just record -> runDB cs . runQuery_ $ rawSQL
+    Just record -> runDBT cs def . runQuery_ $ rawSQL
       "INSERT INTO books_ (name, year, author_id) VALUES ($1, $2, $3)"
       (record::(String, Int32, Int64))
     Nothing -> printLn $ "Invalid book record"
diff --git a/hpqtypes.cabal b/hpqtypes.cabal
--- a/hpqtypes.cabal
+++ b/hpqtypes.cabal
@@ -1,5 +1,5 @@
 name:                hpqtypes
-version:             1.3.2
+version:             1.4.0
 synopsis:            Haskell bindings to libpqtypes
 
 description:         Efficient and easy-to-use bindings to (slightly modified)
@@ -31,7 +31,8 @@
 build-type:          Custom
 cabal-version:       >= 1.8
 
-extra-source-files: examples/Catalog.hs
+extra-source-files: CHANGELOG.md
+                  , examples/Catalog.hs
                   , libpqtypes/AUTHORS
                   , libpqtypes/Makefile.in
                   , libpqtypes/config.guess
@@ -60,8 +61,7 @@
   default: False
 
 library
-  exposed-modules:     Data.Monoid.Space
-                     , Data.Monoid.Utils
+  exposed-modules:     Data.Monoid.Utils
                      , Database.PostgreSQL.PQTypes
                      , Database.PostgreSQL.PQTypes.Composite
                      , Database.PostgreSQL.PQTypes.ToRow
@@ -78,8 +78,8 @@
                      , Database.PostgreSQL.PQTypes.Format
                      , Database.PostgreSQL.PQTypes.Binary
                      , Database.PostgreSQL.PQTypes.Interval
+                     , Database.PostgreSQL.PQTypes.Notification
                      , Database.PostgreSQL.PQTypes.SQL
-                     , Database.PostgreSQL.PQTypes.Single
                      , Database.PostgreSQL.PQTypes.SQL.Raw
                      , Database.PostgreSQL.PQTypes.SQL.Class
                      , Database.PostgreSQL.PQTypes.Transaction.Settings
@@ -91,6 +91,7 @@
                      , Database.PostgreSQL.PQTypes.Internal.Connection
                      , Database.PostgreSQL.PQTypes.Internal.Exception
                      , Database.PostgreSQL.PQTypes.Internal.Monad
+                     , Database.PostgreSQL.PQTypes.Internal.Notification
                      , Database.PostgreSQL.PQTypes.Internal.QueryResult
                      , Database.PostgreSQL.PQTypes.Internal.Query
                      , Database.PostgreSQL.PQTypes.Internal.State
@@ -112,6 +113,7 @@
                      , transformers >= 0.2.2
                      , containers >= 0.4.0.0
                      , exceptions >= 0.6
+                     , data-default-class
 
   hs-source-dirs:    src
 
@@ -160,7 +162,7 @@
                      , monad-control >= 0.3
                      , lifted-base >= 0.2
                      , mtl >= 2.1
-                     , QuickCheck >= 2.5 && < 2.7
+                     , QuickCheck >= 2.5
                      , HUnit >= 1.2
                      , test-framework >= 0.8
                      , test-framework-hunit >= 0.3
diff --git a/src/Data/Monoid/Space.hs b/src/Data/Monoid/Space.hs
deleted file mode 100644
--- a/src/Data/Monoid/Space.hs
+++ /dev/null
@@ -1,41 +0,0 @@
-{-# LANGUAGE FlexibleInstances #-}
-module Data.Monoid.Space (
-    SpaceMonoid(..)
-  , smappend
-  , smconcat
-  , (<+>)
-  ) where
-
-import Data.Monoid
-import qualified Data.Text as T
-import qualified Data.ByteString as BS
-
-import Data.Monoid.Utils
-
--- | Extension of 'Monoid' which abstracts the notion of \'separator\'.
-class Monoid m => SpaceMonoid m where
-  mspace :: m
-
-instance SpaceMonoid String where
-  mspace = " "
-
-instance SpaceMonoid BS.ByteString where
-  mspace = BS.singleton 32
-
-instance SpaceMonoid T.Text where
-  mspace = T.singleton ' '
-
-----------------------------------------
-
--- | Concatenate two elements with separator between them.
-smappend :: SpaceMonoid m => m -> m -> m
-smappend a b = mconcat [a, mspace, b]
-
--- | Concatenate a list of elements, inserting separators between them.
-smconcat :: SpaceMonoid m => [m] -> m
-smconcat = mintercalate mspace
-
--- | Infix version of 'smappend'.
-(<+>) :: SpaceMonoid m => m -> m -> m
-(<+>) = smappend
-infixr 6 <+>
diff --git a/src/Data/Monoid/Utils.hs b/src/Data/Monoid/Utils.hs
--- a/src/Data/Monoid/Utils.hs
+++ b/src/Data/Monoid/Utils.hs
@@ -1,10 +1,32 @@
 module Data.Monoid.Utils (
     mintercalate
+  , mspace
+  , smappend
+  , smconcat
+  , (<+>)
   ) where
 
 import Data.List
 import Data.Monoid
+import Data.String
 
 -- | Generalization of 'intercalate' to arbitrary 'Monoid'.
 mintercalate :: Monoid m => m -> [m] -> m
 mintercalate m = mconcat . intersperse m
+
+-- | Generalization of separator to arbitrary 'Monoid'.
+mspace :: (IsString m, Monoid m) => m
+mspace = fromString " "
+
+-- | Concatenate two elements with separator between them.
+smappend :: (IsString m, Monoid m) => m -> m -> m
+smappend a b = mconcat [a, mspace, b]
+
+-- | Concatenate a list of elements, inserting separators between them.
+smconcat :: (IsString m, Monoid m) => [m] -> m
+smconcat = mintercalate mspace
+
+-- | Infix version of 'smappend'.
+(<+>) :: (IsString m, Monoid m) => m -> m -> m
+(<+>) = smappend
+infixr 6 <+>
diff --git a/src/Database/PostgreSQL/PQTypes.hs b/src/Database/PostgreSQL/PQTypes.hs
--- a/src/Database/PostgreSQL/PQTypes.hs
+++ b/src/Database/PostgreSQL/PQTypes.hs
@@ -5,9 +5,8 @@
     Connection
   , ConnectionStats(..)
   , ConnectionSettings(..)
-  , defaultSettings
   , ConnectionSource
-  , defaultSource
+  , simpleSource
   , poolSource
   -- Database.PostgreSQL.PQTypes.Internal.Error
   -- * Exceptions
@@ -36,6 +35,7 @@
   , ntuples
   , nfields
   -- * Other modules
+  , module Data.Functor.Identity
   , module Database.PostgreSQL.PQTypes.Array
   , module Database.PostgreSQL.PQTypes.Binary
   , module Database.PostgreSQL.PQTypes.Class
@@ -45,7 +45,7 @@
   , module Database.PostgreSQL.PQTypes.FromRow
   , module Database.PostgreSQL.PQTypes.FromSQL
   , module Database.PostgreSQL.PQTypes.Interval
-  , module Database.PostgreSQL.PQTypes.Single
+  , module Database.PostgreSQL.PQTypes.Notification
   , module Database.PostgreSQL.PQTypes.SQL
   , module Database.PostgreSQL.PQTypes.SQL.Class
   , module Database.PostgreSQL.PQTypes.SQL.Raw
@@ -57,6 +57,8 @@
   , module Database.PostgreSQL.PQTypes.XML
   ) where
 
+import Data.Functor.Identity
+
 import Database.PostgreSQL.PQTypes.Internal.Connection
 import Database.PostgreSQL.PQTypes.Internal.Error
 import Database.PostgreSQL.PQTypes.Internal.Error.Code
@@ -74,7 +76,7 @@
 import Database.PostgreSQL.PQTypes.FromRow
 import Database.PostgreSQL.PQTypes.FromSQL
 import Database.PostgreSQL.PQTypes.Interval
-import Database.PostgreSQL.PQTypes.Single
+import Database.PostgreSQL.PQTypes.Notification
 import Database.PostgreSQL.PQTypes.SQL
 import Database.PostgreSQL.PQTypes.SQL.Class
 import Database.PostgreSQL.PQTypes.SQL.Raw
diff --git a/src/Database/PostgreSQL/PQTypes/Array.hs b/src/Database/PostgreSQL/PQTypes/Array.hs
--- a/src/Database/PostgreSQL/PQTypes/Array.hs
+++ b/src/Database/PostgreSQL/PQTypes/Array.hs
@@ -25,6 +25,7 @@
 import Foreign.Storable
 import qualified Control.Exception as E
 import qualified Data.ByteString.Char8 as BS
+import qualified Data.ByteString.Unsafe as BS
 import qualified Data.Vector.Storable as V
 
 import Database.PostgreSQL.PQTypes.Composite
@@ -53,9 +54,8 @@
 instance FromSQL t => FromSQL (Array1 t) where
   type PQBase (Array1 t) = PGarray
   fromSQL Nothing = unexpectedNULL
-  fromSQL (Just arr) = getArray1 Array1 arr ffmt getItem
+  fromSQL (Just arr) = getArray1 Array1 arr getItem
     where
-      ffmt = pqFormat (undefined::t)
       getItem res err i ptr fmt = do
         verifyPQTRes err "fromSQL (Array1)" =<< c_PQgetf1 res err i fmt 0 ptr
         isNull <- c_PQgetisnull res i 0
@@ -85,10 +85,9 @@
 instance CompositeFromSQL t => FromSQL (CompositeArray1 t) where
   type PQBase (CompositeArray1 t) = PGarray
   fromSQL Nothing = unexpectedNULL
-  fromSQL (Just arr) = getArray1 CompositeArray1 arr ffmt getItem
+  fromSQL (Just arr) = getArray1 CompositeArray1 arr getItem
     where
-      ffmt = pqFormat (undefined::CompositeRow t)
-      getItem res err i (_::Ptr CInt) fmt = toComposite <$> fromRow res err i fmt
+      getItem res err i (_::Ptr CInt) _ = toComposite <$> fromRow res err 0 i
 
 instance CompositeToSQL t => ToSQL (CompositeArray1 t) where
   type PQDest (CompositeArray1 t) = PGarray
@@ -110,7 +109,7 @@
           -- along with its format and puts it into inner 'PGparam'.
           -> IO r
 putArray1 arr param conv putItem = do
-  BS.useAsCString (pqFormat (undefined::t)) $ forM_ arr . putItem
+  pqFormat0 (undefined::t) `BS.unsafeUseAsCString` (forM_ arr . putItem)
   put (PGarray {
     pgArrayNDims = 0
   , pgArrayLBound = V.empty
@@ -121,15 +120,14 @@
 
 -- | Helper function for getting elements of
 -- 'Array1' / 'CompositeArray1' out of 'PGarray'.
-getArray1 :: forall a array t. Storable a
+getArray1 :: forall a array t. (PQFormat t, Storable a)
           => ([t] -> array) -- ^ Array constructor.
           -> PGarray -- ^ Source 'PGarray'.
-          -> BS.ByteString -- ^ Format for getting an item from 'PGarray'.
           -> (Ptr PGresult -> Ptr PGerror -> CInt -> Ptr a -> CString -> IO t) -- ^
           -- Function that takes an item with a given index
           -- out of 'PGresult' and stores it in provided 'Ptr'.
           -> IO array
-getArray1 con PGarray{..} ffmt getItem = flip E.finally (c_PQclear pgArrayRes) $
+getArray1 con PGarray{..} getItem = flip E.finally (c_PQclear pgArrayRes) $
   if pgArrayNDims > 1
     then E.throwIO ArrayDimensionMismatch {
         arrDimExpected = 1
@@ -137,8 +135,8 @@
       }
     else do
       size <- c_PQntuples pgArrayRes
-      alloca $ \err -> alloca $ \ptr ->
-        BS.useAsCString ffmt $ loop [] (size - 1) err ptr
+      alloca $ \err -> alloca $ \ptr -> pqFormat0 (undefined::t)
+        `BS.unsafeUseAsCString` loop [] (size - 1) err ptr
   where
     loop :: [t] -> CInt -> Ptr PGerror -> Ptr a -> CString -> IO array
     loop acc !i err ptr fmt = case i of
@@ -163,9 +161,8 @@
 instance FromSQL t => FromSQL (Array2 t) where
   type PQBase (Array2 t) = PGarray
   fromSQL Nothing = unexpectedNULL
-  fromSQL (Just arr) = getArray2 Array2 arr ffmt getItem
+  fromSQL (Just arr) = getArray2 Array2 arr getItem
     where
-      ffmt = pqFormat (undefined::t)
       getItem res err i ptr fmt = do
         verifyPQTRes err "fromSQL (Array2)" =<< c_PQgetf1 res err i fmt 0 ptr
         isNull <- c_PQgetisnull res i 0
@@ -195,10 +192,9 @@
 instance CompositeFromSQL t => FromSQL (CompositeArray2 t) where
   type PQBase (CompositeArray2 t) = PGarray
   fromSQL Nothing = unexpectedNULL
-  fromSQL (Just arr) = getArray2 CompositeArray2 arr ffmt getItem
+  fromSQL (Just arr) = getArray2 CompositeArray2 arr getItem
     where
-      ffmt = pqFormat (undefined::CompositeRow t)
-      getItem res err i (_::Ptr CInt) fmt = toComposite <$> fromRow res err i fmt
+      getItem res err i (_::Ptr CInt) _ = toComposite <$> fromRow res err 0 i
 
 instance CompositeToSQL t => ToSQL (CompositeArray2 t) where
   type PQDest (CompositeArray2 t) = PGarray
@@ -220,7 +216,7 @@
           -- along with its format and puts it into inner 'PGparam'.
           -> IO r
 putArray2 arr param conv putItem = do
-  dims <- BS.useAsCString (pqFormat (undefined::t)) $ loop arr 0 0
+  dims <- pqFormat0 (undefined::t) `BS.unsafeUseAsCString` loop arr 0 0
   put (PGarray {
     pgArrayNDims = 2
   , pgArrayLBound = V.fromList [1, 1]
@@ -247,15 +243,14 @@
 
 -- | Helper function for getting elements of
 -- 'Array2' / 'CompositeArray2' out of 'PGarray'.
-getArray2 :: forall a array t. Storable a
+getArray2 :: forall a array t. (PQFormat t, Storable a)
           => ([[t]] -> array) -- ^ Array constructor.
           -> PGarray -- ^ Source 'PGarray'.
-          -> BS.ByteString -- ^ Format for getting an item from 'PGarray'.
           -> (Ptr PGresult -> Ptr PGerror -> CInt -> Ptr a -> CString -> IO t) -- ^
           -- Function that takes an item with a given index
           -- out of 'PGresult' and stores it in provided 'Ptr'.
           -> IO array
-getArray2 con PGarray{..} ffmt getItem = flip E.finally (c_PQclear pgArrayRes) $ do
+getArray2 con PGarray{..} getItem = flip E.finally (c_PQclear pgArrayRes) $ do
   if pgArrayNDims /= 0 && pgArrayNDims /= 2
     then E.throwIO ArrayDimensionMismatch {
         arrDimExpected = 2
@@ -264,8 +259,8 @@
     else do
       let dim2 = pgArrayDims V.! 1
       size <- c_PQntuples pgArrayRes
-      alloca $ \ptr -> alloca $ \err ->
-        BS.useAsCString ffmt $ loop [] dim2 size err ptr
+      alloca $ \ptr -> alloca $ \err -> pqFormat0 (undefined::t)
+        `BS.unsafeUseAsCString` loop [] dim2 size err ptr
   where
     loop :: [[t]] -> CInt -> CInt -> Ptr PGerror -> Ptr a -> CString -> IO array
     loop acc dim2 !i err ptr fmt = case i of
diff --git a/src/Database/PostgreSQL/PQTypes/Binary.hs b/src/Database/PostgreSQL/PQTypes/Binary.hs
--- a/src/Database/PostgreSQL/PQTypes/Binary.hs
+++ b/src/Database/PostgreSQL/PQTypes/Binary.hs
@@ -23,7 +23,7 @@
 unBinary (Binary b) = b
 
 instance PQFormat (Binary BS.ByteString) where
-  pqFormat _ = BS.pack "%bytea"
+  pqFormat = const $ BS.pack "%bytea"
 
 instance FromSQL (Binary BS.ByteString) where
   type PQBase (Binary BS.ByteString) = PGbytea
diff --git a/src/Database/PostgreSQL/PQTypes/Class.hs b/src/Database/PostgreSQL/PQTypes/Class.hs
--- a/src/Database/PostgreSQL/PQTypes/Class.hs
+++ b/src/Database/PostgreSQL/PQTypes/Class.hs
@@ -6,6 +6,7 @@
 
 import Database.PostgreSQL.PQTypes.FromRow
 import Database.PostgreSQL.PQTypes.Internal.Connection
+import Database.PostgreSQL.PQTypes.Internal.Notification
 import Database.PostgreSQL.PQTypes.Internal.QueryResult
 import Database.PostgreSQL.PQTypes.Transaction.Settings
 import Database.PostgreSQL.PQTypes.SQL.Class
@@ -15,7 +16,7 @@
   -- for a given connection, only one thread may be executing 'runQuery' at
   -- a given time. If simultaneous call is made from another thread, it
   -- will block until currently running 'runQuery' finishes.
-  runQuery     :: IsSQL sql => sql -> m Int
+  runQuery :: IsSQL sql => sql -> m Int
   -- | Get last SQL query that was executed.
   getLastQuery :: m SomeSQL
 
@@ -23,7 +24,7 @@
   getConnectionStats :: m ConnectionStats
 
   -- | Get current query result.
-  getQueryResult   :: m (Maybe QueryResult)
+  getQueryResult :: FromRow row => m (Maybe (QueryResult row))
   -- | Clear current query result.
   clearQueryResult :: m ()
 
@@ -34,10 +35,22 @@
   -- only the subsequent ones.
   setTransactionSettings :: TransactionSettings -> m ()
 
-  -- | Fold the result set of rows from left to right.
-  foldlM :: FromRow row => (acc -> row -> m acc) -> acc -> m acc
-  -- | Fold the result set of rows from right to left.
-  foldrM :: FromRow row => (row -> acc -> m acc) -> acc -> m acc
+  -- | Attempt to receive a notification from the server. This
+  -- function waits until a notification arrives or specified
+  -- number of microseconds has passed. If a negative number
+  -- of microseconds is passed as an argument, it will wait
+  -- indefinitely. In addition, there are a couple of things
+  -- to be aware of:
+  --
+  -- * A lock on the underlying database connection is acquired
+  -- for the duration of the function.
+  --
+  -- * Notifications can be received only between transactions
+  -- (see <http://www.postgresql.org/docs/current/static/sql-notify.html>
+  -- for further info), therefore calling this function within
+  -- a transaction block will return 'Just' only if notifications
+  -- were received before the transaction began.
+  getNotification :: Int -> m (Maybe Notification)
 
   -- | Execute supplied monadic action with new connection
   -- using current connection source and transaction settings.
diff --git a/src/Database/PostgreSQL/PQTypes/Class/Instances.hs b/src/Database/PostgreSQL/PQTypes/Class/Instances.hs
--- a/src/Database/PostgreSQL/PQTypes/Class/Instances.hs
+++ b/src/Database/PostgreSQL/PQTypes/Class/Instances.hs
@@ -2,7 +2,6 @@
 {-# LANGUAGE FlexibleContexts, UndecidableInstances #-}
 module Database.PostgreSQL.PQTypes.Class.Instances where
 
-import Control.Applicative
 import Control.Monad.Trans
 import Control.Monad.Trans.Error
 import Control.Monad.Trans.Identity
@@ -27,10 +26,7 @@
   clearQueryResult = lift clearQueryResult
   getTransactionSettings = lift getTransactionSettings
   setTransactionSettings = lift . setTransactionSettings
-  foldlM f = ErrorT . foldlM (\acc row ->
-    either (return . Left) (\k -> runErrorT $ f k row) acc) . Right
-  foldrM f = ErrorT . foldrM (\row acc ->
-    either (return . Left) (\k -> runErrorT $ f row k) acc) . Right
+  getNotification = lift . getNotification
   withNewConnection = mapErrorT withNewConnection
 
 instance MonadDB m => MonadDB (IdentityT m) where
@@ -41,8 +37,7 @@
   clearQueryResult = lift clearQueryResult
   getTransactionSettings = lift getTransactionSettings
   setTransactionSettings = lift . setTransactionSettings
-  foldlM f = IdentityT . foldlM (\acc row -> runIdentityT $ f acc row)
-  foldrM f = IdentityT . foldrM (\row acc -> runIdentityT $ f row acc)
+  getNotification = lift . getNotification
   withNewConnection = mapIdentityT withNewConnection
 
 instance MonadDB m => MonadDB (ListT m) where
@@ -53,10 +48,7 @@
   clearQueryResult = lift clearQueryResult
   getTransactionSettings = lift getTransactionSettings
   setTransactionSettings = lift . setTransactionSettings
-  foldlM f = ListT . foldlM (\acc row ->
-    concat <$> mapM (\k -> runListT $ f k row) acc) . return
-  foldrM f = ListT . foldrM (\row acc ->
-    concat <$> mapM (\k -> runListT $ f row k) acc) . return
+  getNotification = lift . getNotification
   withNewConnection = mapListT withNewConnection
 
 instance MonadDB m => MonadDB (MaybeT m) where
@@ -67,10 +59,7 @@
   clearQueryResult = lift clearQueryResult
   getTransactionSettings = lift getTransactionSettings
   setTransactionSettings = lift . setTransactionSettings
-  foldlM f = MaybeT . foldlM (\acc row ->
-    maybe (return Nothing) (\k -> runMaybeT $ f k row) acc) . Just
-  foldrM f = MaybeT . foldrM (\row acc ->
-    maybe (return Nothing) (\k -> runMaybeT $ f row k) acc) . Just
+  getNotification = lift . getNotification
   withNewConnection = mapMaybeT withNewConnection
 
 instance (Monoid w, MonadDB m) => MonadDB (L.RWST r w s m) where
@@ -81,12 +70,7 @@
   clearQueryResult = lift clearQueryResult
   getTransactionSettings = lift getTransactionSettings
   setTransactionSettings = lift . setTransactionSettings
-  foldlM f acc = L.RWST $ \r s -> foldlM (\ ~(acc', s', w) row -> do
-    ~(a, s'', w') <- L.runRWST (f acc' row) r s'
-    return (a, s'', w `mappend` w')) (acc, s, mempty)
-  foldrM f acc = L.RWST $ \r s -> foldrM (\row ~(acc', s', w) -> do
-    ~(a, s'', w') <- L.runRWST (f row acc') r s'
-    return (a, s'', w `mappend` w')) (acc, s, mempty)
+  getNotification = lift . getNotification
   withNewConnection = L.mapRWST withNewConnection
 
 instance (Monoid w, MonadDB m) => MonadDB (S.RWST r w s m) where
@@ -97,12 +81,7 @@
   clearQueryResult = lift clearQueryResult
   getTransactionSettings = lift getTransactionSettings
   setTransactionSettings = lift . setTransactionSettings
-  foldlM f acc = S.RWST $ \r s -> foldlM (\(acc', s', w) row -> do
-    (a, s'', w') <- S.runRWST (f acc' row) r s'
-    return (a, s'', w `mappend` w')) (acc, s, mempty)
-  foldrM f acc = S.RWST $ \r s -> foldrM (\row (acc', s', w) -> do
-    (a, s'', w') <- S.runRWST (f row acc') r s'
-    return (a, s'', w `mappend` w')) (acc, s, mempty)
+  getNotification = lift . getNotification
   withNewConnection = S.mapRWST withNewConnection
 
 instance MonadDB m => MonadDB (ReaderT r m) where
@@ -113,10 +92,7 @@
   clearQueryResult = lift clearQueryResult
   getTransactionSettings = lift getTransactionSettings
   setTransactionSettings = lift . setTransactionSettings
-  foldlM f acc = ReaderT $ \r -> foldlM (\acc' row ->
-    runReaderT (f acc' row) r) acc
-  foldrM f acc = ReaderT $ \r -> foldrM (\row acc' ->
-    runReaderT (f row acc') r) acc
+  getNotification = lift . getNotification
   withNewConnection = mapReaderT withNewConnection
 
 instance MonadDB m => MonadDB (L.StateT s m) where
@@ -127,10 +103,7 @@
   clearQueryResult = lift clearQueryResult
   getTransactionSettings = lift getTransactionSettings
   setTransactionSettings = lift . setTransactionSettings
-  foldlM f acc = L.StateT $ \s -> foldlM (\ ~(acc', s') row ->
-    L.runStateT (f acc' row) s') (acc, s)
-  foldrM f acc = L.StateT $ \s -> foldrM (\row ~(acc', s') ->
-    L.runStateT (f row acc') s') (acc, s)
+  getNotification = lift . getNotification
   withNewConnection = L.mapStateT withNewConnection
 
 instance MonadDB m => MonadDB (S.StateT s m) where
@@ -141,10 +114,7 @@
   clearQueryResult = lift clearQueryResult
   getTransactionSettings = lift getTransactionSettings
   setTransactionSettings = lift . setTransactionSettings
-  foldlM f acc = S.StateT $ \s -> foldlM (\(acc', s') row ->
-    S.runStateT (f acc' row) s') (acc, s)
-  foldrM f acc = S.StateT $ \s -> foldrM (\row (acc', s') ->
-    S.runStateT (f row acc') s') (acc, s)
+  getNotification = lift . getNotification
   withNewConnection = S.mapStateT withNewConnection
 
 instance (Monoid w, MonadDB m) => MonadDB (L.WriterT w m) where
@@ -155,12 +125,7 @@
   clearQueryResult = lift clearQueryResult
   getTransactionSettings = lift getTransactionSettings
   setTransactionSettings = lift . setTransactionSettings
-  foldlM f acc = L.WriterT $ foldlM (\ ~(acc', w) row -> do
-    ~(r, w') <- L.runWriterT $ f acc' row
-    return (r, w `mappend` w')) (acc, mempty)
-  foldrM f acc = L.WriterT $ foldrM (\ row ~(acc', w) -> do
-    ~(r, w') <- L.runWriterT $ f row acc'
-    return (r, w `mappend` w')) (acc, mempty)
+  getNotification = lift . getNotification
   withNewConnection = L.mapWriterT withNewConnection
 
 instance (Monoid w, MonadDB m) => MonadDB (S.WriterT w m) where
@@ -171,10 +136,5 @@
   clearQueryResult = lift clearQueryResult
   getTransactionSettings = lift getTransactionSettings
   setTransactionSettings = lift . setTransactionSettings
-  foldlM f acc = S.WriterT $ foldlM (\ (acc', w) row -> do
-    (r, w') <- S.runWriterT $ f acc' row
-    return (r, w `mappend` w')) (acc, mempty)
-  foldrM f acc = S.WriterT $ foldrM (\ row (acc', w) -> do
-    (r, w') <- S.runWriterT $ f row acc'
-    return (r, w `mappend` w')) (acc, mempty)
+  getNotification = lift . getNotification
   withNewConnection = S.mapWriterT withNewConnection
diff --git a/src/Database/PostgreSQL/PQTypes/Class/Instances/Overlapping.hs b/src/Database/PostgreSQL/PQTypes/Class/Instances/Overlapping.hs
--- a/src/Database/PostgreSQL/PQTypes/Class/Instances/Overlapping.hs
+++ b/src/Database/PostgreSQL/PQTypes/Class/Instances/Overlapping.hs
@@ -26,12 +26,7 @@
     clearQueryResult = lift clearQueryResult
     getTransactionSettings = lift getTransactionSettings
     setTransactionSettings = lift . setTransactionSettings
-    foldlM f acc = controlT $ \run ->
-      run (return acc) >>= foldlM (\acc' row ->
-        run $ restoreT (return acc') >>= flip f row)
-    foldrM f acc = controlT $ \run ->
-      run (return acc) >>= foldrM (\row acc' ->
-        run $ restoreT (return acc') >>= f row)
+    getNotification = lift . getNotification
     withNewConnection m = controlT $ \run ->
       withNewConnection (run m)
 
diff --git a/src/Database/PostgreSQL/PQTypes/Composite.hs b/src/Database/PostgreSQL/PQTypes/Composite.hs
--- a/src/Database/PostgreSQL/PQTypes/Composite.hs
+++ b/src/Database/PostgreSQL/PQTypes/Composite.hs
@@ -50,13 +50,13 @@
   fromComposite :: t -> CompositeRow t
 
 instance PQFormat t => PQFormat (Composite t) where
-  pqFormat _ = pqFormat (undefined::t)
+  pqFormat = const $ pqFormat (undefined::t)
 
 instance CompositeFromSQL t => FromSQL (Composite t) where
   type PQBase (Composite t) = Ptr PGresult
   fromSQL Nothing = unexpectedNULL
   fromSQL (Just res) = Composite
-    <$> E.finally (toComposite <$> fromRow' res 0) (c_PQclear res)
+    <$> E.finally (toComposite <$> fromRow' res 0 0) (c_PQclear res)
 
 instance CompositeToSQL t => ToSQL (Composite t) where
   type PQDest (Composite t) = PGparam
diff --git a/src/Database/PostgreSQL/PQTypes/Fold.hs b/src/Database/PostgreSQL/PQTypes/Fold.hs
--- a/src/Database/PostgreSQL/PQTypes/Fold.hs
+++ b/src/Database/PostgreSQL/PQTypes/Fold.hs
@@ -1,85 +1,69 @@
-{-# LANGUAGE BangPatterns, FlexibleContexts, Rank2Types, ScopedTypeVariables #-}
 module Database.PostgreSQL.PQTypes.Fold (
-    foldLeftM
-  , foldRightM
+    queryResult
+  , foldrDB
+  , foldlDB
+  , mapDB_
+  , fetchMany
+  , fetchMaybe
+  , fetchOne
   ) where
 
-import Control.Monad
-import Control.Monad.Base
-import Foreign.ForeignPtr.Safe
-import Foreign.C.Types
-import qualified Control.Exception as E
+import Control.Applicative
+import Control.Monad.Catch
+import qualified Data.Foldable as F
 
 import Database.PostgreSQL.PQTypes.Class
-import Database.PostgreSQL.PQTypes.Format
 import Database.PostgreSQL.PQTypes.FromRow
-import Database.PostgreSQL.PQTypes.Internal.C.Interface
-import Database.PostgreSQL.PQTypes.Internal.C.Types
-import Database.PostgreSQL.PQTypes.Internal.Exception
 import Database.PostgreSQL.PQTypes.Internal.Error
 import Database.PostgreSQL.PQTypes.Internal.QueryResult
-import Database.PostgreSQL.PQTypes.Internal.Utils
-import Database.PostgreSQL.PQTypes.SQL.Class
+import Database.PostgreSQL.PQTypes.Utils
 
--- | Fold the result set of rows from left to right.
-foldLeftM :: forall m row acc. (MonadBase IO m, MonadDB m, FromRow row)
-          => (acc -> row -> m acc) -> acc -> m acc
-foldLeftM f initAcc = withQueryResult $ \(_::row) ctx fres ferr ffmt ->
-  liftBase (withForeignPtr fres c_PQntuples)
-    >>= worker ctx fres ferr ffmt initAcc 0
-  where
-    worker ctx fres ferr ffmt acc !i !n
-      | i == n    = return acc
-      | otherwise = do
-        obj <- liftBase $
-          withForeignPtr fres $ \res ->
-          withForeignPtr ferr $ \err ->
-          withForeignPtr ffmt $ \fmt ->
-            E.handle (rethrowWithContext ctx) (fromRow res err i fmt)
-        acc' <- f acc obj
-        worker ctx fres ferr ffmt acc' (i+1) n
+-- | Get current 'QueryResult' or throw an exception if there isn't one.
+queryResult :: (MonadDB m, MonadThrow m, FromRow row) => m (QueryResult row)
+queryResult = getQueryResult
+  >>= maybe (throwDB . HPQTypesError $ "queryResult: no query result") return
 
--- | Fold the result set of rows from right to left.
-foldRightM :: forall m row acc. (MonadBase IO m, MonadDB m, FromRow row)
-           => (row -> acc -> m acc) -> acc -> m acc
-foldRightM f initAcc = withQueryResult $ \(_::row) ctx fres ferr ffmt ->
-  liftBase (withForeignPtr fres c_PQntuples)
-    >>= worker ctx fres ferr ffmt initAcc (-1) . pred
-  where
-    worker ctx fres ferr ffmt acc !n !i
-      | i == n    = return acc
-      | otherwise = do
-        obj <- liftBase $
-          withForeignPtr fres $ \res ->
-          withForeignPtr ferr $ \err ->
-          withForeignPtr ffmt $ \fmt ->
-            E.handle (rethrowWithContext ctx) (fromRow res err i fmt)
-        acc' <- f obj acc
-        worker ctx fres ferr ffmt acc' n (i-1)
+----------------------------------------
 
+-- | Specialization of 'F.foldrM' for convenient query results fetching.
+foldrDB :: (MonadDB m, FromRow row) => (row -> acc -> m acc) -> acc -> m acc
+foldrDB f acc = maybe (return acc) (F.foldrM f acc) =<< getQueryResult
+
+-- | Specialization of 'F.foldlM' for convenient query results fetching.
+foldlDB :: (MonadDB m, FromRow row) => (acc -> row -> m acc) -> acc -> m acc
+foldlDB f acc = maybe (return acc) (F.foldlM f acc) =<< getQueryResult
+
+-- | Specialization of 'F.mapM_' for convenient mapping over query results.
+mapDB_ :: (MonadDB m, FromRow row) => (row -> m t) -> m ()
+mapDB_ f = maybe (return ()) (F.mapM_ f) =<< getQueryResult
+
 ----------------------------------------
 
--- | Helper for abstracting away shared elements of both folds.
-withQueryResult :: forall m row r. (MonadBase IO m, MonadDB m, FromRow row)
-                => (forall sql. IsSQL sql => row -> sql -> ForeignPtr PGresult -> ForeignPtr PGerror -> ForeignPtr CChar -> m r)
-                -> m r
-withQueryResult f = do
-  mres <- getQueryResult
-  SomeSQL ctx <- getLastQuery
-  case mres of
-    Nothing -> liftBase . rethrowWithContext ctx . E.toException . HPQTypesError
-      $ "withQueryResult: no query result"
-    Just (QueryResult res) -> do
-      liftBase $ do
-        rowlen <- fromIntegral `liftM` withForeignPtr res c_PQnfields
-        let expected = pqVariables (undefined::row)
-        when (rowlen /= expected) $
-          E.throwIO DBException {
-            dbeQueryContext = ctx
-          , dbeError = RowLengthMismatch expected rowlen
-          }
-      fmt <- liftBase . bsToCString $ pqFormat (undefined::row)
-      err <- liftBase mallocForeignPtr
-      acc <- f (undefined::row) ctx res err fmt
-      clearQueryResult
-      return acc
+-- | Specialization of 'foldrDB' that fetches a list of rows.
+fetchMany :: (MonadDB m, FromRow row) => (row -> t) -> m [t]
+fetchMany f = foldrDB (\row acc -> return $ f row : acc) []
+
+-- | Specialization of 'foldlDB' that fetches one or zero rows. If
+-- more rows are delivered, 'AffectedRowsMismatch' exception is thrown.
+fetchMaybe :: (MonadDB m, MonadThrow m, FromRow row) => (row -> t) -> m (Maybe t)
+fetchMaybe f = getQueryResult >>= \mqr -> case mqr of
+  Nothing -> return Nothing
+  Just qr -> fst <$> foldlDB go (Nothing, f <$> qr)
+  where
+    go (Nothing, qr) row = return (Just $ f row, qr)
+    go (Just _, qr) _ = throwDB AffectedRowsMismatch {
+        rowsExpected  = [(0, 1)]
+      , rowsDelivered = ntuples qr
+      }
+
+-- | Specialization of 'fetchMaybe' that fetches exactly one row. If
+-- no row is delivered, 'AffectedRowsMismatch' exception is thrown.
+fetchOne :: (MonadDB m, MonadThrow m, FromRow row) => (row -> t) -> m t
+fetchOne f = do
+  mt <- fetchMaybe f
+  case mt of
+    Just t  -> return t
+    Nothing -> throwDB AffectedRowsMismatch {
+      rowsExpected = [(1, 1)]
+    , rowsDelivered = 0
+    }
diff --git a/src/Database/PostgreSQL/PQTypes/Format.hs b/src/Database/PostgreSQL/PQTypes/Format.hs
--- a/src/Database/PostgreSQL/PQTypes/Format.hs
+++ b/src/Database/PostgreSQL/PQTypes/Format.hs
@@ -1,11 +1,15 @@
-{-# LANGUAGE FlexibleInstances, ScopedTypeVariables #-}
+{-# LANGUAGE DeriveDataTypeable, FlexibleInstances, ScopedTypeVariables
+  , TypeOperators #-}
 module Database.PostgreSQL.PQTypes.Format (
     PQFormat(..)
+  , (:*:)(..)
   ) where
 
 import Data.Int
+import Data.Functor.Identity
 import Data.Time
 import Data.Text (Text)
+import Data.Typeable
 import Data.Word
 import qualified Data.ByteString.Char8 as BS
 
@@ -17,272 +21,299 @@
 class PQFormat t where
   -- | Map type to its libpqtypes format. Note that it should
   -- ignore its argument so that passing 'undefined' is safe.
-  pqFormat    :: t -> BS.ByteString
+  pqFormat :: t -> BS.ByteString
+
+  -- | Map type to its null-terminated libpqtypes format, so
+  -- it can safely be used by 'unsafeUseAsCString'. Also, for
+  -- a specific type it becomes a top level CAF, therefore it
+  -- will be computed by GHC at most once.
+  pqFormat0 :: t -> BS.ByteString
+  pqFormat0 = const $ pqFormat (u::t) `BS.snoc` '\0'
+
   -- | Map type to number of type formats it contains.
   pqVariables :: t -> Int
-  pqVariables _ = 1
+  pqVariables = const 1
 
+-- CARTESIAN PRODUCT
+
+-- | Cartesian product of rows.
+data a :*: b = a :*: b
+  deriving (Eq, Ord, Show, Typeable)
+
+instance (PQFormat t1, PQFormat t2) => PQFormat (t1 :*: t2) where
+  pqFormat = const $ pqFormat (u::t1) `BS.append` pqFormat (u::t2)
+  pqVariables = const $ pqVariables (u::t1) + pqVariables (u::t2)
+
 -- NULLables
 
 instance PQFormat t => PQFormat (Maybe t) where
-  pqFormat _ = pqFormat (u::t)
-  pqVariables _ = pqVariables (u::t)
+  pqFormat = const $ pqFormat (u::t)
+  pqVariables = const $ pqVariables (u::t)
 
 -- NUMERICS
 
 instance PQFormat Int16 where
-  pqFormat _ = BS.pack "%int2"
+  pqFormat = const $ BS.pack "%int2"
 
 instance PQFormat Int32 where
-  pqFormat _ = BS.pack "%int4"
+  pqFormat = const $ BS.pack "%int4"
 
 instance PQFormat Int64 where
-  pqFormat _ = BS.pack "%int8"
+  pqFormat = const $ BS.pack "%int8"
 
+instance PQFormat Int where
+  pqFormat = const $ BS.pack "%int8"
+
 instance PQFormat Float where
-  pqFormat _ = BS.pack "%float4"
+  pqFormat = const $ BS.pack "%float4"
 
 instance PQFormat Double where
-  pqFormat _ = BS.pack "%float8"
+  pqFormat = const $ BS.pack "%float8"
 
 -- CHAR
 
 instance PQFormat Char where
-  pqFormat _ = BS.pack "%char"
+  pqFormat = const $ BS.pack "%char"
 
 instance PQFormat Word8 where
-  pqFormat _ = BS.pack "%char"
+  pqFormat = const $ BS.pack "%char"
 
 -- VARIABLE-LENGTH CHARACTER TYPES
 
 instance PQFormat String where
-  pqFormat _ = BS.pack "%btext"
+  pqFormat = const $ BS.pack "%btext"
 
 instance PQFormat BS.ByteString where
-  pqFormat _ = BS.pack "%btext"
+  pqFormat = const $ BS.pack "%btext"
 
 instance PQFormat Text where
-  pqFormat _ = BS.pack "%btext"
+  pqFormat = const $ BS.pack "%btext"
 
 -- DATE
 
 instance PQFormat Day where
-  pqFormat _ = BS.pack "%date"
+  pqFormat = const $ BS.pack "%date"
 
 -- TIME
 
 instance PQFormat TimeOfDay where
-  pqFormat _ = BS.pack "%time"
+  pqFormat = const $ BS.pack "%time"
 
 -- TIMESTAMP
 
 instance PQFormat LocalTime where
-  pqFormat _ = BS.pack "%timestamp"
+  pqFormat = const $ BS.pack "%timestamp"
 
 -- TIMESTAMPTZ
 
 instance PQFormat UTCTime where
-  pqFormat _ = BS.pack "%timestamptz"
+  pqFormat = const $ BS.pack "%timestamptz"
 
 instance PQFormat ZonedTime where
-  pqFormat _ = BS.pack "%timestamptz"
+  pqFormat = const $ BS.pack "%timestamptz"
 
 -- BOOL
 
 instance PQFormat Bool where
-  pqFormat _ = BS.pack "%bool"
+  pqFormat = const $ BS.pack "%bool"
 
 -- TUPLES
 
 instance PQFormat () where
-    pqFormat _ = BS.empty
-    pqVariables _ = 0
+  pqFormat = const $ BS.empty
+  pqVariables = const 0
 
 instance (
+    PQFormat t
+  ) => PQFormat (Identity t) where
+    pqFormat = const $ pqFormat (u::t)
+    pqVariables = const 1
+
+instance (
     PQFormat t1, PQFormat t2
   ) => PQFormat (t1, t2) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2)
       ]
-    pqVariables _ = 2
+    pqVariables = const 2
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3
   ) => PQFormat (t1, t2, t3) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3)
       ]
-    pqVariables _ = 3
+    pqVariables = const 3
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4
   ) => PQFormat (t1, t2, t3, t4) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       ]
-    pqVariables _ = 4
+    pqVariables = const 4
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5
   ) => PQFormat (t1, t2, t3, t4, t5) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5)
       ]
-    pqVariables _ = 5
+    pqVariables = const 5
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
   ) => PQFormat (t1, t2, t3, t4, t5, t6) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6)
       ]
-    pqVariables _ = 6
+    pqVariables = const 6
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
   , PQFormat t7
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7)
       ]
-    pqVariables _ = 7
+    pqVariables = const 7
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
   , PQFormat t7, PQFormat t8
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       ]
-    pqVariables _ = 8
+    pqVariables = const 8
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
   , PQFormat t7, PQFormat t8, PQFormat t9
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9)
       ]
-    pqVariables _ = 9
+    pqVariables = const 9
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
   , PQFormat t7, PQFormat t8, PQFormat t9, PQFormat t10
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10)
       ]
-    pqVariables _ = 10
+    pqVariables = const 10
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
   , PQFormat t7, PQFormat t8, PQFormat t9, PQFormat t10, PQFormat t11
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11)
       ]
-    pqVariables _ = 11
+    pqVariables = const 11
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
   , PQFormat t7, PQFormat t8, PQFormat t9, PQFormat t10, PQFormat t11, PQFormat t12
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
       ]
-    pqVariables _ = 12
+    pqVariables = const 12
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
   , PQFormat t7, PQFormat t8, PQFormat t9, PQFormat t10, PQFormat t11, PQFormat t12
   , PQFormat t13
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
       , pqFormat (u::t13)
       ]
-    pqVariables _ = 13
+    pqVariables = const 13
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
   , PQFormat t7, PQFormat t8, PQFormat t9, PQFormat t10, PQFormat t11, PQFormat t12
   , PQFormat t13, PQFormat t14
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
       , pqFormat (u::t13), pqFormat (u::t14)
       ]
-    pqVariables _ = 14
+    pqVariables = const 14
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
   , PQFormat t7, PQFormat t8, PQFormat t9, PQFormat t10, PQFormat t11, PQFormat t12
   , PQFormat t13, PQFormat t14, PQFormat t15
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
       , pqFormat (u::t13), pqFormat (u::t14), pqFormat (u::t15)
       ]
-    pqVariables _ = 15
+    pqVariables = const 15
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
   , PQFormat t7, PQFormat t8, PQFormat t9, PQFormat t10, PQFormat t11, PQFormat t12
   , PQFormat t13, PQFormat t14, PQFormat t15, PQFormat t16
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
       , pqFormat (u::t13), pqFormat (u::t14), pqFormat (u::t15), pqFormat (u::t16)
       ]
-    pqVariables _ = 16
+    pqVariables = const 16
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
   , PQFormat t7, PQFormat t8, PQFormat t9, PQFormat t10, PQFormat t11, PQFormat t12
   , PQFormat t13, PQFormat t14, PQFormat t15, PQFormat t16, PQFormat t17
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
       , pqFormat (u::t13), pqFormat (u::t14), pqFormat (u::t15), pqFormat (u::t16)
       , pqFormat (u::t17)
       ]
-    pqVariables _ = 17
+    pqVariables = const 17
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
   , PQFormat t7, PQFormat t8, PQFormat t9, PQFormat t10, PQFormat t11, PQFormat t12
   , PQFormat t13, PQFormat t14, PQFormat t15, PQFormat t16, PQFormat t17, PQFormat t18
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
       , pqFormat (u::t13), pqFormat (u::t14), pqFormat (u::t15), pqFormat (u::t16)
       , pqFormat (u::t17), pqFormat (u::t18)
       ]
-    pqVariables _ = 18
+    pqVariables = const 18
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -290,14 +321,14 @@
   , PQFormat t13, PQFormat t14, PQFormat t15, PQFormat t16, PQFormat t17, PQFormat t18
   , PQFormat t19
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
       , pqFormat (u::t13), pqFormat (u::t14), pqFormat (u::t15), pqFormat (u::t16)
       , pqFormat (u::t17), pqFormat (u::t18), pqFormat (u::t19)
       ]
-    pqVariables _ = 19
+    pqVariables = const 19
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -305,14 +336,14 @@
   , PQFormat t13, PQFormat t14, PQFormat t15, PQFormat t16, PQFormat t17, PQFormat t18
   , PQFormat t19, PQFormat t20
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
       , pqFormat (u::t13), pqFormat (u::t14), pqFormat (u::t15), pqFormat (u::t16)
       , pqFormat (u::t17), pqFormat (u::t18), pqFormat (u::t19), pqFormat (u::t20)
       ]
-    pqVariables _ = 20
+    pqVariables = const 20
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -320,7 +351,7 @@
   , PQFormat t13, PQFormat t14, PQFormat t15, PQFormat t16, PQFormat t17, PQFormat t18
   , PQFormat t19, PQFormat t20, PQFormat t21
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -328,7 +359,7 @@
       , pqFormat (u::t17), pqFormat (u::t18), pqFormat (u::t19), pqFormat (u::t20)
       , pqFormat (u::t21)
       ]
-    pqVariables _ = 21
+    pqVariables = const 21
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -336,7 +367,7 @@
   , PQFormat t13, PQFormat t14, PQFormat t15, PQFormat t16, PQFormat t17, PQFormat t18
   , PQFormat t19, PQFormat t20, PQFormat t21, PQFormat t22
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -344,7 +375,7 @@
       , pqFormat (u::t17), pqFormat (u::t18), pqFormat (u::t19), pqFormat (u::t20)
       , pqFormat (u::t21), pqFormat (u::t22)
       ]
-    pqVariables _ = 22
+    pqVariables = const 22
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -352,7 +383,7 @@
   , PQFormat t13, PQFormat t14, PQFormat t15, PQFormat t16, PQFormat t17, PQFormat t18
   , PQFormat t19, PQFormat t20, PQFormat t21, PQFormat t22, PQFormat t23
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -360,7 +391,7 @@
       , pqFormat (u::t17), pqFormat (u::t18), pqFormat (u::t19), pqFormat (u::t20)
       , pqFormat (u::t21), pqFormat (u::t22), pqFormat (u::t23)
       ]
-    pqVariables _ = 23
+    pqVariables = const 23
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -368,7 +399,7 @@
   , PQFormat t13, PQFormat t14, PQFormat t15, PQFormat t16, PQFormat t17, PQFormat t18
   , PQFormat t19, PQFormat t20, PQFormat t21, PQFormat t22, PQFormat t23, PQFormat t24
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23, t24) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -376,7 +407,7 @@
       , pqFormat (u::t17), pqFormat (u::t18), pqFormat (u::t19), pqFormat (u::t20)
       , pqFormat (u::t21), pqFormat (u::t22), pqFormat (u::t23), pqFormat (u::t24)
       ]
-    pqVariables _ = 24
+    pqVariables = const 24
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -385,7 +416,7 @@
   , PQFormat t19, PQFormat t20, PQFormat t21, PQFormat t22, PQFormat t23, PQFormat t24
   , PQFormat t25
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23, t24, t25) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -394,7 +425,7 @@
       , pqFormat (u::t21), pqFormat (u::t22), pqFormat (u::t23), pqFormat (u::t24)
       , pqFormat (u::t25)
       ]
-    pqVariables _ = 25
+    pqVariables = const 25
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -403,7 +434,7 @@
   , PQFormat t19, PQFormat t20, PQFormat t21, PQFormat t22, PQFormat t23, PQFormat t24
   , PQFormat t25, PQFormat t26
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23, t24, t25, t26) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -412,7 +443,7 @@
       , pqFormat (u::t21), pqFormat (u::t22), pqFormat (u::t23), pqFormat (u::t24)
       , pqFormat (u::t25), pqFormat (u::t26)
       ]
-    pqVariables _ = 26
+    pqVariables = const 26
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -421,7 +452,7 @@
   , PQFormat t19, PQFormat t20, PQFormat t21, PQFormat t22, PQFormat t23, PQFormat t24
   , PQFormat t25, PQFormat t26, PQFormat t27
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23, t24, t25, t26, t27) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -430,7 +461,7 @@
       , pqFormat (u::t21), pqFormat (u::t22), pqFormat (u::t23), pqFormat (u::t24)
       , pqFormat (u::t25), pqFormat (u::t26), pqFormat (u::t27)
       ]
-    pqVariables _ = 27
+    pqVariables = const 27
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -439,7 +470,7 @@
   , PQFormat t19, PQFormat t20, PQFormat t21, PQFormat t22, PQFormat t23, PQFormat t24
   , PQFormat t25, PQFormat t26, PQFormat t27, PQFormat t28
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23, t24, t25, t26, t27, t28) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -448,7 +479,7 @@
       , pqFormat (u::t21), pqFormat (u::t22), pqFormat (u::t23), pqFormat (u::t24)
       , pqFormat (u::t25), pqFormat (u::t26), pqFormat (u::t27), pqFormat (u::t28)
       ]
-    pqVariables _ = 28
+    pqVariables = const 28
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -457,7 +488,7 @@
   , PQFormat t19, PQFormat t20, PQFormat t21, PQFormat t22, PQFormat t23, PQFormat t24
   , PQFormat t25, PQFormat t26, PQFormat t27, PQFormat t28, PQFormat t29
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23, t24, t25, t26, t27, t28, t29) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -467,7 +498,7 @@
       , pqFormat (u::t25), pqFormat (u::t26), pqFormat (u::t27), pqFormat (u::t28)
       , pqFormat (u::t29)
       ]
-    pqVariables _ = 29
+    pqVariables = const 29
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -476,7 +507,7 @@
   , PQFormat t19, PQFormat t20, PQFormat t21, PQFormat t22, PQFormat t23, PQFormat t24
   , PQFormat t25, PQFormat t26, PQFormat t27, PQFormat t28, PQFormat t29, PQFormat t30
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23, t24, t25, t26, t27, t28, t29, t30) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -486,7 +517,7 @@
       , pqFormat (u::t25), pqFormat (u::t26), pqFormat (u::t27), pqFormat (u::t28)
       , pqFormat (u::t29), pqFormat (u::t30)
       ]
-    pqVariables _ = 30
+    pqVariables = const 30
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -496,7 +527,7 @@
   , PQFormat t25, PQFormat t26, PQFormat t27, PQFormat t28, PQFormat t29, PQFormat t30
   , PQFormat t31
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23, t24, t25, t26, t27, t28, t29, t30, t31) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -506,7 +537,7 @@
       , pqFormat (u::t25), pqFormat (u::t26), pqFormat (u::t27), pqFormat (u::t28)
       , pqFormat (u::t29), pqFormat (u::t30), pqFormat (u::t31)
       ]
-    pqVariables _ = 31
+    pqVariables = const 31
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -516,7 +547,7 @@
   , PQFormat t25, PQFormat t26, PQFormat t27, PQFormat t28, PQFormat t29, PQFormat t30
   , PQFormat t31, PQFormat t32
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -526,7 +557,7 @@
       , pqFormat (u::t25), pqFormat (u::t26), pqFormat (u::t27), pqFormat (u::t28)
       , pqFormat (u::t29), pqFormat (u::t30), pqFormat (u::t31), pqFormat (u::t32)
       ]
-    pqVariables _ = 32
+    pqVariables = const 32
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -536,7 +567,7 @@
   , PQFormat t25, PQFormat t26, PQFormat t27, PQFormat t28, PQFormat t29, PQFormat t30
   , PQFormat t31, PQFormat t32, PQFormat t33
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -547,7 +578,7 @@
       , pqFormat (u::t29), pqFormat (u::t30), pqFormat (u::t31), pqFormat (u::t32)
       , pqFormat (u::t33)
       ]
-    pqVariables _ = 33
+    pqVariables = const 33
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -557,7 +588,7 @@
   , PQFormat t25, PQFormat t26, PQFormat t27, PQFormat t28, PQFormat t29, PQFormat t30
   , PQFormat t31, PQFormat t32, PQFormat t33, PQFormat t34
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -568,7 +599,7 @@
       , pqFormat (u::t29), pqFormat (u::t30), pqFormat (u::t31), pqFormat (u::t32)
       , pqFormat (u::t33), pqFormat (u::t34)
       ]
-    pqVariables _ = 34
+    pqVariables = const 34
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -578,7 +609,7 @@
   , PQFormat t25, PQFormat t26, PQFormat t27, PQFormat t28, PQFormat t29, PQFormat t30
   , PQFormat t31, PQFormat t32, PQFormat t33, PQFormat t34, PQFormat t35
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -589,7 +620,7 @@
       , pqFormat (u::t29), pqFormat (u::t30), pqFormat (u::t31), pqFormat (u::t32)
       , pqFormat (u::t33), pqFormat (u::t34), pqFormat (u::t35)
       ]
-    pqVariables _ = 35
+    pqVariables = const 35
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -599,7 +630,7 @@
   , PQFormat t25, PQFormat t26, PQFormat t27, PQFormat t28, PQFormat t29, PQFormat t30
   , PQFormat t31, PQFormat t32, PQFormat t33, PQFormat t34, PQFormat t35, PQFormat t36
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -610,7 +641,7 @@
       , pqFormat (u::t29), pqFormat (u::t30), pqFormat (u::t31), pqFormat (u::t32)
       , pqFormat (u::t33), pqFormat (u::t34), pqFormat (u::t35), pqFormat (u::t36)
       ]
-    pqVariables _ = 36
+    pqVariables = const 36
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -621,7 +652,7 @@
   , PQFormat t31, PQFormat t32, PQFormat t33, PQFormat t34, PQFormat t35, PQFormat t36
   , PQFormat t37
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -633,7 +664,7 @@
       , pqFormat (u::t33), pqFormat (u::t34), pqFormat (u::t35), pqFormat (u::t36)
       , pqFormat (u::t37)
       ]
-    pqVariables _ = 37
+    pqVariables = const 37
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -644,7 +675,7 @@
   , PQFormat t31, PQFormat t32, PQFormat t33, PQFormat t34, PQFormat t35, PQFormat t36
   , PQFormat t37, PQFormat t38
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -656,7 +687,7 @@
       , pqFormat (u::t33), pqFormat (u::t34), pqFormat (u::t35), pqFormat (u::t36)
       , pqFormat (u::t37), pqFormat (u::t38)
       ]
-    pqVariables _ = 38
+    pqVariables = const 38
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -667,7 +698,7 @@
   , PQFormat t31, PQFormat t32, PQFormat t33, PQFormat t34, PQFormat t35, PQFormat t36
   , PQFormat t37, PQFormat t38, PQFormat t39
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -679,7 +710,7 @@
       , pqFormat (u::t33), pqFormat (u::t34), pqFormat (u::t35), pqFormat (u::t36)
       , pqFormat (u::t37), pqFormat (u::t38), pqFormat (u::t39)
       ]
-    pqVariables _ = 39
+    pqVariables = const 39
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -690,7 +721,7 @@
   , PQFormat t31, PQFormat t32, PQFormat t33, PQFormat t34, PQFormat t35, PQFormat t36
   , PQFormat t37, PQFormat t38, PQFormat t39, PQFormat t40
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -702,7 +733,7 @@
       , pqFormat (u::t33), pqFormat (u::t34), pqFormat (u::t35), pqFormat (u::t36)
       , pqFormat (u::t37), pqFormat (u::t38), pqFormat (u::t39), pqFormat (u::t40)
       ]
-    pqVariables _ = 40
+    pqVariables = const 40
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -713,7 +744,7 @@
   , PQFormat t31, PQFormat t32, PQFormat t33, PQFormat t34, PQFormat t35, PQFormat t36
   , PQFormat t37, PQFormat t38, PQFormat t39, PQFormat t40, PQFormat t41
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -726,7 +757,7 @@
       , pqFormat (u::t37), pqFormat (u::t38), pqFormat (u::t39), pqFormat (u::t40)
       , pqFormat (u::t41)
       ]
-    pqVariables _ = 41
+    pqVariables = const 41
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -737,7 +768,7 @@
   , PQFormat t31, PQFormat t32, PQFormat t33, PQFormat t34, PQFormat t35, PQFormat t36
   , PQFormat t37, PQFormat t38, PQFormat t39, PQFormat t40, PQFormat t41, PQFormat t42
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -750,7 +781,7 @@
       , pqFormat (u::t37), pqFormat (u::t38), pqFormat (u::t39), pqFormat (u::t40)
       , pqFormat (u::t41), pqFormat (u::t42)
       ]
-    pqVariables _ = 42
+    pqVariables = const 42
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -762,7 +793,7 @@
   , PQFormat t37, PQFormat t38, PQFormat t39, PQFormat t40, PQFormat t41, PQFormat t42
   , PQFormat t43
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -775,7 +806,7 @@
       , pqFormat (u::t37), pqFormat (u::t38), pqFormat (u::t39), pqFormat (u::t40)
       , pqFormat (u::t41), pqFormat (u::t42), pqFormat (u::t43)
       ]
-    pqVariables _ = 43
+    pqVariables = const 43
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -787,7 +818,7 @@
   , PQFormat t37, PQFormat t38, PQFormat t39, PQFormat t40, PQFormat t41, PQFormat t42
   , PQFormat t43, PQFormat t44
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -800,7 +831,7 @@
       , pqFormat (u::t37), pqFormat (u::t38), pqFormat (u::t39), pqFormat (u::t40)
       , pqFormat (u::t41), pqFormat (u::t42), pqFormat (u::t43), pqFormat (u::t44)
       ]
-    pqVariables _ = 44
+    pqVariables = const 44
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -812,7 +843,7 @@
   , PQFormat t37, PQFormat t38, PQFormat t39, PQFormat t40, PQFormat t41, PQFormat t42
   , PQFormat t43, PQFormat t44, PQFormat t45
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -826,7 +857,7 @@
       , pqFormat (u::t41), pqFormat (u::t42), pqFormat (u::t43), pqFormat (u::t44)
       , pqFormat (u::t45)
       ]
-    pqVariables _ = 45
+    pqVariables = const 45
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -838,7 +869,7 @@
   , PQFormat t37, PQFormat t38, PQFormat t39, PQFormat t40, PQFormat t41, PQFormat t42
   , PQFormat t43, PQFormat t44, PQFormat t45, PQFormat t46
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45, t46) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -852,7 +883,7 @@
       , pqFormat (u::t41), pqFormat (u::t42), pqFormat (u::t43), pqFormat (u::t44)
       , pqFormat (u::t45), pqFormat (u::t46)
       ]
-    pqVariables _ = 46
+    pqVariables = const 46
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -864,7 +895,7 @@
   , PQFormat t37, PQFormat t38, PQFormat t39, PQFormat t40, PQFormat t41, PQFormat t42
   , PQFormat t43, PQFormat t44, PQFormat t45, PQFormat t46, PQFormat t47
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45, t46, t47) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -878,7 +909,7 @@
       , pqFormat (u::t41), pqFormat (u::t42), pqFormat (u::t43), pqFormat (u::t44)
       , pqFormat (u::t45), pqFormat (u::t46), pqFormat (u::t47)
       ]
-    pqVariables _ = 47
+    pqVariables = const 47
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -890,7 +921,7 @@
   , PQFormat t37, PQFormat t38, PQFormat t39, PQFormat t40, PQFormat t41, PQFormat t42
   , PQFormat t43, PQFormat t44, PQFormat t45, PQFormat t46, PQFormat t47, PQFormat t48
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45, t46, t47, t48) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -904,7 +935,7 @@
       , pqFormat (u::t41), pqFormat (u::t42), pqFormat (u::t43), pqFormat (u::t44)
       , pqFormat (u::t45), pqFormat (u::t46), pqFormat (u::t47), pqFormat (u::t48)
       ]
-    pqVariables _ = 48
+    pqVariables = const 48
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -917,7 +948,7 @@
   , PQFormat t43, PQFormat t44, PQFormat t45, PQFormat t46, PQFormat t47, PQFormat t48
   , PQFormat t49
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45, t46, t47, t48, t49) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -932,7 +963,7 @@
       , pqFormat (u::t45), pqFormat (u::t46), pqFormat (u::t47), pqFormat (u::t48)
       , pqFormat (u::t49)
       ]
-    pqVariables _ = 49
+    pqVariables = const 49
 
 instance (
     PQFormat t1, PQFormat t2, PQFormat t3, PQFormat t4, PQFormat t5, PQFormat t6
@@ -945,7 +976,7 @@
   , PQFormat t43, PQFormat t44, PQFormat t45, PQFormat t46, PQFormat t47, PQFormat t48
   , PQFormat t49, PQFormat t50
   ) => PQFormat (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21,  t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45, t46, t47, t48, t49, t50) where
-    pqFormat _ = BS.concat [
+    pqFormat = const $ BS.concat [
         pqFormat (u::t1), pqFormat (u::t2), pqFormat (u::t3), pqFormat (u::t4)
       , pqFormat (u::t5), pqFormat (u::t6), pqFormat (u::t7), pqFormat (u::t8)
       , pqFormat (u::t9), pqFormat (u::t10), pqFormat (u::t11), pqFormat (u::t12)
@@ -960,4 +991,4 @@
       , pqFormat (u::t45), pqFormat (u::t46), pqFormat (u::t47), pqFormat (u::t48)
       , pqFormat (u::t49), pqFormat (u::t50)
       ]
-    pqVariables _ = 50
+    pqVariables = const 50
diff --git a/src/Database/PostgreSQL/PQTypes/FromRow.hs b/src/Database/PostgreSQL/PQTypes/FromRow.hs
--- a/src/Database/PostgreSQL/PQTypes/FromRow.hs
+++ b/src/Database/PostgreSQL/PQTypes/FromRow.hs
@@ -1,1518 +1,1529 @@
-{-# LANGUAGE FlexibleInstances, ScopedTypeVariables #-}
-module Database.PostgreSQL.PQTypes.FromRow (
-    FromRow(..)
-  , fromRow'
-  ) where
-
-import Control.Applicative
-import Foreign.C
-import Foreign.Marshal.Alloc
-import Foreign.Storable
-import Foreign.Ptr
-import qualified Control.Exception as E
-import qualified Data.ByteString as BS
-
-import Database.PostgreSQL.PQTypes.Format
-import Database.PostgreSQL.PQTypes.FromSQL
-import Database.PostgreSQL.PQTypes.Internal.C.Get
-import Database.PostgreSQL.PQTypes.Internal.C.Interface
-import Database.PostgreSQL.PQTypes.Internal.C.Types
-import Database.PostgreSQL.PQTypes.Internal.Error
-import Database.PostgreSQL.PQTypes.Internal.Utils
-import Database.PostgreSQL.PQTypes.Single
-
--- | Convert base (libpqtypes) type to destination type.
-convert :: FromSQL t => Ptr PGresult -> CInt -> CInt -> PQBase t -> IO t
-convert res tuple column base = do
-  isNull <- c_PQgetisnull res tuple column
-  fromSQL (if isNull == 1 then Nothing else Just base) `E.catch` rethrowWithConvError
-  where
-    rethrowWithConvError :: E.SomeException -> IO a
-    rethrowWithConvError (E.SomeException e) = do
-      colname <- safePeekCString' =<< c_PQfname res column
-      E.throwIO ConversionError {
-        convColumn = fromIntegral column + 1
-      , convColumnName = colname
-      , convRow = fromIntegral tuple + 1
-      , convError = e
-      }
-
--- | 'verifyPQTRes' specialized for usage in 'fromRow'.
-verify :: Ptr PGerror -> CInt -> IO ()
-verify err = verifyPQTRes err "fromRow"
-
-----------------------------------------
-
--- | More convenient version of 'fromRow' that
--- allocates 'PGerror' and format string by itself.
-fromRow' :: forall row. FromRow row => Ptr PGresult -> CInt -> IO row
-fromRow' res i = alloca $ \err ->
-  BS.useAsCString (pqFormat (undefined::row)) (fromRow res err i)
-
--- | Class which represents \"from SQL row to Haskell tuple\" transformation.
-class PQFormat row => FromRow row where
-  -- | Extract SQL row from 'PGresult' and convert it into a tuple.
-  fromRow  :: Ptr PGresult -- ^ Source result.
-           -> Ptr PGerror  -- ^ Local error info.
-           -> CInt         -- ^ Index of row to be extracted.
-           -> CString      -- ^ Format of row to be extracted.
-           -> IO row
-
-instance FromRow () where
-  fromRow _ _ _ _ = return ()
-
-instance FromSQL t => FromRow (Single t) where
-  fromRow res err i fmt = alloca $ \p1 -> do
-    verify err =<< c_PQgetf1 res err i fmt 0 p1
-    t <- peek p1 >>= convert res i 0
-    return (Single t)
-
-instance (
-    FromSQL t1, FromSQL t2
-  ) => FromRow (t1, t2) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> do
-        verify err =<< c_PQgetf2 res err i fmt 0 p0 1 p1
-        (,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3
-  ) => FromRow (t1, t2, t3) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> do
-        verify err =<< c_PQgetf3 res err i fmt 0 p0 1 p1 2 p2
-        (,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4
-  ) => FromRow (t1, t2, t3, t4) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> do
-        verify err =<< c_PQgetf4 res err i fmt 0 p0 1 p1 2 p2 3 p3
-        (,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5
-  ) => FromRow (t1, t2, t3, t4, t5) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 -> do
-        verify err =<< c_PQgetf5 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4
-        (,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  ) => FromRow (t1, t2, t3, t4, t5, t6) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> do
-        verify err =<< c_PQgetf6 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5
-        (,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> do
-        verify err =<< c_PQgetf7 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6
-        (,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> do
-        verify err =<< c_PQgetf8 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7
-        (,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> do
-        verify err =<< c_PQgetf9 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8
-        (,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 -> do
-        verify err =<< c_PQgetf10 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9
-        (,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> do
-        verify err =<< c_PQgetf11 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10
-        (,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> do
-        verify err =<< c_PQgetf12 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11
-        (,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> do
-        verify err =<< c_PQgetf13 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12
-        (,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> do
-        verify err =<< c_PQgetf14 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13
-        (,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 -> do
-        verify err =<< c_PQgetf15 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14
-        (,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> do
-        verify err =<< c_PQgetf16 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15
-        (,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> do
-        verify err =<< c_PQgetf17 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16
-        (,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> do
-        verify err =<< c_PQgetf18 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17
-        (,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> do
-        verify err =<< c_PQgetf19 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18
-        (,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 -> do
-        verify err =<< c_PQgetf20 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19
-        (,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> do
-        verify err =<< c_PQgetf21 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20
-        (,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> do
-        verify err =<< c_PQgetf22 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21
-        (,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> do
-        verify err =<< c_PQgetf23 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22
-        (,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> do
-        verify err =<< c_PQgetf24 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22 23 p23
-        (,,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22) <*> (peek p23 >>= convert res i 23)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
-  , FromSQL t25
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 -> do
-        verify err =<< c_PQgetf25 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22 23 p23 24 p24
-        (,,,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22) <*> (peek p23 >>= convert res i 23)
-          <*> (peek p24 >>= convert res i 24)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
-  , FromSQL t25, FromSQL t26
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
-      alloca $ \p25 -> do
-        verify err =<< c_PQgetf26 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22 23 p23 24 p24 25 p25
-        (,,,,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22) <*> (peek p23 >>= convert res i 23)
-          <*> (peek p24 >>= convert res i 24) <*> (peek p25 >>= convert res i 25)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
-  , FromSQL t25, FromSQL t26, FromSQL t27
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
-      alloca $ \p25 -> alloca $ \p26 -> do
-        verify err =<< c_PQgetf27 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22 23 p23 24 p24 25 p25 26 p26
-        (,,,,,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22) <*> (peek p23 >>= convert res i 23)
-          <*> (peek p24 >>= convert res i 24) <*> (peek p25 >>= convert res i 25)
-          <*> (peek p26 >>= convert res i 26)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
-  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
-      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> do
-        verify err =<< c_PQgetf28 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22 23 p23 24 p24 25 p25 26 p26 27 p27
-        (,,,,,,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22) <*> (peek p23 >>= convert res i 23)
-          <*> (peek p24 >>= convert res i 24) <*> (peek p25 >>= convert res i 25)
-          <*> (peek p26 >>= convert res i 26) <*> (peek p27 >>= convert res i 27)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
-  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
-      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> do
-        verify err =<< c_PQgetf29 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22 23 p23 24 p24 25 p25 26 p26 27 p27 28 p28
-        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22) <*> (peek p23 >>= convert res i 23)
-          <*> (peek p24 >>= convert res i 24) <*> (peek p25 >>= convert res i 25)
-          <*> (peek p26 >>= convert res i 26) <*> (peek p27 >>= convert res i 27)
-          <*> (peek p28 >>= convert res i 28)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
-  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
-      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 -> do
-        verify err =<< c_PQgetf30 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22 23 p23 24 p24 25 p25 26 p26 27 p27 28 p28 29 p29
-        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22) <*> (peek p23 >>= convert res i 23)
-          <*> (peek p24 >>= convert res i 24) <*> (peek p25 >>= convert res i 25)
-          <*> (peek p26 >>= convert res i 26) <*> (peek p27 >>= convert res i 27)
-          <*> (peek p28 >>= convert res i 28) <*> (peek p29 >>= convert res i 29)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
-  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
-  , FromSQL t31
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
-      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
-      alloca $ \p30 -> do
-        verify err =<< c_PQgetf31 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22 23 p23 24 p24 25 p25 26 p26 27 p27 28 p28 29 p29 30 p30
-        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22) <*> (peek p23 >>= convert res i 23)
-          <*> (peek p24 >>= convert res i 24) <*> (peek p25 >>= convert res i 25)
-          <*> (peek p26 >>= convert res i 26) <*> (peek p27 >>= convert res i 27)
-          <*> (peek p28 >>= convert res i 28) <*> (peek p29 >>= convert res i 29)
-          <*> (peek p30 >>= convert res i 30)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
-  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
-  , FromSQL t31, FromSQL t32
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
-      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
-      alloca $ \p30 -> alloca $ \p31 -> do
-        verify err =<< c_PQgetf32 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22 23 p23 24 p24 25 p25 26 p26 27 p27 28 p28 29 p29 30 p30 31 p31
-        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22) <*> (peek p23 >>= convert res i 23)
-          <*> (peek p24 >>= convert res i 24) <*> (peek p25 >>= convert res i 25)
-          <*> (peek p26 >>= convert res i 26) <*> (peek p27 >>= convert res i 27)
-          <*> (peek p28 >>= convert res i 28) <*> (peek p29 >>= convert res i 29)
-          <*> (peek p30 >>= convert res i 30) <*> (peek p31 >>= convert res i 31)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
-  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
-  , FromSQL t31, FromSQL t32, FromSQL t33
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
-      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
-      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> do
-        verify err =<< c_PQgetf33 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22 23 p23 24 p24 25 p25 26 p26 27 p27 28 p28 29 p29 30 p30 31 p31 32 p32
-        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22) <*> (peek p23 >>= convert res i 23)
-          <*> (peek p24 >>= convert res i 24) <*> (peek p25 >>= convert res i 25)
-          <*> (peek p26 >>= convert res i 26) <*> (peek p27 >>= convert res i 27)
-          <*> (peek p28 >>= convert res i 28) <*> (peek p29 >>= convert res i 29)
-          <*> (peek p30 >>= convert res i 30) <*> (peek p31 >>= convert res i 31)
-          <*> (peek p32 >>= convert res i 32)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
-  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
-  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
-      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
-      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> do
-        verify err =<< c_PQgetf34 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22 23 p23 24 p24 25 p25 26 p26 27 p27 28 p28 29 p29 30 p30 31 p31 32 p32 33 p33
-        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22) <*> (peek p23 >>= convert res i 23)
-          <*> (peek p24 >>= convert res i 24) <*> (peek p25 >>= convert res i 25)
-          <*> (peek p26 >>= convert res i 26) <*> (peek p27 >>= convert res i 27)
-          <*> (peek p28 >>= convert res i 28) <*> (peek p29 >>= convert res i 29)
-          <*> (peek p30 >>= convert res i 30) <*> (peek p31 >>= convert res i 31)
-          <*> (peek p32 >>= convert res i 32) <*> (peek p33 >>= convert res i 33)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
-  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
-  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
-      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
-      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 -> do
-        verify err =<< c_PQgetf35 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22 23 p23 24 p24 25 p25 26 p26 27 p27 28 p28 29 p29 30 p30 31 p31 32 p32 33 p33 34 p34
-        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22) <*> (peek p23 >>= convert res i 23)
-          <*> (peek p24 >>= convert res i 24) <*> (peek p25 >>= convert res i 25)
-          <*> (peek p26 >>= convert res i 26) <*> (peek p27 >>= convert res i 27)
-          <*> (peek p28 >>= convert res i 28) <*> (peek p29 >>= convert res i 29)
-          <*> (peek p30 >>= convert res i 30) <*> (peek p31 >>= convert res i 31)
-          <*> (peek p32 >>= convert res i 32) <*> (peek p33 >>= convert res i 33)
-          <*> (peek p34 >>= convert res i 34)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
-  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
-  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
-      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
-      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
-      alloca $ \p35 -> do
-        verify err =<< c_PQgetf36 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22 23 p23 24 p24 25 p25 26 p26 27 p27 28 p28 29 p29 30 p30 31 p31 32 p32 33 p33 34 p34 35 p35
-        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22) <*> (peek p23 >>= convert res i 23)
-          <*> (peek p24 >>= convert res i 24) <*> (peek p25 >>= convert res i 25)
-          <*> (peek p26 >>= convert res i 26) <*> (peek p27 >>= convert res i 27)
-          <*> (peek p28 >>= convert res i 28) <*> (peek p29 >>= convert res i 29)
-          <*> (peek p30 >>= convert res i 30) <*> (peek p31 >>= convert res i 31)
-          <*> (peek p32 >>= convert res i 32) <*> (peek p33 >>= convert res i 33)
-          <*> (peek p34 >>= convert res i 34) <*> (peek p35 >>= convert res i 35)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
-  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
-  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
-  , FromSQL t37
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
-      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
-      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
-      alloca $ \p35 -> alloca $ \p36 -> do
-        verify err =<< c_PQgetf37 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22 23 p23 24 p24 25 p25 26 p26 27 p27 28 p28 29 p29 30 p30 31 p31 32 p32 33 p33 34 p34 35 p35 36 p36
-        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22) <*> (peek p23 >>= convert res i 23)
-          <*> (peek p24 >>= convert res i 24) <*> (peek p25 >>= convert res i 25)
-          <*> (peek p26 >>= convert res i 26) <*> (peek p27 >>= convert res i 27)
-          <*> (peek p28 >>= convert res i 28) <*> (peek p29 >>= convert res i 29)
-          <*> (peek p30 >>= convert res i 30) <*> (peek p31 >>= convert res i 31)
-          <*> (peek p32 >>= convert res i 32) <*> (peek p33 >>= convert res i 33)
-          <*> (peek p34 >>= convert res i 34) <*> (peek p35 >>= convert res i 35)
-          <*> (peek p36 >>= convert res i 36)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
-  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
-  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
-  , FromSQL t37, FromSQL t38
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
-      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
-      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
-      alloca $ \p35 -> alloca $ \p36 -> alloca $ \p37 -> do
-        verify err =<< c_PQgetf38 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22 23 p23 24 p24 25 p25 26 p26 27 p27 28 p28 29 p29 30 p30 31 p31 32 p32 33 p33 34 p34 35 p35 36 p36 37 p37
-        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22) <*> (peek p23 >>= convert res i 23)
-          <*> (peek p24 >>= convert res i 24) <*> (peek p25 >>= convert res i 25)
-          <*> (peek p26 >>= convert res i 26) <*> (peek p27 >>= convert res i 27)
-          <*> (peek p28 >>= convert res i 28) <*> (peek p29 >>= convert res i 29)
-          <*> (peek p30 >>= convert res i 30) <*> (peek p31 >>= convert res i 31)
-          <*> (peek p32 >>= convert res i 32) <*> (peek p33 >>= convert res i 33)
-          <*> (peek p34 >>= convert res i 34) <*> (peek p35 >>= convert res i 35)
-          <*> (peek p36 >>= convert res i 36) <*> (peek p37 >>= convert res i 37)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
-  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
-  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
-  , FromSQL t37, FromSQL t38, FromSQL t39
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
-      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
-      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
-      alloca $ \p35 -> alloca $ \p36 -> alloca $ \p37 -> alloca $ \p38 -> do
-        verify err =<< c_PQgetf39 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22 23 p23 24 p24 25 p25 26 p26 27 p27 28 p28 29 p29 30 p30 31 p31 32 p32 33 p33 34 p34 35 p35 36 p36 37 p37 38 p38
-        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22) <*> (peek p23 >>= convert res i 23)
-          <*> (peek p24 >>= convert res i 24) <*> (peek p25 >>= convert res i 25)
-          <*> (peek p26 >>= convert res i 26) <*> (peek p27 >>= convert res i 27)
-          <*> (peek p28 >>= convert res i 28) <*> (peek p29 >>= convert res i 29)
-          <*> (peek p30 >>= convert res i 30) <*> (peek p31 >>= convert res i 31)
-          <*> (peek p32 >>= convert res i 32) <*> (peek p33 >>= convert res i 33)
-          <*> (peek p34 >>= convert res i 34) <*> (peek p35 >>= convert res i 35)
-          <*> (peek p36 >>= convert res i 36) <*> (peek p37 >>= convert res i 37)
-          <*> (peek p38 >>= convert res i 38)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
-  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
-  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
-  , FromSQL t37, FromSQL t38, FromSQL t39, FromSQL t40
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
-      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
-      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
-      alloca $ \p35 -> alloca $ \p36 -> alloca $ \p37 -> alloca $ \p38 -> alloca $ \p39 -> do
-        verify err =<< c_PQgetf40 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22 23 p23 24 p24 25 p25 26 p26 27 p27 28 p28 29 p29 30 p30 31 p31 32 p32 33 p33 34 p34 35 p35 36 p36 37 p37 38 p38 39 p39
-        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22) <*> (peek p23 >>= convert res i 23)
-          <*> (peek p24 >>= convert res i 24) <*> (peek p25 >>= convert res i 25)
-          <*> (peek p26 >>= convert res i 26) <*> (peek p27 >>= convert res i 27)
-          <*> (peek p28 >>= convert res i 28) <*> (peek p29 >>= convert res i 29)
-          <*> (peek p30 >>= convert res i 30) <*> (peek p31 >>= convert res i 31)
-          <*> (peek p32 >>= convert res i 32) <*> (peek p33 >>= convert res i 33)
-          <*> (peek p34 >>= convert res i 34) <*> (peek p35 >>= convert res i 35)
-          <*> (peek p36 >>= convert res i 36) <*> (peek p37 >>= convert res i 37)
-          <*> (peek p38 >>= convert res i 38) <*> (peek p39 >>= convert res i 39)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
-  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
-  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
-  , FromSQL t37, FromSQL t38, FromSQL t39, FromSQL t40, FromSQL t41
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
-      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
-      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
-      alloca $ \p35 -> alloca $ \p36 -> alloca $ \p37 -> alloca $ \p38 -> alloca $ \p39 ->
-      alloca $ \p40 -> do
-        verify err =<< c_PQgetf41 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22 23 p23 24 p24 25 p25 26 p26 27 p27 28 p28 29 p29 30 p30 31 p31 32 p32 33 p33 34 p34 35 p35 36 p36 37 p37 38 p38 39 p39 40 p40
-        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22) <*> (peek p23 >>= convert res i 23)
-          <*> (peek p24 >>= convert res i 24) <*> (peek p25 >>= convert res i 25)
-          <*> (peek p26 >>= convert res i 26) <*> (peek p27 >>= convert res i 27)
-          <*> (peek p28 >>= convert res i 28) <*> (peek p29 >>= convert res i 29)
-          <*> (peek p30 >>= convert res i 30) <*> (peek p31 >>= convert res i 31)
-          <*> (peek p32 >>= convert res i 32) <*> (peek p33 >>= convert res i 33)
-          <*> (peek p34 >>= convert res i 34) <*> (peek p35 >>= convert res i 35)
-          <*> (peek p36 >>= convert res i 36) <*> (peek p37 >>= convert res i 37)
-          <*> (peek p38 >>= convert res i 38) <*> (peek p39 >>= convert res i 39)
-          <*> (peek p40 >>= convert res i 40)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
-  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
-  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
-  , FromSQL t37, FromSQL t38, FromSQL t39, FromSQL t40, FromSQL t41, FromSQL t42
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
-      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
-      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
-      alloca $ \p35 -> alloca $ \p36 -> alloca $ \p37 -> alloca $ \p38 -> alloca $ \p39 ->
-      alloca $ \p40 -> alloca $ \p41 -> do
-        verify err =<< c_PQgetf42 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22 23 p23 24 p24 25 p25 26 p26 27 p27 28 p28 29 p29 30 p30 31 p31 32 p32 33 p33 34 p34 35 p35 36 p36 37 p37 38 p38 39 p39 40 p40 41 p41
-        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22) <*> (peek p23 >>= convert res i 23)
-          <*> (peek p24 >>= convert res i 24) <*> (peek p25 >>= convert res i 25)
-          <*> (peek p26 >>= convert res i 26) <*> (peek p27 >>= convert res i 27)
-          <*> (peek p28 >>= convert res i 28) <*> (peek p29 >>= convert res i 29)
-          <*> (peek p30 >>= convert res i 30) <*> (peek p31 >>= convert res i 31)
-          <*> (peek p32 >>= convert res i 32) <*> (peek p33 >>= convert res i 33)
-          <*> (peek p34 >>= convert res i 34) <*> (peek p35 >>= convert res i 35)
-          <*> (peek p36 >>= convert res i 36) <*> (peek p37 >>= convert res i 37)
-          <*> (peek p38 >>= convert res i 38) <*> (peek p39 >>= convert res i 39)
-          <*> (peek p40 >>= convert res i 40) <*> (peek p41 >>= convert res i 41)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
-  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
-  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
-  , FromSQL t37, FromSQL t38, FromSQL t39, FromSQL t40, FromSQL t41, FromSQL t42
-  , FromSQL t43
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
-      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
-      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
-      alloca $ \p35 -> alloca $ \p36 -> alloca $ \p37 -> alloca $ \p38 -> alloca $ \p39 ->
-      alloca $ \p40 -> alloca $ \p41 -> alloca $ \p42 -> do
-        verify err =<< c_PQgetf43 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22 23 p23 24 p24 25 p25 26 p26 27 p27 28 p28 29 p29 30 p30 31 p31 32 p32 33 p33 34 p34 35 p35 36 p36 37 p37 38 p38 39 p39 40 p40 41 p41 42 p42
-        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22) <*> (peek p23 >>= convert res i 23)
-          <*> (peek p24 >>= convert res i 24) <*> (peek p25 >>= convert res i 25)
-          <*> (peek p26 >>= convert res i 26) <*> (peek p27 >>= convert res i 27)
-          <*> (peek p28 >>= convert res i 28) <*> (peek p29 >>= convert res i 29)
-          <*> (peek p30 >>= convert res i 30) <*> (peek p31 >>= convert res i 31)
-          <*> (peek p32 >>= convert res i 32) <*> (peek p33 >>= convert res i 33)
-          <*> (peek p34 >>= convert res i 34) <*> (peek p35 >>= convert res i 35)
-          <*> (peek p36 >>= convert res i 36) <*> (peek p37 >>= convert res i 37)
-          <*> (peek p38 >>= convert res i 38) <*> (peek p39 >>= convert res i 39)
-          <*> (peek p40 >>= convert res i 40) <*> (peek p41 >>= convert res i 41)
-          <*> (peek p42 >>= convert res i 42)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
-  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
-  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
-  , FromSQL t37, FromSQL t38, FromSQL t39, FromSQL t40, FromSQL t41, FromSQL t42
-  , FromSQL t43, FromSQL t44
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
-      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
-      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
-      alloca $ \p35 -> alloca $ \p36 -> alloca $ \p37 -> alloca $ \p38 -> alloca $ \p39 ->
-      alloca $ \p40 -> alloca $ \p41 -> alloca $ \p42 -> alloca $ \p43 -> do
-        verify err =<< c_PQgetf44 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22 23 p23 24 p24 25 p25 26 p26 27 p27 28 p28 29 p29 30 p30 31 p31 32 p32 33 p33 34 p34 35 p35 36 p36 37 p37 38 p38 39 p39 40 p40 41 p41 42 p42 43 p43
-        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22) <*> (peek p23 >>= convert res i 23)
-          <*> (peek p24 >>= convert res i 24) <*> (peek p25 >>= convert res i 25)
-          <*> (peek p26 >>= convert res i 26) <*> (peek p27 >>= convert res i 27)
-          <*> (peek p28 >>= convert res i 28) <*> (peek p29 >>= convert res i 29)
-          <*> (peek p30 >>= convert res i 30) <*> (peek p31 >>= convert res i 31)
-          <*> (peek p32 >>= convert res i 32) <*> (peek p33 >>= convert res i 33)
-          <*> (peek p34 >>= convert res i 34) <*> (peek p35 >>= convert res i 35)
-          <*> (peek p36 >>= convert res i 36) <*> (peek p37 >>= convert res i 37)
-          <*> (peek p38 >>= convert res i 38) <*> (peek p39 >>= convert res i 39)
-          <*> (peek p40 >>= convert res i 40) <*> (peek p41 >>= convert res i 41)
-          <*> (peek p42 >>= convert res i 42) <*> (peek p43 >>= convert res i 43)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
-  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
-  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
-  , FromSQL t37, FromSQL t38, FromSQL t39, FromSQL t40, FromSQL t41, FromSQL t42
-  , FromSQL t43, FromSQL t44, FromSQL t45
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
-      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
-      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
-      alloca $ \p35 -> alloca $ \p36 -> alloca $ \p37 -> alloca $ \p38 -> alloca $ \p39 ->
-      alloca $ \p40 -> alloca $ \p41 -> alloca $ \p42 -> alloca $ \p43 -> alloca $ \p44 -> do
-        verify err =<< c_PQgetf45 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22 23 p23 24 p24 25 p25 26 p26 27 p27 28 p28 29 p29 30 p30 31 p31 32 p32 33 p33 34 p34 35 p35 36 p36 37 p37 38 p38 39 p39 40 p40 41 p41 42 p42 43 p43 44 p44
-        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22) <*> (peek p23 >>= convert res i 23)
-          <*> (peek p24 >>= convert res i 24) <*> (peek p25 >>= convert res i 25)
-          <*> (peek p26 >>= convert res i 26) <*> (peek p27 >>= convert res i 27)
-          <*> (peek p28 >>= convert res i 28) <*> (peek p29 >>= convert res i 29)
-          <*> (peek p30 >>= convert res i 30) <*> (peek p31 >>= convert res i 31)
-          <*> (peek p32 >>= convert res i 32) <*> (peek p33 >>= convert res i 33)
-          <*> (peek p34 >>= convert res i 34) <*> (peek p35 >>= convert res i 35)
-          <*> (peek p36 >>= convert res i 36) <*> (peek p37 >>= convert res i 37)
-          <*> (peek p38 >>= convert res i 38) <*> (peek p39 >>= convert res i 39)
-          <*> (peek p40 >>= convert res i 40) <*> (peek p41 >>= convert res i 41)
-          <*> (peek p42 >>= convert res i 42) <*> (peek p43 >>= convert res i 43)
-          <*> (peek p44 >>= convert res i 44)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
-  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
-  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
-  , FromSQL t37, FromSQL t38, FromSQL t39, FromSQL t40, FromSQL t41, FromSQL t42
-  , FromSQL t43, FromSQL t44, FromSQL t45, FromSQL t46
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45, t46) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
-      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
-      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
-      alloca $ \p35 -> alloca $ \p36 -> alloca $ \p37 -> alloca $ \p38 -> alloca $ \p39 ->
-      alloca $ \p40 -> alloca $ \p41 -> alloca $ \p42 -> alloca $ \p43 -> alloca $ \p44 ->
-      alloca $ \p45 -> do
-        verify err =<< c_PQgetf46 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22 23 p23 24 p24 25 p25 26 p26 27 p27 28 p28 29 p29 30 p30 31 p31 32 p32 33 p33 34 p34 35 p35 36 p36 37 p37 38 p38 39 p39 40 p40 41 p41 42 p42 43 p43 44 p44 45 p45
-        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22) <*> (peek p23 >>= convert res i 23)
-          <*> (peek p24 >>= convert res i 24) <*> (peek p25 >>= convert res i 25)
-          <*> (peek p26 >>= convert res i 26) <*> (peek p27 >>= convert res i 27)
-          <*> (peek p28 >>= convert res i 28) <*> (peek p29 >>= convert res i 29)
-          <*> (peek p30 >>= convert res i 30) <*> (peek p31 >>= convert res i 31)
-          <*> (peek p32 >>= convert res i 32) <*> (peek p33 >>= convert res i 33)
-          <*> (peek p34 >>= convert res i 34) <*> (peek p35 >>= convert res i 35)
-          <*> (peek p36 >>= convert res i 36) <*> (peek p37 >>= convert res i 37)
-          <*> (peek p38 >>= convert res i 38) <*> (peek p39 >>= convert res i 39)
-          <*> (peek p40 >>= convert res i 40) <*> (peek p41 >>= convert res i 41)
-          <*> (peek p42 >>= convert res i 42) <*> (peek p43 >>= convert res i 43)
-          <*> (peek p44 >>= convert res i 44) <*> (peek p45 >>= convert res i 45)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
-  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
-  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
-  , FromSQL t37, FromSQL t38, FromSQL t39, FromSQL t40, FromSQL t41, FromSQL t42
-  , FromSQL t43, FromSQL t44, FromSQL t45, FromSQL t46, FromSQL t47
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45, t46, t47) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
-      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
-      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
-      alloca $ \p35 -> alloca $ \p36 -> alloca $ \p37 -> alloca $ \p38 -> alloca $ \p39 ->
-      alloca $ \p40 -> alloca $ \p41 -> alloca $ \p42 -> alloca $ \p43 -> alloca $ \p44 ->
-      alloca $ \p45 -> alloca $ \p46 -> do
-        verify err =<< c_PQgetf47 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22 23 p23 24 p24 25 p25 26 p26 27 p27 28 p28 29 p29 30 p30 31 p31 32 p32 33 p33 34 p34 35 p35 36 p36 37 p37 38 p38 39 p39 40 p40 41 p41 42 p42 43 p43 44 p44 45 p45 46 p46
-        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22) <*> (peek p23 >>= convert res i 23)
-          <*> (peek p24 >>= convert res i 24) <*> (peek p25 >>= convert res i 25)
-          <*> (peek p26 >>= convert res i 26) <*> (peek p27 >>= convert res i 27)
-          <*> (peek p28 >>= convert res i 28) <*> (peek p29 >>= convert res i 29)
-          <*> (peek p30 >>= convert res i 30) <*> (peek p31 >>= convert res i 31)
-          <*> (peek p32 >>= convert res i 32) <*> (peek p33 >>= convert res i 33)
-          <*> (peek p34 >>= convert res i 34) <*> (peek p35 >>= convert res i 35)
-          <*> (peek p36 >>= convert res i 36) <*> (peek p37 >>= convert res i 37)
-          <*> (peek p38 >>= convert res i 38) <*> (peek p39 >>= convert res i 39)
-          <*> (peek p40 >>= convert res i 40) <*> (peek p41 >>= convert res i 41)
-          <*> (peek p42 >>= convert res i 42) <*> (peek p43 >>= convert res i 43)
-          <*> (peek p44 >>= convert res i 44) <*> (peek p45 >>= convert res i 45)
-          <*> (peek p46 >>= convert res i 46)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
-  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
-  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
-  , FromSQL t37, FromSQL t38, FromSQL t39, FromSQL t40, FromSQL t41, FromSQL t42
-  , FromSQL t43, FromSQL t44, FromSQL t45, FromSQL t46, FromSQL t47, FromSQL t48
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45, t46, t47, t48) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
-      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
-      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
-      alloca $ \p35 -> alloca $ \p36 -> alloca $ \p37 -> alloca $ \p38 -> alloca $ \p39 ->
-      alloca $ \p40 -> alloca $ \p41 -> alloca $ \p42 -> alloca $ \p43 -> alloca $ \p44 ->
-      alloca $ \p45 -> alloca $ \p46 -> alloca $ \p47 -> do
-        verify err =<< c_PQgetf48 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22 23 p23 24 p24 25 p25 26 p26 27 p27 28 p28 29 p29 30 p30 31 p31 32 p32 33 p33 34 p34 35 p35 36 p36 37 p37 38 p38 39 p39 40 p40 41 p41 42 p42 43 p43 44 p44 45 p45 46 p46 47 p47
-        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22) <*> (peek p23 >>= convert res i 23)
-          <*> (peek p24 >>= convert res i 24) <*> (peek p25 >>= convert res i 25)
-          <*> (peek p26 >>= convert res i 26) <*> (peek p27 >>= convert res i 27)
-          <*> (peek p28 >>= convert res i 28) <*> (peek p29 >>= convert res i 29)
-          <*> (peek p30 >>= convert res i 30) <*> (peek p31 >>= convert res i 31)
-          <*> (peek p32 >>= convert res i 32) <*> (peek p33 >>= convert res i 33)
-          <*> (peek p34 >>= convert res i 34) <*> (peek p35 >>= convert res i 35)
-          <*> (peek p36 >>= convert res i 36) <*> (peek p37 >>= convert res i 37)
-          <*> (peek p38 >>= convert res i 38) <*> (peek p39 >>= convert res i 39)
-          <*> (peek p40 >>= convert res i 40) <*> (peek p41 >>= convert res i 41)
-          <*> (peek p42 >>= convert res i 42) <*> (peek p43 >>= convert res i 43)
-          <*> (peek p44 >>= convert res i 44) <*> (peek p45 >>= convert res i 45)
-          <*> (peek p46 >>= convert res i 46) <*> (peek p47 >>= convert res i 47)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
-  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
-  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
-  , FromSQL t37, FromSQL t38, FromSQL t39, FromSQL t40, FromSQL t41, FromSQL t42
-  , FromSQL t43, FromSQL t44, FromSQL t45, FromSQL t46, FromSQL t47, FromSQL t48
-  , FromSQL t49
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45, t46, t47, t48, t49) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
-      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
-      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
-      alloca $ \p35 -> alloca $ \p36 -> alloca $ \p37 -> alloca $ \p38 -> alloca $ \p39 ->
-      alloca $ \p40 -> alloca $ \p41 -> alloca $ \p42 -> alloca $ \p43 -> alloca $ \p44 ->
-      alloca $ \p45 -> alloca $ \p46 -> alloca $ \p47 -> alloca $ \p48 -> do
-        verify err =<< c_PQgetf49 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22 23 p23 24 p24 25 p25 26 p26 27 p27 28 p28 29 p29 30 p30 31 p31 32 p32 33 p33 34 p34 35 p35 36 p36 37 p37 38 p38 39 p39 40 p40 41 p41 42 p42 43 p43 44 p44 45 p45 46 p46 47 p47 48 p48
-        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22) <*> (peek p23 >>= convert res i 23)
-          <*> (peek p24 >>= convert res i 24) <*> (peek p25 >>= convert res i 25)
-          <*> (peek p26 >>= convert res i 26) <*> (peek p27 >>= convert res i 27)
-          <*> (peek p28 >>= convert res i 28) <*> (peek p29 >>= convert res i 29)
-          <*> (peek p30 >>= convert res i 30) <*> (peek p31 >>= convert res i 31)
-          <*> (peek p32 >>= convert res i 32) <*> (peek p33 >>= convert res i 33)
-          <*> (peek p34 >>= convert res i 34) <*> (peek p35 >>= convert res i 35)
-          <*> (peek p36 >>= convert res i 36) <*> (peek p37 >>= convert res i 37)
-          <*> (peek p38 >>= convert res i 38) <*> (peek p39 >>= convert res i 39)
-          <*> (peek p40 >>= convert res i 40) <*> (peek p41 >>= convert res i 41)
-          <*> (peek p42 >>= convert res i 42) <*> (peek p43 >>= convert res i 43)
-          <*> (peek p44 >>= convert res i 44) <*> (peek p45 >>= convert res i 45)
-          <*> (peek p46 >>= convert res i 46) <*> (peek p47 >>= convert res i 47)
-          <*> (peek p48 >>= convert res i 48)
-
-instance (
-    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
-  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
-  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
-  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
-  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
-  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
-  , FromSQL t37, FromSQL t38, FromSQL t39, FromSQL t40, FromSQL t41, FromSQL t42
-  , FromSQL t43, FromSQL t44, FromSQL t45, FromSQL t46, FromSQL t47, FromSQL t48
-  , FromSQL t49, FromSQL t50
-  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45, t46, t47, t48, t49, t50) where
-    fromRow res err i fmt =
-      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
-      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
-      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
-      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
-      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
-      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
-      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
-      alloca $ \p35 -> alloca $ \p36 -> alloca $ \p37 -> alloca $ \p38 -> alloca $ \p39 ->
-      alloca $ \p40 -> alloca $ \p41 -> alloca $ \p42 -> alloca $ \p43 -> alloca $ \p44 ->
-      alloca $ \p45 -> alloca $ \p46 -> alloca $ \p47 -> alloca $ \p48 -> alloca $ \p49 -> do
-        verify err =<< c_PQgetf50 res err i fmt 0 p0 1 p1 2 p2 3 p3 4 p4 5 p5 6 p6 7 p7 8 p8 9 p9 10 p10 11 p11 12 p12 13 p13 14 p14 15 p15 16 p16 17 p17 18 p18 19 p19 20 p20 21 p21 22 p22 23 p23 24 p24 25 p25 26 p26 27 p27 28 p28 29 p29 30 p30 31 p31 32 p32 33 p33 34 p34 35 p35 36 p36 37 p37 38 p38 39 p39 40 p40 41 p41 42 p42 43 p43 44 p44 45 p45 46 p46 47 p47 48 p48 49 p49
-        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
-          <$> (peek p0 >>= convert res i 0) <*> (peek p1 >>= convert res i 1)
-          <*> (peek p2 >>= convert res i 2) <*> (peek p3 >>= convert res i 3)
-          <*> (peek p4 >>= convert res i 4) <*> (peek p5 >>= convert res i 5)
-          <*> (peek p6 >>= convert res i 6) <*> (peek p7 >>= convert res i 7)
-          <*> (peek p8 >>= convert res i 8) <*> (peek p9 >>= convert res i 9)
-          <*> (peek p10 >>= convert res i 10) <*> (peek p11 >>= convert res i 11)
-          <*> (peek p12 >>= convert res i 12) <*> (peek p13 >>= convert res i 13)
-          <*> (peek p14 >>= convert res i 14) <*> (peek p15 >>= convert res i 15)
-          <*> (peek p16 >>= convert res i 16) <*> (peek p17 >>= convert res i 17)
-          <*> (peek p18 >>= convert res i 18) <*> (peek p19 >>= convert res i 19)
-          <*> (peek p20 >>= convert res i 20) <*> (peek p21 >>= convert res i 21)
-          <*> (peek p22 >>= convert res i 22) <*> (peek p23 >>= convert res i 23)
-          <*> (peek p24 >>= convert res i 24) <*> (peek p25 >>= convert res i 25)
-          <*> (peek p26 >>= convert res i 26) <*> (peek p27 >>= convert res i 27)
-          <*> (peek p28 >>= convert res i 28) <*> (peek p29 >>= convert res i 29)
-          <*> (peek p30 >>= convert res i 30) <*> (peek p31 >>= convert res i 31)
-          <*> (peek p32 >>= convert res i 32) <*> (peek p33 >>= convert res i 33)
-          <*> (peek p34 >>= convert res i 34) <*> (peek p35 >>= convert res i 35)
-          <*> (peek p36 >>= convert res i 36) <*> (peek p37 >>= convert res i 37)
-          <*> (peek p38 >>= convert res i 38) <*> (peek p39 >>= convert res i 39)
-          <*> (peek p40 >>= convert res i 40) <*> (peek p41 >>= convert res i 41)
-          <*> (peek p42 >>= convert res i 42) <*> (peek p43 >>= convert res i 43)
-          <*> (peek p44 >>= convert res i 44) <*> (peek p45 >>= convert res i 45)
-          <*> (peek p46 >>= convert res i 46) <*> (peek p47 >>= convert res i 47)
-          <*> (peek p48 >>= convert res i 48) <*> (peek p49 >>= convert res i 49)
+{-# LANGUAGE FlexibleInstances, ScopedTypeVariables, TypeOperators #-}
+module Database.PostgreSQL.PQTypes.FromRow (
+    FromRow(..)
+  , fromRow'
+  ) where
+
+import Control.Applicative
+import Data.Functor.Identity
+import Foreign.C
+import Foreign.Marshal.Alloc
+import Foreign.Storable
+import Foreign.Ptr
+import qualified Control.Exception as E
+import qualified Data.ByteString.Unsafe as BS
+
+import Database.PostgreSQL.PQTypes.Format
+import Database.PostgreSQL.PQTypes.FromSQL
+import Database.PostgreSQL.PQTypes.Internal.C.Get
+import Database.PostgreSQL.PQTypes.Internal.C.Interface
+import Database.PostgreSQL.PQTypes.Internal.C.Types
+import Database.PostgreSQL.PQTypes.Internal.Error
+import Database.PostgreSQL.PQTypes.Internal.Utils
+
+-- | Convert base (libpqtypes) type to destination type.
+convert :: FromSQL t => Ptr PGresult -> CInt -> CInt -> PQBase t -> IO t
+convert res tuple column base = do
+  isNull <- c_PQgetisnull res tuple column
+  fromSQL (if isNull == 1 then Nothing else Just base)
+    `E.catch` rethrowWithConvError
+  where
+    rethrowWithConvError :: E.SomeException -> IO a
+    rethrowWithConvError (E.SomeException e) = do
+      colname <- safePeekCString' =<< c_PQfname res column
+      E.throwIO ConversionError {
+        convColumn = fromIntegral column + 1
+      , convColumnName = colname
+      , convRow = fromIntegral tuple + 1
+      , convError = e
+      }
+
+-- | 'verifyPQTRes' specialized for usage in 'fromRow'.
+verify :: Ptr PGerror -> CInt -> IO ()
+verify err = verifyPQTRes err "fromRow"
+
+withFormat :: forall row. FromRow row => (CString -> IO row) -> IO row
+withFormat = BS.unsafeUseAsCString $ pqFormat0 (undefined::row)
+
+----------------------------------------
+
+-- | More convenient version of 'fromRow' that allocates 'PGerror' by itself.
+fromRow' :: forall row. FromRow row => Ptr PGresult -> CInt -> CInt -> IO row
+fromRow' res b i = alloca $ \err -> fromRow res err b i
+
+-- | Class which represents \"from SQL row to Haskell tuple\" transformation.
+class PQFormat row => FromRow row where
+  -- | Extract SQL row from 'PGresult' and convert it into a tuple.
+  fromRow  :: Ptr PGresult -- ^ Source result.
+           -> Ptr PGerror  -- ^ Local error info.
+           -> CInt         -- ^ Base position for c_PQgetf.
+           -> CInt         -- ^ Index of row to be extracted.
+           -> IO row
+
+instance (
+    FromRow row1, FromRow row2
+  ) => FromRow (row1 :*: row2) where
+    fromRow res err b i = (:*:)
+      <$> fromRow res err b  i
+      <*> fromRow res err b' i
+      where
+        b' = b + fromIntegral (pqVariables (undefined::row1))
+
+instance FromRow () where
+  fromRow _ _ _ _ = return ()
+
+instance FromSQL t => FromRow (Identity t) where
+  fromRow res err b i = withFormat $ \fmt -> alloca $ \p1 -> do
+    verify err =<< c_PQgetf1 res err i fmt b p1
+    t <- peek p1 >>= convert res i b
+    return (Identity t)
+
+instance (
+    FromSQL t1, FromSQL t2
+  ) => FromRow (t1, t2) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> do
+        verify err =<< c_PQgetf2 res err i fmt b p0 (b+1) p1
+        (,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3
+  ) => FromRow (t1, t2, t3) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> do
+        verify err =<< c_PQgetf3 res err i fmt b p0 (b+1) p1 (b+2) p2
+        (,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4
+  ) => FromRow (t1, t2, t3, t4) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> do
+        verify err =<< c_PQgetf4 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3
+        (,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5
+  ) => FromRow (t1, t2, t3, t4, t5) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 -> do
+        verify err =<< c_PQgetf5 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4
+        (,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  ) => FromRow (t1, t2, t3, t4, t5, t6) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> do
+        verify err =<< c_PQgetf6 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5
+        (,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> do
+        verify err =<< c_PQgetf7 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6
+        (,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> do
+        verify err =<< c_PQgetf8 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7
+        (,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> do
+        verify err =<< c_PQgetf9 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8
+        (,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 -> do
+        verify err =<< c_PQgetf10 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9
+        (,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> do
+        verify err =<< c_PQgetf11 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10
+        (,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> do
+        verify err =<< c_PQgetf12 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11
+        (,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> do
+        verify err =<< c_PQgetf13 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12
+        (,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> do
+        verify err =<< c_PQgetf14 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13
+        (,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 -> do
+        verify err =<< c_PQgetf15 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14
+        (,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> do
+        verify err =<< c_PQgetf16 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15
+        (,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> do
+        verify err =<< c_PQgetf17 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16
+        (,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> do
+        verify err =<< c_PQgetf18 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17
+        (,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> do
+        verify err =<< c_PQgetf19 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18
+        (,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 -> do
+        verify err =<< c_PQgetf20 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19
+        (,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> do
+        verify err =<< c_PQgetf21 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20
+        (,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> do
+        verify err =<< c_PQgetf22 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21
+        (,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> do
+        verify err =<< c_PQgetf23 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22
+        (,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> do
+        verify err =<< c_PQgetf24 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22 (b+23) p23
+        (,,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22)) <*> (peek p23 >>= convert res i (b+23))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
+  , FromSQL t25
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 -> do
+        verify err =<< c_PQgetf25 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22 (b+23) p23 (b+24) p24
+        (,,,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22)) <*> (peek p23 >>= convert res i (b+23))
+          <*> (peek p24 >>= convert res i (b+24))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
+  , FromSQL t25, FromSQL t26
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
+      alloca $ \p25 -> do
+        verify err =<< c_PQgetf26 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22 (b+23) p23 (b+24) p24 (b+25) p25
+        (,,,,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22)) <*> (peek p23 >>= convert res i (b+23))
+          <*> (peek p24 >>= convert res i (b+24)) <*> (peek p25 >>= convert res i (b+25))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
+  , FromSQL t25, FromSQL t26, FromSQL t27
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
+      alloca $ \p25 -> alloca $ \p26 -> do
+        verify err =<< c_PQgetf27 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22 (b+23) p23 (b+24) p24 (b+25) p25 (b+26) p26
+        (,,,,,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22)) <*> (peek p23 >>= convert res i (b+23))
+          <*> (peek p24 >>= convert res i (b+24)) <*> (peek p25 >>= convert res i (b+25))
+          <*> (peek p26 >>= convert res i (b+26))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
+  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
+      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> do
+        verify err =<< c_PQgetf28 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22 (b+23) p23 (b+24) p24 (b+25) p25 (b+26) p26 (b+27) p27
+        (,,,,,,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22)) <*> (peek p23 >>= convert res i (b+23))
+          <*> (peek p24 >>= convert res i (b+24)) <*> (peek p25 >>= convert res i (b+25))
+          <*> (peek p26 >>= convert res i (b+26)) <*> (peek p27 >>= convert res i (b+27))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
+  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
+      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> do
+        verify err =<< c_PQgetf29 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22 (b+23) p23 (b+24) p24 (b+25) p25 (b+26) p26 (b+27) p27 (b+28) p28
+        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22)) <*> (peek p23 >>= convert res i (b+23))
+          <*> (peek p24 >>= convert res i (b+24)) <*> (peek p25 >>= convert res i (b+25))
+          <*> (peek p26 >>= convert res i (b+26)) <*> (peek p27 >>= convert res i (b+27))
+          <*> (peek p28 >>= convert res i (b+28))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
+  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
+      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 -> do
+        verify err =<< c_PQgetf30 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22 (b+23) p23 (b+24) p24 (b+25) p25 (b+26) p26 (b+27) p27 (b+28) p28 (b+29) p29
+        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22)) <*> (peek p23 >>= convert res i (b+23))
+          <*> (peek p24 >>= convert res i (b+24)) <*> (peek p25 >>= convert res i (b+25))
+          <*> (peek p26 >>= convert res i (b+26)) <*> (peek p27 >>= convert res i (b+27))
+          <*> (peek p28 >>= convert res i (b+28)) <*> (peek p29 >>= convert res i (b+29))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
+  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
+  , FromSQL t31
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
+      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
+      alloca $ \p30 -> do
+        verify err =<< c_PQgetf31 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22 (b+23) p23 (b+24) p24 (b+25) p25 (b+26) p26 (b+27) p27 (b+28) p28 (b+29) p29 (b+30) p30
+        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22)) <*> (peek p23 >>= convert res i (b+23))
+          <*> (peek p24 >>= convert res i (b+24)) <*> (peek p25 >>= convert res i (b+25))
+          <*> (peek p26 >>= convert res i (b+26)) <*> (peek p27 >>= convert res i (b+27))
+          <*> (peek p28 >>= convert res i (b+28)) <*> (peek p29 >>= convert res i (b+29))
+          <*> (peek p30 >>= convert res i (b+30))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
+  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
+  , FromSQL t31, FromSQL t32
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
+      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
+      alloca $ \p30 -> alloca $ \p31 -> do
+        verify err =<< c_PQgetf32 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22 (b+23) p23 (b+24) p24 (b+25) p25 (b+26) p26 (b+27) p27 (b+28) p28 (b+29) p29 (b+30) p30 (b+31) p31
+        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22)) <*> (peek p23 >>= convert res i (b+23))
+          <*> (peek p24 >>= convert res i (b+24)) <*> (peek p25 >>= convert res i (b+25))
+          <*> (peek p26 >>= convert res i (b+26)) <*> (peek p27 >>= convert res i (b+27))
+          <*> (peek p28 >>= convert res i (b+28)) <*> (peek p29 >>= convert res i (b+29))
+          <*> (peek p30 >>= convert res i (b+30)) <*> (peek p31 >>= convert res i (b+31))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
+  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
+  , FromSQL t31, FromSQL t32, FromSQL t33
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
+      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
+      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> do
+        verify err =<< c_PQgetf33 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22 (b+23) p23 (b+24) p24 (b+25) p25 (b+26) p26 (b+27) p27 (b+28) p28 (b+29) p29 (b+30) p30 (b+31) p31 (b+32) p32
+        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22)) <*> (peek p23 >>= convert res i (b+23))
+          <*> (peek p24 >>= convert res i (b+24)) <*> (peek p25 >>= convert res i (b+25))
+          <*> (peek p26 >>= convert res i (b+26)) <*> (peek p27 >>= convert res i (b+27))
+          <*> (peek p28 >>= convert res i (b+28)) <*> (peek p29 >>= convert res i (b+29))
+          <*> (peek p30 >>= convert res i (b+30)) <*> (peek p31 >>= convert res i (b+31))
+          <*> (peek p32 >>= convert res i (b+32))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
+  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
+  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
+      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
+      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> do
+        verify err =<< c_PQgetf34 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22 (b+23) p23 (b+24) p24 (b+25) p25 (b+26) p26 (b+27) p27 (b+28) p28 (b+29) p29 (b+30) p30 (b+31) p31 (b+32) p32 (b+33) p33
+        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22)) <*> (peek p23 >>= convert res i (b+23))
+          <*> (peek p24 >>= convert res i (b+24)) <*> (peek p25 >>= convert res i (b+25))
+          <*> (peek p26 >>= convert res i (b+26)) <*> (peek p27 >>= convert res i (b+27))
+          <*> (peek p28 >>= convert res i (b+28)) <*> (peek p29 >>= convert res i (b+29))
+          <*> (peek p30 >>= convert res i (b+30)) <*> (peek p31 >>= convert res i (b+31))
+          <*> (peek p32 >>= convert res i (b+32)) <*> (peek p33 >>= convert res i (b+33))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
+  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
+  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
+      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
+      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 -> do
+        verify err =<< c_PQgetf35 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22 (b+23) p23 (b+24) p24 (b+25) p25 (b+26) p26 (b+27) p27 (b+28) p28 (b+29) p29 (b+30) p30 (b+31) p31 (b+32) p32 (b+33) p33 (b+34) p34
+        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22)) <*> (peek p23 >>= convert res i (b+23))
+          <*> (peek p24 >>= convert res i (b+24)) <*> (peek p25 >>= convert res i (b+25))
+          <*> (peek p26 >>= convert res i (b+26)) <*> (peek p27 >>= convert res i (b+27))
+          <*> (peek p28 >>= convert res i (b+28)) <*> (peek p29 >>= convert res i (b+29))
+          <*> (peek p30 >>= convert res i (b+30)) <*> (peek p31 >>= convert res i (b+31))
+          <*> (peek p32 >>= convert res i (b+32)) <*> (peek p33 >>= convert res i (b+33))
+          <*> (peek p34 >>= convert res i (b+34))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
+  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
+  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
+      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
+      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
+      alloca $ \p35 -> do
+        verify err =<< c_PQgetf36 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22 (b+23) p23 (b+24) p24 (b+25) p25 (b+26) p26 (b+27) p27 (b+28) p28 (b+29) p29 (b+30) p30 (b+31) p31 (b+32) p32 (b+33) p33 (b+34) p34 (b+35) p35
+        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22)) <*> (peek p23 >>= convert res i (b+23))
+          <*> (peek p24 >>= convert res i (b+24)) <*> (peek p25 >>= convert res i (b+25))
+          <*> (peek p26 >>= convert res i (b+26)) <*> (peek p27 >>= convert res i (b+27))
+          <*> (peek p28 >>= convert res i (b+28)) <*> (peek p29 >>= convert res i (b+29))
+          <*> (peek p30 >>= convert res i (b+30)) <*> (peek p31 >>= convert res i (b+31))
+          <*> (peek p32 >>= convert res i (b+32)) <*> (peek p33 >>= convert res i (b+33))
+          <*> (peek p34 >>= convert res i (b+34)) <*> (peek p35 >>= convert res i (b+35))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
+  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
+  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
+  , FromSQL t37
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
+      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
+      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
+      alloca $ \p35 -> alloca $ \p36 -> do
+        verify err =<< c_PQgetf37 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22 (b+23) p23 (b+24) p24 (b+25) p25 (b+26) p26 (b+27) p27 (b+28) p28 (b+29) p29 (b+30) p30 (b+31) p31 (b+32) p32 (b+33) p33 (b+34) p34 (b+35) p35 (b+36) p36
+        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22)) <*> (peek p23 >>= convert res i (b+23))
+          <*> (peek p24 >>= convert res i (b+24)) <*> (peek p25 >>= convert res i (b+25))
+          <*> (peek p26 >>= convert res i (b+26)) <*> (peek p27 >>= convert res i (b+27))
+          <*> (peek p28 >>= convert res i (b+28)) <*> (peek p29 >>= convert res i (b+29))
+          <*> (peek p30 >>= convert res i (b+30)) <*> (peek p31 >>= convert res i (b+31))
+          <*> (peek p32 >>= convert res i (b+32)) <*> (peek p33 >>= convert res i (b+33))
+          <*> (peek p34 >>= convert res i (b+34)) <*> (peek p35 >>= convert res i (b+35))
+          <*> (peek p36 >>= convert res i (b+36))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
+  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
+  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
+  , FromSQL t37, FromSQL t38
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
+      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
+      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
+      alloca $ \p35 -> alloca $ \p36 -> alloca $ \p37 -> do
+        verify err =<< c_PQgetf38 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22 (b+23) p23 (b+24) p24 (b+25) p25 (b+26) p26 (b+27) p27 (b+28) p28 (b+29) p29 (b+30) p30 (b+31) p31 (b+32) p32 (b+33) p33 (b+34) p34 (b+35) p35 (b+36) p36 (b+37) p37
+        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22)) <*> (peek p23 >>= convert res i (b+23))
+          <*> (peek p24 >>= convert res i (b+24)) <*> (peek p25 >>= convert res i (b+25))
+          <*> (peek p26 >>= convert res i (b+26)) <*> (peek p27 >>= convert res i (b+27))
+          <*> (peek p28 >>= convert res i (b+28)) <*> (peek p29 >>= convert res i (b+29))
+          <*> (peek p30 >>= convert res i (b+30)) <*> (peek p31 >>= convert res i (b+31))
+          <*> (peek p32 >>= convert res i (b+32)) <*> (peek p33 >>= convert res i (b+33))
+          <*> (peek p34 >>= convert res i (b+34)) <*> (peek p35 >>= convert res i (b+35))
+          <*> (peek p36 >>= convert res i (b+36)) <*> (peek p37 >>= convert res i (b+37))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
+  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
+  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
+  , FromSQL t37, FromSQL t38, FromSQL t39
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
+      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
+      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
+      alloca $ \p35 -> alloca $ \p36 -> alloca $ \p37 -> alloca $ \p38 -> do
+        verify err =<< c_PQgetf39 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22 (b+23) p23 (b+24) p24 (b+25) p25 (b+26) p26 (b+27) p27 (b+28) p28 (b+29) p29 (b+30) p30 (b+31) p31 (b+32) p32 (b+33) p33 (b+34) p34 (b+35) p35 (b+36) p36 (b+37) p37 (b+38) p38
+        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22)) <*> (peek p23 >>= convert res i (b+23))
+          <*> (peek p24 >>= convert res i (b+24)) <*> (peek p25 >>= convert res i (b+25))
+          <*> (peek p26 >>= convert res i (b+26)) <*> (peek p27 >>= convert res i (b+27))
+          <*> (peek p28 >>= convert res i (b+28)) <*> (peek p29 >>= convert res i (b+29))
+          <*> (peek p30 >>= convert res i (b+30)) <*> (peek p31 >>= convert res i (b+31))
+          <*> (peek p32 >>= convert res i (b+32)) <*> (peek p33 >>= convert res i (b+33))
+          <*> (peek p34 >>= convert res i (b+34)) <*> (peek p35 >>= convert res i (b+35))
+          <*> (peek p36 >>= convert res i (b+36)) <*> (peek p37 >>= convert res i (b+37))
+          <*> (peek p38 >>= convert res i (b+38))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
+  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
+  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
+  , FromSQL t37, FromSQL t38, FromSQL t39, FromSQL t40
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
+      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
+      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
+      alloca $ \p35 -> alloca $ \p36 -> alloca $ \p37 -> alloca $ \p38 -> alloca $ \p39 -> do
+        verify err =<< c_PQgetf40 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22 (b+23) p23 (b+24) p24 (b+25) p25 (b+26) p26 (b+27) p27 (b+28) p28 (b+29) p29 (b+30) p30 (b+31) p31 (b+32) p32 (b+33) p33 (b+34) p34 (b+35) p35 (b+36) p36 (b+37) p37 (b+38) p38 (b+39) p39
+        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22)) <*> (peek p23 >>= convert res i (b+23))
+          <*> (peek p24 >>= convert res i (b+24)) <*> (peek p25 >>= convert res i (b+25))
+          <*> (peek p26 >>= convert res i (b+26)) <*> (peek p27 >>= convert res i (b+27))
+          <*> (peek p28 >>= convert res i (b+28)) <*> (peek p29 >>= convert res i (b+29))
+          <*> (peek p30 >>= convert res i (b+30)) <*> (peek p31 >>= convert res i (b+31))
+          <*> (peek p32 >>= convert res i (b+32)) <*> (peek p33 >>= convert res i (b+33))
+          <*> (peek p34 >>= convert res i (b+34)) <*> (peek p35 >>= convert res i (b+35))
+          <*> (peek p36 >>= convert res i (b+36)) <*> (peek p37 >>= convert res i (b+37))
+          <*> (peek p38 >>= convert res i (b+38)) <*> (peek p39 >>= convert res i (b+39))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
+  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
+  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
+  , FromSQL t37, FromSQL t38, FromSQL t39, FromSQL t40, FromSQL t41
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
+      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
+      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
+      alloca $ \p35 -> alloca $ \p36 -> alloca $ \p37 -> alloca $ \p38 -> alloca $ \p39 ->
+      alloca $ \p40 -> do
+        verify err =<< c_PQgetf41 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22 (b+23) p23 (b+24) p24 (b+25) p25 (b+26) p26 (b+27) p27 (b+28) p28 (b+29) p29 (b+30) p30 (b+31) p31 (b+32) p32 (b+33) p33 (b+34) p34 (b+35) p35 (b+36) p36 (b+37) p37 (b+38) p38 (b+39) p39 (b+40) p40
+        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22)) <*> (peek p23 >>= convert res i (b+23))
+          <*> (peek p24 >>= convert res i (b+24)) <*> (peek p25 >>= convert res i (b+25))
+          <*> (peek p26 >>= convert res i (b+26)) <*> (peek p27 >>= convert res i (b+27))
+          <*> (peek p28 >>= convert res i (b+28)) <*> (peek p29 >>= convert res i (b+29))
+          <*> (peek p30 >>= convert res i (b+30)) <*> (peek p31 >>= convert res i (b+31))
+          <*> (peek p32 >>= convert res i (b+32)) <*> (peek p33 >>= convert res i (b+33))
+          <*> (peek p34 >>= convert res i (b+34)) <*> (peek p35 >>= convert res i (b+35))
+          <*> (peek p36 >>= convert res i (b+36)) <*> (peek p37 >>= convert res i (b+37))
+          <*> (peek p38 >>= convert res i (b+38)) <*> (peek p39 >>= convert res i (b+39))
+          <*> (peek p40 >>= convert res i (b+40))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
+  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
+  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
+  , FromSQL t37, FromSQL t38, FromSQL t39, FromSQL t40, FromSQL t41, FromSQL t42
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
+      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
+      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
+      alloca $ \p35 -> alloca $ \p36 -> alloca $ \p37 -> alloca $ \p38 -> alloca $ \p39 ->
+      alloca $ \p40 -> alloca $ \p41 -> do
+        verify err =<< c_PQgetf42 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22 (b+23) p23 (b+24) p24 (b+25) p25 (b+26) p26 (b+27) p27 (b+28) p28 (b+29) p29 (b+30) p30 (b+31) p31 (b+32) p32 (b+33) p33 (b+34) p34 (b+35) p35 (b+36) p36 (b+37) p37 (b+38) p38 (b+39) p39 (b+40) p40 (b+41) p41
+        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22)) <*> (peek p23 >>= convert res i (b+23))
+          <*> (peek p24 >>= convert res i (b+24)) <*> (peek p25 >>= convert res i (b+25))
+          <*> (peek p26 >>= convert res i (b+26)) <*> (peek p27 >>= convert res i (b+27))
+          <*> (peek p28 >>= convert res i (b+28)) <*> (peek p29 >>= convert res i (b+29))
+          <*> (peek p30 >>= convert res i (b+30)) <*> (peek p31 >>= convert res i (b+31))
+          <*> (peek p32 >>= convert res i (b+32)) <*> (peek p33 >>= convert res i (b+33))
+          <*> (peek p34 >>= convert res i (b+34)) <*> (peek p35 >>= convert res i (b+35))
+          <*> (peek p36 >>= convert res i (b+36)) <*> (peek p37 >>= convert res i (b+37))
+          <*> (peek p38 >>= convert res i (b+38)) <*> (peek p39 >>= convert res i (b+39))
+          <*> (peek p40 >>= convert res i (b+40)) <*> (peek p41 >>= convert res i (b+41))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
+  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
+  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
+  , FromSQL t37, FromSQL t38, FromSQL t39, FromSQL t40, FromSQL t41, FromSQL t42
+  , FromSQL t43
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
+      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
+      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
+      alloca $ \p35 -> alloca $ \p36 -> alloca $ \p37 -> alloca $ \p38 -> alloca $ \p39 ->
+      alloca $ \p40 -> alloca $ \p41 -> alloca $ \p42 -> do
+        verify err =<< c_PQgetf43 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22 (b+23) p23 (b+24) p24 (b+25) p25 (b+26) p26 (b+27) p27 (b+28) p28 (b+29) p29 (b+30) p30 (b+31) p31 (b+32) p32 (b+33) p33 (b+34) p34 (b+35) p35 (b+36) p36 (b+37) p37 (b+38) p38 (b+39) p39 (b+40) p40 (b+41) p41 (b+42) p42
+        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22)) <*> (peek p23 >>= convert res i (b+23))
+          <*> (peek p24 >>= convert res i (b+24)) <*> (peek p25 >>= convert res i (b+25))
+          <*> (peek p26 >>= convert res i (b+26)) <*> (peek p27 >>= convert res i (b+27))
+          <*> (peek p28 >>= convert res i (b+28)) <*> (peek p29 >>= convert res i (b+29))
+          <*> (peek p30 >>= convert res i (b+30)) <*> (peek p31 >>= convert res i (b+31))
+          <*> (peek p32 >>= convert res i (b+32)) <*> (peek p33 >>= convert res i (b+33))
+          <*> (peek p34 >>= convert res i (b+34)) <*> (peek p35 >>= convert res i (b+35))
+          <*> (peek p36 >>= convert res i (b+36)) <*> (peek p37 >>= convert res i (b+37))
+          <*> (peek p38 >>= convert res i (b+38)) <*> (peek p39 >>= convert res i (b+39))
+          <*> (peek p40 >>= convert res i (b+40)) <*> (peek p41 >>= convert res i (b+41))
+          <*> (peek p42 >>= convert res i (b+42))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
+  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
+  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
+  , FromSQL t37, FromSQL t38, FromSQL t39, FromSQL t40, FromSQL t41, FromSQL t42
+  , FromSQL t43, FromSQL t44
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
+      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
+      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
+      alloca $ \p35 -> alloca $ \p36 -> alloca $ \p37 -> alloca $ \p38 -> alloca $ \p39 ->
+      alloca $ \p40 -> alloca $ \p41 -> alloca $ \p42 -> alloca $ \p43 -> do
+        verify err =<< c_PQgetf44 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22 (b+23) p23 (b+24) p24 (b+25) p25 (b+26) p26 (b+27) p27 (b+28) p28 (b+29) p29 (b+30) p30 (b+31) p31 (b+32) p32 (b+33) p33 (b+34) p34 (b+35) p35 (b+36) p36 (b+37) p37 (b+38) p38 (b+39) p39 (b+40) p40 (b+41) p41 (b+42) p42 (b+43) p43
+        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22)) <*> (peek p23 >>= convert res i (b+23))
+          <*> (peek p24 >>= convert res i (b+24)) <*> (peek p25 >>= convert res i (b+25))
+          <*> (peek p26 >>= convert res i (b+26)) <*> (peek p27 >>= convert res i (b+27))
+          <*> (peek p28 >>= convert res i (b+28)) <*> (peek p29 >>= convert res i (b+29))
+          <*> (peek p30 >>= convert res i (b+30)) <*> (peek p31 >>= convert res i (b+31))
+          <*> (peek p32 >>= convert res i (b+32)) <*> (peek p33 >>= convert res i (b+33))
+          <*> (peek p34 >>= convert res i (b+34)) <*> (peek p35 >>= convert res i (b+35))
+          <*> (peek p36 >>= convert res i (b+36)) <*> (peek p37 >>= convert res i (b+37))
+          <*> (peek p38 >>= convert res i (b+38)) <*> (peek p39 >>= convert res i (b+39))
+          <*> (peek p40 >>= convert res i (b+40)) <*> (peek p41 >>= convert res i (b+41))
+          <*> (peek p42 >>= convert res i (b+42)) <*> (peek p43 >>= convert res i (b+43))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
+  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
+  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
+  , FromSQL t37, FromSQL t38, FromSQL t39, FromSQL t40, FromSQL t41, FromSQL t42
+  , FromSQL t43, FromSQL t44, FromSQL t45
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
+      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
+      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
+      alloca $ \p35 -> alloca $ \p36 -> alloca $ \p37 -> alloca $ \p38 -> alloca $ \p39 ->
+      alloca $ \p40 -> alloca $ \p41 -> alloca $ \p42 -> alloca $ \p43 -> alloca $ \p44 -> do
+        verify err =<< c_PQgetf45 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22 (b+23) p23 (b+24) p24 (b+25) p25 (b+26) p26 (b+27) p27 (b+28) p28 (b+29) p29 (b+30) p30 (b+31) p31 (b+32) p32 (b+33) p33 (b+34) p34 (b+35) p35 (b+36) p36 (b+37) p37 (b+38) p38 (b+39) p39 (b+40) p40 (b+41) p41 (b+42) p42 (b+43) p43 (b+44) p44
+        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22)) <*> (peek p23 >>= convert res i (b+23))
+          <*> (peek p24 >>= convert res i (b+24)) <*> (peek p25 >>= convert res i (b+25))
+          <*> (peek p26 >>= convert res i (b+26)) <*> (peek p27 >>= convert res i (b+27))
+          <*> (peek p28 >>= convert res i (b+28)) <*> (peek p29 >>= convert res i (b+29))
+          <*> (peek p30 >>= convert res i (b+30)) <*> (peek p31 >>= convert res i (b+31))
+          <*> (peek p32 >>= convert res i (b+32)) <*> (peek p33 >>= convert res i (b+33))
+          <*> (peek p34 >>= convert res i (b+34)) <*> (peek p35 >>= convert res i (b+35))
+          <*> (peek p36 >>= convert res i (b+36)) <*> (peek p37 >>= convert res i (b+37))
+          <*> (peek p38 >>= convert res i (b+38)) <*> (peek p39 >>= convert res i (b+39))
+          <*> (peek p40 >>= convert res i (b+40)) <*> (peek p41 >>= convert res i (b+41))
+          <*> (peek p42 >>= convert res i (b+42)) <*> (peek p43 >>= convert res i (b+43))
+          <*> (peek p44 >>= convert res i (b+44))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
+  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
+  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
+  , FromSQL t37, FromSQL t38, FromSQL t39, FromSQL t40, FromSQL t41, FromSQL t42
+  , FromSQL t43, FromSQL t44, FromSQL t45, FromSQL t46
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45, t46) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
+      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
+      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
+      alloca $ \p35 -> alloca $ \p36 -> alloca $ \p37 -> alloca $ \p38 -> alloca $ \p39 ->
+      alloca $ \p40 -> alloca $ \p41 -> alloca $ \p42 -> alloca $ \p43 -> alloca $ \p44 ->
+      alloca $ \p45 -> do
+        verify err =<< c_PQgetf46 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22 (b+23) p23 (b+24) p24 (b+25) p25 (b+26) p26 (b+27) p27 (b+28) p28 (b+29) p29 (b+30) p30 (b+31) p31 (b+32) p32 (b+33) p33 (b+34) p34 (b+35) p35 (b+36) p36 (b+37) p37 (b+38) p38 (b+39) p39 (b+40) p40 (b+41) p41 (b+42) p42 (b+43) p43 (b+44) p44 (b+45) p45
+        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22)) <*> (peek p23 >>= convert res i (b+23))
+          <*> (peek p24 >>= convert res i (b+24)) <*> (peek p25 >>= convert res i (b+25))
+          <*> (peek p26 >>= convert res i (b+26)) <*> (peek p27 >>= convert res i (b+27))
+          <*> (peek p28 >>= convert res i (b+28)) <*> (peek p29 >>= convert res i (b+29))
+          <*> (peek p30 >>= convert res i (b+30)) <*> (peek p31 >>= convert res i (b+31))
+          <*> (peek p32 >>= convert res i (b+32)) <*> (peek p33 >>= convert res i (b+33))
+          <*> (peek p34 >>= convert res i (b+34)) <*> (peek p35 >>= convert res i (b+35))
+          <*> (peek p36 >>= convert res i (b+36)) <*> (peek p37 >>= convert res i (b+37))
+          <*> (peek p38 >>= convert res i (b+38)) <*> (peek p39 >>= convert res i (b+39))
+          <*> (peek p40 >>= convert res i (b+40)) <*> (peek p41 >>= convert res i (b+41))
+          <*> (peek p42 >>= convert res i (b+42)) <*> (peek p43 >>= convert res i (b+43))
+          <*> (peek p44 >>= convert res i (b+44)) <*> (peek p45 >>= convert res i (b+45))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
+  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
+  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
+  , FromSQL t37, FromSQL t38, FromSQL t39, FromSQL t40, FromSQL t41, FromSQL t42
+  , FromSQL t43, FromSQL t44, FromSQL t45, FromSQL t46, FromSQL t47
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45, t46, t47) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
+      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
+      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
+      alloca $ \p35 -> alloca $ \p36 -> alloca $ \p37 -> alloca $ \p38 -> alloca $ \p39 ->
+      alloca $ \p40 -> alloca $ \p41 -> alloca $ \p42 -> alloca $ \p43 -> alloca $ \p44 ->
+      alloca $ \p45 -> alloca $ \p46 -> do
+        verify err =<< c_PQgetf47 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22 (b+23) p23 (b+24) p24 (b+25) p25 (b+26) p26 (b+27) p27 (b+28) p28 (b+29) p29 (b+30) p30 (b+31) p31 (b+32) p32 (b+33) p33 (b+34) p34 (b+35) p35 (b+36) p36 (b+37) p37 (b+38) p38 (b+39) p39 (b+40) p40 (b+41) p41 (b+42) p42 (b+43) p43 (b+44) p44 (b+45) p45 (b+46) p46
+        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22)) <*> (peek p23 >>= convert res i (b+23))
+          <*> (peek p24 >>= convert res i (b+24)) <*> (peek p25 >>= convert res i (b+25))
+          <*> (peek p26 >>= convert res i (b+26)) <*> (peek p27 >>= convert res i (b+27))
+          <*> (peek p28 >>= convert res i (b+28)) <*> (peek p29 >>= convert res i (b+29))
+          <*> (peek p30 >>= convert res i (b+30)) <*> (peek p31 >>= convert res i (b+31))
+          <*> (peek p32 >>= convert res i (b+32)) <*> (peek p33 >>= convert res i (b+33))
+          <*> (peek p34 >>= convert res i (b+34)) <*> (peek p35 >>= convert res i (b+35))
+          <*> (peek p36 >>= convert res i (b+36)) <*> (peek p37 >>= convert res i (b+37))
+          <*> (peek p38 >>= convert res i (b+38)) <*> (peek p39 >>= convert res i (b+39))
+          <*> (peek p40 >>= convert res i (b+40)) <*> (peek p41 >>= convert res i (b+41))
+          <*> (peek p42 >>= convert res i (b+42)) <*> (peek p43 >>= convert res i (b+43))
+          <*> (peek p44 >>= convert res i (b+44)) <*> (peek p45 >>= convert res i (b+45))
+          <*> (peek p46 >>= convert res i (b+46))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
+  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
+  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
+  , FromSQL t37, FromSQL t38, FromSQL t39, FromSQL t40, FromSQL t41, FromSQL t42
+  , FromSQL t43, FromSQL t44, FromSQL t45, FromSQL t46, FromSQL t47, FromSQL t48
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45, t46, t47, t48) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
+      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
+      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
+      alloca $ \p35 -> alloca $ \p36 -> alloca $ \p37 -> alloca $ \p38 -> alloca $ \p39 ->
+      alloca $ \p40 -> alloca $ \p41 -> alloca $ \p42 -> alloca $ \p43 -> alloca $ \p44 ->
+      alloca $ \p45 -> alloca $ \p46 -> alloca $ \p47 -> do
+        verify err =<< c_PQgetf48 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22 (b+23) p23 (b+24) p24 (b+25) p25 (b+26) p26 (b+27) p27 (b+28) p28 (b+29) p29 (b+30) p30 (b+31) p31 (b+32) p32 (b+33) p33 (b+34) p34 (b+35) p35 (b+36) p36 (b+37) p37 (b+38) p38 (b+39) p39 (b+40) p40 (b+41) p41 (b+42) p42 (b+43) p43 (b+44) p44 (b+45) p45 (b+46) p46 (b+47) p47
+        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22)) <*> (peek p23 >>= convert res i (b+23))
+          <*> (peek p24 >>= convert res i (b+24)) <*> (peek p25 >>= convert res i (b+25))
+          <*> (peek p26 >>= convert res i (b+26)) <*> (peek p27 >>= convert res i (b+27))
+          <*> (peek p28 >>= convert res i (b+28)) <*> (peek p29 >>= convert res i (b+29))
+          <*> (peek p30 >>= convert res i (b+30)) <*> (peek p31 >>= convert res i (b+31))
+          <*> (peek p32 >>= convert res i (b+32)) <*> (peek p33 >>= convert res i (b+33))
+          <*> (peek p34 >>= convert res i (b+34)) <*> (peek p35 >>= convert res i (b+35))
+          <*> (peek p36 >>= convert res i (b+36)) <*> (peek p37 >>= convert res i (b+37))
+          <*> (peek p38 >>= convert res i (b+38)) <*> (peek p39 >>= convert res i (b+39))
+          <*> (peek p40 >>= convert res i (b+40)) <*> (peek p41 >>= convert res i (b+41))
+          <*> (peek p42 >>= convert res i (b+42)) <*> (peek p43 >>= convert res i (b+43))
+          <*> (peek p44 >>= convert res i (b+44)) <*> (peek p45 >>= convert res i (b+45))
+          <*> (peek p46 >>= convert res i (b+46)) <*> (peek p47 >>= convert res i (b+47))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
+  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
+  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
+  , FromSQL t37, FromSQL t38, FromSQL t39, FromSQL t40, FromSQL t41, FromSQL t42
+  , FromSQL t43, FromSQL t44, FromSQL t45, FromSQL t46, FromSQL t47, FromSQL t48
+  , FromSQL t49
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45, t46, t47, t48, t49) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
+      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
+      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
+      alloca $ \p35 -> alloca $ \p36 -> alloca $ \p37 -> alloca $ \p38 -> alloca $ \p39 ->
+      alloca $ \p40 -> alloca $ \p41 -> alloca $ \p42 -> alloca $ \p43 -> alloca $ \p44 ->
+      alloca $ \p45 -> alloca $ \p46 -> alloca $ \p47 -> alloca $ \p48 -> do
+        verify err =<< c_PQgetf49 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22 (b+23) p23 (b+24) p24 (b+25) p25 (b+26) p26 (b+27) p27 (b+28) p28 (b+29) p29 (b+30) p30 (b+31) p31 (b+32) p32 (b+33) p33 (b+34) p34 (b+35) p35 (b+36) p36 (b+37) p37 (b+38) p38 (b+39) p39 (b+40) p40 (b+41) p41 (b+42) p42 (b+43) p43 (b+44) p44 (b+45) p45 (b+46) p46 (b+47) p47 (b+48) p48
+        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22)) <*> (peek p23 >>= convert res i (b+23))
+          <*> (peek p24 >>= convert res i (b+24)) <*> (peek p25 >>= convert res i (b+25))
+          <*> (peek p26 >>= convert res i (b+26)) <*> (peek p27 >>= convert res i (b+27))
+          <*> (peek p28 >>= convert res i (b+28)) <*> (peek p29 >>= convert res i (b+29))
+          <*> (peek p30 >>= convert res i (b+30)) <*> (peek p31 >>= convert res i (b+31))
+          <*> (peek p32 >>= convert res i (b+32)) <*> (peek p33 >>= convert res i (b+33))
+          <*> (peek p34 >>= convert res i (b+34)) <*> (peek p35 >>= convert res i (b+35))
+          <*> (peek p36 >>= convert res i (b+36)) <*> (peek p37 >>= convert res i (b+37))
+          <*> (peek p38 >>= convert res i (b+38)) <*> (peek p39 >>= convert res i (b+39))
+          <*> (peek p40 >>= convert res i (b+40)) <*> (peek p41 >>= convert res i (b+41))
+          <*> (peek p42 >>= convert res i (b+42)) <*> (peek p43 >>= convert res i (b+43))
+          <*> (peek p44 >>= convert res i (b+44)) <*> (peek p45 >>= convert res i (b+45))
+          <*> (peek p46 >>= convert res i (b+46)) <*> (peek p47 >>= convert res i (b+47))
+          <*> (peek p48 >>= convert res i (b+48))
+
+instance (
+    FromSQL t1, FromSQL t2, FromSQL t3, FromSQL t4, FromSQL t5, FromSQL t6
+  , FromSQL t7, FromSQL t8, FromSQL t9, FromSQL t10, FromSQL t11, FromSQL t12
+  , FromSQL t13, FromSQL t14, FromSQL t15, FromSQL t16, FromSQL t17, FromSQL t18
+  , FromSQL t19, FromSQL t20, FromSQL t21, FromSQL t22, FromSQL t23, FromSQL t24
+  , FromSQL t25, FromSQL t26, FromSQL t27, FromSQL t28, FromSQL t29, FromSQL t30
+  , FromSQL t31, FromSQL t32, FromSQL t33, FromSQL t34, FromSQL t35, FromSQL t36
+  , FromSQL t37, FromSQL t38, FromSQL t39, FromSQL t40, FromSQL t41, FromSQL t42
+  , FromSQL t43, FromSQL t44, FromSQL t45, FromSQL t46, FromSQL t47, FromSQL t48
+  , FromSQL t49, FromSQL t50
+  ) => FromRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45, t46, t47, t48, t49, t50) where
+    fromRow res err b i = withFormat $ \fmt ->
+      alloca $ \p0 -> alloca $ \p1 -> alloca $ \p2 -> alloca $ \p3 -> alloca $ \p4 ->
+      alloca $ \p5 -> alloca $ \p6 -> alloca $ \p7 -> alloca $ \p8 -> alloca $ \p9 ->
+      alloca $ \p10 -> alloca $ \p11 -> alloca $ \p12 -> alloca $ \p13 -> alloca $ \p14 ->
+      alloca $ \p15 -> alloca $ \p16 -> alloca $ \p17 -> alloca $ \p18 -> alloca $ \p19 ->
+      alloca $ \p20 -> alloca $ \p21 -> alloca $ \p22 -> alloca $ \p23 -> alloca $ \p24 ->
+      alloca $ \p25 -> alloca $ \p26 -> alloca $ \p27 -> alloca $ \p28 -> alloca $ \p29 ->
+      alloca $ \p30 -> alloca $ \p31 -> alloca $ \p32 -> alloca $ \p33 -> alloca $ \p34 ->
+      alloca $ \p35 -> alloca $ \p36 -> alloca $ \p37 -> alloca $ \p38 -> alloca $ \p39 ->
+      alloca $ \p40 -> alloca $ \p41 -> alloca $ \p42 -> alloca $ \p43 -> alloca $ \p44 ->
+      alloca $ \p45 -> alloca $ \p46 -> alloca $ \p47 -> alloca $ \p48 -> alloca $ \p49 -> do
+        verify err =<< c_PQgetf50 res err i fmt b p0 (b+1) p1 (b+2) p2 (b+3) p3 (b+4) p4 (b+5) p5 (b+6) p6 (b+7) p7 (b+8) p8 (b+9) p9 (b+10) p10 (b+11) p11 (b+12) p12 (b+13) p13 (b+14) p14 (b+15) p15 (b+16) p16 (b+17) p17 (b+18) p18 (b+19) p19 (b+20) p20 (b+21) p21 (b+22) p22 (b+23) p23 (b+24) p24 (b+25) p25 (b+26) p26 (b+27) p27 (b+28) p28 (b+29) p29 (b+30) p30 (b+31) p31 (b+32) p32 (b+33) p33 (b+34) p34 (b+35) p35 (b+36) p36 (b+37) p37 (b+38) p38 (b+39) p39 (b+40) p40 (b+41) p41 (b+42) p42 (b+43) p43 (b+44) p44 (b+45) p45 (b+46) p46 (b+47) p47 (b+48) p48 (b+49) p49
+        (,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,)
+          <$> (peek p0 >>= convert res i b) <*> (peek p1 >>= convert res i (b+1))
+          <*> (peek p2 >>= convert res i (b+2)) <*> (peek p3 >>= convert res i (b+3))
+          <*> (peek p4 >>= convert res i (b+4)) <*> (peek p5 >>= convert res i (b+5))
+          <*> (peek p6 >>= convert res i (b+6)) <*> (peek p7 >>= convert res i (b+7))
+          <*> (peek p8 >>= convert res i (b+8)) <*> (peek p9 >>= convert res i (b+9))
+          <*> (peek p10 >>= convert res i (b+10)) <*> (peek p11 >>= convert res i (b+11))
+          <*> (peek p12 >>= convert res i (b+12)) <*> (peek p13 >>= convert res i (b+13))
+          <*> (peek p14 >>= convert res i (b+14)) <*> (peek p15 >>= convert res i (b+15))
+          <*> (peek p16 >>= convert res i (b+16)) <*> (peek p17 >>= convert res i (b+17))
+          <*> (peek p18 >>= convert res i (b+18)) <*> (peek p19 >>= convert res i (b+19))
+          <*> (peek p20 >>= convert res i (b+20)) <*> (peek p21 >>= convert res i (b+21))
+          <*> (peek p22 >>= convert res i (b+22)) <*> (peek p23 >>= convert res i (b+23))
+          <*> (peek p24 >>= convert res i (b+24)) <*> (peek p25 >>= convert res i (b+25))
+          <*> (peek p26 >>= convert res i (b+26)) <*> (peek p27 >>= convert res i (b+27))
+          <*> (peek p28 >>= convert res i (b+28)) <*> (peek p29 >>= convert res i (b+29))
+          <*> (peek p30 >>= convert res i (b+30)) <*> (peek p31 >>= convert res i (b+31))
+          <*> (peek p32 >>= convert res i (b+32)) <*> (peek p33 >>= convert res i (b+33))
+          <*> (peek p34 >>= convert res i (b+34)) <*> (peek p35 >>= convert res i (b+35))
+          <*> (peek p36 >>= convert res i (b+36)) <*> (peek p37 >>= convert res i (b+37))
+          <*> (peek p38 >>= convert res i (b+38)) <*> (peek p39 >>= convert res i (b+39))
+          <*> (peek p40 >>= convert res i (b+40)) <*> (peek p41 >>= convert res i (b+41))
+          <*> (peek p42 >>= convert res i (b+42)) <*> (peek p43 >>= convert res i (b+43))
+          <*> (peek p44 >>= convert res i (b+44)) <*> (peek p45 >>= convert res i (b+45))
+          <*> (peek p46 >>= convert res i (b+46)) <*> (peek p47 >>= convert res i (b+47))
+          <*> (peek p48 >>= convert res i (b+48)) <*> (peek p49 >>= convert res i (b+49))
diff --git a/src/Database/PostgreSQL/PQTypes/Internal/C/Interface.hs b/src/Database/PostgreSQL/PQTypes/Internal/C/Interface.hs
--- a/src/Database/PostgreSQL/PQTypes/Internal/C/Interface.hs
+++ b/src/Database/PostgreSQL/PQTypes/Internal/C/Interface.hs
@@ -2,9 +2,12 @@
 -- | Exports a set of FFI-imported libpq/libpqtypes functions.
 module Database.PostgreSQL.PQTypes.Internal.C.Interface (
   -- * libpq imports
-    c_PQstatus
+    c_PQfreemem
+  , c_PQstatus
   , c_PQerrorMessage
   , c_PQsetClientEncoding
+  , c_PQsocket
+  , c_PQconsumeInput
   , c_PQresultStatus
   , c_PQresultErrorField
   , c_PQresultErrorMessage
@@ -31,12 +34,16 @@
 import Foreign.ForeignPtr
 import Foreign.Ptr
 import Foreign.Storable
+import System.Posix.Types
 import qualified Control.Exception as E
 
 import Database.PostgreSQL.PQTypes.Internal.C.Types
 
 -- libpq imports
 
+foreign import ccall unsafe "PQfreemem"
+  c_PQfreemem :: Ptr a -> IO ()
+
 foreign import ccall unsafe "PQstatus"
   c_PQstatus :: Ptr PGconn -> IO ConnStatusType
 
@@ -45,6 +52,12 @@
 
 foreign import ccall unsafe "PQsetClientEncoding"
   c_PQsetClientEncoding :: Ptr PGconn -> CString -> IO CInt
+
+foreign import ccall unsafe "PQsocket"
+  c_PQsocket :: Ptr PGconn -> IO Fd
+
+foreign import ccall unsafe "PQconsumeInput"
+  c_PQconsumeInput :: Ptr PGconn -> IO CInt
 
 foreign import ccall unsafe "PQresultStatus"
   c_PQresultStatus :: Ptr PGresult -> IO ExecStatusType
diff --git a/src/Database/PostgreSQL/PQTypes/Internal/Connection.hs b/src/Database/PostgreSQL/PQTypes/Internal/Connection.hs
--- a/src/Database/PostgreSQL/PQTypes/Internal/Connection.hs
+++ b/src/Database/PostgreSQL/PQTypes/Internal/Connection.hs
@@ -1,23 +1,26 @@
-{-# LANGUAGE FlexibleContexts, Rank2Types, RecordWildCards #-}
+{-# LANGUAGE FlexibleContexts, RankNTypes, RecordWildCards
+  , TupleSections #-}
 module Database.PostgreSQL.PQTypes.Internal.Connection (
     Connection(..)
   , ConnectionData(..)
+  , withConnectionData
   , ConnectionStats(..)
   , ConnectionSettings(..)
-  , defaultSettings
+  , def
   , ConnectionSource(..)
-  , defaultSource
+  , simpleSource
   , poolSource
   , connect
   , disconnect
   ) where
 
 import Control.Applicative
+import Control.Arrow
 import Control.Concurrent.MVar
 import Control.Monad
 import Control.Monad.Base
 import Control.Monad.Catch
-import Data.Monoid
+import Data.Default.Class
 import Data.Pool
 import Data.Time.Clock
 import Foreign.ForeignPtr
@@ -31,9 +34,7 @@
 import Database.PostgreSQL.PQTypes.Internal.C.Types
 import Database.PostgreSQL.PQTypes.Internal.Composite
 import Database.PostgreSQL.PQTypes.Internal.Error
-import Database.PostgreSQL.PQTypes.Internal.Exception
 import Database.PostgreSQL.PQTypes.Internal.Utils
-import Database.PostgreSQL.PQTypes.SQL
 
 data ConnectionSettings = ConnectionSettings {
 -- | Connection info string.
@@ -46,12 +47,12 @@
 } deriving (Eq, Ord, Show)
 
 -- | Default connection settings.
-defaultSettings :: ConnectionSettings
-defaultSettings = ConnectionSettings {
-  csConnInfo = BS.empty
-, csClientEncoding = Nothing
-, csComposites = []
-}
+instance Default ConnectionSettings where
+  def = ConnectionSettings {
+    csConnInfo = BS.empty
+  , csClientEncoding = Nothing
+  , csComposites = []
+  }
 
 ----------------------------------------
 
@@ -91,6 +92,15 @@
   unConnection :: MVar (Maybe ConnectionData)
 }
 
+withConnectionData :: Connection
+                   -> String
+                   -> (ConnectionData -> IO (ConnectionData, r))
+                   -> IO r
+withConnectionData (Connection mvc) fname f =
+  modifyMVar mvc $ \mc -> case mc of
+    Nothing -> hpqTypesError $ fname ++ ": no connection"
+    Just cd -> first Just <$> f cd
+
 -- | Database connection supplier.
 newtype ConnectionSource = ConnectionSource {
   withConnection :: (MonadBase IO m, MonadMask m) => (Connection -> m a) -> m a
@@ -98,8 +108,8 @@
 
 -- | Default connection supplier. It estabilishes new
 -- database connection each time 'withConnection' is called.
-defaultSource :: ConnectionSettings -> ConnectionSource
-defaultSource cs = ConnectionSource {
+simpleSource :: ConnectionSettings -> ConnectionSource
+simpleSource cs = ConnectionSource {
   withConnection = bracket (liftBase $ connect cs) (liftBase . disconnect)
 }
 
@@ -145,7 +155,7 @@
 -- | Low-level function for connecting to the database.
 -- Useful if one wants to implement custom connection source.
 connect :: ConnectionSettings -> IO Connection
-connect ConnectionSettings{..} = wrapException $ do
+connect ConnectionSettings{..} = do
   fconn <- BS.useAsCString csConnInfo c_PQconnectdb
   withForeignPtr fconn $ \connPtr -> do
     conn <- peek connPtr
@@ -167,13 +177,8 @@
 -- | Low-level function for disconnecting from the database.
 -- Useful if one wants to implement custom connection source.
 disconnect :: Connection -> IO ()
-disconnect (Connection mvconn) = wrapException . modifyMVar_ mvconn $ \mconn -> do
+disconnect (Connection mvconn) = modifyMVar_ mvconn $ \mconn -> do
   case mconn of
     Just cd -> withForeignPtr (cdFrgnPtr cd) c_PQfinishPtr
     Nothing -> E.throwIO (HPQTypesError "disconnect: no connection (shouldn't happen)")
   return Nothing
-
-----------------------------------------
-
-wrapException :: IO a -> IO a
-wrapException = E.handle $ rethrowWithContext (mempty::SQL)
diff --git a/src/Database/PostgreSQL/PQTypes/Internal/Monad.hs b/src/Database/PostgreSQL/PQTypes/Internal/Monad.hs
--- a/src/Database/PostgreSQL/PQTypes/Internal/Monad.hs
+++ b/src/Database/PostgreSQL/PQTypes/Internal/Monad.hs
@@ -1,6 +1,6 @@
 {-# LANGUAGE FlexibleContexts, FlexibleInstances, GeneralizedNewtypeDeriving
-  , MultiParamTypeClasses, ScopedTypeVariables, TypeFamilies
-  , UndecidableInstances, CPP #-}
+  , MultiParamTypeClasses, ScopedTypeVariables, TupleSections
+  , TypeFamilies, UndecidableInstances, CPP #-}
 module Database.PostgreSQL.PQTypes.Internal.Monad (
     DBT(..)
   , runDBT
@@ -17,27 +17,26 @@
 import Control.Monad.Trans.Control
 import Control.Monad.Writer.Class
 import Data.Monoid
-import System.Exit
 import qualified Control.Monad.Trans.State as S
 
 import Database.PostgreSQL.PQTypes.Class
-import Database.PostgreSQL.PQTypes.Fold
 import Database.PostgreSQL.PQTypes.Internal.Connection
 import Database.PostgreSQL.PQTypes.Internal.Error
-import Database.PostgreSQL.PQTypes.Internal.Exception
+import Database.PostgreSQL.PQTypes.Internal.Notification
 import Database.PostgreSQL.PQTypes.Internal.Query
 import Database.PostgreSQL.PQTypes.Internal.State
 import Database.PostgreSQL.PQTypes.SQL
 import Database.PostgreSQL.PQTypes.SQL.Class
 import Database.PostgreSQL.PQTypes.Transaction
 import Database.PostgreSQL.PQTypes.Transaction.Settings
+import Database.PostgreSQL.PQTypes.Utils
 
 type InnerDBT = StateT DBState
 
 -- | Monad transformer for adding database
 -- interaction capabilities to the underlying monad.
 newtype DBT m a = DBT { unDBT :: InnerDBT m a }
-  deriving (Alternative, Applicative, Functor, Monad, MonadBase b, MonadCatch, MonadIO, MonadMask, MonadPlus, MonadTrans)
+  deriving (Alternative, Applicative, Functor, Monad, MonadBase b, MonadCatch, MonadIO, MonadMask, MonadPlus, MonadThrow, MonadTrans)
 
 -- | Evaluate monadic action with supplied
 -- connection source and transaction settings.
@@ -48,7 +47,7 @@
     dbConnection = conn
   , dbConnectionSource = cs
   , dbTransactionSettings = ts
-  , dbLastQuery = someSQL (mempty::SQL)
+  , dbLastQuery = SomeSQL (mempty::SQL)
   , dbQueryResult = Nothing
   }
   where
@@ -63,13 +62,13 @@
 ----------------------------------------
 
 instance (MonadBase IO m, MonadMask m) => MonadDB (DBT m) where
-  runQuery = runSQLQuery DBT
+  runQuery sql = DBT . StateT $ liftBase . runQueryIO sql
   getLastQuery = DBT . gets $ dbLastQuery
 
   getConnectionStats = do
     mconn <- DBT $ liftBase . readMVar =<< gets (unConnection . dbConnection)
     case mconn of
-      Nothing -> throwM $ HPQTypesError "getConnectionStats: no connection"
+      Nothing -> throwDB $ HPQTypesError "getConnectionStats: no connection"
       Just cd -> return $ cdStats cd
 
   getTransactionSettings = DBT . gets $ dbTransactionSettings
@@ -78,8 +77,8 @@
   getQueryResult = DBT . gets $ dbQueryResult
   clearQueryResult = DBT . modify $ \st -> st { dbQueryResult = Nothing }
 
-  foldlM = foldLeftM
-  foldrM = foldRightM
+  getNotification time = DBT . StateT $ \st -> (, st)
+    <$> liftBase (getNotificationIO st time)
 
   withNewConnection m = DBT . StateT $ \st -> do
     let cs = dbConnectionSource st
@@ -118,19 +117,6 @@
   {-# INLINE liftBaseWith #-}
   {-# INLINE restoreM #-}
 #endif
-
--- | When given 'DBException' or 'ExitCode', throw it
--- immediately. Otherwise wrap it in 'DBException' first.
-instance MonadThrow m => MonadThrow (DBT m) where
-  throwM e = DBT $ case (,) <$> fromException <*> fromException $ toException e of
-    (Just (dbe::DBException), _) -> throwM dbe
-    (_, Just (ec::ExitCode))     -> throwM ec
-    _ -> do
-      SomeSQL sql <- gets $ dbLastQuery
-      throwM DBException {
-        dbeQueryContext = sql
-      , dbeError = e
-      }
 
 instance MonadError e m => MonadError e (DBT m) where
   throwError = lift . throwError
diff --git a/src/Database/PostgreSQL/PQTypes/Internal/Notification.hsc b/src/Database/PostgreSQL/PQTypes/Internal/Notification.hsc
new file mode 100644
--- /dev/null
+++ b/src/Database/PostgreSQL/PQTypes/Internal/Notification.hsc
@@ -0,0 +1,105 @@
+{-# LANGUAGE DeriveDataTypeable, ForeignFunctionInterface, RecordWildCards
+  , TupleSections #-}
+module Database.PostgreSQL.PQTypes.Internal.Notification (
+    Channel(..)
+  , Notification(..)
+  , getNotificationIO
+  ) where
+
+import Control.Concurrent
+import Control.Monad
+import Control.Monad.Fix
+import Data.String
+import Data.Typeable
+import Foreign.Ptr
+import Foreign.Storable
+import System.Posix.Types
+import System.Timeout
+import qualified Control.Exception as E
+import qualified Data.ByteString.Char8 as BS
+
+import Database.PostgreSQL.PQTypes.Internal.C.Interface
+import Database.PostgreSQL.PQTypes.Internal.C.Types
+import Database.PostgreSQL.PQTypes.Internal.Connection
+import Database.PostgreSQL.PQTypes.Internal.State
+import Database.PostgreSQL.PQTypes.Internal.Utils
+import Database.PostgreSQL.PQTypes.SQL.Raw
+
+#let alignment t = "%lu", (unsigned long)offsetof(struct {char x__; t (y__);}, y__)
+
+#include <libpq-fe.h>
+
+foreign import ccall unsafe "PQnotifies"
+  c_PQnotifies :: Ptr PGconn -> IO (Ptr Notification)
+
+----------------------------------------
+
+-- | Representation of notification channel.
+newtype Channel = Channel (RawSQL ())
+  deriving (Eq, Ord, Typeable)
+
+instance IsString Channel where
+  fromString = Channel . fromString
+
+instance Show Channel where
+  showsPrec n (Channel chan) = ("Channel " ++) . showsPrec n (unRawSQL chan)
+
+----------------------------------------
+
+-- | Representation of a notification sent by PostgreSQL.
+data Notification = Notification {
+-- | Process ID of notifying server.
+  ntPID     :: !CPid
+  -- | Notification channel name.
+, ntChannel :: !Channel
+  -- | Notification payload string.
+, ntPayload :: !BS.ByteString
+} deriving (Eq, Ord, Show, Typeable)
+
+instance Storable Notification where
+  sizeOf _ = #{size PGnotify}
+  alignment _ = #{alignment PGnotify}
+  peek ptr = do
+    ntPID <- return . CPid
+      =<< #{peek PGnotify, be_pid} ptr
+    ntChannel <- fmap (Channel . flip rawSQL ()) . BS.packCString
+      =<< #{peek PGnotify, relname} ptr
+    ntPayload <- BS.packCString
+      =<< #{peek PGnotify, extra} ptr
+    return Notification{..}
+  poke _ _ = error "Storable Notification: poke is not supposed to be used"
+
+----------------------------------------
+
+-- | Low-level function that waits for a notification for a given
+-- number of microseconds (it uses 'timeout' function internally).
+getNotificationIO :: DBState -> Int -> IO (Maybe Notification)
+getNotificationIO st n = timeout n $ do
+  withConnectionData (dbConnection st) fname $ \cd -> fix $ \loop -> do
+    let conn = cdPtr cd
+    mmsg <- tryGet conn
+    case mmsg of
+      Just msg -> return (cd, msg)
+      Nothing -> do
+        fd <- c_PQsocket conn
+        if fd == -1
+          then hpqTypesError $ fname ++ ": invalid file descriptor"
+          else do
+            threadWaitRead fd
+            res <- c_PQconsumeInput conn
+            when (res /= 1) $ do
+              throwLibPQError conn fname
+            loop
+  where
+    fname :: String
+    fname = "getNotificationIO"
+
+    tryGet :: Ptr PGconn -> IO (Maybe Notification)
+    tryGet connPtr = E.mask_ $ do
+      ptr <- c_PQnotifies connPtr
+      if ptr /= nullPtr
+        then do
+          msg <- peek ptr
+          c_PQfreemem ptr
+          return $ Just msg
+        else return Nothing
diff --git a/src/Database/PostgreSQL/PQTypes/Internal/Query.hs b/src/Database/PostgreSQL/PQTypes/Internal/Query.hs
--- a/src/Database/PostgreSQL/PQTypes/Internal/Query.hs
+++ b/src/Database/PostgreSQL/PQTypes/Internal/Query.hs
@@ -1,12 +1,9 @@
 {-# LANGUAGE FlexibleContexts, RecordWildCards #-}
 module Database.PostgreSQL.PQTypes.Internal.Query (
-    runSQLQuery
+    runQueryIO
   ) where
 
 import Control.Applicative
-import Control.Concurrent.MVar
-import Control.Monad.Base
-import Control.Monad.Trans.State
 import Foreign.ForeignPtr
 import Foreign.Ptr
 import qualified Control.Exception as E
@@ -16,54 +13,52 @@
 import Database.PostgreSQL.PQTypes.Internal.C.Types
 import Database.PostgreSQL.PQTypes.Internal.Connection
 import Database.PostgreSQL.PQTypes.Internal.Error
+import Database.PostgreSQL.PQTypes.Internal.Error.Code
 import Database.PostgreSQL.PQTypes.Internal.Exception
 import Database.PostgreSQL.PQTypes.Internal.QueryResult
 import Database.PostgreSQL.PQTypes.Internal.State
 import Database.PostgreSQL.PQTypes.SQL.Class
 import Database.PostgreSQL.PQTypes.Internal.Utils
 
--- | Run SQL query.
-runSQLQuery :: (IsSQL sql, MonadBase IO m)
-            => (StateT DBState m Int -> r) -> sql -> r
-runSQLQuery dbT sql = dbT $ do
-  mvconn <- gets (unConnection . dbConnection)
-  (affected, res) <- liftBase . modifyMVar mvconn $ \mconn -> case mconn of
-    Nothing -> E.throwIO DBException {
-      dbeQueryContext = sql
-    , dbeError = HPQTypesError "runQuery: no connection"
-    }
-    Just cd@ConnectionData{..} -> E.handle (rethrowWithContext sql) $ do
-      (paramCount, res) <- withSQL sql (withPGparam cdPtr) $ \param query -> (,)
-        <$> (fromIntegral <$> c_PQparamCount param)
-        <*> c_PQparamExec cdPtr nullPtr param query c_RESULT_BINARY
-      affected <- withForeignPtr res $ verifyResult cdPtr
-      stats' <- case affected of
-        Left _ -> return cdStats {
+-- | Low-level function for running SQL query.
+runQueryIO :: IsSQL sql => sql -> DBState -> IO (Int, DBState)
+runQueryIO sql st = do
+  (affected, res) <- withConnectionData (dbConnection st) "runQueryIO" $ \cd -> do
+    let ConnectionData{..} = cd
+    (paramCount, res) <- withSQL sql (withPGparam cdPtr) $ \param query -> (,)
+      <$> (fromIntegral <$> c_PQparamCount param)
+      <*> c_PQparamExec cdPtr nullPtr param query c_RESULT_BINARY
+    affected <- withForeignPtr res $ verifyResult cdPtr
+    stats' <- case affected of
+      Left _ -> return cdStats {
+        statsQueries = statsQueries cdStats + 1
+      , statsParams  = statsParams cdStats + paramCount
+      }
+      Right rows -> do
+        columns <- fromIntegral <$> withForeignPtr res c_PQnfields
+        return ConnectionStats {
           statsQueries = statsQueries cdStats + 1
+        , statsRows    = statsRows cdStats + rows
+        , statsValues  = statsValues cdStats + (rows * columns)
         , statsParams  = statsParams cdStats + paramCount
         }
-        Right rows -> do
-          columns <- fromIntegral <$> withForeignPtr res c_PQnfields
-          return ConnectionStats {
-            statsQueries = statsQueries cdStats + 1
-          , statsRows    = statsRows cdStats + rows
-          , statsValues  = statsValues cdStats + (rows * columns)
-          , statsParams  = statsParams cdStats + paramCount
-          }
-      -- Force evaluation of modified stats to squash space leak.
-      stats' `seq` return (Just cd { cdStats = stats' }, (either id id affected, res))
-  modify $ \st -> st {
-    dbLastQuery = someSQL sql
-  , dbQueryResult = Just $ QueryResult res
-  }
-  return affected
+    -- Force evaluation of modified stats to squash space leak.
+    stats' `seq` return (cd { cdStats = stats' }, (either id id affected, res))
+  return (affected, st {
+    dbLastQuery = SomeSQL sql
+  , dbQueryResult = Just QueryResult {
+      qrSQL = SomeSQL sql
+    , qrResult = res
+    , qrFromRow = id
+    }
+  })
   where
     verifyResult :: Ptr PGconn -> Ptr PGresult -> IO (Either Int Int)
     verifyResult conn res = do
       -- works even if res is NULL
-      st <- c_PQresultStatus res
-      case st of
-        _ | st == c_PGRES_COMMAND_OK -> do
+      rst <- c_PQresultStatus res
+      case rst of
+        _ | rst == c_PGRES_COMMAND_OK -> do
           sn <- c_PQcmdTuples res >>= BS.packCString
           case BS.readInt sn of
             Nothing
@@ -72,12 +67,31 @@
             Just (n, rest)
               | rest /= BS.empty -> throwParseError sn
               | otherwise        -> return . Left $ n
-        _ | st == c_PGRES_TUPLES_OK    -> Right . fromIntegral <$> c_PQntuples res
-        _ | st == c_PGRES_FATAL_ERROR  -> throwSQLError
-        _ | st == c_PGRES_BAD_RESPONSE -> throwSQLError
+        _ | rst == c_PGRES_TUPLES_OK    -> Right . fromIntegral <$> c_PQntuples res
+        _ | rst == c_PGRES_FATAL_ERROR  -> throwSQLError
+        _ | rst == c_PGRES_BAD_RESPONSE -> throwSQLError
         _ | otherwise                  -> return . Left $ 0
         where
-          throwSQLError = throwQueryError conn res
+          throwSQLError = rethrowWithContext sql =<< if res == nullPtr
+            then return . E.toException . QueryError
+              =<< safePeekCString' =<< c_PQerrorMessage conn
+            else E.toException <$> (DetailedQueryError
+              <$> field c_PG_DIAG_SEVERITY
+              <*> (stringToErrorCode <$> field c_PG_DIAG_SQLSTATE)
+              <*> field c_PG_DIAG_MESSAGE_PRIMARY
+              <*> mfield c_PG_DIAG_MESSAGE_DETAIL
+              <*> mfield c_PG_DIAG_MESSAGE_HINT
+              <*> ((mread =<<) <$> mfield c_PG_DIAG_STATEMENT_POSITION)
+              <*> ((mread =<<) <$> mfield c_PG_DIAG_INTERNAL_POSITION)
+              <*> mfield c_PG_DIAG_INTERNAL_QUERY
+              <*> mfield c_PG_DIAG_CONTEXT
+              <*> mfield c_PG_DIAG_SOURCE_FILE
+              <*> ((mread =<<) <$> mfield c_PG_DIAG_SOURCE_LINE)
+              <*> mfield c_PG_DIAG_SOURCE_FUNCTION)
+            where
+              field f = maybe "" id <$> mfield f
+              mfield f = safePeekCString =<< c_PQresultErrorField res f
+
           throwParseError sn = E.throwIO DBException {
             dbeQueryContext = sql
           , dbeError = HPQTypesError ("runQuery.verifyResult: string returned by PQcmdTuples is not a valid number: " ++ show sn)
diff --git a/src/Database/PostgreSQL/PQTypes/Internal/QueryResult.hs b/src/Database/PostgreSQL/PQTypes/Internal/QueryResult.hs
--- a/src/Database/PostgreSQL/PQTypes/Internal/QueryResult.hs
+++ b/src/Database/PostgreSQL/PQTypes/Internal/QueryResult.hs
@@ -1,30 +1,96 @@
+{-# LANGUAGE BangPatterns, ExistentialQuantification #-}
 module Database.PostgreSQL.PQTypes.Internal.QueryResult (
     QueryResult(..)
   , ntuples
   , nfields
   ) where
 
+import Control.Applicative
 import Control.Monad
+import Data.Foldable
+import Foreign.C.Types
 import Foreign.ForeignPtr
+import Foreign.Marshal.Alloc
+import Foreign.Ptr
 import System.IO.Unsafe
+import qualified Control.Exception as E
 
+import Database.PostgreSQL.PQTypes.Format
+import Database.PostgreSQL.PQTypes.FromRow
 import Database.PostgreSQL.PQTypes.Internal.C.Interface
 import Database.PostgreSQL.PQTypes.Internal.C.Types
+import Database.PostgreSQL.PQTypes.Internal.Error
+import Database.PostgreSQL.PQTypes.Internal.Exception
+import Database.PostgreSQL.PQTypes.SQL.Class
 
+-- | Representation of a query result. Provides 'Functor'
+-- and 'Foldable' instances for data transformation and
+-- extraction appropriately.
+data QueryResult t = forall row. FromRow row => QueryResult {
+  qrSQL     :: !SomeSQL
+, qrResult  :: !(ForeignPtr PGresult)
+, qrFromRow :: !(row -> t)
+}
+
+instance Functor QueryResult where
+  f `fmap` QueryResult ctx fres g = QueryResult ctx fres (f . g)
+
+instance Foldable QueryResult where
+  foldr  = foldImpl False (fmap pred . c_PQntuples) (const . return $ -1) pred
+  foldr' = foldImpl True  (fmap pred . c_PQntuples) (const . return $ -1) pred
+
+  foldl  = foldImpl False (const $ return 0) c_PQntuples succ . flip
+  foldl' = foldImpl True  (const $ return 0) c_PQntuples succ . flip
+
+foldImpl :: Bool
+         -> (Ptr PGresult -> IO CInt)
+         -> (Ptr PGresult -> IO CInt)
+         -> (CInt -> CInt)
+         -> (t -> acc -> acc)
+         -> acc
+         -> QueryResult t
+         -> acc
+foldImpl strict initCtr termCtr advCtr f iacc (QueryResult (SomeSQL ctx) fres g) =
+  unsafePerformIO $ withForeignPtr fres $ \res -> do
+    -- This bit is referentially transparent iff appropriate
+    -- FrowRow and FromSQL instances are (the ones provided
+    -- by the library fulfil this requirement).
+    rowlen <- fromIntegral <$> c_PQnfields res
+    when (rowlen /= pqVariables row) $ E.throwIO DBException {
+      dbeQueryContext = ctx
+    , dbeError = RowLengthMismatch {
+        lengthExpected  = pqVariables row
+      , lengthDelivered = rowlen
+      }
+    }
+    alloca $ \err -> do
+      i <- initCtr res
+      n <- termCtr res
+      worker res err i n iacc
+  where
+    -- ⊥ of existential type hidden in QueryResult
+    row = let _ = g row in row
+
+    apply = if strict then ($!) else ($)
+
+    worker res err !i n acc
+      | i == n    = return acc
+      | otherwise = do
+        -- mask asynchronous exceptions so they won't be wrapped in DBException
+        obj <- E.mask_ (g <$> fromRow res err 0 i `E.catch` rethrowWithContext ctx)
+        worker res err (advCtr i) n `apply` f obj acc
+
 -- Note: c_PQntuples/c_PQnfields are pure on a C level and QueryResult
 -- constructor is not exported to the end user (so it's not possible
 -- to enforce premature finalization via finalizeForeignPtr), which
 -- makes usage of unsafeDupablePerformIO fine here.
 
--- | Wrapper for hiding representation of query result.
-newtype QueryResult = QueryResult (ForeignPtr PGresult)
-
 -- | Extract number of returned tuples (rows) from query result.
-ntuples :: QueryResult -> Int
-ntuples (QueryResult fres) = unsafeDupablePerformIO $
-  fromIntegral `liftM` withForeignPtr fres c_PQntuples
+ntuples :: QueryResult t -> Int
+ntuples qr = unsafeDupablePerformIO $ do
+  fromIntegral <$> withForeignPtr (qrResult qr) c_PQntuples
 
 -- | Extract number of returned fields (columns) from query result.
-nfields :: QueryResult -> Int
-nfields (QueryResult fres) = unsafeDupablePerformIO $
-  fromIntegral `liftM` withForeignPtr fres c_PQnfields
+nfields :: QueryResult t -> Int
+nfields qr = unsafeDupablePerformIO $ do
+  fromIntegral <$> withForeignPtr (qrResult qr) c_PQnfields
diff --git a/src/Database/PostgreSQL/PQTypes/Internal/State.hs b/src/Database/PostgreSQL/PQTypes/Internal/State.hs
--- a/src/Database/PostgreSQL/PQTypes/Internal/State.hs
+++ b/src/Database/PostgreSQL/PQTypes/Internal/State.hs
@@ -1,8 +1,10 @@
 -- | Definition of internal DBT state.
+{-# LANGUAGE RankNTypes #-}
 module Database.PostgreSQL.PQTypes.Internal.State (
     DBState(..)
   ) where
 
+import Database.PostgreSQL.PQTypes.FromRow
 import Database.PostgreSQL.PQTypes.Internal.Connection
 import Database.PostgreSQL.PQTypes.Internal.QueryResult
 import Database.PostgreSQL.PQTypes.SQL.Class
@@ -19,5 +21,5 @@
 -- | Last SQL query that was executed.
 , dbLastQuery           :: !SomeSQL
 -- | Current query result.
-, dbQueryResult         :: !(Maybe QueryResult)
+, dbQueryResult         :: !(FromRow row => Maybe (QueryResult row))
 }
diff --git a/src/Database/PostgreSQL/PQTypes/Internal/Utils.hs b/src/Database/PostgreSQL/PQTypes/Internal/Utils.hs
--- a/src/Database/PostgreSQL/PQTypes/Internal/Utils.hs
+++ b/src/Database/PostgreSQL/PQTypes/Internal/Utils.hs
@@ -8,7 +8,6 @@
   , bsToCString
   , verifyPQTRes
   , withPGparam
-  , throwQueryError
   , throwLibPQError
   , throwLibPQTypesError
   , rethrowWithArrayError
@@ -31,7 +30,6 @@
 import Database.PostgreSQL.PQTypes.Internal.C.Interface
 import Database.PostgreSQL.PQTypes.Internal.C.Types
 import Database.PostgreSQL.PQTypes.Internal.Error
-import Database.PostgreSQL.PQTypes.Internal.Error.Code
 
 -- Safely read value.
 mread :: Read a => String -> Maybe a
@@ -86,27 +84,6 @@
       return param
 
 ----------------------------------------
-
--- | Throw query error.
-throwQueryError :: Ptr PGconn -> Ptr PGresult -> IO a
-throwQueryError conn res = if res == nullPtr
-  then E.throwIO . QueryError =<< safePeekCString' =<< c_PQerrorMessage conn
-  else E.throwIO =<< DetailedQueryError
-    <$> field c_PG_DIAG_SEVERITY
-    <*> (stringToErrorCode <$> field c_PG_DIAG_SQLSTATE)
-    <*> field c_PG_DIAG_MESSAGE_PRIMARY
-    <*> mfield c_PG_DIAG_MESSAGE_DETAIL
-    <*> mfield c_PG_DIAG_MESSAGE_HINT
-    <*> ((mread =<<) <$> mfield c_PG_DIAG_STATEMENT_POSITION)
-    <*> ((mread =<<) <$> mfield c_PG_DIAG_INTERNAL_POSITION)
-    <*> mfield c_PG_DIAG_INTERNAL_QUERY
-    <*> mfield c_PG_DIAG_CONTEXT
-    <*> mfield c_PG_DIAG_SOURCE_FILE
-    <*> ((mread =<<) <$> mfield c_PG_DIAG_SOURCE_LINE)
-    <*> mfield c_PG_DIAG_SOURCE_FUNCTION
-  where
-    field f = maybe "" id <$> mfield f
-    mfield f = safePeekCString =<< c_PQresultErrorField res f
 
 -- | Throw libpq specific error.
 throwLibPQError :: Ptr PGconn -> String -> IO a
diff --git a/src/Database/PostgreSQL/PQTypes/Interval.hsc b/src/Database/PostgreSQL/PQTypes/Interval.hsc
--- a/src/Database/PostgreSQL/PQTypes/Interval.hsc
+++ b/src/Database/PostgreSQL/PQTypes/Interval.hsc
@@ -12,6 +12,7 @@
 
 import Control.Applicative
 import Data.Int
+import Data.List
 import Data.Monoid
 import Data.Typeable
 import Foreign.Storable
@@ -37,8 +38,24 @@
 , intMinutes       :: !Int32
 , intSeconds       :: !Int32
 , intMicroseconds  :: !Int32
-} deriving (Eq, Ord, Show, Typeable)
+} deriving (Eq, Ord, Typeable)
 
+instance Show Interval where
+  showsPrec _ Interval{..} = (++) . intercalate ", " $ filter (not . null) [
+      f intYears "year"
+    , f intMonths "month"
+    , f intDays "day"
+    , f intHours "hour"
+    , f intMinutes "minute"
+    , f intSeconds "second"
+    , f intMicroseconds "microsecond"
+    ]
+    where
+      f n desc = case n of
+        0 -> ""
+        1 -> show n ++ " " ++ desc
+        _ -> show n ++ " " ++ desc ++ "s"
+
 instance Monoid Interval where
   mempty = Interval 0 0 0 0 0 0 0
   mappend a b = Interval {
@@ -72,7 +89,7 @@
     #{poke PGinterval, usecs} ptr intMicroseconds
 
 instance PQFormat Interval where
-  pqFormat _ = BS.pack "%interval"
+  pqFormat = const $ BS.pack "%interval"
 
 instance FromSQL Interval where
   type PQBase Interval = Interval
diff --git a/src/Database/PostgreSQL/PQTypes/Notification.hs b/src/Database/PostgreSQL/PQTypes/Notification.hs
new file mode 100644
--- /dev/null
+++ b/src/Database/PostgreSQL/PQTypes/Notification.hs
@@ -0,0 +1,34 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Database.PostgreSQL.PQTypes.Notification (
+    Channel(..)
+  , Notification(..)
+  , listen
+  , unlisten
+  , unlistenAll
+  , notify
+  ) where
+
+import Data.ByteString (ByteString)
+
+import Data.Monoid.Utils
+import Database.PostgreSQL.PQTypes.Class
+import Database.PostgreSQL.PQTypes.Internal.Notification
+import Database.PostgreSQL.PQTypes.SQL.Raw
+import Database.PostgreSQL.PQTypes.Utils
+
+-- | Start listening for notifications on a given channel.
+listen :: MonadDB m => Channel -> m ()
+listen (Channel chan) = runQuery_ $ "LISTEN" <+> chan
+
+-- | Stop listening for notifications on a given channel.
+unlisten :: MonadDB m => Channel -> m ()
+unlisten (Channel chan) = runQuery_ $ "UNLISTEN" <+> chan
+
+-- | Cancel all listener registrations for the current session.
+unlistenAll :: MonadDB m => m ()
+unlistenAll = runSQL_ "UNLISTEN *"
+
+-- | Generate a notification on a given channel.
+notify :: MonadDB m => Channel -> ByteString -> m ()
+notify (Channel chan) payload = runQuery_
+  $ rawSQL "SELECT pg_notify($1, $2)" (unRawSQL chan, payload)
diff --git a/src/Database/PostgreSQL/PQTypes/SQL.hs b/src/Database/PostgreSQL/PQTypes/SQL.hs
--- a/src/Database/PostgreSQL/PQTypes/SQL.hs
+++ b/src/Database/PostgreSQL/PQTypes/SQL.hs
@@ -18,7 +18,7 @@
 import qualified Data.Text as T
 import qualified Data.Text.Encoding as T
 
-import Data.Monoid.Space
+import Data.Monoid.Utils
 import Database.PostgreSQL.PQTypes.Format
 import Database.PostgreSQL.PQTypes.Internal.C.Put
 import Database.PostgreSQL.PQTypes.Internal.Utils
@@ -45,7 +45,6 @@
   fromString = mkSQL . T.encodeUtf8 . T.pack
 
 instance IsSQL SQL where
-  someSQL = SomeSQL
   withSQL sql allocParam execute = alloca $ \err -> allocParam $ \param -> do
     nums <- newMVar (1::Int)
     query <- BS.concat <$> mapM (f param err nums) (unSQL sql)
@@ -61,9 +60,6 @@
 instance Monoid SQL where
   mempty = mkSQL BS.empty
   SQL a `mappend` SQL b = SQL (a S.>< b)
-
-instance SpaceMonoid SQL where
-  mspace = mkSQL mspace
 
 instance Show SQL where
   showsPrec n sql = ("SQL " ++) . (showsPrec n . concatMap conv . unSQL $ sql)
diff --git a/src/Database/PostgreSQL/PQTypes/SQL/Class.hs b/src/Database/PostgreSQL/PQTypes/SQL/Class.hs
--- a/src/Database/PostgreSQL/PQTypes/SQL/Class.hs
+++ b/src/Database/PostgreSQL/PQTypes/SQL/Class.hs
@@ -17,9 +17,6 @@
 
 -- | Class representing \"SQLness\" of a given type.
 class Show sql => IsSQL sql where
-  -- | Convert 'sql' to 'SomeSQL'.
-  someSQL :: sql -> SomeSQL
-
   -- | Convert 'sql' to libpqtypes representation and pass
   -- it to supplied continuation (usually for execution).
   withSQL :: sql
diff --git a/src/Database/PostgreSQL/PQTypes/SQL/Raw.hs b/src/Database/PostgreSQL/PQTypes/SQL/Raw.hs
--- a/src/Database/PostgreSQL/PQTypes/SQL/Raw.hs
+++ b/src/Database/PostgreSQL/PQTypes/SQL/Raw.hs
@@ -12,8 +12,6 @@
 import qualified Data.Text as T
 import qualified Data.Text.Encoding as T
 
-import Data.Monoid.Space
-import Database.PostgreSQL.PQTypes.Format
 import Database.PostgreSQL.PQTypes.SQL.Class
 import Database.PostgreSQL.PQTypes.ToRow
 
@@ -24,10 +22,9 @@
   deriving (Eq, Ord, Show)
 
 instance (Show row, ToRow row) => IsSQL (RawSQL row) where
-  someSQL = SomeSQL
   withSQL (RawSQL query row) allocParam execute = alloca $ \err ->
-    allocParam $ \param -> BS.useAsCString (pqFormat row) $ \fmt -> do
-      toRow row allocParam param err fmt
+    allocParam $ \param -> do
+      toRow row allocParam param err
       BS.useAsCString query (execute param)
 
 -- | Construct 'RawSQL' () from 'String'. The underlying 'ByteString'
@@ -40,9 +37,6 @@
   mempty = rawSQL BS.empty ()
   RawSQL a () `mappend` RawSQL b () = RawSQL (a `mappend` b) ()
   mconcat xs = RawSQL (BS.concat $ map (\(RawSQL s ()) -> s) xs) ()
-
-instance SpaceMonoid (RawSQL ()) where
-  mspace = RawSQL mspace ()
 
 -- | Construct 'RawSQL' from 'ByteString' and a tuple of parameters.
 rawSQL :: (Show row, ToRow row) => BS.ByteString -> row -> RawSQL row
diff --git a/src/Database/PostgreSQL/PQTypes/Single.hs b/src/Database/PostgreSQL/PQTypes/Single.hs
deleted file mode 100644
--- a/src/Database/PostgreSQL/PQTypes/Single.hs
+++ /dev/null
@@ -1,21 +0,0 @@
-{-# LANGUAGE DeriveDataTypeable, DeriveFunctor, ScopedTypeVariables #-}
-module Database.PostgreSQL.PQTypes.Single (
-    Single(..)
-  , unSingle
-  ) where
-
-import Data.Typeable
-
-import Database.PostgreSQL.PQTypes.Format
-
--- | Representation of \"single element tuple\", used
--- to avoid resorting to usage of OverlappingInstances.
-newtype Single a = Single a
-  deriving (Eq, Functor, Ord, Show, Typeable)
-
--- | Extract underlying value.
-unSingle :: Single a -> a
-unSingle (Single a) = a
-
-instance PQFormat t => PQFormat (Single t) where
-  pqFormat _ = pqFormat (undefined::t)
diff --git a/src/Database/PostgreSQL/PQTypes/ToRow.hs b/src/Database/PostgreSQL/PQTypes/ToRow.hs
--- a/src/Database/PostgreSQL/PQTypes/ToRow.hs
+++ b/src/Database/PostgreSQL/PQTypes/ToRow.hs
@@ -1,32 +1,35 @@
-{-# LANGUAGE FlexibleInstances, Rank2Types, ScopedTypeVariables #-}
+{-# LANGUAGE FlexibleInstances, Rank2Types, ScopedTypeVariables
+  , TypeOperators #-}
 module Database.PostgreSQL.PQTypes.ToRow (
     ToRow(..)
   , toRow'
   ) where
 
+import Data.Functor.Identity
 import Foreign.C
 import Foreign.Marshal.Alloc
 import Foreign.Ptr
-import qualified Data.ByteString as BS
+import qualified Data.ByteString.Unsafe as BS
 
 import Database.PostgreSQL.PQTypes.Format
 import Database.PostgreSQL.PQTypes.Internal.C.Put
 import Database.PostgreSQL.PQTypes.Internal.C.Types
 import Database.PostgreSQL.PQTypes.Internal.Utils
-import Database.PostgreSQL.PQTypes.Single
 import Database.PostgreSQL.PQTypes.ToSQL
 
 -- | 'verifyPQTRes' specialized for usage in 'toRow'.
 verify :: Ptr PGerror -> CInt -> IO ()
 verify err = verifyPQTRes err "toRow"
 
+withFormat :: forall row. ToRow row => row -> (CString -> IO ()) -> IO ()
+withFormat = const $ BS.unsafeUseAsCString $ pqFormat0 (undefined::row)
+
 ----------------------------------------
 
 -- | More convenient version of 'toRow' that
 -- allocates 'PGerror' and format string by itself.
 toRow' :: forall row. ToRow row => row -> ParamAllocator -> Ptr PGparam -> IO ()
-toRow' row pa param = alloca $ \err ->
-  BS.useAsCString (pqFormat row) (toRow row pa param err)
+toRow' row pa param = alloca $ \err -> toRow row pa param err
 
 -- | Class which represents \"from Haskell tuple to SQL row\" transformation.
 class PQFormat row => ToRow row where
@@ -35,20 +38,28 @@
         -> ParamAllocator -- ^ 'PGparam' allocator for 'toSQL'.
         -> Ptr PGparam    -- ^ 'PGparam' to put tuple into.
         -> Ptr PGerror    -- ^ Local error info.
-        -> CString        -- ^ Format of a tuple to be put.
         -> IO ()
 
+instance (
+    ToRow row1, ToRow row2
+  ) => ToRow (row1 :*: row2) where
+    toRow (row1 :*: row2) pa param err = do
+      toRow row1 pa param err
+      toRow row2 pa param err
+
 instance ToRow () where
-  toRow _ _ _ _ _ = return ()
+  toRow _ _ _ _ = return ()
 
-instance ToSQL t => ToRow (Single t) where
-  toRow (Single t) pa param err fmt = toSQL t pa $ \base ->
+instance ToSQL t => ToRow (Identity t) where
+  toRow row pa param err = withFormat row $ \fmt -> toSQL t pa $ \base ->
     verify err =<< c_PQputf1 param err fmt base
+    where
+      Identity t = row
 
 instance (
     ToSQL t1, ToSQL t2
   ) => ToRow (t1, t2) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 ->
         verify err =<< c_PQputf2 param err fmt p1 p2
       where
@@ -57,7 +68,7 @@
 instance (
     ToSQL t1, ToSQL t2, ToSQL t3
   ) => ToRow (t1, t2, t3) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
         verify err =<< c_PQputf3 param err fmt p1 p2 p3
       where
@@ -66,7 +77,7 @@
 instance (
     ToSQL t1, ToSQL t2, ToSQL t3, ToSQL t4
   ) => ToRow (t1, t2, t3, t4) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 ->
         verify err =<< c_PQputf4 param err fmt p1 p2 p3 p4
@@ -76,7 +87,7 @@
 instance (
     ToSQL t1, ToSQL t2, ToSQL t3, ToSQL t4, ToSQL t5
   ) => ToRow (t1, t2, t3, t4, t5) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 ->
         verify err =<< c_PQputf5 param err fmt p1 p2 p3 p4 p5
@@ -86,7 +97,7 @@
 instance (
     ToSQL t1, ToSQL t2, ToSQL t3, ToSQL t4, ToSQL t5, ToSQL t6
   ) => ToRow (t1, t2, t3, t4, t5, t6) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
         verify err =<< c_PQputf6 param err fmt p1 p2 p3 p4 p5 p6
@@ -96,7 +107,7 @@
 instance (
     ToSQL t1, ToSQL t2, ToSQL t3, ToSQL t4, ToSQL t5, ToSQL t6, ToSQL t7
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 ->
@@ -108,7 +119,7 @@
     ToSQL t1, ToSQL t2, ToSQL t3, ToSQL t4, ToSQL t5, ToSQL t6, ToSQL t7
   , ToSQL t8
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 ->
@@ -120,7 +131,7 @@
     ToSQL t1, ToSQL t2, ToSQL t3, ToSQL t4, ToSQL t5, ToSQL t6, ToSQL t7
   , ToSQL t8, ToSQL t9
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -132,7 +143,7 @@
     ToSQL t1, ToSQL t2, ToSQL t3, ToSQL t4, ToSQL t5, ToSQL t6, ToSQL t7
   , ToSQL t8, ToSQL t9, ToSQL t10
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -145,7 +156,7 @@
     ToSQL t1, ToSQL t2, ToSQL t3, ToSQL t4, ToSQL t5, ToSQL t6, ToSQL t7
   , ToSQL t8, ToSQL t9, ToSQL t10, ToSQL t11
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -158,7 +169,7 @@
     ToSQL t1, ToSQL t2, ToSQL t3, ToSQL t4, ToSQL t5, ToSQL t6, ToSQL t7
   , ToSQL t8, ToSQL t9, ToSQL t10, ToSQL t11, ToSQL t12
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -171,7 +182,7 @@
     ToSQL t1, ToSQL t2, ToSQL t3, ToSQL t4, ToSQL t5, ToSQL t6, ToSQL t7
   , ToSQL t8, ToSQL t9, ToSQL t10, ToSQL t11, ToSQL t12, ToSQL t13
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -185,7 +196,7 @@
     ToSQL t1, ToSQL t2, ToSQL t3, ToSQL t4, ToSQL t5, ToSQL t6, ToSQL t7
   , ToSQL t8, ToSQL t9, ToSQL t10, ToSQL t11, ToSQL t12, ToSQL t13, ToSQL t14
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -200,7 +211,7 @@
   , ToSQL t8, ToSQL t9, ToSQL t10, ToSQL t11, ToSQL t12, ToSQL t13, ToSQL t14
   , ToSQL t15
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -215,7 +226,7 @@
   , ToSQL t8, ToSQL t9, ToSQL t10, ToSQL t11, ToSQL t12, ToSQL t13, ToSQL t14
   , ToSQL t15, ToSQL t16
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -231,7 +242,7 @@
   , ToSQL t8, ToSQL t9, ToSQL t10, ToSQL t11, ToSQL t12, ToSQL t13, ToSQL t14
   , ToSQL t15, ToSQL t16, ToSQL t17
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -247,7 +258,7 @@
   , ToSQL t8, ToSQL t9, ToSQL t10, ToSQL t11, ToSQL t12, ToSQL t13, ToSQL t14
   , ToSQL t15, ToSQL t16, ToSQL t17, ToSQL t18
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -263,7 +274,7 @@
   , ToSQL t8, ToSQL t9, ToSQL t10, ToSQL t11, ToSQL t12, ToSQL t13, ToSQL t14
   , ToSQL t15, ToSQL t16, ToSQL t17, ToSQL t18, ToSQL t19
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -280,7 +291,7 @@
   , ToSQL t8, ToSQL t9, ToSQL t10, ToSQL t11, ToSQL t12, ToSQL t13, ToSQL t14
   , ToSQL t15, ToSQL t16, ToSQL t17, ToSQL t18, ToSQL t19, ToSQL t20
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -297,7 +308,7 @@
   , ToSQL t8, ToSQL t9, ToSQL t10, ToSQL t11, ToSQL t12, ToSQL t13, ToSQL t14
   , ToSQL t15, ToSQL t16, ToSQL t17, ToSQL t18, ToSQL t19, ToSQL t20, ToSQL t21
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -315,7 +326,7 @@
   , ToSQL t15, ToSQL t16, ToSQL t17, ToSQL t18, ToSQL t19, ToSQL t20, ToSQL t21
   , ToSQL t22
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -334,7 +345,7 @@
   , ToSQL t15, ToSQL t16, ToSQL t17, ToSQL t18, ToSQL t19, ToSQL t20, ToSQL t21
   , ToSQL t22, ToSQL t23
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -353,7 +364,7 @@
   , ToSQL t15, ToSQL t16, ToSQL t17, ToSQL t18, ToSQL t19, ToSQL t20, ToSQL t21
   , ToSQL t22, ToSQL t23, ToSQL t24
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -372,7 +383,7 @@
   , ToSQL t15, ToSQL t16, ToSQL t17, ToSQL t18, ToSQL t19, ToSQL t20, ToSQL t21
   , ToSQL t22, ToSQL t23, ToSQL t24, ToSQL t25
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -392,7 +403,7 @@
   , ToSQL t15, ToSQL t16, ToSQL t17, ToSQL t18, ToSQL t19, ToSQL t20, ToSQL t21
   , ToSQL t22, ToSQL t23, ToSQL t24, ToSQL t25, ToSQL t26
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -412,7 +423,7 @@
   , ToSQL t15, ToSQL t16, ToSQL t17, ToSQL t18, ToSQL t19, ToSQL t20, ToSQL t21
   , ToSQL t22, ToSQL t23, ToSQL t24, ToSQL t25, ToSQL t26, ToSQL t27
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -432,7 +443,7 @@
   , ToSQL t15, ToSQL t16, ToSQL t17, ToSQL t18, ToSQL t19, ToSQL t20, ToSQL t21
   , ToSQL t22, ToSQL t23, ToSQL t24, ToSQL t25, ToSQL t26, ToSQL t27, ToSQL t28
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -454,7 +465,7 @@
   , ToSQL t22, ToSQL t23, ToSQL t24, ToSQL t25, ToSQL t26, ToSQL t27, ToSQL t28
   , ToSQL t29
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -476,7 +487,7 @@
   , ToSQL t22, ToSQL t23, ToSQL t24, ToSQL t25, ToSQL t26, ToSQL t27, ToSQL t28
   , ToSQL t29, ToSQL t30
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -498,7 +509,7 @@
   , ToSQL t22, ToSQL t23, ToSQL t24, ToSQL t25, ToSQL t26, ToSQL t27, ToSQL t28
   , ToSQL t29, ToSQL t30, ToSQL t31
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -521,7 +532,7 @@
   , ToSQL t22, ToSQL t23, ToSQL t24, ToSQL t25, ToSQL t26, ToSQL t27, ToSQL t28
   , ToSQL t29, ToSQL t30, ToSQL t31, ToSQL t32
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -544,7 +555,7 @@
   , ToSQL t22, ToSQL t23, ToSQL t24, ToSQL t25, ToSQL t26, ToSQL t27, ToSQL t28
   , ToSQL t29, ToSQL t30, ToSQL t31, ToSQL t32, ToSQL t33
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -567,7 +578,7 @@
   , ToSQL t22, ToSQL t23, ToSQL t24, ToSQL t25, ToSQL t26, ToSQL t27, ToSQL t28
   , ToSQL t29, ToSQL t30, ToSQL t31, ToSQL t32, ToSQL t33, ToSQL t34
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -591,7 +602,7 @@
   , ToSQL t22, ToSQL t23, ToSQL t24, ToSQL t25, ToSQL t26, ToSQL t27, ToSQL t28
   , ToSQL t29, ToSQL t30, ToSQL t31, ToSQL t32, ToSQL t33, ToSQL t34, ToSQL t35
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -616,7 +627,7 @@
   , ToSQL t29, ToSQL t30, ToSQL t31, ToSQL t32, ToSQL t33, ToSQL t34, ToSQL t35
   , ToSQL t36
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -641,7 +652,7 @@
   , ToSQL t29, ToSQL t30, ToSQL t31, ToSQL t32, ToSQL t33, ToSQL t34, ToSQL t35
   , ToSQL t36, ToSQL t37
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -667,7 +678,7 @@
   , ToSQL t29, ToSQL t30, ToSQL t31, ToSQL t32, ToSQL t33, ToSQL t34, ToSQL t35
   , ToSQL t36, ToSQL t37, ToSQL t38
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -693,7 +704,7 @@
   , ToSQL t29, ToSQL t30, ToSQL t31, ToSQL t32, ToSQL t33, ToSQL t34, ToSQL t35
   , ToSQL t36, ToSQL t37, ToSQL t38, ToSQL t39
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -719,7 +730,7 @@
   , ToSQL t29, ToSQL t30, ToSQL t31, ToSQL t32, ToSQL t33, ToSQL t34, ToSQL t35
   , ToSQL t36, ToSQL t37, ToSQL t38, ToSQL t39, ToSQL t40
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -746,7 +757,7 @@
   , ToSQL t29, ToSQL t30, ToSQL t31, ToSQL t32, ToSQL t33, ToSQL t34, ToSQL t35
   , ToSQL t36, ToSQL t37, ToSQL t38, ToSQL t39, ToSQL t40, ToSQL t41
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -773,7 +784,7 @@
   , ToSQL t29, ToSQL t30, ToSQL t31, ToSQL t32, ToSQL t33, ToSQL t34, ToSQL t35
   , ToSQL t36, ToSQL t37, ToSQL t38, ToSQL t39, ToSQL t40, ToSQL t41, ToSQL t42
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -801,7 +812,7 @@
   , ToSQL t36, ToSQL t37, ToSQL t38, ToSQL t39, ToSQL t40, ToSQL t41, ToSQL t42
   , ToSQL t43
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -830,7 +841,7 @@
   , ToSQL t36, ToSQL t37, ToSQL t38, ToSQL t39, ToSQL t40, ToSQL t41, ToSQL t42
   , ToSQL t43, ToSQL t44
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -859,7 +870,7 @@
   , ToSQL t36, ToSQL t37, ToSQL t38, ToSQL t39, ToSQL t40, ToSQL t41, ToSQL t42
   , ToSQL t43, ToSQL t44, ToSQL t45
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -888,7 +899,7 @@
   , ToSQL t36, ToSQL t37, ToSQL t38, ToSQL t39, ToSQL t40, ToSQL t41, ToSQL t42
   , ToSQL t43, ToSQL t44, ToSQL t45, ToSQL t46
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45, t46) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -918,7 +929,7 @@
   , ToSQL t36, ToSQL t37, ToSQL t38, ToSQL t39, ToSQL t40, ToSQL t41, ToSQL t42
   , ToSQL t43, ToSQL t44, ToSQL t45, ToSQL t46, ToSQL t47
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45, t46, t47) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -948,7 +959,7 @@
   , ToSQL t36, ToSQL t37, ToSQL t38, ToSQL t39, ToSQL t40, ToSQL t41, ToSQL t42
   , ToSQL t43, ToSQL t44, ToSQL t45, ToSQL t46, ToSQL t47, ToSQL t48
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45, t46, t47, t48) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -978,7 +989,7 @@
   , ToSQL t36, ToSQL t37, ToSQL t38, ToSQL t39, ToSQL t40, ToSQL t41, ToSQL t42
   , ToSQL t43, ToSQL t44, ToSQL t45, ToSQL t46, ToSQL t47, ToSQL t48, ToSQL t49
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45, t46, t47, t48, t49) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
@@ -1010,7 +1021,7 @@
   , ToSQL t43, ToSQL t44, ToSQL t45, ToSQL t46, ToSQL t47, ToSQL t48, ToSQL t49
   , ToSQL t50
   ) => ToRow (t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22, t23, t24, t25, t26, t27, t28, t29, t30, t31, t32, t33, t34, t35, t36, t37, t38, t39, t40, t41, t42, t43, t44, t45, t46, t47, t48, t49, t50) where
-    toRow row pa param err fmt =
+    toRow row pa param err = withFormat row $ \fmt ->
       toSQL t1 pa $ \p1 -> toSQL t2 pa $ \p2 -> toSQL t3 pa $ \p3 ->
       toSQL t4 pa $ \p4 -> toSQL t5 pa $ \p5 -> toSQL t6 pa $ \p6 ->
       toSQL t7 pa $ \p7 -> toSQL t8 pa $ \p8 -> toSQL t9 pa $ \p9 ->
diff --git a/src/Database/PostgreSQL/PQTypes/ToSQL.hs b/src/Database/PostgreSQL/PQTypes/ToSQL.hs
--- a/src/Database/PostgreSQL/PQTypes/ToSQL.hs
+++ b/src/Database/PostgreSQL/PQTypes/ToSQL.hs
@@ -65,6 +65,10 @@
   type PQDest Int64 = CLLong
   toSQL n _ = put (fromIntegral n)
 
+instance ToSQL Int where
+  type PQDest Int = CLLong
+  toSQL n _ = put (fromIntegral n)
+
 instance ToSQL Float where
   type PQDest Float = CFloat
   toSQL n _ = put (realToFrac n)
diff --git a/src/Database/PostgreSQL/PQTypes/Transaction.hs b/src/Database/PostgreSQL/PQTypes/Transaction.hs
--- a/src/Database/PostgreSQL/PQTypes/Transaction.hs
+++ b/src/Database/PostgreSQL/PQTypes/Transaction.hs
@@ -18,7 +18,6 @@
 import Data.String
 import Data.Typeable
 
-import Data.Monoid.Space
 import Data.Monoid.Utils
 import Database.PostgreSQL.PQTypes.Class
 import Database.PostgreSQL.PQTypes.Internal.Exception
@@ -88,12 +87,17 @@
       commit' ts
       return res
       where
-        expred :: DBException -> Maybe ()
-        expred DBException{..} = do
+        expred :: SomeException -> Maybe ()
+        expred e = do
           -- check if the predicate exists
           RestartPredicate f <- tsRestartPredicate ts
           -- cast exception to the type expected by the predicate
-          err <- cast dbeError
+          err <- msum [
+              -- either cast the exception itself...
+              fromException e
+              -- ...or extract it from DBException
+            , fromException e >>= \DBException{..} -> cast dbeError
+            ]
           -- check if the predicate allows for the restart
           guard $ f err n
 
diff --git a/src/Database/PostgreSQL/PQTypes/Transaction/Settings.hs b/src/Database/PostgreSQL/PQTypes/Transaction/Settings.hs
--- a/src/Database/PostgreSQL/PQTypes/Transaction/Settings.hs
+++ b/src/Database/PostgreSQL/PQTypes/Transaction/Settings.hs
@@ -5,9 +5,10 @@
   , TransactionSettings(..)
   , IsolationLevel(..)
   , Permissions(..)
-  , defaultTransactionSettings
+  , def
   ) where
 
+import Data.Default.Class
 import Data.Typeable
 import qualified Control.Exception as E
 
@@ -49,10 +50,10 @@
   deriving (Eq, Ord, Show, Typeable)
 
 -- | Default transaction settings.
-defaultTransactionSettings :: TransactionSettings
-defaultTransactionSettings = TransactionSettings {
-  tsAutoTransaction  = True
-, tsIsolationLevel   = DefaultLevel
-, tsRestartPredicate = Nothing
-, tsPermissions      = DefaultPermissions
-}
+instance Default TransactionSettings where
+  def = TransactionSettings {
+    tsAutoTransaction  = True
+  , tsIsolationLevel   = DefaultLevel
+  , tsRestartPredicate = Nothing
+  , tsPermissions      = DefaultPermissions
+  }
diff --git a/src/Database/PostgreSQL/PQTypes/Utils.hs b/src/Database/PostgreSQL/PQTypes/Utils.hs
--- a/src/Database/PostgreSQL/PQTypes/Utils.hs
+++ b/src/Database/PostgreSQL/PQTypes/Utils.hs
@@ -1,5 +1,7 @@
+{-# LANGUAGE ScopedTypeVariables #-}
 module Database.PostgreSQL.PQTypes.Utils (
-    raw
+    throwDB
+  , raw
   , runQuery_
   , runQuery01
   , runQuery01_
@@ -7,9 +9,6 @@
   , runSQL_
   , runSQL01
   , runSQL01_
-  , fetchMany
-  , fetchMaybe
-  , fetchOne
   -- Internal.Utils
   , hpqTypesError
   ) where
@@ -18,14 +17,27 @@
 import Control.Monad.Catch
 
 import Database.PostgreSQL.PQTypes.Class
-import Database.PostgreSQL.PQTypes.FromRow
 import Database.PostgreSQL.PQTypes.Internal.Error
-import Database.PostgreSQL.PQTypes.Internal.QueryResult
+import Database.PostgreSQL.PQTypes.Internal.Exception
 import Database.PostgreSQL.PQTypes.Internal.Utils
 import Database.PostgreSQL.PQTypes.SQL
 import Database.PostgreSQL.PQTypes.SQL.Class
 import Database.PostgreSQL.PQTypes.SQL.Raw
 
+-- | When given 'DBException', throw it immediately. Otherwise
+-- wrap it in 'DBException' with the current query context first.
+throwDB :: (Exception e, MonadDB m, MonadThrow m) => e -> m a
+throwDB e = case fromException $ toException e of
+  Just (dbe::DBException) -> throwM dbe
+  Nothing -> do
+    SomeSQL sql <- getLastQuery
+    throwM DBException {
+      dbeQueryContext = sql
+    , dbeError = e
+    }
+
+----------------------------------------
+
 -- | Convert 'RawSQL' () to 'SQL'.
 raw :: RawSQL () -> SQL
 raw = mkSQL . unRawSQL
@@ -42,7 +54,7 @@
 runQuery01 :: (IsSQL sql, MonadDB m, MonadThrow m) => sql -> m Bool
 runQuery01 sql = do
   n <- runQuery sql
-  when (n > 1) $ throwM AffectedRowsMismatch {
+  when (n > 1) $ throwDB AffectedRowsMismatch {
     rowsExpected = [(0, 1)]
   , rowsDelivered = n
   }
@@ -71,31 +83,3 @@
 runSQL01_ = runQuery01_
 
 ----------------------------------------
-
--- | Specialization of 'foldrM' that fetches list of rows.
-fetchMany :: (MonadDB m, FromRow row) => (row -> t) -> m [t]
-fetchMany f = foldrM (\row acc -> return $ f row : acc) []
-
--- | Specialization of 'foldlM' that fetches one or zero rows. If more
--- rows are delivered, 'AffectedRowsMismatch' exception is thrown.
-fetchMaybe :: (MonadDB m, MonadThrow m, FromRow row) => (row -> t) -> m (Maybe t)
-fetchMaybe f = flip foldlM Nothing $ \acc row -> case acc of
-  Just _ -> do
-    Just res <- getQueryResult
-    throwM AffectedRowsMismatch {
-      rowsExpected  = [(0, 1)]
-    , rowsDelivered = ntuples res
-    }
-  Nothing -> return . Just . f $ row
-
--- | Specialization of 'foldlM' that fetches exactly one row. If different
--- number of rows is delivered, 'AffectedRowsMismatch' exception is thrown.
-fetchOne :: (MonadDB m, MonadThrow m, FromRow row) => (row -> t) -> m t
-fetchOne f = do
-  mt <- fetchMaybe f
-  case mt of
-    Just t  -> return t
-    Nothing -> throwM AffectedRowsMismatch {
-      rowsExpected = [(1, 1)]
-    , rowsDelivered = 0
-    }
diff --git a/src/Database/PostgreSQL/PQTypes/XML.hs b/src/Database/PostgreSQL/PQTypes/XML.hs
--- a/src/Database/PostgreSQL/PQTypes/XML.hs
+++ b/src/Database/PostgreSQL/PQTypes/XML.hs
@@ -18,7 +18,7 @@
   deriving (Eq, Ord, Read, Show, Typeable)
 
 instance PQFormat XML where
-  pqFormat _ = BSC.pack "%xml"
+  pqFormat = const $ BSC.pack "%xml"
 
 instance FromSQL XML where
   type PQBase XML = PGbytea
diff --git a/test/Main.hs b/test/Main.hs
--- a/test/Main.hs
+++ b/test/Main.hs
@@ -1,10 +1,12 @@
 {-# OPTIONS_GHC -fno-warn-orphans #-}
-{-# LANGUAGE BangPatterns, DeriveDataTypeable, FlexibleContexts
-  , GeneralizedNewtypeDeriving, MultiParamTypeClasses, OverloadedStrings
-  , ScopedTypeVariables, TypeFamilies, UndecidableInstances, CPP #-}
+{-# LANGUAGE BangPatterns, CPP, DeriveDataTypeable
+  , FlexibleContexts, GeneralizedNewtypeDeriving, MultiParamTypeClasses
+  , OverloadedStrings, RecordWildCards, ScopedTypeVariables
+  , TypeFamilies, TypeOperators, UndecidableInstances #-}
 module Main where
 
 import Control.Applicative
+import Control.Concurrent.Lifted
 import Control.Monad
 import Control.Monad.Base
 import Control.Monad.Catch
@@ -12,6 +14,7 @@
 import Control.Monad.Trans.Control
 import Data.Char
 import Data.Int
+import Data.Maybe
 import Data.Time
 import Data.Typeable
 import Data.Word
@@ -22,18 +25,18 @@
 import Test.Framework.Providers.HUnit
 import Test.HUnit hiding (Test, assertEqual)
 import Test.QuickCheck
+import Test.QuickCheck.Compat
 import Test.QuickCheck.Gen
 import qualified Data.ByteString as BS
 import qualified Data.ByteString.Char8 as BSC
 import qualified Data.Text as T
 
-import Data.Monoid.Space
 import Data.Monoid.Utils
 import Database.PostgreSQL.PQTypes
 import Prelude.Instances ()
 import Test.QuickCheck.Arbitrary.Instances ()
 
-type InnerTestEnv = StateT StdGen (DBT IO)
+type InnerTestEnv = StateT QCGen (DBT IO)
 
 newtype TestEnv a = TestEnv { unTestEnv :: InnerTestEnv a }
   deriving (Applicative, Functor, Monad, MonadBase IO, MonadCatch, MonadDB, MonadMask, MonadThrow)
@@ -41,9 +44,9 @@
 instance MonadBaseControl IO TestEnv where
 #if MIN_VERSION_monad_control(1,0,0)
   type StM TestEnv a = StM InnerTestEnv a
-  liftBaseWith f = liftBaseWith $ \run ->
-                         f $ run
-  restoreM = restoreM
+  liftBaseWith f = TestEnv $ liftBaseWith $ \run ->
+                         f $ run . unTestEnv
+  restoreM = TestEnv . restoreM
 #else
   newtype StM TestEnv a = StTestEnv { unStTestEnv :: StM InnerTestEnv a }
   liftBaseWith f = TestEnv $ liftBaseWith $ \run ->
@@ -51,15 +54,15 @@
   restoreM = TestEnv . restoreM . unStTestEnv
 #endif
 
-withStdGen :: (StdGen -> r) -> TestEnv r
-withStdGen f = do
+withQCGen :: (QCGen -> r) -> TestEnv r
+withQCGen f = do
   gen <- TestEnv get
   TestEnv . modify $ snd . next
   return (f gen)
 
 ----------------------------------------
 
-type TestData = (StdGen, ConnectionSource)
+type TestData = (QCGen, ConnectionSource)
 
 runTestEnv :: TestData -> TransactionSettings -> TestEnv a -> IO a
 runTestEnv (env, cs) ts m = runDBT cs ts $ evalStateT (unTestEnv m) env
@@ -139,14 +142,17 @@
 
 ----------------------------------------
 
+instance (Arbitrary a1, Arbitrary a2) => Arbitrary (a1 :*: a2) where
+  arbitrary = (:*:) <$> arbitrary <*> arbitrary
+
 instance Arbitrary a => Arbitrary (Binary a) where
   arbitrary = Binary <$> arbitrary
 
 instance Arbitrary a => Arbitrary (Composite a) where
   arbitrary = Composite <$> arbitrary
 
-instance Arbitrary a => Arbitrary (Single a) where
-  arbitrary = Single <$> arbitrary
+instance Arbitrary a => Arbitrary (Identity a) where
+  arbitrary = Identity <$> arbitrary
 
 instance Arbitrary a => Arbitrary (Array1 a) where
   arbitrary = arbitraryArray1 Array1
@@ -241,11 +247,11 @@
 
 ----------------------------------------
 
-dts :: TransactionSettings
-dts = defaultTransactionSettings
+tsNoTrans :: TransactionSettings
+tsNoTrans = def { tsAutoTransaction = False }
 
 randomValue :: Arbitrary t => Int -> TestEnv t
-randomValue n = withStdGen $ \gen -> unGen arbitrary gen n
+randomValue n = withQCGen $ \gen -> unGen arbitrary gen n
 
 assertEqual :: (Show a, MonadBase IO m)
             => String -> a -> a -> (a -> a -> Bool) -> m ()
@@ -260,8 +266,8 @@
 ----------------------------------------
 
 autocommitTest :: TestData -> Test
-autocommitTest td = testCase "Autocommit mode works" . runTestEnv td dts{tsAutoTransaction = False} $ do
-  let sint = Single (1::Int32)
+autocommitTest td = testCase "Autocommit mode works" . runTestEnv td tsNoTrans $ do
+  let sint = Identity (1::Int32)
   runQuery_ $ rawSQL "INSERT INTO test1_ (a) VALUES ($1)" sint
   withNewConnection $ do
     n <- runQuery $ rawSQL "SELECT a FROM test1_ WHERE a = $1" sint
@@ -269,8 +275,8 @@
   runQuery_ $ rawSQL "DELETE FROM test1_ WHERE a = $1" sint
 
 readOnlyTest :: TestData -> Test
-readOnlyTest td = testCase "Read only transaction mode works" . runTestEnv td dts{tsPermissions = ReadOnly} $ do
-  let sint = Single (2::Int32)
+readOnlyTest td = testCase "Read only transaction mode works" . runTestEnv td def{tsPermissions = ReadOnly} $ do
+  let sint = Identity (2::Int32)
   eres <- try . runQuery_ $ rawSQL "INSERT INTO test1_ (a) VALUES ($1)" sint
   case eres :: Either DBException () of
     Left _ -> return ()
@@ -280,32 +286,57 @@
   assertEqual "SELECT works in read only mode" n 0 (==)
 
 savepointTest :: TestData -> Test
-savepointTest td = testCase "Savepoint support works" . runTestEnv td dts $ do
+savepointTest td = testCase "Savepoint support works" . runTestEnv td def $ do
   let int1 = 3 :: Int32
       int2 = 4 :: Int32
 
   -- action executed within withSavepoint throws
-  runQuery_ $ rawSQL "INSERT INTO test1_ (a) VALUES ($1)" (Single int1)
+  runQuery_ $ rawSQL "INSERT INTO test1_ (a) VALUES ($1)" (Identity int1)
   _ :: Either DBException () <- try . withSavepoint (Savepoint "test") $ do
-    runQuery_ $ rawSQL "INSERT INTO test1_ (a) VALUES ($1)" (Single int2)
+    runQuery_ $ rawSQL "INSERT INTO test1_ (a) VALUES ($1)" (Identity int2)
     runSQL_ "SELECT * FROM table_that_is_not_there"
   runQuery_ $ rawSQL "SELECT a FROM test1_ WHERE a IN ($1, $2)" (int1, int2)
-  res1 <- fetchMany unSingle
+  res1 <- fetchMany runIdentity
   assertEqual "Part of transaction was rolled back" res1 [int1] (==)
 
   rollback
 
   -- action executed within withSavepoint doesn't throw
-  runQuery_ $ rawSQL "INSERT INTO test1_ (a) VALUES ($1)" (Single int1)
+  runQuery_ $ rawSQL "INSERT INTO test1_ (a) VALUES ($1)" (Identity int1)
   withSavepoint (Savepoint "test") $ do
-    runQuery_ $ rawSQL "INSERT INTO test1_ (a) VALUES ($1)" (Single int2)
+    runQuery_ $ rawSQL "INSERT INTO test1_ (a) VALUES ($1)" (Identity int2)
   runQuery_ $ rawSQL "SELECT a FROM test1_ WHERE a IN ($1, $2) ORDER BY a" (int1, int2)
-  res2 <- fetchMany unSingle
+  res2 <- fetchMany runIdentity
   assertEqual "Result of all queries is visible" res2 [int1, int2] (==)
 
+notifyTest :: TestData -> Test
+notifyTest td = testCase "Notifications work" . runTestEnv td tsNoTrans $ do
+  listen chan
+  forkNewConn $ notify chan payload
+  mnt1 <- getNotification 100000
+  liftBase $ assertBool "Notification received" (isJust mnt1)
+  let Just nt1 = mnt1
+  assertEqual "Channels are equal" chan (ntChannel nt1) (==)
+  assertEqual "Payloads are equal" payload (ntPayload nt1) (==)
+
+  unlisten chan
+  forkNewConn $ notify chan payload
+  mnt2 <- getNotification 100000
+  assertEqual "No notification received after unlisten" Nothing mnt2 (==)
+
+  listen chan
+  unlistenAll
+  forkNewConn $ notify chan payload
+  mnt3 <- getNotification 100000
+  assertEqual "No notification received after unlistenAll" Nothing mnt3 (==)
+  where
+    chan = "test_channel"
+    payload = "test_payload"
+    forkNewConn = void . fork . withNewConnection
+
 transactionTest :: TestData -> IsolationLevel -> Test
-transactionTest td lvl = testCase ("Auto transaction works by default with isolation level" <+> show lvl) . runTestEnv td dts{tsIsolationLevel = lvl} $ do
-  let sint = Single (5::Int32)
+transactionTest td lvl = testCase ("Auto transaction works by default with isolation level" <+> show lvl) . runTestEnv td def{tsIsolationLevel = lvl} $ do
+  let sint = Identity (5::Int32)
   runQuery_ $ rawSQL "INSERT INTO test1_ (a) VALUES ($1)" sint
   withNewConnection $ do
     n <- runQuery $ rawSQL "SELECT a FROM test1_ WHERE a = $1" sint
@@ -314,37 +345,37 @@
 
 nullTest :: forall t. (Show t, ToSQL t, FromSQL t, Typeable t)
          => TestData -> t -> Test
-nullTest td t = testCase ("Attempt to get non-NULL value of type" <+> show (typeOf t) <+> "fails if NULL is provided") . runTestEnv td dts $ do
+nullTest td t = testCase ("Attempt to get non-NULL value of type" <+> show (typeOf t) <+> "fails if NULL is provided") . runTestEnv td def $ do
   runSQL_ $ "SELECT" <?> (Nothing::Maybe t)
-  eres  <- try $ fetchOne unSingle
+  eres  <- try $ fetchOne runIdentity
   case eres :: Either DBException t of
     Left _ -> return ()
     Right _ -> liftBase . assertFailure $ "DBException wasn't thrown"
 
 putGetTest :: forall t. (Arbitrary t, Show t, ToSQL t, FromSQL t, Typeable t)
            => TestData -> Int -> t -> (t -> t -> Bool) -> Test
-putGetTest td n t eq = testCase ("Putting value of type" <+> show (typeOf t) <+> "through database doesn't change its value") . runTestEnv td dts . runTimes 1000 $ do
+putGetTest td n t eq = testCase ("Putting value of type" <+> show (typeOf t) <+> "through database doesn't change its value") . runTestEnv td def . runTimes 1000 $ do
   v :: t <- randomValue n
   --liftBase . putStrLn . show $ v
   runSQL_ $ "SELECT" <?> v
-  v' <- fetchOne unSingle
+  v' <- fetchOne runIdentity
   assertEqual "Value doesn't change after getting through database" v v' eq
 
 xmlTest :: TestData -> Test
-xmlTest td  = testCase "Put and get XML value works" . runTestEnv td dts $ do
+xmlTest td  = testCase "Put and get XML value works" . runTestEnv td def $ do
   runSQL_ $ "SET CLIENT_ENCODING TO 'UTF8'"
   let v = XML "some<tag>stringå</tag>"
   runSQL_ $ "SELECT XML 'some<tag>stringå</tag>'"
-  v' <- fetchOne unSingle
+  v' <- fetchOne runIdentity
   assertEqual "XML value correct" v v' (==)
   runSQL_ $ "SELECT" <?> v
-  v'' <- fetchOne unSingle
+  v'' <- fetchOne runIdentity
   assertEqual "XML value correct" v v'' (==)
   runSQL_ $ "SET CLIENT_ENCODING TO 'latin-1'"
 
 rowTest :: forall row. (Arbitrary row, Eq row, Show row, ToRow row, FromRow row)
         => TestData -> row -> Test
-rowTest td r = testCase ("Putting row of length" <+> show (pqVariables r) <+> "through database works") . runTestEnv td dts . runTimes 100 $ do
+rowTest td r = testCase ("Putting row of length" <+> show (pqVariables r) <+> "through database works") . runTestEnv td def . runTimes 100 $ do
   row :: row <- randomValue 100
   let fmt = mintercalate ", " $ map (BSC.pack . ('$' :) . show) [1..pqVariables r]
   runQuery_ $ rawSQL ("SELECT" <+> fmt) row
@@ -365,6 +396,7 @@
   , xmlTest td
   , readOnlyTest td
   , savepointTest td
+  , notifyTest td
   ----------------------------------------
   , transactionTest td ReadCommitted
   , transactionTest td RepeatableRead
@@ -421,7 +453,10 @@
   , putGetTest td 1000 (u::CompositeArray1 Nested) (==)
   , putGetTest td 1000 (u::CompositeArray2 Nested) eqCompositeArray2
   ----------------------------------------
-  , rowTest td (u::Single Int16)
+  , rowTest td (u::Identity Int16)
+  , rowTest td (u::Identity T.Text :*: (Double, Int16))
+  , rowTest td (u::(T.Text, Double) :*: Identity Int16)
+  , rowTest td (u::(Int16, T.Text, Int64, Double) :*: Identity Bool :*: (String0, Char))
   , rowTest td (u::(Int16, Int32))
   , rowTest td (u::(Int16, Int32, Int64))
   , rowTest td (u::(Int16, Int32, Int64, Float))
@@ -478,14 +513,14 @@
 ----------------------------------------
 
 createStructures :: ConnectionSource -> IO ()
-createStructures cs = runDBT cs dts $ do
+createStructures cs = runDBT cs def $ do
   liftBase . putStrLn $ "Creating structures..."
   runSQL_ "CREATE TABLE test1_ (a INTEGER)"
   runSQL_ "CREATE TYPE simple_ AS (a INTEGER, b DATE)"
   runSQL_ "CREATE TYPE nested_ AS (d DOUBLE PRECISION, s SIMPLE_)"
 
 dropStructures :: ConnectionSource -> IO ()
-dropStructures cs = runDBT cs dts $ do
+dropStructures cs = runDBT cs def $ do
   liftBase . putStrLn $ "Dropping structures..."
   runSQL_ "DROP TYPE nested_"
   runSQL_ "DROP TYPE simple_"
@@ -499,16 +534,15 @@
     putStrLn $ "Usage:" <+> prog <+> "<connection info string> [test-framework args]"
     exitFailure
 
-  let connSettings = ConnectionSettings {
+  let connSettings = def {
           csConnInfo = BSC.pack $ head args
         , csClientEncoding = Just "latin1"
-        , csComposites = []
         }
-      connSource = defaultSource connSettings
+      connSource = simpleSource connSettings
 
   createStructures connSource
   connPool <- poolSource (connSettings { csComposites = ["simple_", "nested_"] }) 1 30 16
-  gen <- getStdGen
+  gen <- newQCGen
   putStrLn $ "PRNG:" <+> show gen
 
   finally (defaultMainWithArgs (tests (gen, connPool)) $ tail args) $ do
