This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-02
Channels
- # aws-lambda (1)
- # beginners (28)
- # boot (54)
- # cider (11)
- # clara (28)
- # cljs-dev (74)
- # cljsrn (13)
- # clojure (342)
- # clojure-austin (3)
- # clojure-dusseldorf (4)
- # clojure-france (2)
- # clojure-greece (11)
- # clojure-italy (42)
- # clojure-poland (7)
- # clojure-russia (11)
- # clojure-spec (44)
- # clojure-uk (156)
- # clojure-ukraine (4)
- # clojurescript (102)
- # cursive (17)
- # datascript (19)
- # datomic (17)
- # dirac (39)
- # emacs (22)
- # funcool (56)
- # hoplon (25)
- # jobs (3)
- # jobs-discuss (31)
- # leiningen (2)
- # luminus (4)
- # lumo (3)
- # off-topic (47)
- # om (51)
- # onyx (57)
- # re-frame (13)
- # reagent (57)
- # remote-jobs (15)
- # ring (9)
- # ring-swagger (7)
- # robots (2)
- # rum (6)
- # specter (16)
- # sql (7)
- # test-check (37)
- # untangled (7)
- # yada (5)
By the way great blog post
thanks
Regarding Haskell lenses and Lens/Traversal distinction: if I recall correctly, for Lens you're guaranteed that you can read a single value. This is handy with Haskell's type system, but in a dynamic language like Clojure, it does not really matter or make sense.
In general, if you try to port Haskell lenses directly to dynamic languages (like people sometimes do), you'll end up with a bunch of things that just do not do anything useful without the type system.
@miikka Thanks, interesting point. Makes sense that the distinction would have something to do with the type system.
(NEWBIE QUESTION) - I have been using specter to work with a structure that was originally yaml. The basic selectors I have some grasp of. What I need to do is find a set of map entries where the values are maps and that have a particular key - eg:
I want to be able to return :field1 and its contents by finding it because it has the :require true set.
@mmer I think you're looking for (select [MAP-VALS map? (pred :required)] data)
@mmer you can do (select [ALL (collect-one FIRST) LAST map? (pred :required)] data)
Thanks Nathan. I guess I am struggling to understand how this ends up working - for example the (collect-one FIRST) Is it FIRST because you treat the map as a list? The map? after the LAST is applied to what is returned by the LAST which is the end of the list created from the map?
would this work:
=> (select [ALL (pred (comp :required val))] m)
[[:field1 {:type "string", :required true}]]
?@mmer ALL
on a map navigates you to each key/value pair as a 2-element vector
@tolitius yea, that works too