   "Supplies a sub-tree of `db` to the handler. A narrowed view.
   Assumes \"pure\" is in the middleware pipeline prior.
   Grafts the result back into db.
-  If a get-in of the path results in a nil, then \"default-fn\" will be called to supply a value."
+  If a get-in of the path results in a nil, then \"default-fn\" will be called to supply a value.
+  XXX very like update-in. Should the name be more indicative of that closeness? "
   ([p]
     (path p hash-map))
   ([p default-fn]

      (logger v)
      (handler db v))))


;; warning: untested
;; check the state of db AFTER the handler has run, using a prismatic Schema.
#_(defn check-schema
"Middleware for checking that a handlers mutations leave the state in a schema-matching way"
[a-prismatic-schema]
(fn middleware
  [next-handler]
  (fn handler
    [db v]
    (let [val    (next-handler db v)
          valid? true]   ;; XXXXX  replace true by code which checks the schema using original parameter
      (if (not valid?)
        (warn "re-frame: schema not valid after:" v))
      val))))


(defn trim-v
  "Middleware which removes the first element of v which allows you to write
  more asthetically pleasing handlers. No leading underscore on the event-v!
  Your handlers will look like this:
      (defn my-handler
        [db [x y z]]    ;; <-- instead of [_ x y z]
