       [(slurp stmt-res) tx-state])))
 
 (defn with-db-transaction
+  "Exectue `tx-op` within a database transaction."
+  {:added "0.2.0"}
   [db tx-op]
   {:pre [(database? db)]}
   (io!

     {:post [(sequential? ~'%) (transaction-state? (second ~'%))]}
     (let [tx-state# ~tx-state-bnd]
       (try
         (if (rollback-only? tx-state#)
           [nil tx-state#]
           (io! ~@body))
         (catch Exception ex#
           (*exception-during-transaction* tx-state# ex#))))))

(defmacro transactional
  [form]
  `(transactional-operation [tx-state#] [~form tx-state#]))

(defn transactional-bind
  [tx-op tx-op-factory]
  (transactional-operation
   [tx-state]
   (let [[res next-tx-state] (tx-op tx-state)
         next-tx-op (tx-op-factory res)]
     (next-tx-op next-tx-state))))

(defn- emit-tx-op-factory
  [bnd tx-op]
  `(fn [~bnd] ~tx-op))

(defmacro transactional-let
  [bindings & body]
  {:pre [(not-empty bindings) (even? (count bindings)) (not-empty body)]}
  (let [emit-binding-op-factoy (fn [[tx-op op-factory] [bnd-sym prev-tx-op]]
                                 (let [prev-op-factory (emit-tx-op-factory bnd-sym
                                                                           `(transactional-bind ~tx-op ~op-factory))]
                                   [prev-tx-op prev-op-factory]))
        reversed-bindings (->> bindings
                               (partition 2)
                               (reverse))
        [innermost-bnd-sym innermost-tx-op] (first reversed-bindings)

     [t-con (db-spec db)]
     (let [tx-state (map->TransactionState {:t-con t-con :db db})
           [tx-result final-tx-state] (tx-op tx-state)]
       (if (#'rollback-only? final-tx-state)
         [tx-result err-transaction-rolled-back]
         [tx-result nil])))))