This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-11
Channels
- # announcements (8)
- # beginners (17)
- # boot (1)
- # cider (20)
- # cljdoc (7)
- # cljs-dev (14)
- # clojure (62)
- # clojure-dev (16)
- # clojure-hamburg (1)
- # clojure-russia (2)
- # clojure-spec (22)
- # clojure-uk (15)
- # clojurebridge (1)
- # clojurescript (23)
- # core-async (4)
- # core-logic (17)
- # cursive (2)
- # datomic (4)
- # duct (1)
- # figwheel-main (40)
- # fulcro (15)
- # leiningen (1)
- # off-topic (27)
- # re-frame (3)
- # shadow-cljs (9)
- # specter (3)
- # sql (59)
@esanmiguelc You can exclude the Ring dependency from boot-http
and provide your own.
:dependencies [[pandeiro/boot-http "..." :exclusions [ring]] [ring "1.6.3"]]
:thinking_face: Thatās an awesome idea, thanks! Iām already doing that for other things.
is there a library, or a function that lives somewhere, that can do like select-keys
, but with arbitrarily nested maps?
Iām thinking of like a projection written like so:
(project {:a {:b 1 :c 2 :d {:x 3}}}
[:a [:b :d [:x]]])
If you build it like this:
(project {:a {:b 1 :c 2 :d {:x 3}}}
[[:a], [:a :b], [:a :d :x]])
You could implement it using (defn project [m keyspecs](map #(get-in m keyspec) keyspecs))
@lilactown Sounds like Specter?
I looked at specter but immediately felt like Iām not smart enough to figure out how to use it š
@lilactown Yeah, its daunting. This helped: https://www.youtube.com/watch?v=rh5J4vacG98
I've never used it -- I agree that it seems like an impenetrable DSL -- but I gather it's perfect for your use case š
turns out itās about 20 lines and a few hours of thinking: https://gist.github.com/Lokeh/b5e0f6b4ac45320c63ab5a07172a5250
Specter is not even remotely 'impenetrable' - it only seems that way before you start. Once you get into it, it is very consistent and well thought out and quite intuitive.
For general purpose selection and (even more importantly) changing of data it will totally make your work (life) vastly easier and more fun.
Hi, I have spring boot/kotlin/gradle project and thinking about integrating clojure there, at least for repl experiments. Anyone tried something like that?
Have anyone seen a library similar to Spec, but designed explicitly to be used with on boundaries of the system, with the different set of assumptions: 1) closed-world (if incoming data does not exactly match the specification, stop the world and let humans investigate); 2) coercion-friendly due to mismatch between Clojure and external world?
If you want keys predicate to fail on unknown keys, you can write your own or use some of the existing ones like: https://github.com/bhauman/spell-spec#spell-specalphastrict-keys cc @U0FF3A4V6
I've generated json schema from spec for that kind of purpose (describing the api to a non-clojure system), but have essentially abandoned that for graphql, which I haven't tried to tie into spec at all
@U662GKS3F That's a good start. There are also bits and pieces scattered around other libraries (not allowing un-spec-ed values, and there was some library for better conforming). I could combine them all, and what I'm looking for is whether someone has given it enough thought, combined and published it.
spec-tools (I've never used it) is library that also supports coercion and according to the docs, you can choose if unspecced keys are thrown away or coercion fails: https://github.com/metosin/spec-tools#spec-driven-transformations
In case you mean http api by that boundary, reitit looks nice: https://github.com/metosin/reitit (it also generates swagger).
No, no HTTP API. It's about consumption (think all CSVs and PDFs generated by the various financial institutions around the world and you'll be not so off the mark), not providing an API to someone else.
@dottedmag FWIW I would not call that a job for spec. Dealing with those kinds of formats involves specialized tooling to turn those formats or "wire protocols" into data- clj data structures. Once there are data structures, one can use spec for validation or conformance.
Separately- I'm working in that domain- financial data ingestion and processing- feel free to ping on DM.
@dottedmag I am thinking for a security project of using spec on data reaching system boundaries, with similar assumptions, am curious about gaps in that approach for which another solution is needed...
thereās (def xyz 123) in the same namespace, (resolve āxyz) right next to it works, (resolve āxyz) in a function right next to it also works but it doesnāt in body of -main
probably has to do with the value of *ns*
when starting via a main, I donāt think thatās set
or use ns-resolve
which explicitly says "resolve this symbol as if in that ns"
a common pattern in my app startup code is ... (require 'foo.bar) ... ((resolve 'foo.bar/entry-point)) ...
@lilactown there's always: (reduce get {:a {:b 1 :c 2 :d {:x 3}}} [:a :d :x]) #_=> 3
yeah thatās not quite what I want. I want to be able to write a projection
[:a [:b :d]]
and basically get a map back that has only the keys specified.
Iām sure that specter would be more performant but Iām going to defer that for awhile longer
I already figured it out š a combination of using loop-recur to construct all of the paths and the reduce using assoc-in on a new map and get-in on the old one
I was wondering, why isn't JavaFX used within the clojure ecosystem? There's a pretty mature swing library seesaw
, but any libraries targeting JavaFX seemed to have fallen out of use.
good question. seems like GUI libraries like that need a lot of love and attention, at least at first. seesaw has been maintained pretty much solely by Dave Ray
@benzap I forget the exact details but I looked into JavaFX briefly and it doesn't seem to work smoothly with a repl driven style out of the box. I think it could be made to work with some hacks but that might play into it
I also think that the JVM just isnāt in much demand for GUI applications, and Clojure even less so; most people are getting up faster with Electron + JS (or CLJS!) than Swing or JavaFX these days
JVM (and thus Clojure) seems to have been relegated to server apps at this point. not that I agree with this, it just seems to be where the tides have brought us