This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-08-02
Channels
- # admin-announcements (3)
- # architecture (5)
- # beginners (10)
- # boot (223)
- # cider (13)
- # cljsjs (2)
- # cljsrn (50)
- # clojure (208)
- # clojure-austin (16)
- # clojure-belgium (1)
- # clojure-india (1)
- # clojure-poland (13)
- # clojure-russia (130)
- # clojure-spec (27)
- # clojure-uk (144)
- # clojurescript (135)
- # css (2)
- # cursive (10)
- # datavis (1)
- # datomic (29)
- # dirac (9)
- # funcool (2)
- # hoplon (41)
- # jobs (3)
- # leiningen (6)
- # om (37)
- # onyx (20)
- # pedestal (1)
- # planck (1)
- # proton (4)
- # re-frame (45)
- # reagent (17)
- # rethinkdb (16)
- # ring-swagger (19)
- # schema (5)
- # specter (93)
- # sql (16)
- # test-check (33)
- # untangled (7)
(require '[com.rpl.specter :as s])
(require-macros '[com.rpl.specter.macros :refer [select transform]])
@nathanmarz: cool, I was trying something with :refer :all, but that isn't going to work probably
macros namespace also has declarepath, providepath, and other operations for defining navigators
yea I think you need to require macros individually
not sure, don't really use cljs
I'm trying to get Specter going with Planck, but failing so far: https://gist.github.com/borkdude/a7706bf096e1280b3d8a3fd0b33ec95e
can you get a stack trace for that?
@nathanmarz: for transform?
Don't know if this is helpful? https://gist.github.com/borkdude/9287a872db1038160fd0444ec1cac443
FWIW, I quickly tried that expression with older versions of specter, back to 0.9.3 and it fails in Planck in the same way. So not a regression at least. Perhaps just a problematic expression.
@borkdude: can you open an issue on github for this?
@mfikes: master branch is on clojure 1.7.0 now, does that mean we should be able to integrate automated tests for specter+bootstrap ?
@mfikes: hmmm, timestamps there aren't so encouraging
would it be possible to fork test.check in the meantime with the appropriate changes? I'd be perfectly happy using that
few questions.. how would I make select* analogous to get-in, currently (select* [:bleh :blah] {:bleh {:blah 1}}) returns [1] instead of just 1
and why do the examples on the github use just 'select' when the function is select* ?
@nathanmarz: Yeah… let me check. There’s an issue related to Transit that might be holding it up, and if that’s the case perhaps I can address it. I agree, if no progress, I’ll pursue an interim fork.
@mattsfrey: There is a select*
function, but it's preferred to use the select
macro, as in the docs
and if you know you'll only be selecting one thing, you can use select-one
or select-any
(`select` is in the com.rpl.specter.macros
namespace)
@mfikes: sounds good
@codonnell @mattsfrey select*
is the navigator implementation function, which is distinct from select
select-any
(introduced in 0.12.0) is the most efficient way to get one result back
@codonnell @mattsfrey nevermind, just realized you were referring to the functional version of select
macro
the reason to use the macro is because it does inline caching of the navigation path, so is very efficient
see https://github.com/nathanmarz/specter/wiki/Specter-0.11.0:-Performance-without-the-tradeoffs for details on that
noob question … how do I combine clauses? ;p
(spec/comp-paths THINGS spec/ALL (and (spec/selected? :category #{"A"})
(spec/not-selected? :id #{1 2})))
@hueyp: just get rid of the and
(spec/comp-paths THINGS spec/ALL (spec/selected? :category #{"A"}) (spec/not-selected? :id #{1 2}))
If you know you are selecting one element, what are the pros and cons of choosing select-one or select-any vs select-first?
@nathanmarz: ahh, ok it's a macro
@puzzler: select-any
is the fastest
not really any perf difference between select-one
and select-first
(for now), they just have different semantics in terms of what happens if there's multiple elements to select
@puzzler: Also, select-one
will throw an exception if more than one result is found, while select-first
and select-any
will not (as you may infer from their names)
Is select-any in the latest stable version 0.11.2? For some reason, although I'm "use"ing the macros namespace, I'm not seeing it.
it's in 0.12.0
should probably get around to releasing it
this question will probably sound dumb, but I can't for the the life of me figure out how to include the macros
#object[TypeError TypeError: undefined is not an object (evaluating 'bocl.account.data_test.select.call')]
@mattsfrey: are you using clojure or clojurescript?
I haven't done much clojurescript; you have the correct namespace. Did you do a lein clean?
maybe you need it to be (:require-macros [com.rpl.specter.macros :refer [select transform]])
?
tried pretty much every permutation of :refer :all, :include-macros, etc etc and they all end up in error other than just (:require-macros [com.rpl.specter]), but that isn't actually incuding any macros
ok, good
that's good to know
it should be in com.rpl.specter
is there clojure sugar around importing both ns's as the same alias? e.g. (s/select [s/ALL] things)
@hueyp: not that I know of
@hueyp: I use https://github.com/ztellman/potemkin/blob/master/src/potemkin/namespaces.clj to get everything into the same namespace
It appears that transform [ALL] on a lazy sequence does not produce a lazy sequence. Is there a way to make it operate in a lazy fashion?
@puzzler: you would need to make a new navigator for that
ALL
could have been implemented to work differently for lazy sequences, but I think it's better for lazy behavior to be explicit
not sure which construct in specter I’d want to use … I have this:
(defn Foo
[foo-id]
[(spec/selected? :type #{"foo"}) (spec/selected? :id #{foo-id})])
(select [THINGS (Foo "bar")]
things)
… which works, but I feel is wrong 🙂. I can move it to declarepath
/ providepath
but wondering if it should use something elseattempt at declarepath
/ provide
path is
(declarepath Foo [foo-id])
(providepath Foo
[(spec/selected? :type #{"foo"})
(spec/selected? :id (paramsfn [foo-id] [id] (= foo-id id)))])
@hueyp: use comp-paths
(def Foo
(comp-paths
(spec/selected? :type #{"foo"})
(spec/selected? :id (paramsfn [foo-id] [id] (= foo-id id)))))
declarepath
/`providepath` is for defining recursive navigators
comp-paths
result will be high performance and can be further composed with other navigators without its params
no problem