This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-06-12
Channels
- # admin-announcements (1)
- # arachne (3)
- # cider (11)
- # cljsrn (5)
- # clojure (26)
- # clojure-android (10)
- # clojure-greece (8)
- # clojure-russia (5)
- # clojure-spec (7)
- # clojure-uk (3)
- # clojurescript (16)
- # clojurex (38)
- # core-async (1)
- # css (3)
- # cursive (42)
- # dirac (2)
- # hoplon (28)
- # keechma (1)
- # lein-figwheel (2)
- # leiningen (1)
- # mount (3)
- # om (132)
- # onyx (46)
- # re-frame (53)
- # reagent (17)
- # spacemacs (7)
- # specter (50)
- # untangled (2)
- # yada (3)
@nathanmarz: ok, so it's a more general version of pathed functions like srange and filterer
thanks for the response
the example was very helpful
@codonnell: It's a generalization of filterer but not of srange
filterer is defined as (subselect ALL (selected? path))
the expected transformed sequence for subselect is expected to remain the same size, with each index referring to a particular location in the original structure
the transformed sequence for srange can be of any size and will splice back into the original sequence to replace the original subsequence
@nathanmarz: that makes sense.
@nathanmarz: I put up my notes and examples as a github wiki page at https://github.com/codonnell/specter/wiki/List-of-Navigators. It could serve as a starting point for navigator reference documentation; you're welcome to copy any of it that you'd like.
I like your wiki page because every navigator has a few examples. I'm hoping Specter's official docs will be like that eventually.
@codonnell: That's great, I'd like to get that merged into the official docs at some point
I made some modifications for things that were implementation details and not promised to have that exact behavior in future versions
For example, in many parts it said "returns a lazy sequence when used in a select", and that behavior is already completely different in 0.12.0
As for params-reset
, that's used to make a recursive path that requires parameters
by wrapping the recursive call in params-reset
, it tells the recursive navigation to use the same parameters
e.g.
(declarepath MyWalker [k])
(providepath MyWalker
(stay-then-continue must (params-reset MyWalker)))
(select (MyWalker :a) {:a {:a {:b 2}}})
;; => [{:a {:a {:b 2}}} {:a {:b 2}} {:b 2}]
I merged it into the Specter wiki: https://github.com/nathanmarz/specter/wiki/List-of-Navigators
It's such a pain, I can't currently upgrade and I'm stuck with an older version since the breaking macros changes.
@rauh breaking changes are only done when they are necessary to enable very significant improvements
what's preventing you from upgrading and making the appropriate updates?
@nathanmarz: I can't upgrade since midje pulls in an older specter
@rauh yea, that's unfortunate
Not the end of the world, but specter is getting to the point (1100 gh stars, 57k clojar pulls) that it should be careful if the breaking changes are needed.
like I said, I only make breaking changes when the benefits are very significant
0.12.0 will have another breaking change, but it only affects projects that define their own navigators
Well I blame suchwow
(used by midje) more for that since they use specter twice! (Two simple transform
)
Ah, well the 0.12.0 change only affects the select path
is there a better way to write the following: https://gist.github.com/luxbock/93d61ccd38b340a99dfd3a93682b5f6c
(let [foo-map {:foo #{1 2 3} :bar #{5 6}}]
(transform [ALL
(collect-one FIRST (view #(get foo-map %)))
LAST
ALL
]
(fn [aset v]
(if (aset v)
(str v)
(inc v)
))
{:foo [1 2 4 5]
:bar [2 3 5 6]}
))
@nathanmarz: nice, I'll have to get familiar with view
`
@nathanmarz: I added a description and examples for params-reset
at https://github.com/codonnell/specter/wiki/List-of-Navigators#params-reset
Thanks for removing the implementation detail.
Is there a reason params-reset
takes a single path argument rather than a varargs like most of the other pathed functions?
@codonnell: It's only intended for the particular use case of recursive parameterized navigators
your description for params-reset is a little inaccurate – it actually decrements position in params array by the number of parameters that navigator requires
where that's important is a path like [must MyWalker]
will merge in and fix description
The new description makes perfect sense.
By the way, really appreciate the documentation contribution – that's Specter's biggest problem at the moment
You're most welcome.
@nathanmarz: I just realized every all-caps link and link with a >
in it was broken. It's fixed on my wiki. (Oops)
Also, discovered the map-vals bug earlier wasn’t a bug, just my own insufficient cleaning of compiled javascript when updating specter versions.
@codonnell: merged, thanks
@conaw: cool, good to know