com.rpl.specter.defhelpers
define-ParamsNeededPath
macro
(define-ParamsNeededPath clj? fn-type invoke-name var-arity-impl)diff --git a/com.rpl.specter.defhelpers.html b/com.rpl.specter.defhelpers.html deleted file mode 100644 index 5339846..0000000 --- a/com.rpl.specter.defhelpers.html +++ /dev/null @@ -1,3 +0,0 @@ - -
(define-ParamsNeededPath clj? fn-type invoke-name var-arity-impl)Navigate to every element of the collection. For maps navigates to -a vector of `[key value]`.
Takes a compiled path that needs late-bound params and supplies it with -an array of params and a position in the array from which to begin reading -params. The return value is an executable selector.
(collect & path)Adds the result of running select with the given path on the -current value to the collected vals.
(collect-one & path)Adds the result of running select-one with the given path on the -current value to the collected vals.
(comp-paths & apath)Returns a compiled version of the given path for use with +com.rpl.specter documentation Generated by Codox
Specter 0.13.0
\ No newline at end of file +were declared.com.rpl.specter
ALL
Navigate to every element of the collection. For maps navigates to +a vector of `[key value]`.collect
Adds the result of running select with the given path on the +current value to the collected vals.collect-one
Adds the result of running select-one with the given path on the +current value to the collected vals.collected?
macro
(collected? params & body)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.comp-paths
(comp-paths & apath)Returns a compiled version of the given path for use with compiled-{select/transform/setval/etc.} functions. This can compile navigators (defined with `defnav`) without their parameters, and the resulting compiled path will require parameters for all such navigators in the order in which -they were declared.compiled-multi-transform
Version of `multi-transform` that takes in a path precompiled with `comp-paths` -compiled-replace-in
Version of replace-in that takes in a path precompiled with comp-paths -compiled-select-any
Version of select-any that takes in a path precompiled with comp-paths -compiled-select-first
Version of select-first that takes in a path precompiled with comp-paths -compiled-select-one
Version of select-one that takes in a path precompiled with comp-paths -compiled-select-one!
Version of select-one! that takes in a path precompiled with comp-paths -compiled-selected-any?
Version of selected-any? that takes in a path precompiled with comp-paths -compiled-transform
Version of transform that takes in a path precompiled with comp-paths -cond-path
(cond-path & conds)Takes in alternating cond-path path cond-path path... +they were declared.compiled-multi-transform
Version of `multi-transform` that takes in a path precompiled with `comp-paths` +compiled-replace-in
Version of replace-in that takes in a path precompiled with comp-paths +compiled-select-any
Version of select-any that takes in a path precompiled with comp-paths +compiled-select-first
Version of select-first that takes in a path precompiled with comp-paths +compiled-select-one
Version of select-one that takes in a path precompiled with comp-paths +compiled-select-one!
Version of select-one! that takes in a path precompiled with comp-paths +compiled-selected-any?
Version of selected-any? that takes in a path precompiled with comp-paths +compiled-transform
Version of transform that takes in a path precompiled with comp-paths +cond-path
Takes in alternating cond-path path cond-path path... Tests the structure if selecting with cond-path returns anything. If so, it uses the following path for this portion of the navigation. Otherwise, it tries the next cond-path. If nothing matches, then the structure @@ -31,91 +32,122 @@ is not selected. The input paths may be parameterized, in which case the result of cond-path will be parameterized in the order of which the parameterized navigators -were declared.continue-then-stay
(continue-then-stay & path)Navigates to the provided path and then to the current element. This can be used -to implement post-order traversal.continuous-subseqs
Navigates to every continuous subsequence of elements matching `pred` -filterer
(filterer & path)Navigates to a view of the current sequence that only contains elements that +were declared.continue-then-stay
Navigates to the provided path and then to the current element. This can be used +to implement post-order traversal.continuous-subseqs
Navigates to every continuous subsequence of elements matching `pred` +defprotocolpath
macro
(defprotocolpath name)(defprotocolpath name params)Defines a navigator that chooses the path to take based on the type +of the value at the current point. May be specified with parameters to +specify that all extensions must require that number of parameters. + +Currently not available for ClojureScript. + +Example of usage: +(defrecord SingleAccount [funds]) +(defrecord FamilyAccount [single-accounts]) + +(defprotocolpath FundsPath) +(extend-protocolpath FundsPath + SingleAccount :funds + FamilyAccount [ALL FundsPath] + ) +extend-protocolpath
macro
(extend-protocolpath protpath & extensions)Used in conjunction with `defprotocolpath`. See [[defprotocolpath]]. +filterer
Navigates to a view of the current sequence that only contains elements that match the given path. An element matches the selector path if calling select on that element with the path yields anything other than an empty sequence. The input path may be parameterized, in which case the result of filterer will be parameterized in the order of which the parameterized selectors - were declared.FIRST
Navigate to the first element of the collection. If the collection is -empty navigation is stopped at this point.if-path
(if-path cond-p then-path)(if-path cond-p then-path else-path)Like cond-path, but with if semantics. -LAST
Navigate to the last element of the collection. If the collection is -empty navigation is stopped at this point.MAP-VALS
Navigate to each value of the map. This is more efficient than -navigating via [ALL LAST]META
Navigates to the metadata of the structure, or nil if -the structure has no metadata or may not contain metadata.multi-path
(multi-path)(multi-path path)(multi-path path1 path2)(multi-path path1 path2 & paths)A path that branches on multiple paths. For updates, -applies updates to the paths in order.multi-transform*
(multi-transform* path structure)Just like `transform` but expects transform functions to be specified + were declared.FIRST
Navigate to the first element of the collection. If the collection is +empty navigation is stopped at this point.LAST
Navigate to the last element of the collection. If the collection is +empty navigation is stopped at this point.MAP-VALS
Navigate to each value of the map. This is more efficient than +navigating via [ALL LAST]META
Navigates to the metadata of the structure, or nil if +the structure has no metadata or may not contain metadata.multi-path
A path that branches on multiple paths. For updates, +applies updates to the paths in order.multi-transform
macro
(multi-transform apath structure)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`.must-cache-paths!
Mandate that operations that do inline path factoring and compilation -(select/transform/setval/replace-in/path/etc.) must succeed in -factoring the path into static and dynamic portions. If not, an -error will be thrown and the reasons for not being able to factor -will be printed. Defaults to false, and `(must-cache-paths! false)` -can be used to turn this feature off. - -Reasons why it may not be able to factor a path include using -a local symbol, special form, or regular function invocation -where a navigator is expected.NIL->LIST
Navigates to '() if the value is nil. Otherwise it stays -navigated at the current value.NIL->SET
Navigates to #{} if the value is nil. Otherwise it stays -navigated at the current value.nil->val
Navigates to the provided val if the structure is nil. Otherwise it stays -navigated at the structure.NIL->VECTOR
Navigates to [] if the value is nil. Otherwise it stays -navigated at the current value.parser
Navigate to the result of running `parse-fn` on the value. For -transforms, the transformed value then has `unparse-fn` run on -it to get the final value at this point.pred
Keeps the element only if it matches the supplied predicate. This is the -late-bound parameterized version of using a function directly in a path.putval
Adds an external value to the collected vals. Useful when additional arguments +at a non-`terminal` navigator. `terminal-val` is a wrapper around `terminal` and is +the `multi-transform` equivalent of `setval`. +This macro will do inline caching of the path.multi-transform*
(multi-transform* path structure)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`.NIL->LIST
Navigates to '() if the value is nil. Otherwise it stays +navigated at the current value.NIL->SET
Navigates to #{} if the value is nil. Otherwise it stays +navigated at the current value.nil->val
Navigates to the provided val if the structure is nil. Otherwise it stays +navigated at the structure.NIL->VECTOR
Navigates to [] if the value is nil. Otherwise it stays +navigated at the current value.parser
Navigate to the result of running `parse-fn` on the value. For +transforms, the transformed value then has `unparse-fn` run on +it to get the final value at this point.path
macro
(path & path)Same as calling comp-paths, except it caches the composition of the static parts +of the path for later re-use (when possible). For almost all idiomatic uses +of Specter provides huge speedup. This macro is automatically used by the +select/transform/setval/replace-in/etc. macros.pred
Keeps the element only if it matches the supplied predicate. This is the +late-bound parameterized version of using a function directly in a path.putval
Adds an external value to the collected vals. Useful when additional arguments are required to the transform function that would otherwise require partial application or a wrapper function. e.g., incrementing val at path [:a :b] by 3: -(transform [:a :b (putval 3)] + some-map)replace-in*
(replace-in* path transform-fn structure & {:keys [merge-fn], :or {merge-fn concat}})Similar to transform, except returns a pair of [transformed-structure sequence-of-user-ret]. +(transform [:a :b (putval 3)] + some-map)replace-in
macro
(replace-in apath transform-fn structure & args)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.select*
(select* path structure)Navigates to and returns a sequence of all the elements specified by the path. -select-any*
(select-any* path structure)Returns any element found or [[NONE]] if nothing selected. This is the most -efficient of the various selection operations.select-one!*
(select-one!* path structure)Returns exactly one element, throws exception if zero or multiple elements found -select-one*
(select-one* path structure)Like select, but returns either one element or nil. Throws exception if multiple elements found -selected-any?*
(selected-any?* path structure)Returns true if any element was selected, false otherwise. -selected?
(selected? & path)Filters the current value based on whether a path finds anything. +of what was transformed in the data structure. +This macro will do inline caching of the path.replace-in*
(replace-in* path transform-fn structure & {:keys [merge-fn], :or {merge-fn concat}})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.select
macro
(select apath structure)Navigates to and returns a sequence of all the elements specified by the path. +This macro will do inline caching of the path.select*
(select* path structure)Navigates to and returns a sequence of all the elements specified by the path. +select-any
macro
(select-any apath structure)Returns any element found or [[NONE]] if nothing selected. This is the most +efficient of the various selection operations. +This macro will do inline caching of the path.select-any*
(select-any* path structure)Returns any element found or [[NONE]] if nothing selected. This is the most +efficient of the various selection operations.select-first
macro
(select-first apath structure)Returns first element found. +This macro will do inline caching of the path.select-one
macro
(select-one apath structure)Like select, but returns either one element or nil. Throws exception if multiple elements found. +This macro will do inline caching of the path.select-one!
macro
(select-one! apath structure)Returns exactly one element, throws exception if zero or multiple elements found. +This macro will do inline caching of the path.select-one!*
(select-one!* path structure)Returns exactly one element, throws exception if zero or multiple elements found +select-one*
(select-one* path structure)Like select, but returns either one element or nil. Throws exception if multiple elements found +selected-any?
macro
(selected-any? apath structure)Returns true if any element was selected, false otherwise. +This macro will do inline caching of the path.selected-any?*
(selected-any?* path structure)Returns true if any element was selected, false otherwise. +selected?
Filters the current value based on whether a path finds anything. e.g. (selected? :vals ALL even?) keeps the current element only if an -even number exists for the :vals key. - -The input path may be parameterized, in which case the result of selected? -will be parameterized in the order of which the parameterized navigators -were declared.setval*
(setval* path val structure)Navigates to each value specified by the path and replaces it by val -srange
Navigates to the subsequence bound by the indexes start (inclusive) -and end (exclusive)srange-dynamic
Uses start-fn and end-fn to determine the bounds of the subsequence -to select when navigating. Each function takes in the structure as input.stay-then-continue
(stay-then-continue & path)Navigates to the current element and then navigates via the provided path. -This can be used to implement pre-order traversal.STOP
Stops navigation at this point. For selection returns nothing and for -transformation returns the structure unchangedsubmap
Navigates to the specified submap (using select-keys). +even number exists for the :vals key.setval
macro
(setval apath aval structure)Navigates to each value specified by the path and replaces it by `aval`. +This macro will do inline caching of the path.setval*
(setval* path val structure)Navigates to each value specified by the path and replaces it by val +srange
Navigates to the subsequence bound by the indexes start (inclusive) +and end (exclusive)srange-dynamic
Uses start-fn and end-fn to determine the bounds of the subsequence +to select when navigating. Each function takes in the structure as input.stay-then-continue
Navigates to the current element and then navigates via the provided path. +This can be used to implement pre-order traversal.STOP
Stops navigation at this point. For selection returns nothing and for +transformation returns the structure unchangedsubmap
Navigates to the specified submap (using select-keys). In a transform, that submap in the original map is changed to the new -value of the submap.subselect
(subselect & path)Navigates to a sequence that contains the results of (select ...), +value of the submap.subselect
Navigates to a sequence that contains the results of (select ...), but is a view to the original structure that can be transformed. Requires that the input navigators will walk the structure's children in the same order when executed on "select" and then -"transform".subset
Navigates to the specified subset (by taking an intersection). In a transform, that subset in the original set is changed to the -new value of the subset.terminal
For usage with `multi-transform`, defines an endpoint in the navigation +new value of the subset.terminal
For usage with `multi-transform`, defines an endpoint in the navigation that will have the parameterized transform function run. The transform function works just like it does in `transform`, with collected values -given as the first argumentsterminal-val
Like `terminal` but specifies a val to set at the location regardless of -the collected values or the value at the location.transform*
(transform* path transform-fn structure)Navigates to each value specified by the path and replaces it by the result of running -the transform-fn on ittransformed
(transformed path update-fn)Navigates to a view of the current value by transforming it with the +given as the first argumentsterminal-val
(terminal-val v)Like `terminal` but specifies a val to set at the location regardless of +the collected values or the value at the location.transform
macro
(transform apath transform-fn structure)Navigates to each value specified by the path and replaces it by the result of running +the transform-fn on it. +This macro will do inline caching of the path.transform*
(transform* path transform-fn structure)Navigates to each value specified by the path and replaces it by the result of running +the transform-fn on ittransformed
Navigates to a view of the current value by transforming it with the specified path and update-fn. The input path may be parameterized, in which case the result of transformed will be parameterized in the order of which the parameterized navigators -were declared.traverse*
(traverse* apath structure)Return a reducible object that traverses over `structure` to every element -specified by the pathwalker
Using clojure.walk, navigate the data structure until reaching -a value for which `afn` returns truthy.
(traverse apath structure)Return a reducible object that traverses over `structure` to every element +specified by the path. +This macro will do inline caching of the path.
(traverse* apath structure)Return a reducible object that traverses over `structure` to every element +specified by the path
Using clojure.walk, navigate the data structure until reaching +a value for which `afn` returns truthy.
(collected? params & body)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.
(defpathedfn name & args)Defines a higher order navigator that itself takes in one or more paths -as input. This macro is generally used in conjunction with [[fixed-pathed-nav]] -or [[variable-pathed-nav]]. When inline factoring is applied to a path containing -one of these higher order navigators, it will automatically interepret all -arguments as paths, factor them accordingly, and set up the callsite to -provide the parameters dynamically. Use ^:notpath metadata on arguments -to indicate non-path arguments that should not be factored – note that in order -to be inline factorable, these arguments must be statically resolvable (e.g. a -top level var). See `transformed` for an example.
(defprotocolpath name)(defprotocolpath name params)Defines a navigator that chooses the path to take based on the type -of the value at the current point. May be specified with parameters to -specify that all extensions must require that number of parameters. - -Currently not available for ClojureScript. - -Example of usage: -(defrecord SingleAccount [funds]) -(defrecord FamilyAccount [single-accounts]) - -(defprotocolpath FundsPath) -(extend-protocolpath FundsPath - SingleAccount :funds - FamilyAccount [ALL FundsPath] - ) -
(extend-protocolpath protpath & extensions)Used in conjunction with `defprotocolpath`. See [[defprotocolpath]]. -
(multi-transform apath structure)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.
(paramscollector params impl)Defines a Collector with late bound parameters. This collector can be precompiled -with other selectors without knowing the parameters. When precompiled with other -selectors, the resulting selector takes in parameters for all selectors in the path -that needed parameters (in the order in which they were declared). -
(path & path)Same as calling comp-paths, except it caches the composition of the static part -of the path for later re-use (when possible). For almost all idiomatic uses -of Specter provides huge speedup. This macro is automatically used by the -select/transform/setval/replace-in/etc. macros.
(pathed-collector [name path] impl)This helper is used to define collectors that take in a single selector -paths as input. That path may require late-bound params, so this helper -will create a parameterized selector if that is the case. If no late-bound params -are required, then the result is executable.
(replace-in apath transform-fn structure & args)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.
(select apath structure)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.
(select-any apath structure)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.
(select-first apath structure)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.
(select-one apath structure)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.
(select-one! apath structure)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.
(selected-any? apath structure)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.
(setval apath aval structure)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.
(transform apath transform-fn structure)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.
(traverse apath structure)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.
Navigates to the specified key of a transient collection, -navigating to nil if it doesn't exist.
Navigates to the specified key of a transient collection, +navigating to nil if it doesn't exist.
Navigate the zipper to the first element +com.rpl.specter.zipper documentation Generated by Codox
Specter 0.13.0
\ No newline at end of file +from the structurecom.rpl.specter.zipper
find-first
Navigate the zipper to the first element in the structure matching predfn. A linear scan -is done using NEXT to find the element.NODE-SEQ
Navigate to the subsequence containing only -the node currently pointed to. This works just +is done using NEXT to find the element.NODE-SEQ
Navigate to the subsequence containing only +the node currently pointed to. This works just like srange and can be used to remove elements -from the structure
To install, add the following dependency to your project or build file:
[com.rpl/specter "0.12.0"]
Public variables and functions:
Public variables and functions:
To install, add the following dependency to your project or build file:
[com.rpl/specter "0.13.0"]
Public variables and functions: