From 423da1e03fda821d9d3419267d16ce38f834087d Mon Sep 17 00:00:00 2001 From: Nathan Marz Date: Thu, 4 Aug 2016 15:03:00 -0400 Subject: [PATCH] more fixes --- src/clj/com/rpl/specter.cljx | 8 ++++---- src/clj/com/rpl/specter/impl.cljx | 32 +++++++++++++++++++++++++++++- src/clj/com/rpl/specter/macros.clj | 4 ++-- src/clj/com/rpl/specter/navs.cljx | 29 --------------------------- 4 files changed, 37 insertions(+), 36 deletions(-) diff --git a/src/clj/com/rpl/specter.cljx b/src/clj/com/rpl/specter.cljx index a7f3db2..8bd36e5 100644 --- a/src/clj/com/rpl/specter.cljx +++ b/src/clj/com/rpl/specter.cljx @@ -465,12 +465,12 @@ afn (fixed-pathed-nav [late path] (select* [this structure next-fn] - (n/filter-select + (i/filter-select #(n/selected?* late %) structure next-fn)) (transform* [this structure next-fn] - (n/filter-transform + (i/filter-transform #(n/selected?* late %) structure next-fn))))) @@ -480,12 +480,12 @@ (fn [s] (not (afn s))) (fixed-pathed-nav [late path] (select* [this structure next-fn] - (n/filter-select + (i/filter-select #(n/not-selected?* late %) structure next-fn)) (transform* [this structure next-fn] - (n/filter-transform + (i/filter-transform #(n/not-selected?* late %) structure next-fn))))) diff --git a/src/clj/com/rpl/specter/impl.cljx b/src/clj/com/rpl/specter/impl.cljx index 516f653..2be4812 100644 --- a/src/clj/com/rpl/specter/impl.cljx +++ b/src/clj/com/rpl/specter/impl.cljx @@ -416,7 +416,9 @@ ) needs-params-paths (filter #(instance? ParamsNeededPath %) coerced)] (if (empty? needs-params-paths) - (no-params-rich-compiled-path result-nav) + (if (satisfies? Navigator result-nav) + (lean-compiled-path result-nav) + (no-params-rich-compiled-path result-nav)) (->ParamsNeededPath (coerce-rich-navigator result-nav) (->> needs-params-paths @@ -700,6 +702,16 @@ (bind-params* precompiled params 0) )) +(defn filter-select [afn structure next-fn] + (if (afn structure) + (next-fn structure) + NONE)) + +(defn filter-transform [afn structure next-fn] + (if (afn structure) + (next-fn structure) + structure)) + (def pred* (->ParamsNeededPath (reify RichNavigator @@ -718,6 +730,24 @@ 1 )) +(def collected?* + (->ParamsNeededPath + (reify RichNavigator + (rich-select* [this params params-idx vals structure next-fn] + (let [afn (aget ^objects params params-idx)] + (if (afn vals) + (next-fn params (inc params-idx) vals structure) + NONE + ))) + (rich-transform* [this params params-idx vals structure next-fn] + (let [afn (aget ^objects params params-idx)] + (if (afn vals) + (next-fn params (inc params-idx) vals structure) + structure + )))) + 1 + )) + (def rich-compiled-path-proxy (->ParamsNeededPath (reify RichNavigator diff --git a/src/clj/com/rpl/specter/macros.clj b/src/clj/com/rpl/specter/macros.clj index fe8b724..12bf1c0 100644 --- a/src/clj/com/rpl/specter/macros.clj +++ b/src/clj/com/rpl/specter/macros.clj @@ -137,9 +137,9 @@ [num-params impl1 impl2] (let [[[s-params & s-body] [t-params & t-body]] (determine-params-impls impl1 impl2) s-next-fn-sym (last s-params) - s-pidx-sym (second s-params) + s-pidx-sym (nth s-params 2) t-next-fn-sym (last t-params) - t-pidx-sym (second t-params) + t-pidx-sym (nth t-params 2) ] `(let [num-params# ~num-params nav# (reify RichNavigator diff --git a/src/clj/com/rpl/specter/navs.cljx b/src/clj/com/rpl/specter/navs.cljx index 30a7a00..db36f2d 100644 --- a/src/clj/com/rpl/specter/navs.cljx +++ b/src/clj/com/rpl/specter/navs.cljx @@ -307,16 +307,6 @@ (apply afn (conj vals structure))) )) -(defn filter-select [afn structure next-fn] - (if (afn structure) - (next-fn structure) - i/NONE)) - -(defn filter-transform [afn structure next-fn] - (if (afn structure) - (next-fn structure) - structure)) - (defprotocol AddExtremes (append-all [structure elements]) @@ -457,25 +447,6 @@ ret )))) - -(def collected?* - (i/->ParamsNeededPath - (reify i/RichNavigator - (rich-select* [this params params-idx vals structure next-fn] - (let [afn (aget ^objects params params-idx)] - (if (afn vals) - (next-fn params (inc params-idx) vals structure) - i/NONE - ))) - (rich-transform* [this params params-idx vals structure next-fn] - (let [afn (aget ^objects params params-idx)] - (if (afn vals) - (next-fn params (inc params-idx) vals structure) - structure - )))) - 1 - )) - (def DISPENSE* (i/no-params-rich-compiled-path (reify i/RichNavigator