better names for higher order parameterized path helpers
This commit is contained in:
parent
a983e6e028
commit
ef40adbe3b
2 changed files with 11 additions and 11 deletions
|
|
@ -127,22 +127,22 @@
|
||||||
(defmacro defparamspath [name & body]
|
(defmacro defparamspath [name & body]
|
||||||
`(def ~name (paramspath ~@body)))
|
`(def ~name (paramspath ~@body)))
|
||||||
|
|
||||||
(defmacro params-paramspath [bindings & impls]
|
(defmacro fixed-pathed-path [bindings & impls]
|
||||||
(let [bindings (partition 2 bindings)
|
(let [bindings (partition 2 bindings)
|
||||||
paths (mapv second bindings)
|
paths (mapv second bindings)
|
||||||
names (mapv first bindings)
|
names (mapv first bindings)
|
||||||
latefns-sym (gensym "latefns")
|
latefns-sym (gensym "latefns")
|
||||||
latefn-syms (vec (i/gensyms (count paths)))]
|
latefn-syms (vec (i/gensyms (count paths)))]
|
||||||
(i/params-paramspath*
|
(i/pathed-path*
|
||||||
paths
|
paths
|
||||||
latefns-sym
|
latefns-sym
|
||||||
[latefn-syms latefns-sym]
|
[latefn-syms latefns-sym]
|
||||||
(mapcat (fn [n l] [n `(~l ~i/PARAMS-SYM ~i/PARAMS-IDX-SYM)]) names latefn-syms)
|
(mapcat (fn [n l] [n `(~l ~i/PARAMS-SYM ~i/PARAMS-IDX-SYM)]) names latefn-syms)
|
||||||
impls)))
|
impls)))
|
||||||
|
|
||||||
(defmacro params-varparamspath [[latepaths-seq-sym paths-seq] & impls]
|
(defmacro variable-pathed-path [[latepaths-seq-sym paths-seq] & impls]
|
||||||
(let [latefns-sym (gensym "latefns")]
|
(let [latefns-sym (gensym "latefns")]
|
||||||
(i/params-paramspath*
|
(i/pathed-path*
|
||||||
paths-seq
|
paths-seq
|
||||||
latefns-sym
|
latefns-sym
|
||||||
[]
|
[]
|
||||||
|
|
@ -176,7 +176,7 @@
|
||||||
(defn codewalker [afn] (i/->CodeWalkerStructurePath afn))
|
(defn codewalker [afn] (i/->CodeWalkerStructurePath afn))
|
||||||
|
|
||||||
(defn filterer [& path]
|
(defn filterer [& path]
|
||||||
(params-paramspath [late path]
|
(fixed-pathed-path [late path]
|
||||||
(select* [this structure next-fn]
|
(select* [this structure next-fn]
|
||||||
(->> structure (filter #(i/selected?* late %)) doall next-fn))
|
(->> structure (filter #(i/selected?* late %)) doall next-fn))
|
||||||
(transform* [this structure next-fn]
|
(transform* [this structure next-fn]
|
||||||
|
|
@ -205,7 +205,7 @@
|
||||||
e.g. (selected? :vals ALL even?) keeps the current element only if an
|
e.g. (selected? :vals ALL even?) keeps the current element only if an
|
||||||
even number exists for the :vals key"
|
even number exists for the :vals key"
|
||||||
[& path]
|
[& path]
|
||||||
(params-paramspath [late path]
|
(fixed-pathed-path [late path]
|
||||||
(select* [this structure next-fn]
|
(select* [this structure next-fn]
|
||||||
(i/filter-select
|
(i/filter-select
|
||||||
#(i/selected?* late %)
|
#(i/selected?* late %)
|
||||||
|
|
@ -218,7 +218,7 @@
|
||||||
next-fn))))
|
next-fn))))
|
||||||
|
|
||||||
(defn not-selected? [& path]
|
(defn not-selected? [& path]
|
||||||
(params-paramspath [late path]
|
(fixed-pathed-path [late path]
|
||||||
(select* [this structure next-fn]
|
(select* [this structure next-fn]
|
||||||
(i/filter-select
|
(i/filter-select
|
||||||
#(i/not-selected?* late %)
|
#(i/not-selected?* late %)
|
||||||
|
|
@ -234,7 +234,7 @@
|
||||||
"Navigates to a view of the current value by transforming it with the
|
"Navigates to a view of the current value by transforming it with the
|
||||||
specified selector and update-fn."
|
specified selector and update-fn."
|
||||||
[path update-fn]
|
[path update-fn]
|
||||||
(params-paramspath [late path]
|
(fixed-pathed-path [late path]
|
||||||
(select* [this structure next-fn]
|
(select* [this structure next-fn]
|
||||||
(next-fn (compiled-transform late update-fn structure)))
|
(next-fn (compiled-transform late update-fn structure)))
|
||||||
(transform* [this structure next-fn]
|
(transform* [this structure next-fn]
|
||||||
|
|
@ -287,7 +287,7 @@
|
||||||
Otherwise, it tries the next cond-path. If nothing matches, then the structure
|
Otherwise, it tries the next cond-path. If nothing matches, then the structure
|
||||||
is not selected."
|
is not selected."
|
||||||
[& conds]
|
[& conds]
|
||||||
(params-varparamspath [compiled-paths conds]
|
(variable-pathed-path [compiled-paths conds]
|
||||||
(select* [this structure next-fn]
|
(select* [this structure next-fn]
|
||||||
(if-let [selector (i/retrieve-cond-selector compiled-paths structure)]
|
(if-let [selector (i/retrieve-cond-selector compiled-paths structure)]
|
||||||
(->> (compiled-select selector structure)
|
(->> (compiled-select selector structure)
|
||||||
|
|
@ -309,7 +309,7 @@
|
||||||
"A path that branches on multiple paths. For updates,
|
"A path that branches on multiple paths. For updates,
|
||||||
applies updates to the paths in order."
|
applies updates to the paths in order."
|
||||||
[& paths]
|
[& paths]
|
||||||
(params-varparamspath [compiled-paths paths]
|
(variable-pathed-path [compiled-paths paths]
|
||||||
(select* [this structure next-fn]
|
(select* [this structure next-fn]
|
||||||
(->> compiled-paths
|
(->> compiled-paths
|
||||||
(mapcat #(compiled-select % structure))
|
(mapcat #(compiled-select % structure))
|
||||||
|
|
|
||||||
|
|
@ -363,7 +363,7 @@
|
||||||
0
|
0
|
||||||
(:num-needed-params path)))
|
(:num-needed-params path)))
|
||||||
|
|
||||||
(defn params-paramspath* [paths-seq latefns-sym pre-bindings post-bindings impls]
|
(defn pathed-path* [paths-seq latefns-sym pre-bindings post-bindings impls]
|
||||||
(let [num-params-sym (gensym "num-params")]
|
(let [num-params-sym (gensym "num-params")]
|
||||||
`(let [paths# (map comp-paths* ~paths-seq)
|
`(let [paths# (map comp-paths* ~paths-seq)
|
||||||
needed-params# (map num-needed-params paths#)
|
needed-params# (map num-needed-params paths#)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue