         ;; to invoke and/or parameterize the precompiled path without
         ;; a bunch of checks beforehand
         cache-sym (vary-meta
-                    (gensym "pathcache")
-                      assoc :cljs.analyzer/no-resolve true)
+                   (gensym "pathcache")
+                   assoc :cljs.analyzer/no-resolve true)
 
         info-sym (gensym "info")
 
         get-cache-code (if (= platform :clj)
                          `(try (i/get-cell ~cache-sym)
-                            (catch ClassCastException e#
-                              (if (bound? (var ~cache-sym))
-                                (throw e#)
-                                (do
-                                  (alter-var-root
-                                    (var ~cache-sym)
-                                    (fn [_#] (i/mutable-cell)))
-                                  nil
-                                  ))))
+                               (catch ClassCastException e#
+                                 (if (bound? (var ~cache-sym))
+                                   (throw e#)
+                                   (do
+                                     (alter-var-root
+                                      (var ~cache-sym)
+                                      (fn [_#] (i/mutable-cell)))
+                                     nil
+                                     ))))
                          cache-sym
                          )
         add-cache-code (if (= platform :clj)


(defmacro declarepath
  ([name]
    `(declarepath ~name []))
  ([name params]
    (let [platform (if (contains? &env :locals) :cljs :clj)
          select-exec (if (= platform :clj)
                        `i/exec-rich-select*
                        `i/rich-select*)
          transform-exec (if (= platform :clj)
                           `i/exec-rich-transform*
                           `i/rich-transform*)
          num-params (count params)
          declared (declared-name name)
          rargs [(gensym "params") (gensym "pidx") (gensym "vals")
                 (gensym "structure") (gensym "next-fn")]]
      `(do
         (declare ~declared)
         (def ~name
           (let [nav# (reify RichNavigator
                        (~'rich-select* [this# ~@rargs]
                          (~select-exec ~declared ~@rargs))
                        (~'rich-transform* [this# ~@rargs]
                          (~transform-exec ~declared ~@rargs)
                          ))]
             (if (= ~num-params 0)
               (i/no-params-rich-compiled-path nav#)
               (i/->ParamsNeededPath nav# ~num-params)
               )))))))

(defmacro providepath [name apath]
  `(let [comped# (i/comp-paths-internalized ~apath)

           ~handle-params-code
           )
         ))
    ))

(defmacro select
  "Navigates to and returns a sequence of all the elements specified by the path.
  This macro will attempt to do inline factoring and caching of the path, falling
  back to compiling the path on every invocation if it's not possible to
  factor/cache the path."
  [apath structure]
  `(i/compiled-select* (path ~apath) ~structure))

(defmacro select-one!
  "Returns exactly one element, throws exception if zero or multiple elements found.
  This macro will attempt to do inline factoring and caching of the path, falling
  back to compiling the path on every invocation if it's not possible to
  factor/cache the path."
  [apath structure]
  `(i/compiled-select-one!* (path ~apath) ~structure))

(defmacro select-one
  "Like select, but returns either one element or nil. Throws exception if multiple elements found.
  This macro will attempt to do inline factoring and caching of the path, falling
  back to compiling the path on every invocation if it's not possible to
  factor/cache the path."
  [apath structure]
  `(i/compiled-select-one* (path ~apath) ~structure))

(defmacro select-first
  "Returns first element found.
  This macro will attempt to do inline factoring and caching of the path, falling
  back to compiling the path on every invocation if it's not possible to
  factor/cache the path."
  [apath structure]
  `(i/compiled-select-first* (path ~apath) ~structure))

(defmacro select-any
  "Returns any element found or [[NONE]] if nothing selected. This is the most
  efficient of the various selection operations.
  This macro will attempt to do inline factoring and caching of the path, falling
  back to compiling the path on every invocation if it's not possible to
  factor/cache the path."
  [apath structure]
  `(i/compiled-select-any* (path ~apath) ~structure))

(defmacro selected-any?
  "Returns true if any element was selected, false otherwise.
  This macro will attempt to do inline factoring and caching of the path, falling
  back to compiling the path on every invocation if it's not possible to
  factor/cache the path."
  [apath structure]
  `(i/compiled-selected-any?* (path ~apath) ~structure))

(defmacro transform
  "Navigates to each value specified by the path and replaces it by the result of running
  the transform-fn on it.
  This macro will attempt to do inline factoring and caching of the path, falling
  back to compiling the path on every invocation if it's not possible to
  factor/cache the path."
  [apath transform-fn structure]
  `(i/compiled-transform* (path ~apath) ~transform-fn ~structure))

(defmacro multi-transform
  "Just like `transform` but expects transform functions to be specified
  inline in the path using `terminal`. Error is thrown if navigation finishes
  at a non-`terminal` navigator. `terminal-val` is a wrapper around `terminal` and is
  the `multi-transform` equivalent of `setval`.
  This macro will attempt to do inline factoring and caching of the path, falling
  back to compiling the path on every invocation if it's not possible to
  factor/cache the path."
  [apath structure]
  `(i/compiled-multi-transform* (path ~apath) ~structure))


(defmacro setval
  "Navigates to each value specified by the path and replaces it by `aval`.
  This macro will attempt to do inline factoring and caching of the path, falling
  back to compiling the path on every invocation if it's not possible to
  factor/cache the path."
  [apath aval structure]
  `(i/compiled-setval* (path ~apath) ~aval ~structure))

(defmacro traverse
  "Return a reducible object that traverses over `structure` to every element
  specified by the path.
  This macro will attempt to do inline factoring and caching of the path, falling
  back to compiling the path on every invocation if it's not possible to
  factor/cache the path."
  [apath structure]
  `(i/do-compiled-traverse (path ~apath) ~structure))

(defmacro replace-in
  "Similar to transform, except returns a pair of [transformed-structure sequence-of-user-ret].
  The transform-fn in this case is expected to return [ret user-ret]. ret is
  what's used to transform the data structure, while user-ret will be added to the user-ret sequence
  in the final return. replace-in is useful for situations where you need to know the specific values
  of what was transformed in the data structure.
  This macro will attempt to do inline factoring and caching of the path, falling
  back to compiling the path on every invocation if it's not possible to
  factor/cache the path."
  [apath transform-fn structure & args]
  `(i/compiled-replace-in* (path ~apath) ~transform-fn ~structure ~@args))

(defmacro collected?
  "Creates a filter function navigator that takes in all the collected values
  as input. For arguments, can use `(collected? [a b] ...)` syntax to look
  at each collected value as individual arguments, or `(collected? v ...)` syntax
  to capture all the collected values as a single vector."
  [params & body]
  (let [platform (if (contains? &env :locals) :cljs :clj)]
    `(i/collected?* (~'fn [~params] ~@body))
