diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+# v0.5.1
+
+* Add GHC 9.8 support
+* Drop support for GHC < 9.4
+
 # v0.5.0.1
 
 * Add GHC 9.4 support
diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
 # `persistent-mtl`
 
-[![GitHub Actions](https://img.shields.io/github/workflow/status/brandonchinn178/persistent-mtl/CI/main)](https://github.com/brandonchinn178/persistent-mtl/actions?query=branch%3Amain)
+[![GitHub Actions](https://img.shields.io/github/actions/workflow/status/brandonchinn178/persistent-mtl/ci.yml?branch=main)](https://github.com/brandonchinn178/persistent-mtl/actions?query=branch%3Amain)
 [![Hackage](https://img.shields.io/hackage/v/persistent-mtl)](https://hackage.haskell.org/package/persistent-mtl)
 [![Codecov](https://img.shields.io/codecov/c/gh/brandonchinn178/persistent-mtl)](https://app.codecov.io/gh/brandonchinn178/persistent-mtl)
 
diff --git a/persistent-mtl.cabal b/persistent-mtl.cabal
--- a/persistent-mtl.cabal
+++ b/persistent-mtl.cabal
@@ -1,11 +1,11 @@
 cabal-version: 1.12
 
--- This file has been generated from package.yaml by hpack version 0.35.0.
+-- This file has been generated from package.yaml by hpack version 0.36.0.
 --
 -- see: https://github.com/sol/hpack
 
 name:           persistent-mtl
-version:        0.5.0.1
+version:        0.5.1
 synopsis:       Monad transformer for the persistent API
 description:    A monad transformer and mtl-style type class for using the
                 persistent API directly in your monad transformer stack.
@@ -42,24 +42,24 @@
       Paths_persistent_mtl
   hs-source-dirs:
       src
-  ghc-options: -Wall
+  ghc-options: -Wall -Wcompat -Wunused-packages
   build-depends:
       base >=4.14 && <5
-    , conduit >=1.3.4 && <1.4
-    , containers ==0.6.*
-    , exceptions ==0.10.*
-    , monad-logger ==0.3.*
-    , mtl >=2.2.2 && <2.3
+    , conduit <1.4
+    , containers <0.7
+    , exceptions <0.11
+    , monad-logger <0.4
+    , mtl <2.4
     , persistent >=2.13 && <2.15
-    , resource-pool >=0.2.3.2 && <0.4
-    , resourcet >=1.2.4 && <1.3
-    , text >=1.2.4 && <2.1
-    , transformers >=0.5.6 && <0.6
-    , unliftio ==0.2.*
-    , unliftio-core ==0.2.*
-    , unliftio-pool ==0.2.*
+    , resource-pool <1
+    , resourcet <1.4
+    , text <2.2
+    , transformers <0.7
+    , unliftio <0.3
+    , unliftio-core <0.3
+    , unliftio-pool <1
   default-language: Haskell2010
-  if impl(ghc >= 9.2.0) && impl(ghc < 9.3) || impl(ghc >= 9.4.0) && impl(ghc < 9.4.3)
+  if impl(ghc >= 9.4.0) && impl(ghc < 9.4.3)
 
     buildable: False
 
@@ -78,7 +78,7 @@
       Paths_persistent_mtl
   hs-source-dirs:
       test
-  ghc-options: -Wall -F -pgmF=tasty-autocollect
+  ghc-options: -Wall -Wcompat -Wunused-packages -F -pgmF=tasty-autocollect
   build-tool-depends:
       tasty-autocollect:tasty-autocollect
   build-depends:
@@ -86,18 +86,17 @@
     , bytestring
     , conduit
     , containers
-    , esqueleto
-    , explainable-predicates
+    , esqueleto >=3.5
+    , explainable-predicates >=0.1.2.0
     , monad-logger
     , persistent
     , persistent-mtl
-    , persistent-postgresql
-    , persistent-sqlite
-    , persistent-template
+    , persistent-postgresql >=2.13.0.0
+    , persistent-sqlite >=2.13.0.3
     , resource-pool
     , resourcet
     , tasty
-    , tasty-autocollect
+    , tasty-autocollect >=0.2.0.0
     , tasty-golden
     , tasty-hunit
     , text
diff --git a/src/Control/Monad/IO/Rerunnable.hs b/src/Control/Monad/IO/Rerunnable.hs
--- a/src/Control/Monad/IO/Rerunnable.hs
+++ b/src/Control/Monad/IO/Rerunnable.hs
@@ -22,10 +22,9 @@
 import qualified Control.Monad.Trans.Writer.Lazy as Writer.Lazy
 import qualified Control.Monad.Trans.Writer.Strict as Writer.Strict
 
-{-| A copy of 'Control.Monad.IO.Class.MonadIO' to explicitly allow only IO
- operations that are rerunnable, e.g. in the context of a SQL transaction.
--}
-class Monad m => MonadRerunnableIO m where
+-- | A copy of 'Control.Monad.IO.Class.MonadIO' to explicitly allow only IO
+--  operations that are rerunnable, e.g. in the context of a SQL transaction.
+class (Monad m) => MonadRerunnableIO m where
   -- | Lift the given IO operation to @m@.
   --
   -- The given IO operation may be rerun, so use of this function requires
@@ -37,16 +36,16 @@
 
 {- Instances for common monad transformers -}
 
-instance MonadRerunnableIO m => MonadRerunnableIO (Reader.ReaderT r m) where
+instance (MonadRerunnableIO m) => MonadRerunnableIO (Reader.ReaderT r m) where
   rerunnableIO = lift . rerunnableIO
 
-instance MonadRerunnableIO m => MonadRerunnableIO (Except.ExceptT e m) where
+instance (MonadRerunnableIO m) => MonadRerunnableIO (Except.ExceptT e m) where
   rerunnableIO = lift . rerunnableIO
 
-instance MonadRerunnableIO m => MonadRerunnableIO (Identity.IdentityT m) where
+instance (MonadRerunnableIO m) => MonadRerunnableIO (Identity.IdentityT m) where
   rerunnableIO = lift . rerunnableIO
 
-instance MonadRerunnableIO m => MonadRerunnableIO (Maybe.MaybeT m) where
+instance (MonadRerunnableIO m) => MonadRerunnableIO (Maybe.MaybeT m) where
   rerunnableIO = lift . rerunnableIO
 
 instance (Monoid w, MonadRerunnableIO m) => MonadRerunnableIO (RWS.Lazy.RWST r w s m) where
@@ -55,10 +54,10 @@
 instance (Monoid w, MonadRerunnableIO m) => MonadRerunnableIO (RWS.Strict.RWST r w s m) where
   rerunnableIO = lift . rerunnableIO
 
-instance MonadRerunnableIO m => MonadRerunnableIO (State.Lazy.StateT s m) where
+instance (MonadRerunnableIO m) => MonadRerunnableIO (State.Lazy.StateT s m) where
   rerunnableIO = lift . rerunnableIO
 
-instance MonadRerunnableIO m => MonadRerunnableIO (State.Strict.StateT s m) where
+instance (MonadRerunnableIO m) => MonadRerunnableIO (State.Strict.StateT s m) where
   rerunnableIO = lift . rerunnableIO
 
 instance (Monoid w, MonadRerunnableIO m) => MonadRerunnableIO (Writer.Lazy.WriterT w m) where
@@ -67,5 +66,5 @@
 instance (Monoid w, MonadRerunnableIO m) => MonadRerunnableIO (Writer.Strict.WriterT w m) where
   rerunnableIO = lift . rerunnableIO
 
-instance MonadRerunnableIO m => MonadRerunnableIO (Resource.ResourceT m) where
+instance (MonadRerunnableIO m) => MonadRerunnableIO (Resource.ResourceT m) where
   rerunnableIO = lift . rerunnableIO
diff --git a/src/Control/Monad/Trans/Rerunnable.hs b/src/Control/Monad/Trans/Rerunnable.hs
--- a/src/Control/Monad/Trans/Rerunnable.hs
+++ b/src/Control/Monad/Trans/Rerunnable.hs
@@ -22,15 +22,14 @@
 import qualified Control.Monad.Trans.Writer.Lazy as Writer.Lazy
 import qualified Control.Monad.Trans.Writer.Strict as Writer.Strict
 
-{-| A copy of 'Control.Monad.Trans.Class.MonadTrans' to explicitly allow only
-lifting actions that are rerunnable, e.g. in the context of a SQL transaction.
--}
+-- | A copy of 'Control.Monad.Trans.Class.MonadTrans' to explicitly allow only
+-- lifting actions that are rerunnable, e.g. in the context of a SQL transaction.
 class MonadRerunnableTrans t where
   -- | Lift the given action.
   --
   -- The given action may be rerun, so use of this function requires
   -- manually verifying that the given action is rerunnable.
-  rerunnableLift :: Monad m => m a -> t m a
+  rerunnableLift :: (Monad m) => m a -> t m a
 
 {- Instances for common monad transformers -}
 
@@ -46,10 +45,10 @@
 instance MonadRerunnableTrans Maybe.MaybeT where
   rerunnableLift = lift
 
-instance Monoid w => MonadRerunnableTrans (RWS.Lazy.RWST r w s) where
+instance (Monoid w) => MonadRerunnableTrans (RWS.Lazy.RWST r w s) where
   rerunnableLift = lift
 
-instance Monoid w => MonadRerunnableTrans (RWS.Strict.RWST r w s) where
+instance (Monoid w) => MonadRerunnableTrans (RWS.Strict.RWST r w s) where
   rerunnableLift = lift
 
 instance MonadRerunnableTrans (State.Lazy.StateT s) where
@@ -58,10 +57,10 @@
 instance MonadRerunnableTrans (State.Strict.StateT s) where
   rerunnableLift = lift
 
-instance Monoid w => MonadRerunnableTrans (Writer.Lazy.WriterT w) where
+instance (Monoid w) => MonadRerunnableTrans (Writer.Lazy.WriterT w) where
   rerunnableLift = lift
 
-instance Monoid w => MonadRerunnableTrans (Writer.Strict.WriterT w) where
+instance (Monoid w) => MonadRerunnableTrans (Writer.Strict.WriterT w) where
   rerunnableLift = lift
 
 instance MonadRerunnableTrans Resource.ResourceT where
diff --git a/src/Database/Persist/Monad.hs b/src/Database/Persist/Monad.hs
--- a/src/Database/Persist/Monad.hs
+++ b/src/Database/Persist/Monad.hs
@@ -94,12 +94,11 @@
 
 {- SqlQueryT monad -}
 
-{-| Environment to configure running 'SqlQueryT'.
-
- For simple usage, you can just use 'runSqlQueryT', but for more advanced
- usage, including the ability to retry transactions, use 'mkSqlQueryEnv' with
- 'runSqlQueryTWith'.
--}
+-- | Environment to configure running 'SqlQueryT'.
+--
+--  For simple usage, you can just use 'runSqlQueryT', but for more advanced
+--  usage, including the ability to retry transactions, use 'mkSqlQueryEnv' with
+--  'runSqlQueryTWith'.
 data SqlQueryEnv = SqlQueryEnv
   { backendPool :: Pool SqlBackend
   -- ^ The pool for your persistent backend. Get this from @withSqlitePool@
@@ -117,15 +116,14 @@
   -- ^ A callback to run if 'retryIf' returns True. Useful for logging.
   }
 
-{-| Build a SqlQueryEnv from the default.
-
- Usage:
-
- @
- let env = mkSqlQueryEnv pool $ \\env -> env { retryIf = 10 }
- in runSqlQueryTWith env m
- @
--}
+-- | Build a SqlQueryEnv from the default.
+--
+--  Usage:
+--
+--  @
+--  let env = mkSqlQueryEnv pool $ \\env -> env { retryIf = 10 }
+--  in runSqlQueryTWith env m
+--  @
 mkSqlQueryEnv :: Pool SqlBackend -> (SqlQueryEnv -> SqlQueryEnv) -> SqlQueryEnv
 mkSqlQueryEnv backendPool f =
   f
@@ -155,7 +153,7 @@
     , MonadLogger
     )
 
-instance MonadUnliftIO m => MonadSqlQuery (SqlQueryT m) where
+instance (MonadUnliftIO m) => MonadSqlQuery (SqlQueryT m) where
   type TransactionM (SqlQueryT m) = SqlTransaction (SqlQueryT m)
 
   -- Running a query directly in SqlQueryT will create a one-off transaction.
@@ -180,13 +178,13 @@
               else throwIO RetryLimitExceeded
        in loop 0
 
-instance MonadUnliftIO m => MonadUnliftIO (SqlQueryT m) where
+instance (MonadUnliftIO m) => MonadUnliftIO (SqlQueryT m) where
   withRunInIO = wrappedWithRunInIO SqlQueryT unSqlQueryT
 
 mapSqlQueryT :: (m a -> n b) -> SqlQueryT m a -> SqlQueryT n b
 mapSqlQueryT f = SqlQueryT . mapReaderT f . unSqlQueryT
 
-instance MonadReader r m => MonadReader r (SqlQueryT m) where
+instance (MonadReader r m) => MonadReader r (SqlQueryT m) where
   ask = lift ask
   local = mapSqlQueryT . local
 
@@ -204,13 +202,12 @@
 runSqlQueryT :: Pool SqlBackend -> SqlQueryT m a -> m a
 runSqlQueryT backendPool = runSqlQueryTWith $ mkSqlQueryEnv backendPool id
 
-{-| Run the 'SqlQueryT' monad transformer with the explicitly provided
- environment.
--}
+-- | Run the 'SqlQueryT' monad transformer with the explicitly provided
+--  environment.
 runSqlQueryTWith :: SqlQueryEnv -> SqlQueryT m a -> m a
 runSqlQueryTWith env = (`runReaderT` env) . unSqlQueryT
 
 {- SqlQueryT environment -}
 
-getSqlBackendPool :: Monad m => SqlQueryT m (Pool SqlBackend)
+getSqlBackendPool :: (Monad m) => SqlQueryT m (Pool SqlBackend)
 getSqlBackendPool = SqlQueryT (asks backendPool)
diff --git a/src/Database/Persist/Monad/Class.hs b/src/Database/Persist/Monad/Class.hs
--- a/src/Database/Persist/Monad/Class.hs
+++ b/src/Database/Persist/Monad/Class.hs
@@ -35,29 +35,29 @@
   type TransactionM m :: Type -> Type
 
   -- | Interpret the given SQL query operation.
-  runQueryRep :: Typeable record => SqlQueryRep record a -> m a
+  runQueryRep :: (Typeable record) => SqlQueryRep record a -> m a
 
   -- | Run all queries in the given action using the same database connection.
   withTransaction :: TransactionM m a -> m a
 
 {- Instances for common monad transformers -}
 
-instance MonadSqlQuery m => MonadSqlQuery (Reader.ReaderT r m) where
+instance (MonadSqlQuery m) => MonadSqlQuery (Reader.ReaderT r m) where
   type TransactionM (Reader.ReaderT r m) = TransactionM m
   runQueryRep = lift . runQueryRep
   withTransaction = lift . withTransaction
 
-instance MonadSqlQuery m => MonadSqlQuery (Except.ExceptT e m) where
+instance (MonadSqlQuery m) => MonadSqlQuery (Except.ExceptT e m) where
   type TransactionM (Except.ExceptT e m) = TransactionM m
   runQueryRep = lift . runQueryRep
   withTransaction = lift . withTransaction
 
-instance MonadSqlQuery m => MonadSqlQuery (Identity.IdentityT m) where
+instance (MonadSqlQuery m) => MonadSqlQuery (Identity.IdentityT m) where
   type TransactionM (Identity.IdentityT m) = TransactionM m
   runQueryRep = lift . runQueryRep
   withTransaction = lift . withTransaction
 
-instance MonadSqlQuery m => MonadSqlQuery (Maybe.MaybeT m) where
+instance (MonadSqlQuery m) => MonadSqlQuery (Maybe.MaybeT m) where
   type TransactionM (Maybe.MaybeT m) = TransactionM m
   runQueryRep = lift . runQueryRep
   withTransaction = lift . withTransaction
@@ -72,12 +72,12 @@
   runQueryRep = lift . runQueryRep
   withTransaction = lift . withTransaction
 
-instance MonadSqlQuery m => MonadSqlQuery (State.Lazy.StateT s m) where
+instance (MonadSqlQuery m) => MonadSqlQuery (State.Lazy.StateT s m) where
   type TransactionM (State.Lazy.StateT s m) = TransactionM m
   runQueryRep = lift . runQueryRep
   withTransaction = lift . withTransaction
 
-instance MonadSqlQuery m => MonadSqlQuery (State.Strict.StateT s m) where
+instance (MonadSqlQuery m) => MonadSqlQuery (State.Strict.StateT s m) where
   type TransactionM (State.Strict.StateT s m) = TransactionM m
   runQueryRep = lift . runQueryRep
   withTransaction = lift . withTransaction
diff --git a/src/Database/Persist/Monad/Internal/SqlTransaction.hs b/src/Database/Persist/Monad/Internal/SqlTransaction.hs
--- a/src/Database/Persist/Monad/Internal/SqlTransaction.hs
+++ b/src/Database/Persist/Monad/Internal/SqlTransaction.hs
@@ -25,26 +25,25 @@
 import Database.Persist.Monad.Class
 import Database.Persist.Monad.SqlQueryRep
 
-{-| The monad that tracks transaction state.
-
- Conceptually equivalent to 'Database.Persist.Sql.SqlPersistT', but restricts
- IO operations, for two reasons:
-
-   1. Forking a thread that uses the same 'SqlBackend' as the current thread
-      causes Bad Things to happen.
-   2. Transactions may need to be retried, in which case IO operations in
-      a transaction are required to be rerunnable.
-
- You shouldn't need to explicitly use this type; your functions should only
- declare the 'MonadSqlQuery' constraint.
--}
+-- | The monad that tracks transaction state.
+--
+--  Conceptually equivalent to 'Database.Persist.Sql.SqlPersistT', but restricts
+--  IO operations, for two reasons:
+--
+--    1. Forking a thread that uses the same 'SqlBackend' as the current thread
+--       causes Bad Things to happen.
+--    2. Transactions may need to be retried, in which case IO operations in
+--       a transaction are required to be rerunnable.
+--
+--  You shouldn't need to explicitly use this type; your functions should only
+--  declare the 'MonadSqlQuery' constraint.
 newtype SqlTransaction m a = UnsafeSqlTransaction
   { unSqlTransaction :: ReaderT SqlTransactionEnv m a
   }
   deriving (Functor, Applicative, Monad, MonadFix, MonadRerunnableIO, MonadRerunnableTrans)
 
 instance
-  ( GHC.TypeError ( 'GHC.Text "Cannot run arbitrary IO actions within a transaction. If the IO action is rerunnable, use rerunnableIO")
+  ( GHC.TypeError ('GHC.Text "Cannot run arbitrary IO actions within a transaction. If the IO action is rerunnable, use rerunnableIO")
   , Monad m
   ) =>
   MonadIO (SqlTransaction m)
@@ -66,10 +65,10 @@
   }
 
 runSqlTransaction ::
-  MonadUnliftIO m =>
-  SqlTransactionEnv ->
-  SqlTransaction m a ->
-  m a
+  (MonadUnliftIO m) =>
+  SqlTransactionEnv
+  -> SqlTransaction m a
+  -> m a
 runSqlTransaction opts =
   (`runSqlConn` sqlBackend opts)
     . withReaderT (\conn -> opts{sqlBackend = conn})
@@ -78,9 +77,9 @@
 -- | Like normal 'catch', except ignores errors specified by 'ignoreCatch'.
 catchSqlTransaction ::
   (MonadUnliftIO m, Exception e) =>
-  SqlTransaction m a ->
-  (e -> SqlTransaction m a) ->
   SqlTransaction m a
+  -> (e -> SqlTransaction m a)
+  -> SqlTransaction m a
 catchSqlTransaction (UnsafeSqlTransaction m) handler =
   UnsafeSqlTransaction $ m `catch` (unSqlTransaction . handler)
   where
diff --git a/src/Database/Persist/Monad/Shim.hs b/src/Database/Persist/Monad/Shim.hs
--- a/src/Database/Persist/Monad/Shim.hs
+++ b/src/Database/Persist/Monad/Shim.hs
@@ -1,6 +1,12 @@
 {- THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED MANUALLY -}
 {- FOURMOLU_DISABLE -}
 
+{-# LANGUAGE CPP #-}
+{-# LANGUAGE FlexibleContexts #-}
+{-# LANGUAGE GADTs #-}
+{-# LANGUAGE PatternSynonyms #-}
+{-# LANGUAGE RankNTypes #-}
+
 {-|
 Module: Database.Persist.Monad.Shim
 
@@ -9,13 +15,6 @@
 This file is autogenerated, to keep it in sync with
 @Database.Persist.Monad.SqlQueryRep@.
 -}
-
-{-# LANGUAGE CPP #-}
-{-# LANGUAGE FlexibleContexts #-}
-{-# LANGUAGE GADTs #-}
-{-# LANGUAGE PatternSynonyms #-}
-{-# LANGUAGE RankNTypes #-}
-
 module Database.Persist.Monad.Shim where
 
 import Control.Monad.IO.Class (MonadIO)
@@ -31,426 +30,589 @@
 import Database.Persist.Sql hiding (pattern Update)
 import GHC.Stack (HasCallStack)
 
-import Database.Persist.Monad.Class (MonadSqlQuery(..))
-import Database.Persist.Monad.SqlQueryRep (SqlQueryRep(..))
+import Database.Persist.Monad.Class (MonadSqlQuery (..))
+import Database.Persist.Monad.SqlQueryRep (SqlQueryRep (..))
 
 #if !MIN_VERSION_persistent(2,14,1)
 import Database.Persist.Monad.Internal.PersistentShim (SafeToInsert)
 #endif
 
 -- | The lifted version of 'Database.Persist.Sql.get'
-get
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => Key record -> m (Maybe record)
-get a1 = runQueryRep $ Get a1
+get ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  Key record ->
+  m (Maybe record)
+get a1 =
+  runQueryRep $ Get a1
 
 -- | The lifted version of 'Database.Persist.Sql.getMany'
-getMany
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => [Key record] -> m (Map (Key record) record)
-getMany a1 = runQueryRep $ GetMany a1
+getMany ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  [Key record] ->
+  m (Map (Key record) record)
+getMany a1 =
+  runQueryRep $ GetMany a1
 
 -- | The lifted version of 'Database.Persist.Sql.getJust'
-getJust
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => Key record -> m record
-getJust a1 = runQueryRep $ GetJust a1
+getJust ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  Key record ->
+  m record
+getJust a1 =
+  runQueryRep $ GetJust a1
 
 -- | The lifted version of 'Database.Persist.Sql.getJustEntity'
-getJustEntity
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => Key record -> m (Entity record)
-getJustEntity a1 = runQueryRep $ GetJustEntity a1
+getJustEntity ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  Key record ->
+  m (Entity record)
+getJustEntity a1 =
+  runQueryRep $ GetJustEntity a1
 
 -- | The lifted version of 'Database.Persist.Sql.getEntity'
-getEntity
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => Key record -> m (Maybe (Entity record))
-getEntity a1 = runQueryRep $ GetEntity a1
+getEntity ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  Key record ->
+  m (Maybe (Entity record))
+getEntity a1 =
+  runQueryRep $ GetEntity a1
 
 -- | The lifted version of 'Database.Persist.Sql.belongsTo'
-belongsTo
-  :: (PersistEntity record1, PersistRecordBackend record2 SqlBackend, Typeable record1, Typeable record2, MonadSqlQuery m)
-  => (record1 -> Maybe (Key record2)) -> record1 -> m (Maybe record2)
-belongsTo a1 a2 = runQueryRep $ BelongsTo a1 a2
+belongsTo ::
+  (PersistEntity record1, PersistRecordBackend record2 SqlBackend, Typeable record1, Typeable record2, MonadSqlQuery m) =>
+  (record1 -> Maybe (Key record2)) ->
+  record1 ->
+  m (Maybe record2)
+belongsTo a1 a2 =
+  runQueryRep $ BelongsTo a1 a2
 
 -- | The lifted version of 'Database.Persist.Sql.belongsToJust'
-belongsToJust
-  :: (PersistEntity record1, PersistRecordBackend record2 SqlBackend, Typeable record1, Typeable record2, MonadSqlQuery m)
-  => (record1 -> Key record2) -> record1 -> m record2
-belongsToJust a1 a2 = runQueryRep $ BelongsToJust a1 a2
+belongsToJust ::
+  (PersistEntity record1, PersistRecordBackend record2 SqlBackend, Typeable record1, Typeable record2, MonadSqlQuery m) =>
+  (record1 -> Key record2) ->
+  record1 ->
+  m record2
+belongsToJust a1 a2 =
+  runQueryRep $ BelongsToJust a1 a2
 
 -- | The lifted version of 'Database.Persist.Sql.insert'
-insert
-  :: (PersistRecordBackend record SqlBackend, SafeToInsert record, Typeable record, MonadSqlQuery m)
-  => record -> m (Key record)
-insert a1 = runQueryRep $ Insert a1
+insert ::
+  (PersistRecordBackend record SqlBackend, SafeToInsert record, Typeable record, MonadSqlQuery m) =>
+  record ->
+  m (Key record)
+insert a1 =
+  runQueryRep $ Insert a1
 
 -- | The lifted version of 'Database.Persist.Sql.insert_'
-insert_
-  :: (PersistRecordBackend record SqlBackend, SafeToInsert record, Typeable record, MonadSqlQuery m)
-  => record -> m ()
-insert_ a1 = runQueryRep $ Insert_ a1
+insert_ ::
+  (PersistRecordBackend record SqlBackend, SafeToInsert record, Typeable record, MonadSqlQuery m) =>
+  record ->
+  m ()
+insert_ a1 =
+  runQueryRep $ Insert_ a1
 
 -- | The lifted version of 'Database.Persist.Sql.insertMany'
-insertMany
-  :: (PersistRecordBackend record SqlBackend, SafeToInsert record, Typeable record, MonadSqlQuery m)
-  => [record] -> m [Key record]
-insertMany a1 = runQueryRep $ InsertMany a1
+insertMany ::
+  (PersistRecordBackend record SqlBackend, SafeToInsert record, Typeable record, MonadSqlQuery m) =>
+  [record] ->
+  m [Key record]
+insertMany a1 =
+  runQueryRep $ InsertMany a1
 
 -- | The lifted version of 'Database.Persist.Sql.insertMany_'
-insertMany_
-  :: (PersistRecordBackend record SqlBackend, SafeToInsert record, Typeable record, MonadSqlQuery m)
-  => [record] -> m ()
-insertMany_ a1 = runQueryRep $ InsertMany_ a1
+insertMany_ ::
+  (PersistRecordBackend record SqlBackend, SafeToInsert record, Typeable record, MonadSqlQuery m) =>
+  [record] ->
+  m ()
+insertMany_ a1 =
+  runQueryRep $ InsertMany_ a1
 
 -- | The lifted version of 'Database.Persist.Sql.insertEntityMany'
-insertEntityMany
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => [Entity record] -> m ()
-insertEntityMany a1 = runQueryRep $ InsertEntityMany a1
+insertEntityMany ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  [Entity record] ->
+  m ()
+insertEntityMany a1 =
+  runQueryRep $ InsertEntityMany a1
 
 -- | The lifted version of 'Database.Persist.Sql.insertKey'
-insertKey
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => Key record -> record -> m ()
-insertKey a1 a2 = runQueryRep $ InsertKey a1 a2
+insertKey ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  Key record ->
+  record ->
+  m ()
+insertKey a1 a2 =
+  runQueryRep $ InsertKey a1 a2
 
 -- | The lifted version of 'Database.Persist.Sql.repsert'
-repsert
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => Key record -> record -> m ()
-repsert a1 a2 = runQueryRep $ Repsert a1 a2
+repsert ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  Key record ->
+  record ->
+  m ()
+repsert a1 a2 =
+  runQueryRep $ Repsert a1 a2
 
 -- | The lifted version of 'Database.Persist.Sql.repsertMany'
-repsertMany
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => [(Key record, record)] -> m ()
-repsertMany a1 = runQueryRep $ RepsertMany a1
+repsertMany ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  [(Key record, record)] ->
+  m ()
+repsertMany a1 =
+  runQueryRep $ RepsertMany a1
 
 -- | The lifted version of 'Database.Persist.Sql.replace'
-replace
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => Key record -> record -> m ()
-replace a1 a2 = runQueryRep $ Replace a1 a2
+replace ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  Key record ->
+  record ->
+  m ()
+replace a1 a2 =
+  runQueryRep $ Replace a1 a2
 
 -- | The lifted version of 'Database.Persist.Sql.delete'
-delete
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => Key record -> m ()
-delete a1 = runQueryRep $ Delete a1
+delete ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  Key record ->
+  m ()
+delete a1 =
+  runQueryRep $ Delete a1
 
 -- | The lifted version of 'Database.Persist.Sql.update'
-update
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => Key record -> [Update record] -> m ()
-update a1 a2 = runQueryRep $ Update a1 a2
+update ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  Key record ->
+  [Update record] ->
+  m ()
+update a1 a2 =
+  runQueryRep $ Update a1 a2
 
 -- | The lifted version of 'Database.Persist.Sql.updateGet'
-updateGet
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => Key record -> [Update record] -> m record
-updateGet a1 a2 = runQueryRep $ UpdateGet a1 a2
+updateGet ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  Key record ->
+  [Update record] ->
+  m record
+updateGet a1 a2 =
+  runQueryRep $ UpdateGet a1 a2
 
 -- | The lifted version of 'Database.Persist.Sql.insertEntity'
-insertEntity
-  :: (PersistRecordBackend record SqlBackend, SafeToInsert record, Typeable record, MonadSqlQuery m)
-  => record -> m (Entity record)
-insertEntity a1 = runQueryRep $ InsertEntity a1
+insertEntity ::
+  (PersistRecordBackend record SqlBackend, SafeToInsert record, Typeable record, MonadSqlQuery m) =>
+  record ->
+  m (Entity record)
+insertEntity a1 =
+  runQueryRep $ InsertEntity a1
 
 -- | The lifted version of 'Database.Persist.Sql.insertRecord'
-insertRecord
-  :: (PersistRecordBackend record SqlBackend, SafeToInsert record, Typeable record, MonadSqlQuery m)
-  => record -> m record
-insertRecord a1 = runQueryRep $ InsertRecord a1
+insertRecord ::
+  (PersistRecordBackend record SqlBackend, SafeToInsert record, Typeable record, MonadSqlQuery m) =>
+  record ->
+  m record
+insertRecord a1 =
+  runQueryRep $ InsertRecord a1
 
 -- | The lifted version of 'Database.Persist.Sql.getBy'
-getBy
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => Unique record -> m (Maybe (Entity record))
-getBy a1 = runQueryRep $ GetBy a1
+getBy ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  Unique record ->
+  m (Maybe (Entity record))
+getBy a1 =
+  runQueryRep $ GetBy a1
 
 -- | The lifted version of 'Database.Persist.Sql.getByValue'
-getByValue
-  :: (PersistRecordBackend record SqlBackend, AtLeastOneUniqueKey record, Typeable record, MonadSqlQuery m)
-  => record -> m (Maybe (Entity record))
-getByValue a1 = runQueryRep $ GetByValue a1
+getByValue ::
+  (PersistRecordBackend record SqlBackend, AtLeastOneUniqueKey record, Typeable record, MonadSqlQuery m) =>
+  record ->
+  m (Maybe (Entity record))
+getByValue a1 =
+  runQueryRep $ GetByValue a1
 
 -- | The lifted version of 'Database.Persist.Sql.checkUnique'
-checkUnique
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => record -> m (Maybe (Unique record))
-checkUnique a1 = runQueryRep $ CheckUnique a1
+checkUnique ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  record ->
+  m (Maybe (Unique record))
+checkUnique a1 =
+  runQueryRep $ CheckUnique a1
 
 -- | The lifted version of 'Database.Persist.Sql.checkUniqueUpdateable'
-checkUniqueUpdateable
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => Entity record -> m (Maybe (Unique record))
-checkUniqueUpdateable a1 = runQueryRep $ CheckUniqueUpdateable a1
+checkUniqueUpdateable ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  Entity record ->
+  m (Maybe (Unique record))
+checkUniqueUpdateable a1 =
+  runQueryRep $ CheckUniqueUpdateable a1
 
 -- | The lifted version of 'Database.Persist.Sql.deleteBy'
-deleteBy
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => Unique record -> m ()
-deleteBy a1 = runQueryRep $ DeleteBy a1
+deleteBy ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  Unique record ->
+  m ()
+deleteBy a1 =
+  runQueryRep $ DeleteBy a1
 
 -- | The lifted version of 'Database.Persist.Sql.insertUnique'
-insertUnique
-  :: (PersistRecordBackend record SqlBackend, SafeToInsert record, Typeable record, MonadSqlQuery m)
-  => record -> m (Maybe (Key record))
-insertUnique a1 = runQueryRep $ InsertUnique a1
+insertUnique ::
+  (PersistRecordBackend record SqlBackend, SafeToInsert record, Typeable record, MonadSqlQuery m) =>
+  record ->
+  m (Maybe (Key record))
+insertUnique a1 =
+  runQueryRep $ InsertUnique a1
 
 -- | The lifted version of 'Database.Persist.Sql.upsert'
-upsert
-  :: (PersistRecordBackend record SqlBackend, OnlyOneUniqueKey record, SafeToInsert record, Typeable record, MonadSqlQuery m)
-  => record -> [Update record] -> m (Entity record)
-upsert a1 a2 = runQueryRep $ Upsert a1 a2
+upsert ::
+  (PersistRecordBackend record SqlBackend, OnlyOneUniqueKey record, SafeToInsert record, Typeable record, MonadSqlQuery m) =>
+  record ->
+  [Update record] ->
+  m (Entity record)
+upsert a1 a2 =
+  runQueryRep $ Upsert a1 a2
 
 -- | The lifted version of 'Database.Persist.Sql.upsertBy'
-upsertBy
-  :: (PersistRecordBackend record SqlBackend, SafeToInsert record, Typeable record, MonadSqlQuery m)
-  => Unique record -> record -> [Update record] -> m (Entity record)
-upsertBy a1 a2 a3 = runQueryRep $ UpsertBy a1 a2 a3
+upsertBy ::
+  (PersistRecordBackend record SqlBackend, SafeToInsert record, Typeable record, MonadSqlQuery m) =>
+  Unique record ->
+  record ->
+  [Update record] ->
+  m (Entity record)
+upsertBy a1 a2 a3 =
+  runQueryRep $ UpsertBy a1 a2 a3
 
 -- | The lifted version of 'Database.Persist.Sql.putMany'
-putMany
-  :: (PersistRecordBackend record SqlBackend, SafeToInsert record, Typeable record, MonadSqlQuery m)
-  => [record] -> m ()
-putMany a1 = runQueryRep $ PutMany a1
+putMany ::
+  (PersistRecordBackend record SqlBackend, SafeToInsert record, Typeable record, MonadSqlQuery m) =>
+  [record] ->
+  m ()
+putMany a1 =
+  runQueryRep $ PutMany a1
 
 -- | The lifted version of 'Database.Persist.Sql.insertBy'
-insertBy
-  :: (PersistRecordBackend record SqlBackend, AtLeastOneUniqueKey record, SafeToInsert record, Typeable record, MonadSqlQuery m)
-  => record -> m (Either (Entity record) (Key record))
-insertBy a1 = runQueryRep $ InsertBy a1
+insertBy ::
+  (PersistRecordBackend record SqlBackend, AtLeastOneUniqueKey record, SafeToInsert record, Typeable record, MonadSqlQuery m) =>
+  record ->
+  m (Either (Entity record) (Key record))
+insertBy a1 =
+  runQueryRep $ InsertBy a1
 
 -- | The lifted version of 'Database.Persist.Sql.insertUniqueEntity'
-insertUniqueEntity
-  :: (PersistRecordBackend record SqlBackend, SafeToInsert record, Typeable record, MonadSqlQuery m)
-  => record -> m (Maybe (Entity record))
-insertUniqueEntity a1 = runQueryRep $ InsertUniqueEntity a1
+insertUniqueEntity ::
+  (PersistRecordBackend record SqlBackend, SafeToInsert record, Typeable record, MonadSqlQuery m) =>
+  record ->
+  m (Maybe (Entity record))
+insertUniqueEntity a1 =
+  runQueryRep $ InsertUniqueEntity a1
 
 -- | The lifted version of 'Database.Persist.Sql.replaceUnique'
-replaceUnique
-  :: (PersistRecordBackend record SqlBackend, Eq (Unique record), Eq record, Typeable record, MonadSqlQuery m)
-  => Key record -> record -> m (Maybe (Unique record))
-replaceUnique a1 a2 = runQueryRep $ ReplaceUnique a1 a2
+replaceUnique ::
+  (PersistRecordBackend record SqlBackend, Eq (Unique record), Eq record, Typeable record, MonadSqlQuery m) =>
+  Key record ->
+  record ->
+  m (Maybe (Unique record))
+replaceUnique a1 a2 =
+  runQueryRep $ ReplaceUnique a1 a2
 
 -- | The lifted version of 'Database.Persist.Sql.onlyUnique'
-onlyUnique
-  :: (PersistRecordBackend record SqlBackend, OnlyOneUniqueKey record, Typeable record, MonadSqlQuery m)
-  => record -> m (Unique record)
-onlyUnique a1 = runQueryRep $ OnlyUnique a1
+onlyUnique ::
+  (PersistRecordBackend record SqlBackend, OnlyOneUniqueKey record, Typeable record, MonadSqlQuery m) =>
+  record ->
+  m (Unique record)
+onlyUnique a1 =
+  runQueryRep $ OnlyUnique a1
 
 -- | The lifted version of 'Database.Persist.Sql.selectSourceRes'
-selectSourceRes
-  :: (MonadIO m2, PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => [Filter record] -> [SelectOpt record] -> m (Acquire (ConduitM () (Entity record) m2 ()))
-selectSourceRes a1 a2 = runQueryRep $ SelectSourceRes a1 a2
+selectSourceRes ::
+  (MonadIO m2, PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  [Filter record] ->
+  [SelectOpt record] ->
+  m (Acquire (ConduitM () (Entity record) m2 ()))
+selectSourceRes a1 a2 =
+  runQueryRep $ SelectSourceRes a1 a2
 
 -- | The lifted version of 'Database.Persist.Sql.selectFirst'
-selectFirst
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => [Filter record] -> [SelectOpt record] -> m (Maybe (Entity record))
-selectFirst a1 a2 = runQueryRep $ SelectFirst a1 a2
+selectFirst ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  [Filter record] ->
+  [SelectOpt record] ->
+  m (Maybe (Entity record))
+selectFirst a1 a2 =
+  runQueryRep $ SelectFirst a1 a2
 
 -- | The lifted version of 'Database.Persist.Sql.selectKeysRes'
-selectKeysRes
-  :: (MonadIO m2, PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => [Filter record] -> [SelectOpt record] -> m (Acquire (ConduitM () (Key record) m2 ()))
-selectKeysRes a1 a2 = runQueryRep $ SelectKeysRes a1 a2
+selectKeysRes ::
+  (MonadIO m2, PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  [Filter record] ->
+  [SelectOpt record] ->
+  m (Acquire (ConduitM () (Key record) m2 ()))
+selectKeysRes a1 a2 =
+  runQueryRep $ SelectKeysRes a1 a2
 
 -- | The lifted version of 'Database.Persist.Sql.count'
-count
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => [Filter record] -> m Int
-count a1 = runQueryRep $ Count a1
+count ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  [Filter record] ->
+  m Int
+count a1 =
+  runQueryRep $ Count a1
 
 -- | The lifted version of 'Database.Persist.Sql.exists'
-exists
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => [Filter record] -> m Bool
-exists a1 = runQueryRep $ Exists a1
+exists ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  [Filter record] ->
+  m Bool
+exists a1 =
+  runQueryRep $ Exists a1
 
 -- | The lifted version of 'Database.Persist.Sql.selectSource'
-selectSource
-  :: (PersistRecordBackend record SqlBackend, MonadResource m, Typeable record, MonadSqlQuery m)
-  => [Filter record] -> [SelectOpt record] -> ConduitM () (Entity record) m ()
-selectSource a1 a2 = fromAcquire $ runQueryRep $ SelectSourceRes a1 a2
+selectSource ::
+  (PersistRecordBackend record SqlBackend, MonadResource m, Typeable record, MonadSqlQuery m) =>
+  [Filter record] ->
+  [SelectOpt record] ->
+  ConduitM () (Entity record) m ()
+selectSource a1 a2 =
+  fromAcquire $ runQueryRep $ SelectSourceRes a1 a2
 
 -- | The lifted version of 'Database.Persist.Sql.selectKeys'
-selectKeys
-  :: (PersistRecordBackend record SqlBackend, MonadResource m, Typeable record, MonadSqlQuery m)
-  => [Filter record] -> [SelectOpt record] -> ConduitM () (Key record) m ()
-selectKeys a1 a2 = fromAcquire $ runQueryRep $ SelectKeysRes a1 a2
+selectKeys ::
+  (PersistRecordBackend record SqlBackend, MonadResource m, Typeable record, MonadSqlQuery m) =>
+  [Filter record] ->
+  [SelectOpt record] ->
+  ConduitM () (Key record) m ()
+selectKeys a1 a2 =
+  fromAcquire $ runQueryRep $ SelectKeysRes a1 a2
 
 -- | The lifted version of 'Database.Persist.Sql.selectList'
-selectList
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => [Filter record] -> [SelectOpt record] -> m [Entity record]
-selectList a1 a2 = runQueryRep $ SelectList a1 a2
+selectList ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  [Filter record] ->
+  [SelectOpt record] ->
+  m [Entity record]
+selectList a1 a2 =
+  runQueryRep $ SelectList a1 a2
 
 -- | The lifted version of 'Database.Persist.Sql.selectKeysList'
-selectKeysList
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => [Filter record] -> [SelectOpt record] -> m [Key record]
-selectKeysList a1 a2 = runQueryRep $ SelectKeysList a1 a2
+selectKeysList ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  [Filter record] ->
+  [SelectOpt record] ->
+  m [Key record]
+selectKeysList a1 a2 =
+  runQueryRep $ SelectKeysList a1 a2
 
 -- | The lifted version of 'Database.Persist.Sql.updateWhere'
-updateWhere
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => [Filter record] -> [Update record] -> m ()
-updateWhere a1 a2 = runQueryRep $ UpdateWhere a1 a2
+updateWhere ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  [Filter record] ->
+  [Update record] ->
+  m ()
+updateWhere a1 a2 =
+  runQueryRep $ UpdateWhere a1 a2
 
 -- | The lifted version of 'Database.Persist.Sql.deleteWhere'
-deleteWhere
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => [Filter record] -> m ()
-deleteWhere a1 = runQueryRep $ DeleteWhere a1
+deleteWhere ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  [Filter record] ->
+  m ()
+deleteWhere a1 =
+  runQueryRep $ DeleteWhere a1
 
 -- | The lifted version of 'Database.Persist.Sql.deleteWhereCount'
-deleteWhereCount
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => [Filter record] -> m Int64
-deleteWhereCount a1 = runQueryRep $ DeleteWhereCount a1
+deleteWhereCount ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  [Filter record] ->
+  m Int64
+deleteWhereCount a1 =
+  runQueryRep $ DeleteWhereCount a1
 
 -- | The lifted version of 'Database.Persist.Sql.updateWhereCount'
-updateWhereCount
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => [Filter record] -> [Update record] -> m Int64
-updateWhereCount a1 a2 = runQueryRep $ UpdateWhereCount a1 a2
+updateWhereCount ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  [Filter record] ->
+  [Update record] ->
+  m Int64
+updateWhereCount a1 a2 =
+  runQueryRep $ UpdateWhereCount a1 a2
 
 -- | The lifted version of 'Database.Persist.Sql.parseMigration'
-parseMigration
-  :: (HasCallStack, MonadSqlQuery m)
-  => Migration -> m (Either [Text] CautiousMigration)
-parseMigration a1 = runQueryRep $ ParseMigration a1
+parseMigration ::
+  (HasCallStack, MonadSqlQuery m) =>
+  Migration ->
+  m (Either [Text] CautiousMigration)
+parseMigration a1 =
+  runQueryRep $ ParseMigration a1
 
 -- | The lifted version of 'Database.Persist.Sql.parseMigration''
-parseMigration'
-  :: (HasCallStack, MonadSqlQuery m)
-  => Migration -> m CautiousMigration
-parseMigration' a1 = runQueryRep $ ParseMigration' a1
+parseMigration' ::
+  (HasCallStack, MonadSqlQuery m) =>
+  Migration ->
+  m CautiousMigration
+parseMigration' a1 =
+  runQueryRep $ ParseMigration' a1
 
 -- | The lifted version of 'Database.Persist.Sql.printMigration'
-printMigration
-  :: (HasCallStack, MonadSqlQuery m)
-  => Migration -> m ()
-printMigration a1 = runQueryRep $ PrintMigration a1
+printMigration ::
+  (HasCallStack, MonadSqlQuery m) =>
+  Migration ->
+  m ()
+printMigration a1 =
+  runQueryRep $ PrintMigration a1
 
 -- | The lifted version of 'Database.Persist.Sql.showMigration'
-showMigration
-  :: (HasCallStack, MonadSqlQuery m)
-  => Migration -> m [Text]
-showMigration a1 = runQueryRep $ ShowMigration a1
+showMigration ::
+  (HasCallStack, MonadSqlQuery m) =>
+  Migration ->
+  m [Text]
+showMigration a1 =
+  runQueryRep $ ShowMigration a1
 
 -- | The lifted version of 'Database.Persist.Sql.getMigration'
-getMigration
-  :: (HasCallStack, MonadSqlQuery m)
-  => Migration -> m [Sql]
-getMigration a1 = runQueryRep $ GetMigration a1
+getMigration ::
+  (HasCallStack, MonadSqlQuery m) =>
+  Migration ->
+  m [Sql]
+getMigration a1 =
+  runQueryRep $ GetMigration a1
 
 -- | The lifted version of 'Database.Persist.Sql.runMigration'
-runMigration
-  :: (MonadSqlQuery m)
-  => Migration -> m ()
-runMigration a1 = runQueryRep $ RunMigration a1
+runMigration ::
+  (MonadSqlQuery m) =>
+  Migration ->
+  m ()
+runMigration a1 =
+  runQueryRep $ RunMigration a1
 
 -- | The lifted version of 'Database.Persist.Sql.runMigrationQuiet'
-runMigrationQuiet
-  :: (MonadSqlQuery m)
-  => Migration -> m [Text]
-runMigrationQuiet a1 = runQueryRep $ RunMigrationQuiet a1
+runMigrationQuiet ::
+  (MonadSqlQuery m) =>
+  Migration ->
+  m [Text]
+runMigrationQuiet a1 =
+  runQueryRep $ RunMigrationQuiet a1
 
 -- | The lifted version of 'Database.Persist.Sql.runMigrationSilent'
-runMigrationSilent
-  :: (MonadSqlQuery m)
-  => Migration -> m [Text]
-runMigrationSilent a1 = runQueryRep $ RunMigrationSilent a1
+runMigrationSilent ::
+  (MonadSqlQuery m) =>
+  Migration ->
+  m [Text]
+runMigrationSilent a1 =
+  runQueryRep $ RunMigrationSilent a1
 
 -- | The lifted version of 'Database.Persist.Sql.runMigrationUnsafe'
-runMigrationUnsafe
-  :: (MonadSqlQuery m)
-  => Migration -> m ()
-runMigrationUnsafe a1 = runQueryRep $ RunMigrationUnsafe a1
+runMigrationUnsafe ::
+  (MonadSqlQuery m) =>
+  Migration ->
+  m ()
+runMigrationUnsafe a1 =
+  runQueryRep $ RunMigrationUnsafe a1
 
 -- | The lifted version of 'Database.Persist.Sql.runMigrationUnsafeQuiet'
-runMigrationUnsafeQuiet
-  :: (HasCallStack, MonadSqlQuery m)
-  => Migration -> m [Text]
-runMigrationUnsafeQuiet a1 = runQueryRep $ RunMigrationUnsafeQuiet a1
+runMigrationUnsafeQuiet ::
+  (HasCallStack, MonadSqlQuery m) =>
+  Migration ->
+  m [Text]
+runMigrationUnsafeQuiet a1 =
+  runQueryRep $ RunMigrationUnsafeQuiet a1
 
 -- | The lifted version of 'Database.Persist.Sql.getFieldName'
-getFieldName
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => EntityField record typ -> m Text
-getFieldName a1 = runQueryRep $ GetFieldName a1
+getFieldName ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  EntityField record typ ->
+  m Text
+getFieldName a1 =
+  runQueryRep $ GetFieldName a1
 
 -- | The lifted version of 'Database.Persist.Sql.getTableName'
-getTableName
-  :: (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m)
-  => record -> m Text
-getTableName a1 = runQueryRep $ GetTableName a1
+getTableName ::
+  (PersistRecordBackend record SqlBackend, Typeable record, MonadSqlQuery m) =>
+  record ->
+  m Text
+getTableName a1 =
+  runQueryRep $ GetTableName a1
 
 -- | The lifted version of 'Database.Persist.Sql.withRawQuery'
-withRawQuery
-  :: (MonadSqlQuery m)
-  => Text -> [PersistValue] -> ConduitM [PersistValue] Void IO a -> m a
-withRawQuery a1 a2 a3 = runQueryRep $ WithRawQuery a1 a2 a3
+withRawQuery ::
+  (MonadSqlQuery m) =>
+  Text ->
+  [PersistValue] ->
+  ConduitM [PersistValue] Void IO a ->
+  m a
+withRawQuery a1 a2 a3 =
+  runQueryRep $ WithRawQuery a1 a2 a3
 
 -- | The lifted version of 'Database.Persist.Sql.rawQueryRes'
-rawQueryRes
-  :: (MonadIO m2, MonadSqlQuery m)
-  => Text -> [PersistValue] -> m (Acquire (ConduitM () [PersistValue] m2 ()))
-rawQueryRes a1 a2 = runQueryRep $ RawQueryRes a1 a2
+rawQueryRes ::
+  (MonadIO m2, MonadSqlQuery m) =>
+  Text ->
+  [PersistValue] ->
+  m (Acquire (ConduitM () [PersistValue] m2 ()))
+rawQueryRes a1 a2 =
+  runQueryRep $ RawQueryRes a1 a2
 
 -- | The lifted version of 'Database.Persist.Sql.rawQuery'
-rawQuery
-  :: (MonadResource m, MonadSqlQuery m)
-  => Text -> [PersistValue] -> ConduitM () [PersistValue] m ()
-rawQuery a1 a2 = fromAcquire $ runQueryRep $ RawQueryRes a1 a2
+rawQuery ::
+  (MonadResource m, MonadSqlQuery m) =>
+  Text ->
+  [PersistValue] ->
+  ConduitM () [PersistValue] m ()
+rawQuery a1 a2 =
+  fromAcquire $ runQueryRep $ RawQueryRes a1 a2
 
 -- | The lifted version of 'Database.Persist.Sql.rawExecute'
-rawExecute
-  :: (MonadSqlQuery m)
-  => Text -> [PersistValue] -> m ()
-rawExecute a1 a2 = runQueryRep $ RawExecute a1 a2
+rawExecute ::
+  (MonadSqlQuery m) =>
+  Text ->
+  [PersistValue] ->
+  m ()
+rawExecute a1 a2 =
+  runQueryRep $ RawExecute a1 a2
 
 -- | The lifted version of 'Database.Persist.Sql.rawExecuteCount'
-rawExecuteCount
-  :: (MonadSqlQuery m)
-  => Text -> [PersistValue] -> m Int64
-rawExecuteCount a1 a2 = runQueryRep $ RawExecuteCount a1 a2
+rawExecuteCount ::
+  (MonadSqlQuery m) =>
+  Text ->
+  [PersistValue] ->
+  m Int64
+rawExecuteCount a1 a2 =
+  runQueryRep $ RawExecuteCount a1 a2
 
 -- | The lifted version of 'Database.Persist.Sql.rawSql'
-rawSql
-  :: (RawSql a, MonadSqlQuery m)
-  => Text -> [PersistValue] -> m [a]
-rawSql a1 a2 = runQueryRep $ RawSql a1 a2
+rawSql ::
+  (RawSql a, MonadSqlQuery m) =>
+  Text ->
+  [PersistValue] ->
+  m [a]
+rawSql a1 a2 =
+  runQueryRep $ RawSql a1 a2
 
 -- | The lifted version of 'Database.Persist.Sql.transactionSave'
-transactionSave
-  :: (MonadSqlQuery m)
-  => m ()
-transactionSave = runQueryRep $ TransactionSave
+transactionSave ::
+  (MonadSqlQuery m) =>
+  m ()
+transactionSave =
+  runQueryRep $ TransactionSave
 
 -- | The lifted version of 'Database.Persist.Sql.transactionSaveWithIsolation'
-transactionSaveWithIsolation
-  :: (MonadSqlQuery m)
-  => IsolationLevel -> m ()
-transactionSaveWithIsolation a1 = runQueryRep $ TransactionSaveWithIsolation a1
+transactionSaveWithIsolation ::
+  (MonadSqlQuery m) =>
+  IsolationLevel ->
+  m ()
+transactionSaveWithIsolation a1 =
+  runQueryRep $ TransactionSaveWithIsolation a1
 
 -- | The lifted version of 'Database.Persist.Sql.transactionUndo'
-transactionUndo
-  :: (MonadSqlQuery m)
-  => m ()
-transactionUndo = runQueryRep $ TransactionUndo
+transactionUndo ::
+  (MonadSqlQuery m) =>
+  m ()
+transactionUndo =
+  runQueryRep $ TransactionUndo
 
 -- | The lifted version of 'Database.Persist.Sql.transactionUndoWithIsolation'
-transactionUndoWithIsolation
-  :: (MonadSqlQuery m)
-  => IsolationLevel -> m ()
-transactionUndoWithIsolation a1 = runQueryRep $ TransactionUndoWithIsolation a1
+transactionUndoWithIsolation ::
+  (MonadSqlQuery m) =>
+  IsolationLevel ->
+  m ()
+transactionUndoWithIsolation a1 =
+  runQueryRep $ TransactionUndoWithIsolation a1
 
 -- | Lift an arbitrary 'SqlPersistT' action into 'MonadSqlQuery'.
 --
diff --git a/src/Database/Persist/Monad/SqlQueryRep.hs b/src/Database/Persist/Monad/SqlQueryRep.hs
--- a/src/Database/Persist/Monad/SqlQueryRep.hs
+++ b/src/Database/Persist/Monad/SqlQueryRep.hs
@@ -1,16 +1,6 @@
 {- THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED MANUALLY -}
 {- FOURMOLU_DISABLE -}
 
-{-|
-Module: Database.Persist.Monad.SqlQueryRep
-
-Defines the 'SqlQueryRep' data type that contains a constructor corresponding
-to a @persistent@ function.
-
-This file is autogenerated, to keep it in sync with
-@Database.Persist.Monad.Shim@.
--}
-
 {-# LANGUAGE CPP #-}
 {-# LANGUAGE FlexibleContexts #-}
 {-# LANGUAGE GADTs #-}
@@ -20,8 +10,17 @@
 {-# LANGUAGE ScopedTypeVariables #-}
 {-# LANGUAGE TypeApplications #-}
 
+{-|
+Module: Database.Persist.Monad.SqlQueryRep
+
+Defines the 'SqlQueryRep' data type that contains a constructor corresponding
+to a @persistent@ function.
+
+This file is autogenerated, to keep it in sync with
+@Database.Persist.Monad.Shim@.
+-}
 module Database.Persist.Monad.SqlQueryRep
-  ( SqlQueryRep(..)
+  ( SqlQueryRep (..)
   , runSqlQueryRep
   ) where
 
@@ -31,10 +30,10 @@
 import Data.Conduit (ConduitM)
 import Data.Int (Int64)
 import Data.Map (Map)
-import Data.Proxy (Proxy(..))
+import Data.Proxy (Proxy (..))
 import Data.Text (Text)
 import qualified Data.Text as Text
-import Data.Typeable (Typeable, eqT, typeRep, (:~:)(..))
+import Data.Typeable (Typeable, eqT, typeRep, (:~:) (..))
 import Data.Void (Void)
 import Database.Persist.Sql as Persist hiding (pattern Update)
 import GHC.Stack (HasCallStack)
@@ -54,334 +53,422 @@
 -- mock out persistent calls in tests.
 data SqlQueryRep record a where
   -- | Constructor corresponding to 'Persist.get'
-  Get
-    :: (PersistRecordBackend record SqlBackend)
-    => Key record -> SqlQueryRep record (Maybe record)
+  Get ::
+    (PersistRecordBackend record SqlBackend) =>
+    Key record ->
+    SqlQueryRep (record) (Maybe record)
 
   -- | Constructor corresponding to 'Persist.getMany'
-  GetMany
-    :: (PersistRecordBackend record SqlBackend)
-    => [Key record] -> SqlQueryRep record (Map (Key record) record)
+  GetMany ::
+    (PersistRecordBackend record SqlBackend) =>
+    [Key record] ->
+    SqlQueryRep (record) (Map (Key record) record)
 
   -- | Constructor corresponding to 'Persist.getJust'
-  GetJust
-    :: (PersistRecordBackend record SqlBackend)
-    => Key record -> SqlQueryRep record record
+  GetJust ::
+    (PersistRecordBackend record SqlBackend) =>
+    Key record ->
+    SqlQueryRep (record) record
 
   -- | Constructor corresponding to 'Persist.getJustEntity'
-  GetJustEntity
-    :: (PersistRecordBackend record SqlBackend)
-    => Key record -> SqlQueryRep record (Entity record)
+  GetJustEntity ::
+    (PersistRecordBackend record SqlBackend) =>
+    Key record ->
+    SqlQueryRep (record) (Entity record)
 
   -- | Constructor corresponding to 'Persist.getEntity'
-  GetEntity
-    :: (PersistRecordBackend record SqlBackend)
-    => Key record -> SqlQueryRep record (Maybe (Entity record))
+  GetEntity ::
+    (PersistRecordBackend record SqlBackend) =>
+    Key record ->
+    SqlQueryRep (record) (Maybe (Entity record))
 
   -- | Constructor corresponding to 'Persist.belongsTo'
-  BelongsTo
-    :: (PersistEntity record1, PersistRecordBackend record2 SqlBackend)
-    => (record1 -> Maybe (Key record2)) -> record1 -> SqlQueryRep (record1, record2) (Maybe record2)
+  BelongsTo ::
+    (PersistEntity record1, PersistRecordBackend record2 SqlBackend) =>
+    (record1 -> Maybe (Key record2)) ->
+    record1 ->
+    SqlQueryRep (record1, record2) (Maybe record2)
 
   -- | Constructor corresponding to 'Persist.belongsToJust'
-  BelongsToJust
-    :: (PersistEntity record1, PersistRecordBackend record2 SqlBackend)
-    => (record1 -> Key record2) -> record1 -> SqlQueryRep (record1, record2) record2
+  BelongsToJust ::
+    (PersistEntity record1, PersistRecordBackend record2 SqlBackend) =>
+    (record1 -> Key record2) ->
+    record1 ->
+    SqlQueryRep (record1, record2) record2
 
   -- | Constructor corresponding to 'Persist.insert'
-  Insert
-    :: (PersistRecordBackend record SqlBackend, SafeToInsert record)
-    => record -> SqlQueryRep record (Key record)
+  Insert ::
+    (PersistRecordBackend record SqlBackend, SafeToInsert record) =>
+    record ->
+    SqlQueryRep (record) (Key record)
 
   -- | Constructor corresponding to 'Persist.insert_'
-  Insert_
-    :: (PersistRecordBackend record SqlBackend, SafeToInsert record)
-    => record -> SqlQueryRep record ()
+  Insert_ ::
+    (PersistRecordBackend record SqlBackend, SafeToInsert record) =>
+    record ->
+    SqlQueryRep (record) ()
 
   -- | Constructor corresponding to 'Persist.insertMany'
-  InsertMany
-    :: (PersistRecordBackend record SqlBackend, SafeToInsert record)
-    => [record] -> SqlQueryRep record [Key record]
+  InsertMany ::
+    (PersistRecordBackend record SqlBackend, SafeToInsert record) =>
+    [record] ->
+    SqlQueryRep (record) [Key record]
 
   -- | Constructor corresponding to 'Persist.insertMany_'
-  InsertMany_
-    :: (PersistRecordBackend record SqlBackend, SafeToInsert record)
-    => [record] -> SqlQueryRep record ()
+  InsertMany_ ::
+    (PersistRecordBackend record SqlBackend, SafeToInsert record) =>
+    [record] ->
+    SqlQueryRep (record) ()
 
   -- | Constructor corresponding to 'Persist.insertEntityMany'
-  InsertEntityMany
-    :: (PersistRecordBackend record SqlBackend)
-    => [Entity record] -> SqlQueryRep record ()
+  InsertEntityMany ::
+    (PersistRecordBackend record SqlBackend) =>
+    [Entity record] ->
+    SqlQueryRep (record) ()
 
   -- | Constructor corresponding to 'Persist.insertKey'
-  InsertKey
-    :: (PersistRecordBackend record SqlBackend)
-    => Key record -> record -> SqlQueryRep record ()
+  InsertKey ::
+    (PersistRecordBackend record SqlBackend) =>
+    Key record ->
+    record ->
+    SqlQueryRep (record) ()
 
   -- | Constructor corresponding to 'Persist.repsert'
-  Repsert
-    :: (PersistRecordBackend record SqlBackend)
-    => Key record -> record -> SqlQueryRep record ()
+  Repsert ::
+    (PersistRecordBackend record SqlBackend) =>
+    Key record ->
+    record ->
+    SqlQueryRep (record) ()
 
   -- | Constructor corresponding to 'Persist.repsertMany'
-  RepsertMany
-    :: (PersistRecordBackend record SqlBackend)
-    => [(Key record, record)] -> SqlQueryRep record ()
+  RepsertMany ::
+    (PersistRecordBackend record SqlBackend) =>
+    [(Key record, record)] ->
+    SqlQueryRep (record) ()
 
   -- | Constructor corresponding to 'Persist.replace'
-  Replace
-    :: (PersistRecordBackend record SqlBackend)
-    => Key record -> record -> SqlQueryRep record ()
+  Replace ::
+    (PersistRecordBackend record SqlBackend) =>
+    Key record ->
+    record ->
+    SqlQueryRep (record) ()
 
   -- | Constructor corresponding to 'Persist.delete'
-  Delete
-    :: (PersistRecordBackend record SqlBackend)
-    => Key record -> SqlQueryRep record ()
+  Delete ::
+    (PersistRecordBackend record SqlBackend) =>
+    Key record ->
+    SqlQueryRep (record) ()
 
   -- | Constructor corresponding to 'Persist.update'
-  Update
-    :: (PersistRecordBackend record SqlBackend)
-    => Key record -> [Update record] -> SqlQueryRep record ()
+  Update ::
+    (PersistRecordBackend record SqlBackend) =>
+    Key record ->
+    [Update record] ->
+    SqlQueryRep (record) ()
 
   -- | Constructor corresponding to 'Persist.updateGet'
-  UpdateGet
-    :: (PersistRecordBackend record SqlBackend)
-    => Key record -> [Update record] -> SqlQueryRep record record
+  UpdateGet ::
+    (PersistRecordBackend record SqlBackend) =>
+    Key record ->
+    [Update record] ->
+    SqlQueryRep (record) record
 
   -- | Constructor corresponding to 'Persist.insertEntity'
-  InsertEntity
-    :: (PersistRecordBackend record SqlBackend, SafeToInsert record)
-    => record -> SqlQueryRep record (Entity record)
+  InsertEntity ::
+    (PersistRecordBackend record SqlBackend, SafeToInsert record) =>
+    record ->
+    SqlQueryRep (record) (Entity record)
 
   -- | Constructor corresponding to 'Persist.insertRecord'
-  InsertRecord
-    :: (PersistRecordBackend record SqlBackend, SafeToInsert record)
-    => record -> SqlQueryRep record record
+  InsertRecord ::
+    (PersistRecordBackend record SqlBackend, SafeToInsert record) =>
+    record ->
+    SqlQueryRep (record) record
 
   -- | Constructor corresponding to 'Persist.getBy'
-  GetBy
-    :: (PersistRecordBackend record SqlBackend)
-    => Unique record -> SqlQueryRep record (Maybe (Entity record))
+  GetBy ::
+    (PersistRecordBackend record SqlBackend) =>
+    Unique record ->
+    SqlQueryRep (record) (Maybe (Entity record))
 
   -- | Constructor corresponding to 'Persist.getByValue'
-  GetByValue
-    :: (PersistRecordBackend record SqlBackend, AtLeastOneUniqueKey record)
-    => record -> SqlQueryRep record (Maybe (Entity record))
+  GetByValue ::
+    (PersistRecordBackend record SqlBackend, AtLeastOneUniqueKey record) =>
+    record ->
+    SqlQueryRep (record) (Maybe (Entity record))
 
   -- | Constructor corresponding to 'Persist.checkUnique'
-  CheckUnique
-    :: (PersistRecordBackend record SqlBackend)
-    => record -> SqlQueryRep record (Maybe (Unique record))
+  CheckUnique ::
+    (PersistRecordBackend record SqlBackend) =>
+    record ->
+    SqlQueryRep (record) (Maybe (Unique record))
 
   -- | Constructor corresponding to 'Persist.checkUniqueUpdateable'
-  CheckUniqueUpdateable
-    :: (PersistRecordBackend record SqlBackend)
-    => Entity record -> SqlQueryRep record (Maybe (Unique record))
+  CheckUniqueUpdateable ::
+    (PersistRecordBackend record SqlBackend) =>
+    Entity record ->
+    SqlQueryRep (record) (Maybe (Unique record))
 
   -- | Constructor corresponding to 'Persist.deleteBy'
-  DeleteBy
-    :: (PersistRecordBackend record SqlBackend)
-    => Unique record -> SqlQueryRep record ()
+  DeleteBy ::
+    (PersistRecordBackend record SqlBackend) =>
+    Unique record ->
+    SqlQueryRep (record) ()
 
   -- | Constructor corresponding to 'Persist.insertUnique'
-  InsertUnique
-    :: (PersistRecordBackend record SqlBackend, SafeToInsert record)
-    => record -> SqlQueryRep record (Maybe (Key record))
+  InsertUnique ::
+    (PersistRecordBackend record SqlBackend, SafeToInsert record) =>
+    record ->
+    SqlQueryRep (record) (Maybe (Key record))
 
   -- | Constructor corresponding to 'Persist.upsert'
-  Upsert
-    :: (PersistRecordBackend record SqlBackend, OnlyOneUniqueKey record, SafeToInsert record)
-    => record -> [Update record] -> SqlQueryRep record (Entity record)
+  Upsert ::
+    (PersistRecordBackend record SqlBackend, OnlyOneUniqueKey record, SafeToInsert record) =>
+    record ->
+    [Update record] ->
+    SqlQueryRep (record) (Entity record)
 
   -- | Constructor corresponding to 'Persist.upsertBy'
-  UpsertBy
-    :: (PersistRecordBackend record SqlBackend, SafeToInsert record)
-    => Unique record -> record -> [Update record] -> SqlQueryRep record (Entity record)
+  UpsertBy ::
+    (PersistRecordBackend record SqlBackend, SafeToInsert record) =>
+    Unique record ->
+    record ->
+    [Update record] ->
+    SqlQueryRep (record) (Entity record)
 
   -- | Constructor corresponding to 'Persist.putMany'
-  PutMany
-    :: (PersistRecordBackend record SqlBackend, SafeToInsert record)
-    => [record] -> SqlQueryRep record ()
+  PutMany ::
+    (PersistRecordBackend record SqlBackend, SafeToInsert record) =>
+    [record] ->
+    SqlQueryRep (record) ()
 
   -- | Constructor corresponding to 'Persist.insertBy'
-  InsertBy
-    :: (PersistRecordBackend record SqlBackend, AtLeastOneUniqueKey record, SafeToInsert record)
-    => record -> SqlQueryRep record (Either (Entity record) (Key record))
+  InsertBy ::
+    (PersistRecordBackend record SqlBackend, AtLeastOneUniqueKey record, SafeToInsert record) =>
+    record ->
+    SqlQueryRep (record) (Either (Entity record) (Key record))
 
   -- | Constructor corresponding to 'Persist.insertUniqueEntity'
-  InsertUniqueEntity
-    :: (PersistRecordBackend record SqlBackend, SafeToInsert record)
-    => record -> SqlQueryRep record (Maybe (Entity record))
+  InsertUniqueEntity ::
+    (PersistRecordBackend record SqlBackend, SafeToInsert record) =>
+    record ->
+    SqlQueryRep (record) (Maybe (Entity record))
 
   -- | Constructor corresponding to 'Persist.replaceUnique'
-  ReplaceUnique
-    :: (PersistRecordBackend record SqlBackend, Eq (Unique record), Eq record)
-    => Key record -> record -> SqlQueryRep record (Maybe (Unique record))
+  ReplaceUnique ::
+    (PersistRecordBackend record SqlBackend, Eq (Unique record), Eq record) =>
+    Key record ->
+    record ->
+    SqlQueryRep (record) (Maybe (Unique record))
 
   -- | Constructor corresponding to 'Persist.onlyUnique'
-  OnlyUnique
-    :: (PersistRecordBackend record SqlBackend, OnlyOneUniqueKey record)
-    => record -> SqlQueryRep record (Unique record)
+  OnlyUnique ::
+    (PersistRecordBackend record SqlBackend, OnlyOneUniqueKey record) =>
+    record ->
+    SqlQueryRep (record) (Unique record)
 
   -- | Constructor corresponding to 'Persist.selectSourceRes'
-  SelectSourceRes
-    :: (MonadIO m2, PersistRecordBackend record SqlBackend)
-    => [Filter record] -> [SelectOpt record] -> SqlQueryRep record (Acquire (ConduitM () (Entity record) m2 ()))
+  SelectSourceRes ::
+    (MonadIO m2, PersistRecordBackend record SqlBackend) =>
+    [Filter record] ->
+    [SelectOpt record] ->
+    SqlQueryRep (record) (Acquire (ConduitM () (Entity record) m2 ()))
 
   -- | Constructor corresponding to 'Persist.selectFirst'
-  SelectFirst
-    :: (PersistRecordBackend record SqlBackend)
-    => [Filter record] -> [SelectOpt record] -> SqlQueryRep record (Maybe (Entity record))
+  SelectFirst ::
+    (PersistRecordBackend record SqlBackend) =>
+    [Filter record] ->
+    [SelectOpt record] ->
+    SqlQueryRep (record) (Maybe (Entity record))
 
   -- | Constructor corresponding to 'Persist.selectKeysRes'
-  SelectKeysRes
-    :: (MonadIO m2, PersistRecordBackend record SqlBackend)
-    => [Filter record] -> [SelectOpt record] -> SqlQueryRep record (Acquire (ConduitM () (Key record) m2 ()))
+  SelectKeysRes ::
+    (MonadIO m2, PersistRecordBackend record SqlBackend) =>
+    [Filter record] ->
+    [SelectOpt record] ->
+    SqlQueryRep (record) (Acquire (ConduitM () (Key record) m2 ()))
 
   -- | Constructor corresponding to 'Persist.count'
-  Count
-    :: (PersistRecordBackend record SqlBackend)
-    => [Filter record] -> SqlQueryRep record Int
+  Count ::
+    (PersistRecordBackend record SqlBackend) =>
+    [Filter record] ->
+    SqlQueryRep (record) Int
 
   -- | Constructor corresponding to 'Persist.exists'
-  Exists
-    :: (PersistRecordBackend record SqlBackend)
-    => [Filter record] -> SqlQueryRep record Bool
+  Exists ::
+    (PersistRecordBackend record SqlBackend) =>
+    [Filter record] ->
+    SqlQueryRep (record) Bool
 
   -- | Constructor corresponding to 'Persist.selectList'
-  SelectList
-    :: (PersistRecordBackend record SqlBackend)
-    => [Filter record] -> [SelectOpt record] -> SqlQueryRep record [Entity record]
+  SelectList ::
+    (PersistRecordBackend record SqlBackend) =>
+    [Filter record] ->
+    [SelectOpt record] ->
+    SqlQueryRep (record) [Entity record]
 
   -- | Constructor corresponding to 'Persist.selectKeysList'
-  SelectKeysList
-    :: (PersistRecordBackend record SqlBackend)
-    => [Filter record] -> [SelectOpt record] -> SqlQueryRep record [Key record]
+  SelectKeysList ::
+    (PersistRecordBackend record SqlBackend) =>
+    [Filter record] ->
+    [SelectOpt record] ->
+    SqlQueryRep (record) [Key record]
 
   -- | Constructor corresponding to 'Persist.updateWhere'
-  UpdateWhere
-    :: (PersistRecordBackend record SqlBackend)
-    => [Filter record] -> [Update record] -> SqlQueryRep record ()
+  UpdateWhere ::
+    (PersistRecordBackend record SqlBackend) =>
+    [Filter record] ->
+    [Update record] ->
+    SqlQueryRep (record) ()
 
   -- | Constructor corresponding to 'Persist.deleteWhere'
-  DeleteWhere
-    :: (PersistRecordBackend record SqlBackend)
-    => [Filter record] -> SqlQueryRep record ()
+  DeleteWhere ::
+    (PersistRecordBackend record SqlBackend) =>
+    [Filter record] ->
+    SqlQueryRep (record) ()
 
   -- | Constructor corresponding to 'Persist.deleteWhereCount'
-  DeleteWhereCount
-    :: (PersistRecordBackend record SqlBackend)
-    => [Filter record] -> SqlQueryRep record Int64
+  DeleteWhereCount ::
+    (PersistRecordBackend record SqlBackend) =>
+    [Filter record] ->
+    SqlQueryRep (record) Int64
 
   -- | Constructor corresponding to 'Persist.updateWhereCount'
-  UpdateWhereCount
-    :: (PersistRecordBackend record SqlBackend)
-    => [Filter record] -> [Update record] -> SqlQueryRep record Int64
+  UpdateWhereCount ::
+    (PersistRecordBackend record SqlBackend) =>
+    [Filter record] ->
+    [Update record] ->
+    SqlQueryRep (record) Int64
 
   -- | Constructor corresponding to 'Persist.parseMigration'
-  ParseMigration
-    :: (HasCallStack)
-    => Migration -> SqlQueryRep Void (Either [Text] CautiousMigration)
+  ParseMigration ::
+    (HasCallStack) =>
+    Migration ->
+    SqlQueryRep (Void) (Either [Text] CautiousMigration)
 
   -- | Constructor corresponding to 'Persist.parseMigration''
-  ParseMigration'
-    :: (HasCallStack)
-    => Migration -> SqlQueryRep Void CautiousMigration
+  ParseMigration' ::
+    (HasCallStack) =>
+    Migration ->
+    SqlQueryRep (Void) CautiousMigration
 
   -- | Constructor corresponding to 'Persist.printMigration'
-  PrintMigration
-    :: (HasCallStack)
-    => Migration -> SqlQueryRep Void ()
+  PrintMigration ::
+    (HasCallStack) =>
+    Migration ->
+    SqlQueryRep (Void) ()
 
   -- | Constructor corresponding to 'Persist.showMigration'
-  ShowMigration
-    :: (HasCallStack)
-    => Migration -> SqlQueryRep Void [Text]
+  ShowMigration ::
+    (HasCallStack) =>
+    Migration ->
+    SqlQueryRep (Void) [Text]
 
   -- | Constructor corresponding to 'Persist.getMigration'
-  GetMigration
-    :: (HasCallStack)
-    => Migration -> SqlQueryRep Void [Sql]
+  GetMigration ::
+    (HasCallStack) =>
+    Migration ->
+    SqlQueryRep (Void) [Sql]
 
   -- | Constructor corresponding to 'Persist.runMigration'
-  RunMigration
-    :: ()
-    => Migration -> SqlQueryRep Void ()
+  RunMigration ::
+    () =>
+    Migration ->
+    SqlQueryRep (Void) ()
 
   -- | Constructor corresponding to 'Persist.runMigrationQuiet'
-  RunMigrationQuiet
-    :: ()
-    => Migration -> SqlQueryRep Void [Text]
+  RunMigrationQuiet ::
+    () =>
+    Migration ->
+    SqlQueryRep (Void) [Text]
 
   -- | Constructor corresponding to 'Persist.runMigrationSilent'
-  RunMigrationSilent
-    :: ()
-    => Migration -> SqlQueryRep Void [Text]
+  RunMigrationSilent ::
+    () =>
+    Migration ->
+    SqlQueryRep (Void) [Text]
 
   -- | Constructor corresponding to 'Persist.runMigrationUnsafe'
-  RunMigrationUnsafe
-    :: ()
-    => Migration -> SqlQueryRep Void ()
+  RunMigrationUnsafe ::
+    () =>
+    Migration ->
+    SqlQueryRep (Void) ()
 
   -- | Constructor corresponding to 'Persist.runMigrationUnsafeQuiet'
-  RunMigrationUnsafeQuiet
-    :: (HasCallStack)
-    => Migration -> SqlQueryRep Void [Text]
+  RunMigrationUnsafeQuiet ::
+    (HasCallStack) =>
+    Migration ->
+    SqlQueryRep (Void) [Text]
 
   -- | Constructor corresponding to 'Persist.getFieldName'
-  GetFieldName
-    :: (PersistRecordBackend record SqlBackend)
-    => EntityField record typ -> SqlQueryRep record Text
+  GetFieldName ::
+    (PersistRecordBackend record SqlBackend) =>
+    EntityField record typ ->
+    SqlQueryRep (record) Text
 
   -- | Constructor corresponding to 'Persist.getTableName'
-  GetTableName
-    :: (PersistRecordBackend record SqlBackend)
-    => record -> SqlQueryRep record Text
+  GetTableName ::
+    (PersistRecordBackend record SqlBackend) =>
+    record ->
+    SqlQueryRep (record) Text
 
   -- | Constructor corresponding to 'Persist.withRawQuery'
-  WithRawQuery
-    :: ()
-    => Text -> [PersistValue] -> ConduitM [PersistValue] Void IO a -> SqlQueryRep Void a
+  WithRawQuery ::
+    () =>
+    Text ->
+    [PersistValue] ->
+    ConduitM [PersistValue] Void IO a ->
+    SqlQueryRep (Void) a
 
   -- | Constructor corresponding to 'Persist.rawQueryRes'
-  RawQueryRes
-    :: (MonadIO m2)
-    => Text -> [PersistValue] -> SqlQueryRep Void (Acquire (ConduitM () [PersistValue] m2 ()))
+  RawQueryRes ::
+    (MonadIO m2) =>
+    Text ->
+    [PersistValue] ->
+    SqlQueryRep (Void) (Acquire (ConduitM () [PersistValue] m2 ()))
 
   -- | Constructor corresponding to 'Persist.rawExecute'
-  RawExecute
-    :: ()
-    => Text -> [PersistValue] -> SqlQueryRep Void ()
+  RawExecute ::
+    () =>
+    Text ->
+    [PersistValue] ->
+    SqlQueryRep (Void) ()
 
   -- | Constructor corresponding to 'Persist.rawExecuteCount'
-  RawExecuteCount
-    :: ()
-    => Text -> [PersistValue] -> SqlQueryRep Void Int64
+  RawExecuteCount ::
+    () =>
+    Text ->
+    [PersistValue] ->
+    SqlQueryRep (Void) Int64
 
   -- | Constructor corresponding to 'Persist.rawSql'
-  RawSql
-    :: (RawSql a)
-    => Text -> [PersistValue] -> SqlQueryRep Void [a]
+  RawSql ::
+    (RawSql a) =>
+    Text ->
+    [PersistValue] ->
+    SqlQueryRep (Void) [a]
 
   -- | Constructor corresponding to 'Persist.transactionSave'
-  TransactionSave
-    :: ()
-    => SqlQueryRep Void ()
+  TransactionSave ::
+    () =>
+    SqlQueryRep (Void) ()
 
   -- | Constructor corresponding to 'Persist.transactionSaveWithIsolation'
-  TransactionSaveWithIsolation
-    :: ()
-    => IsolationLevel -> SqlQueryRep Void ()
+  TransactionSaveWithIsolation ::
+    () =>
+    IsolationLevel ->
+    SqlQueryRep (Void) ()
 
   -- | Constructor corresponding to 'Persist.transactionUndo'
-  TransactionUndo
-    :: ()
-    => SqlQueryRep Void ()
+  TransactionUndo ::
+    () =>
+    SqlQueryRep (Void) ()
 
   -- | Constructor corresponding to 'Persist.transactionUndoWithIsolation'
-  TransactionUndoWithIsolation
-    :: ()
-    => IsolationLevel -> SqlQueryRep Void ()
+  TransactionUndoWithIsolation ::
+    () =>
+    IsolationLevel ->
+    SqlQueryRep (Void) ()
 
   -- | Constructor for lifting an arbitrary SqlPersistT action into SqlQueryRep.
   UnsafeLiftSql
diff --git a/src/Database/Persist/Monad/TestUtils.hs b/src/Database/Persist/Monad/TestUtils.hs
--- a/src/Database/Persist/Monad/TestUtils.hs
+++ b/src/Database/Persist/Monad/TestUtils.hs
@@ -64,39 +64,38 @@
     , MonadResource
     )
 
-{-| Runs a 'MockSqlQueryT' monad transformer using the given mocks.
-
- When a database query is executed, the first mock that returns a 'Just' is
- returned. If no mocks match the query, an error is thrown. See 'SqlQueryRep'
- for the constructors available to match against. Most of the time, you'll
- want to use 'withRecord' to only match queries against a specific @record@
- type (e.g. only match 'Database.Persist.Monad.Shim.selectList' calls for
- the @Person@ entity).
-
- Usage:
-
- @
- myFunction :: MonadSqlQuery m => m [String]
- myFunction = map personName <$> selectList [PersonAge >. 25] []
-
- let persons = [Person ...]
- result <- runMockSqlQueryT myFunction
-   [ withRecord \@Person $ \\case
-       SelectList _ _ -> Just persons
-       _ -> Nothing
-   , withRecord \@Post $ \\case
-       Insert Post{ name = "post1" } -> Just $ toSqlKey 1
-       _ -> Nothing
-   , mockQuery $ \\case
-       RawExecuteCount "DELETE FROM person WHERE name = \'Alice\'" [] -> Just 1
-       _ -> Nothing
-   ]
- @
--}
+-- | Runs a 'MockSqlQueryT' monad transformer using the given mocks.
+--
+--  When a database query is executed, the first mock that returns a 'Just' is
+--  returned. If no mocks match the query, an error is thrown. See 'SqlQueryRep'
+--  for the constructors available to match against. Most of the time, you'll
+--  want to use 'withRecord' to only match queries against a specific @record@
+--  type (e.g. only match 'Database.Persist.Monad.Shim.selectList' calls for
+--  the @Person@ entity).
+--
+--  Usage:
+--
+--  @
+--  myFunction :: MonadSqlQuery m => m [String]
+--  myFunction = map personName <$> selectList [PersonAge >. 25] []
+--
+--  let persons = [Person ...]
+--  result <- runMockSqlQueryT myFunction
+--    [ withRecord \@Person $ \\case
+--        SelectList _ _ -> Just persons
+--        _ -> Nothing
+--    , withRecord \@Post $ \\case
+--        Insert Post{ name = "post1" } -> Just $ toSqlKey 1
+--        _ -> Nothing
+--    , mockQuery $ \\case
+--        RawExecuteCount "DELETE FROM person WHERE name = \'Alice\'" [] -> Just 1
+--        _ -> Nothing
+--    ]
+--  @
 runMockSqlQueryT :: MockSqlQueryT m a -> [MockQuery] -> m a
 runMockSqlQueryT action mockQueries = (`runReaderT` mockQueries) . unMockSqlQueryT $ action
 
-instance MonadIO m => MonadSqlQuery (MockSqlQueryT m) where
+instance (MonadIO m) => MonadSqlQuery (MockSqlQueryT m) where
   type TransactionM (MockSqlQueryT m) = MockSqlQueryT m
 
   runQueryRep rep = do
@@ -109,104 +108,98 @@
 
   withTransaction = id
 
-{-| A mocked query to use in 'runMockSqlQueryT'.
-
- Use 'withRecord' or another helper to create a 'MockQuery'.
--}
-data MockQuery = MockQuery (forall record a. Typeable record => SqlQueryRep record a -> Maybe (IO a))
-
-{-| A helper for defining a mocked database query against a specific @record@
- type. Designed to be used with TypeApplications.
-
- Most 'SqlQueryRep' constructors are in the context of a specific @record@
- type, like @Person@. This helper only matches mocked database queries that
- are querying the record you specify.
-
- Some constructors reference multiple @record@ types, like
- 'Database.Persist.Monad.BelongsTo'. Look at the type to see the record you
- need to match against. For example,
-
- @
- withRecord \@(Person, Post) $ \\case
-   BelongsTo _ _ -> ...
- @
-
- would match the function call
+-- | A mocked query to use in 'runMockSqlQueryT'.
+--
+--  Use 'withRecord' or another helper to create a 'MockQuery'.
+data MockQuery = MockQuery (forall record a. (Typeable record) => SqlQueryRep record a -> Maybe (IO a))
 
- @
- belongsTo :: (Person -> Maybe (Key Post)) -> Person -> SqlQueryRep (Person, Post) (Maybe Post)
- @
--}
-withRecord :: forall record. Typeable record => (forall a. SqlQueryRep record a -> Maybe a) -> MockQuery
+-- | A helper for defining a mocked database query against a specific @record@
+--  type. Designed to be used with TypeApplications.
+--
+--  Most 'SqlQueryRep' constructors are in the context of a specific @record@
+--  type, like @Person@. This helper only matches mocked database queries that
+--  are querying the record you specify.
+--
+--  Some constructors reference multiple @record@ types, like
+--  'Database.Persist.Monad.BelongsTo'. Look at the type to see the record you
+--  need to match against. For example,
+--
+--  @
+--  withRecord \@(Person, Post) $ \\case
+--    BelongsTo _ _ -> ...
+--  @
+--
+--  would match the function call
+--
+--  @
+--  belongsTo :: (Person -> Maybe (Key Post)) -> Person -> SqlQueryRep (Person, Post) (Maybe Post)
+--  @
+withRecord :: forall record. (Typeable record) => (forall a. SqlQueryRep record a -> Maybe a) -> MockQuery
 withRecord f = MockQuery $ \(rep :: SqlQueryRep someRecord result) ->
   case eqT @record @someRecord of
     Just Refl -> pure <$> f rep
     Nothing -> Nothing
 
-{-| A helper for defining a mocked database query.
-
- This does not do any matching on the @record@ type, so it is mostly useful
- for queries that don't use the @record@ type, like
- 'Database.Persist.Monad.Shim.rawExecute'.
--}
-mockQuery :: (forall record a. Typeable record => SqlQueryRep record a -> Maybe a) -> MockQuery
+-- | A helper for defining a mocked database query.
+--
+--  This does not do any matching on the @record@ type, so it is mostly useful
+--  for queries that don't use the @record@ type, like
+--  'Database.Persist.Monad.Shim.rawExecute'.
+mockQuery :: (forall record a. (Typeable record) => SqlQueryRep record a -> Maybe a) -> MockQuery
 mockQuery f = MockQuery (fmap pure . f)
 
-{-| A helper for mocking a 'Database.Persist.Monad.Shim.selectSource' or
- 'Database.Persist.Monad.Shim.selectSourceRes' call.
-
- Usage:
-
- @
- mockSelectSource $ \\filters opts ->
-   if null filters && null opts
-     then
-       let person1 = [Entity (toSqlKey 1) $ Person \"Alice\"]
-           person2 = [Entity (toSqlKey 2) $ Person \"Bob\"]
-       in Just [person1, person2]
-     else Nothing
- @
--}
-mockSelectSource :: forall record. Typeable record => ([Filter record] -> [SelectOpt record] -> Maybe [Entity record]) -> MockQuery
+-- | A helper for mocking a 'Database.Persist.Monad.Shim.selectSource' or
+--  'Database.Persist.Monad.Shim.selectSourceRes' call.
+--
+--  Usage:
+--
+--  @
+--  mockSelectSource $ \\filters opts ->
+--    if null filters && null opts
+--      then
+--        let person1 = [Entity (toSqlKey 1) $ Person \"Alice\"]
+--            person2 = [Entity (toSqlKey 2) $ Person \"Bob\"]
+--        in Just [person1, person2]
+--      else Nothing
+--  @
+mockSelectSource :: forall record. (Typeable record) => ([Filter record] -> [SelectOpt record] -> Maybe [Entity record]) -> MockQuery
 mockSelectSource f = withRecord @record $ \case
   SelectSourceRes filters opts ->
     let toAcquire entities = Acquire.mkAcquire (pure $ Conduit.yieldMany entities) (\_ -> pure ())
      in toAcquire <$> f filters opts
   _ -> Nothing
 
-{-| A helper for mocking a 'Database.Persist.Monad.Shim.selectKeys' or
- 'Database.Persist.Monad.Shim.selectKeysRes' call.
-
- Usage:
-
- @
- mockSelectKeys $ \\filters opts ->
-   if null filters && null opts
-     then Just $ map toSqlKey [1, 2]
-     else Nothing
- @
--}
-mockSelectKeys :: forall record. Typeable record => ([Filter record] -> [SelectOpt record] -> Maybe [Key record]) -> MockQuery
+-- | A helper for mocking a 'Database.Persist.Monad.Shim.selectKeys' or
+--  'Database.Persist.Monad.Shim.selectKeysRes' call.
+--
+--  Usage:
+--
+--  @
+--  mockSelectKeys $ \\filters opts ->
+--    if null filters && null opts
+--      then Just $ map toSqlKey [1, 2]
+--      else Nothing
+--  @
+mockSelectKeys :: forall record. (Typeable record) => ([Filter record] -> [SelectOpt record] -> Maybe [Key record]) -> MockQuery
 mockSelectKeys f = withRecord @record $ \case
   SelectKeysRes filters opts ->
     let toAcquire keys = Acquire.mkAcquire (pure $ Conduit.yieldMany keys) (\_ -> pure ())
      in toAcquire <$> f filters opts
   _ -> Nothing
 
-{-| A helper for mocking a 'Database.Persist.Monad.Shim.withRawQuery' call.
-
- Usage:
-
- @
- mockWithRawQuery $ \\sql vals ->
-   if sql == "SELECT id, name FROM person"
-     then
-       let row1 = [toPersistValue 1, toPersistValue \"Alice\"]
-           row2 = [toPersistValue 2, toPersistValue \"Bob\"]
-       in Just [row1, row2]
-     else Nothing
- @
--}
+-- | A helper for mocking a 'Database.Persist.Monad.Shim.withRawQuery' call.
+--
+--  Usage:
+--
+--  @
+--  mockWithRawQuery $ \\sql vals ->
+--    if sql == "SELECT id, name FROM person"
+--      then
+--        let row1 = [toPersistValue 1, toPersistValue \"Alice\"]
+--            row2 = [toPersistValue 2, toPersistValue \"Bob\"]
+--        in Just [row1, row2]
+--      else Nothing
+--  @
 mockWithRawQuery :: (Text -> [PersistValue] -> Maybe [[PersistValue]]) -> MockQuery
 mockWithRawQuery f = MockQuery $ \case
   WithRawQuery sql vals conduit ->
@@ -214,21 +207,20 @@
      in outputRows <$> f sql vals
   _ -> Nothing
 
-{-| A helper for mocking a 'Database.Persist.Monad.Shim.rawQuery' or
- 'Database.Persist.Monad.Shim.rawQueryRes' call.
-
- Usage:
-
- @
- mockRawQuery $ \\sql vals ->
-   if sql == "SELECT id, name FROM person"
-     then
-       let row1 = [toPersistValue 1, toPersistValue \"Alice\"]
-           row2 = [toPersistValue 2, toPersistValue \"Bob\"]
-       in Just [row1, row2]
-     else Nothing
- @
--}
+-- | A helper for mocking a 'Database.Persist.Monad.Shim.rawQuery' or
+--  'Database.Persist.Monad.Shim.rawQueryRes' call.
+--
+--  Usage:
+--
+--  @
+--  mockRawQuery $ \\sql vals ->
+--    if sql == "SELECT id, name FROM person"
+--      then
+--        let row1 = [toPersistValue 1, toPersistValue \"Alice\"]
+--            row2 = [toPersistValue 2, toPersistValue \"Bob\"]
+--        in Just [row1, row2]
+--      else Nothing
+--  @
 mockRawQuery :: (Text -> [PersistValue] -> Maybe [[PersistValue]]) -> MockQuery
 mockRawQuery f = MockQuery $ \case
   RawQueryRes sql vals ->
@@ -236,20 +228,19 @@
      in pure . toAcquire <$> f sql vals
   _ -> Nothing
 
-{-| A helper for mocking a 'Database.Persist.Monad.Shim.rawSql' call.
-
- Usage:
-
- @
- mockRawSql $ \\sql vals ->
-   if sql == "SELECT id, name FROM person"
-     then
-       let row1 = [toPersistValue 1, toPersistValue \"Alice\"]
-           row2 = [toPersistValue 2, toPersistValue \"Bob\"]
-       in Just [row1, row2]
-     else Nothing
- @
--}
+-- | A helper for mocking a 'Database.Persist.Monad.Shim.rawSql' call.
+--
+--  Usage:
+--
+--  @
+--  mockRawSql $ \\sql vals ->
+--    if sql == "SELECT id, name FROM person"
+--      then
+--        let row1 = [toPersistValue 1, toPersistValue \"Alice\"]
+--            row2 = [toPersistValue 2, toPersistValue \"Bob\"]
+--        in Just [row1, row2]
+--      else Nothing
+--  @
 mockRawSql :: (Text -> [PersistValue] -> Maybe [[PersistValue]]) -> MockQuery
 mockRawSql f = MockQuery $ \case
   RawSql sql vals ->
diff --git a/src/Database/Persist/Sql/Shim.hs b/src/Database/Persist/Sql/Shim.hs
--- a/src/Database/Persist/Sql/Shim.hs
+++ b/src/Database/Persist/Sql/Shim.hs
@@ -1,6 +1,8 @@
 {- THIS FILE IS AUTOGENERATED AND SHOULD NOT BE EDITED MANUALLY -}
 {- FOURMOLU_DISABLE -}
 
+{-# LANGUAGE CPP #-}
+
 {-|
 Module: Database.Persist.Sql.Shim
 
@@ -11,9 +13,6 @@
 This file is autogenerated, to keep it in sync with
 @Database.Persist.Monad.Shim@.
 -}
-
-{-# LANGUAGE CPP #-}
-
 module Database.Persist.Sql.Shim (
   module Database.Persist.Sql,
   get,
@@ -86,148 +85,148 @@
   transactionUndo,
   transactionUndoWithIsolation,
   unsafeLiftSql,
-  ) where
+) where
 
 import Database.Persist.Monad.Shim (
-    get,
-    getMany,
-    getJust,
-    getJustEntity,
-    getEntity,
-    belongsTo,
-    belongsToJust,
-    insert,
-    insert_,
-    insertMany,
-    insertMany_,
-    insertEntityMany,
-    insertKey,
-    repsert,
-    repsertMany,
-    replace,
-    delete,
-    update,
-    updateGet,
-    insertEntity,
-    insertRecord,
-    getBy,
-    getByValue,
-    checkUnique,
-    checkUniqueUpdateable,
-    deleteBy,
-    insertUnique,
-    upsert,
-    upsertBy,
-    putMany,
-    insertBy,
-    insertUniqueEntity,
-    replaceUnique,
-    onlyUnique,
-    selectSourceRes,
-    selectFirst,
-    selectKeysRes,
-    count,
-    exists,
-    selectSource,
-    selectKeys,
-    selectList,
-    selectKeysList,
-    updateWhere,
-    deleteWhere,
-    deleteWhereCount,
-    updateWhereCount,
-    parseMigration,
-    parseMigration',
-    printMigration,
-    showMigration,
-    getMigration,
-    runMigration,
-    runMigrationQuiet,
-    runMigrationSilent,
-    runMigrationUnsafe,
-    runMigrationUnsafeQuiet,
-    getFieldName,
-    getTableName,
-    withRawQuery,
-    rawQueryRes,
-    rawQuery,
-    rawExecute,
-    rawExecuteCount,
-    rawSql,
-    transactionSave,
-    transactionSaveWithIsolation,
-    transactionUndo,
-    transactionUndoWithIsolation,
-    unsafeLiftSql
-    )
+  get,
+  getMany,
+  getJust,
+  getJustEntity,
+  getEntity,
+  belongsTo,
+  belongsToJust,
+  insert,
+  insert_,
+  insertMany,
+  insertMany_,
+  insertEntityMany,
+  insertKey,
+  repsert,
+  repsertMany,
+  replace,
+  delete,
+  update,
+  updateGet,
+  insertEntity,
+  insertRecord,
+  getBy,
+  getByValue,
+  checkUnique,
+  checkUniqueUpdateable,
+  deleteBy,
+  insertUnique,
+  upsert,
+  upsertBy,
+  putMany,
+  insertBy,
+  insertUniqueEntity,
+  replaceUnique,
+  onlyUnique,
+  selectSourceRes,
+  selectFirst,
+  selectKeysRes,
+  count,
+  exists,
+  selectSource,
+  selectKeys,
+  selectList,
+  selectKeysList,
+  updateWhere,
+  deleteWhere,
+  deleteWhereCount,
+  updateWhereCount,
+  parseMigration,
+  parseMigration',
+  printMigration,
+  showMigration,
+  getMigration,
+  runMigration,
+  runMigrationQuiet,
+  runMigrationSilent,
+  runMigrationUnsafe,
+  runMigrationUnsafeQuiet,
+  getFieldName,
+  getTableName,
+  withRawQuery,
+  rawQueryRes,
+  rawQuery,
+  rawExecute,
+  rawExecuteCount,
+  rawSql,
+  transactionSave,
+  transactionSaveWithIsolation,
+  transactionUndo,
+  transactionUndoWithIsolation,
+  unsafeLiftSql,
+ )
 import Database.Persist.Sql hiding (
-    get,
-    getMany,
-    getJust,
-    getJustEntity,
-    getEntity,
-    belongsTo,
-    belongsToJust,
-    insert,
-    insert_,
-    insertMany,
-    insertMany_,
-    insertEntityMany,
-    insertKey,
-    repsert,
-    repsertMany,
-    replace,
-    delete,
-    update,
-    updateGet,
-    insertEntity,
-    insertRecord,
-    getBy,
-    getByValue,
-    checkUnique,
-    checkUniqueUpdateable,
-    deleteBy,
-    insertUnique,
-    upsert,
-    upsertBy,
-    putMany,
-    insertBy,
-    insertUniqueEntity,
-    replaceUnique,
-    onlyUnique,
-    selectSourceRes,
-    selectFirst,
-    selectKeysRes,
-    count,
-    exists,
-    selectSource,
-    selectKeys,
-    selectList,
-    selectKeysList,
-    updateWhere,
-    deleteWhere,
-    deleteWhereCount,
-    updateWhereCount,
-    parseMigration,
-    parseMigration',
-    printMigration,
-    showMigration,
-    getMigration,
-    runMigration,
-    runMigrationQuiet,
-    runMigrationSilent,
-    runMigrationUnsafe,
-    runMigrationUnsafeQuiet,
-    getFieldName,
-    getTableName,
-    withRawQuery,
-    rawQueryRes,
-    rawQuery,
-    rawExecute,
-    rawExecuteCount,
-    rawSql,
-    transactionSave,
-    transactionSaveWithIsolation,
-    transactionUndo,
-    transactionUndoWithIsolation,
-    )
+  get,
+  getMany,
+  getJust,
+  getJustEntity,
+  getEntity,
+  belongsTo,
+  belongsToJust,
+  insert,
+  insert_,
+  insertMany,
+  insertMany_,
+  insertEntityMany,
+  insertKey,
+  repsert,
+  repsertMany,
+  replace,
+  delete,
+  update,
+  updateGet,
+  insertEntity,
+  insertRecord,
+  getBy,
+  getByValue,
+  checkUnique,
+  checkUniqueUpdateable,
+  deleteBy,
+  insertUnique,
+  upsert,
+  upsertBy,
+  putMany,
+  insertBy,
+  insertUniqueEntity,
+  replaceUnique,
+  onlyUnique,
+  selectSourceRes,
+  selectFirst,
+  selectKeysRes,
+  count,
+  exists,
+  selectSource,
+  selectKeys,
+  selectList,
+  selectKeysList,
+  updateWhere,
+  deleteWhere,
+  deleteWhereCount,
+  updateWhereCount,
+  parseMigration,
+  parseMigration',
+  printMigration,
+  showMigration,
+  getMigration,
+  runMigration,
+  runMigrationQuiet,
+  runMigrationSilent,
+  runMigrationUnsafe,
+  runMigrationUnsafeQuiet,
+  getFieldName,
+  getTableName,
+  withRawQuery,
+  rawQueryRes,
+  rawQuery,
+  rawExecute,
+  rawExecuteCount,
+  rawSql,
+  transactionSave,
+  transactionSaveWithIsolation,
+  transactionUndo,
+  transactionUndoWithIsolation,
+ )
diff --git a/test/Example.hs b/test/Example.hs
--- a/test/Example.hs
+++ b/test/Example.hs
@@ -131,10 +131,10 @@
 getName :: Entity Person -> String
 getName = personName . entityVal
 
-getPeople :: MonadSqlQuery m => m [Person]
+getPeople :: (MonadSqlQuery m) => m [Person]
 getPeople = map entityVal <$> selectList [] [Asc PersonId]
 
-getPeopleNames :: MonadSqlQuery m => m [String]
+getPeopleNames :: (MonadSqlQuery m) => m [String]
 getPeopleNames = map personName <$> getPeople
 
 nameAndAge :: Person -> (String, Int)
@@ -145,8 +145,8 @@
 post :: String -> Key Person -> Post
 post title author = Post title author Nothing
 
-getPosts :: MonadSqlQuery m => m [Post]
+getPosts :: (MonadSqlQuery m) => m [Post]
 getPosts = map entityVal <$> selectList [] []
 
-getPostTitles :: MonadSqlQuery m => m [String]
+getPostTitles :: (MonadSqlQuery m) => m [String]
 getPostTitles = map postTitle <$> getPosts
diff --git a/test/Generated.hs b/test/Generated.hs
--- a/test/Generated.hs
+++ b/test/Generated.hs
@@ -20,70 +20,70 @@
 
 allSqlQueryRepShowRepresentations :: [String]
 allSqlQueryRepShowRepresentations =
-  [ show (Get undefined :: SqlQueryRep Person (Maybe Person))
-  , show (GetMany undefined :: SqlQueryRep Person (Map (Key Person) Person))
-  , show (GetJust undefined :: SqlQueryRep Person Person)
-  , show (GetJustEntity undefined :: SqlQueryRep Person (Entity Person))
-  , show (GetEntity undefined :: SqlQueryRep Person (Maybe (Entity Person)))
+  [ show (Get undefined :: SqlQueryRep (Person) (Maybe Person))
+  , show (GetMany undefined :: SqlQueryRep (Person) (Map (Key Person) Person))
+  , show (GetJust undefined :: SqlQueryRep (Person) Person)
+  , show (GetJustEntity undefined :: SqlQueryRep (Person) (Entity Person))
+  , show (GetEntity undefined :: SqlQueryRep (Person) (Maybe (Entity Person)))
   , show (BelongsTo undefined undefined :: SqlQueryRep (Person, Post) (Maybe Post))
   , show (BelongsToJust undefined undefined :: SqlQueryRep (Person, Post) Post)
-  , show (Insert undefined :: SqlQueryRep Person (Key Person))
-  , show (Insert_ undefined :: SqlQueryRep Person ())
-  , show (InsertMany undefined :: SqlQueryRep Person [Key Person])
-  , show (InsertMany_ undefined :: SqlQueryRep Person ())
-  , show (InsertEntityMany undefined :: SqlQueryRep Person ())
-  , show (InsertKey undefined undefined :: SqlQueryRep Person ())
-  , show (Repsert undefined undefined :: SqlQueryRep Person ())
-  , show (RepsertMany undefined :: SqlQueryRep Person ())
-  , show (Replace undefined undefined :: SqlQueryRep Person ())
-  , show (Delete undefined :: SqlQueryRep Person ())
-  , show (Update undefined undefined :: SqlQueryRep Person ())
-  , show (UpdateGet undefined undefined :: SqlQueryRep Person Person)
-  , show (InsertEntity undefined :: SqlQueryRep Person (Entity Person))
-  , show (InsertRecord undefined :: SqlQueryRep Person Person)
-  , show (GetBy undefined :: SqlQueryRep Person (Maybe (Entity Person)))
-  , show (GetByValue undefined :: SqlQueryRep Person (Maybe (Entity Person)))
-  , show (CheckUnique undefined :: SqlQueryRep Person (Maybe (Unique Person)))
-  , show (CheckUniqueUpdateable undefined :: SqlQueryRep Person (Maybe (Unique Person)))
-  , show (DeleteBy undefined :: SqlQueryRep Person ())
-  , show (InsertUnique undefined :: SqlQueryRep Person (Maybe (Key Person)))
-  , show (Upsert undefined undefined :: SqlQueryRep Person (Entity Person))
-  , show (UpsertBy undefined undefined undefined :: SqlQueryRep Person (Entity Person))
-  , show (PutMany undefined :: SqlQueryRep Person ())
-  , show (InsertBy undefined :: SqlQueryRep Person (Either (Entity Person) (Key Person)))
-  , show (InsertUniqueEntity undefined :: SqlQueryRep Person (Maybe (Entity Person)))
-  , show (ReplaceUnique undefined undefined :: SqlQueryRep Person (Maybe (Unique Person)))
-  , show (OnlyUnique undefined :: SqlQueryRep Person (Unique Person))
-  , show (SelectSourceRes undefined undefined :: SqlQueryRep Person (Acquire (ConduitM () (Entity Person) IO ())))
-  , show (SelectFirst undefined undefined :: SqlQueryRep Person (Maybe (Entity Person)))
-  , show (SelectKeysRes undefined undefined :: SqlQueryRep Person (Acquire (ConduitM () (Key Person) IO ())))
-  , show (Count undefined :: SqlQueryRep Person Int)
-  , show (Exists undefined :: SqlQueryRep Person Bool)
-  , show (SelectList undefined undefined :: SqlQueryRep Person [Entity Person])
-  , show (SelectKeysList undefined undefined :: SqlQueryRep Person [Key Person])
-  , show (UpdateWhere undefined undefined :: SqlQueryRep Person ())
-  , show (DeleteWhere undefined :: SqlQueryRep Person ())
-  , show (DeleteWhereCount undefined :: SqlQueryRep Person Int64)
-  , show (UpdateWhereCount undefined undefined :: SqlQueryRep Person Int64)
-  , show (ParseMigration undefined :: SqlQueryRep Void (Either [Text] CautiousMigration))
-  , show (ParseMigration' undefined :: SqlQueryRep Void CautiousMigration)
-  , show (PrintMigration undefined :: SqlQueryRep Void ())
-  , show (ShowMigration undefined :: SqlQueryRep Void [Text])
-  , show (GetMigration undefined :: SqlQueryRep Void [Sql])
-  , show (RunMigration undefined :: SqlQueryRep Void ())
-  , show (RunMigrationQuiet undefined :: SqlQueryRep Void [Text])
-  , show (RunMigrationSilent undefined :: SqlQueryRep Void [Text])
-  , show (RunMigrationUnsafe undefined :: SqlQueryRep Void ())
-  , show (RunMigrationUnsafeQuiet undefined :: SqlQueryRep Void [Text])
-  , show (GetFieldName undefined :: SqlQueryRep Person Text)
-  , show (GetTableName undefined :: SqlQueryRep Person Text)
-  , show (WithRawQuery undefined undefined undefined :: SqlQueryRep Void a)
-  , show (RawQueryRes undefined undefined :: SqlQueryRep Void (Acquire (ConduitM () [PersistValue] IO ())))
-  , show (RawExecute undefined undefined :: SqlQueryRep Void ())
-  , show (RawExecuteCount undefined undefined :: SqlQueryRep Void Int64)
-  , show (RawSql undefined undefined :: SqlQueryRep Void [Entity Person])
-  , show (TransactionSave :: SqlQueryRep Void ())
-  , show (TransactionSaveWithIsolation undefined :: SqlQueryRep Void ())
-  , show (TransactionUndo :: SqlQueryRep Void ())
-  , show (TransactionUndoWithIsolation undefined :: SqlQueryRep Void ())
+  , show (Insert undefined :: SqlQueryRep (Person) (Key Person))
+  , show (Insert_ undefined :: SqlQueryRep (Person) ())
+  , show (InsertMany undefined :: SqlQueryRep (Person) [Key Person])
+  , show (InsertMany_ undefined :: SqlQueryRep (Person) ())
+  , show (InsertEntityMany undefined :: SqlQueryRep (Person) ())
+  , show (InsertKey undefined undefined :: SqlQueryRep (Person) ())
+  , show (Repsert undefined undefined :: SqlQueryRep (Person) ())
+  , show (RepsertMany undefined :: SqlQueryRep (Person) ())
+  , show (Replace undefined undefined :: SqlQueryRep (Person) ())
+  , show (Delete undefined :: SqlQueryRep (Person) ())
+  , show (Update undefined undefined :: SqlQueryRep (Person) ())
+  , show (UpdateGet undefined undefined :: SqlQueryRep (Person) Person)
+  , show (InsertEntity undefined :: SqlQueryRep (Person) (Entity Person))
+  , show (InsertRecord undefined :: SqlQueryRep (Person) Person)
+  , show (GetBy undefined :: SqlQueryRep (Person) (Maybe (Entity Person)))
+  , show (GetByValue undefined :: SqlQueryRep (Person) (Maybe (Entity Person)))
+  , show (CheckUnique undefined :: SqlQueryRep (Person) (Maybe (Unique Person)))
+  , show (CheckUniqueUpdateable undefined :: SqlQueryRep (Person) (Maybe (Unique Person)))
+  , show (DeleteBy undefined :: SqlQueryRep (Person) ())
+  , show (InsertUnique undefined :: SqlQueryRep (Person) (Maybe (Key Person)))
+  , show (Upsert undefined undefined :: SqlQueryRep (Person) (Entity Person))
+  , show (UpsertBy undefined undefined undefined :: SqlQueryRep (Person) (Entity Person))
+  , show (PutMany undefined :: SqlQueryRep (Person) ())
+  , show (InsertBy undefined :: SqlQueryRep (Person) (Either (Entity Person) (Key Person)))
+  , show (InsertUniqueEntity undefined :: SqlQueryRep (Person) (Maybe (Entity Person)))
+  , show (ReplaceUnique undefined undefined :: SqlQueryRep (Person) (Maybe (Unique Person)))
+  , show (OnlyUnique undefined :: SqlQueryRep (Person) (Unique Person))
+  , show (SelectSourceRes undefined undefined :: SqlQueryRep (Person) (Acquire (ConduitM () (Entity Person) IO ())))
+  , show (SelectFirst undefined undefined :: SqlQueryRep (Person) (Maybe (Entity Person)))
+  , show (SelectKeysRes undefined undefined :: SqlQueryRep (Person) (Acquire (ConduitM () (Key Person) IO ())))
+  , show (Count undefined :: SqlQueryRep (Person) Int)
+  , show (Exists undefined :: SqlQueryRep (Person) Bool)
+  , show (SelectList undefined undefined :: SqlQueryRep (Person) [Entity Person])
+  , show (SelectKeysList undefined undefined :: SqlQueryRep (Person) [Key Person])
+  , show (UpdateWhere undefined undefined :: SqlQueryRep (Person) ())
+  , show (DeleteWhere undefined :: SqlQueryRep (Person) ())
+  , show (DeleteWhereCount undefined :: SqlQueryRep (Person) Int64)
+  , show (UpdateWhereCount undefined undefined :: SqlQueryRep (Person) Int64)
+  , show (ParseMigration undefined :: SqlQueryRep (Void) (Either [Text] CautiousMigration))
+  , show (ParseMigration' undefined :: SqlQueryRep (Void) CautiousMigration)
+  , show (PrintMigration undefined :: SqlQueryRep (Void) ())
+  , show (ShowMigration undefined :: SqlQueryRep (Void) [Text])
+  , show (GetMigration undefined :: SqlQueryRep (Void) [Sql])
+  , show (RunMigration undefined :: SqlQueryRep (Void) ())
+  , show (RunMigrationQuiet undefined :: SqlQueryRep (Void) [Text])
+  , show (RunMigrationSilent undefined :: SqlQueryRep (Void) [Text])
+  , show (RunMigrationUnsafe undefined :: SqlQueryRep (Void) ())
+  , show (RunMigrationUnsafeQuiet undefined :: SqlQueryRep (Void) [Text])
+  , show (GetFieldName undefined :: SqlQueryRep (Person) Text)
+  , show (GetTableName undefined :: SqlQueryRep (Person) Text)
+  , show (WithRawQuery undefined undefined undefined :: SqlQueryRep (Void) a)
+  , show (RawQueryRes undefined undefined :: SqlQueryRep (Void) (Acquire (ConduitM () [PersistValue] IO ())))
+  , show (RawExecute undefined undefined :: SqlQueryRep (Void) ())
+  , show (RawExecuteCount undefined undefined :: SqlQueryRep (Void) Int64)
+  , show (RawSql undefined undefined :: SqlQueryRep (Void) [Entity Person])
+  , show (TransactionSave :: SqlQueryRep (Void) ())
+  , show (TransactionSaveWithIsolation undefined :: SqlQueryRep (Void) ())
+  , show (TransactionUndo :: SqlQueryRep (Void) ())
+  , show (TransactionUndoWithIsolation undefined :: SqlQueryRep (Void) ())
   ]
diff --git a/test/IntegrationTest.hs b/test/IntegrationTest.hs
--- a/test/IntegrationTest.hs
+++ b/test/IntegrationTest.hs
@@ -1,4 +1,5 @@
 {- AUTOCOLLECT.TEST -}
+{-# LANGUAGE LambdaCase #-}
 {-# LANGUAGE NamedFieldPuns #-}
 {-# LANGUAGE OverloadedStrings #-}
 {-# LANGUAGE ScopedTypeVariables #-}
@@ -167,7 +168,7 @@
 -- this should compile
 testComposability :: BackendType -> TestTree
 testComposability backendType = testCase "Operations can be composed" $ do
-  let onlySql :: MonadSqlQuery m => m ()
+  let onlySql :: (MonadSqlQuery m) => m ()
       onlySql = do
         _ <- getPeople
         return ()
@@ -178,12 +179,12 @@
         _ <- rerunnableIO $ newIORef True
         return ()
 
-      onlyRerunnableIO :: MonadRerunnableIO m => m ()
+      onlyRerunnableIO :: (MonadRerunnableIO m) => m ()
       onlyRerunnableIO = do
         _ <- rerunnableIO $ newIORef True
         return ()
 
-      arbitraryIO :: MonadIO m => m ()
+      arbitraryIO :: (MonadIO m) => m ()
       arbitraryIO = do
         _ <- liftIO $ newIORef True
         return ()
@@ -698,7 +699,7 @@
         result <- runTestApp backendType $ do
           insertMany_ [person "Alice", person "Bob"]
           withRawQuery "SELECT name FROM person" [] $
-            Conduit.mapC (fromPersistValue' @Text . head) .| Conduit.sinkList
+            Conduit.mapC (getFirstPersistValue @Text) .| Conduit.sinkList
 
         result @?= ["Alice", "Bob"]
     , testCase "rawQueryRes" $ do
@@ -706,12 +707,12 @@
           insertMany_ [person "Alice", person "Bob"]
           acquire <- rawQueryRes "SELECT name FROM person" []
           Acquire.with acquire $ \conduit ->
-            runConduit $ conduit .| Conduit.mapC (fromPersistValue' @Text . head) .| Conduit.sinkList
+            runConduit $ conduit .| Conduit.mapC (getFirstPersistValue @Text) .| Conduit.sinkList
         result @?= ["Alice", "Bob"]
     , testCase "rawQuery" $ do
         result <- runTestApp backendType $ do
           insertMany_ [person "Alice", person "Bob"]
-          runConduit $ rawQuery "SELECT name FROM person" [] .| Conduit.mapC (fromPersistValue' @Text . head) .| Conduit.sinkList
+          runConduit $ rawQuery "SELECT name FROM person" [] .| Conduit.mapC (getFirstPersistValue @Text) .| Conduit.sinkList
         result @?= ["Alice", "Bob"]
     , testCase "rawExecute" $ do
         result <- runTestApp backendType $ do
@@ -792,21 +793,26 @@
 
 {- Persistent helpers -}
 
-fromPersistValue' :: PersistField a => PersistValue -> a
-fromPersistValue' = either (error . Text.unpack) id . fromPersistValue
+getFirstPersistValue :: (PersistField a) => [PersistValue] -> a
+getFirstPersistValue = \case
+  [] -> error "Unexpectedly got no values"
+  v : _ -> fromPersistValueOrFail v
 
+fromPersistValueOrFail :: (PersistField a) => PersistValue -> a
+fromPersistValueOrFail = either (error . Text.unpack) id . fromPersistValue
+
 {- Meta SQL helpers -}
 
 -- | Put the database in a state where running a migration is safe.
-setupSafeMigration :: MonadSqlQuery m => m ()
+setupSafeMigration :: (MonadSqlQuery m) => m ()
 setupSafeMigration = rawExecute "ALTER TABLE person ADD COLUMN removed_column VARCHAR" []
 
 -- | Put the database in a state where running a migration is unsafe.
-setupUnsafeMigration :: MonadSqlQuery m => m ()
+setupUnsafeMigration :: (MonadSqlQuery m) => m ()
 setupUnsafeMigration = rawExecute "ALTER TABLE person ADD COLUMN foo VARCHAR" []
 
 -- | Get the names of all columns in the given table.
-getSchemaColumnNames :: MonadSqlQuery m => BackendType -> String -> m [String]
+getSchemaColumnNames :: (MonadSqlQuery m) => BackendType -> String -> m [String]
 getSchemaColumnNames backendType tableName = map unSingle <$> rawSql sql []
   where
     sql = Text.pack $ case backendType of
@@ -836,8 +842,8 @@
   , Typeable record
   , SafeToInsert record
   ) =>
-  record ->
-  m ()
+  record
+  -> m ()
 insertAndFail record = do
   insert_ record
   rerunnableIO $ throwIO TestError
diff --git a/test/MockedTest.hs b/test/MockedTest.hs
--- a/test/MockedTest.hs
+++ b/test/MockedTest.hs
@@ -12,6 +12,7 @@
 import qualified Conduit
 import qualified Data.Acquire as Acquire
 import qualified Data.Map.Strict as Map
+import Data.Maybe (listToMaybe)
 import Database.Persist.Sql (
   Entity (..),
   Single (..),
@@ -48,8 +49,8 @@
         case result of
           Right _ -> assertFailure "runMockSqlQueryT did not fail"
           Left e -> do
-            let msg = head $ lines $ show (e :: SomeException)
-            msg @?= "Could not find mock for query: SelectList{..}<Person>"
+            let msg = listToMaybe $ lines $ show (e :: SomeException)
+            msg @?= Just "Could not find mock for query: SelectList{..}<Person>"
     , testCase "it continues after a mock doesn't match" $ do
         result <-
           runMockSqlQueryT
diff --git a/test/READMETest.hs b/test/READMETest.hs
--- a/test/READMETest.hs
+++ b/test/READMETest.hs
@@ -15,11 +15,11 @@
 
 test =
   testCase "withTransaction example works" $ do
-    let foo :: MonadSqlQuery m => m ()
+    let foo :: (MonadSqlQuery m) => m ()
         foo = insert_ $ person "Alice"
-        bar :: MonadSqlQuery m => m ()
+        bar :: (MonadSqlQuery m) => m ()
         bar = insert_ $ person "Bob"
-        fooAndBar :: MonadSqlQuery m => m ()
+        fooAndBar :: (MonadSqlQuery m) => m ()
         fooAndBar = withTransaction $ foo >> bar
     runMockSqlQueryT
       fooAndBar
