Fork me on GitHub
#clojure
<
2018-08-11
>
seancorfield00:08:36

@esanmiguelc You can exclude the Ring dependency from boot-http and provide your own.

seancorfield00:08:07

:dependencies [[pandeiro/boot-http "..." :exclusions [ring]] [ring "1.6.3"]]

💯 4
esanmiguelc00:08:27

:thinking_face: That’s an awesome idea, thanks! I’m already doing that for other things.

lilactown00:08:16

is there a library, or a function that lives somewhere, that can do like select-keys, but with arbitrarily nested maps?

🙏 4
lilactown00:08:26

I’m thinking of like a projection written like so:

(project {:a {:b 1 :c 2 :d {:x 3}}}
          [:a [:b :d [:x]]])

bja15:08:21

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))

lilactown19:08:42

too easy 😛

seancorfield02:08:49

@lilactown Sounds like Specter?

lilactown02:08:16

I looked at specter but immediately felt like I’m not smart enough to figure out how to use it 😕

seancorfield03:08:56

I've never used it -- I agree that it seems like an impenetrable DSL -- but I gather it's perfect for your use case 🙂

lilactown04:08:51

turns out it’s about 20 lines and a few hours of thinking: https://gist.github.com/Lokeh/b5e0f6b4ac45320c63ab5a07172a5250

jsa-aerial05:08:11

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.

jsa-aerial05:08:34

For general purpose selection and (even more importantly) changing of data it will totally make your work (life) vastly easier and more fun.

👍 12
valerauko06:08:16

is there any clojure/java library to handle linked data signatures?

Artem Yarulin13:08:09

Hi, I have spring boot/kotlin/gradle project and thinking about integrating clojure there, at least for repl experiments. Anyone tried something like that?

sobel13:08:40

More languages => more problems

☝️ 12
dottedmag14:08:11

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?

nenadalm17:08:44

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

hiredman21:08:45

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

dottedmag08:08:54

@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.

nenadalm09:08:22

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

nenadalm09:08:58

In case you mean http api by that boundary, reitit looks nice: https://github.com/metosin/reitit (it also generates swagger).

dottedmag09:08:49

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.

jonahbenton16:08:20

@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.

jonahbenton16:08:29

Separately- I'm working in that domain- financial data ingestion and processing- feel free to ping on DM.

jonahbenton15:08:36

@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...

keymone20:08:29

it seems i can’t (resolve ’xyz) in -main

keymone20:08:33

what am i doing wrong?

keymone21:08:41

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

keymone21:08:24

^ just made a clean lein app

alexmiller21:08:07

probably has to do with the value of *ns*

alexmiller21:08:26

when starting via a main, I don’t think that’s set

keymone21:08:45

that’s.. surprising

keymone21:08:48

but you’re right

keymone21:08:08

it’s “user” in lein run and “clojure.core” in uberjar

keymone21:08:40

doing (ns foo.bar) feels icky in -main =/

noisesmith21:08:38

you can include the ns on the symbol to resolve

👍 4
noisesmith21:08:57

or use ns-resolve which explicitly says "resolve this symbol as if in that ns"

noisesmith21:08:09

a common pattern in my app startup code is ... (require 'foo.bar) ... ((resolve 'foo.bar/entry-point)) ...

keymone21:08:15

that is obvious now that you’ve said it

john22:08:12

@lilactown there's always: (reduce get {:a {:b 1 :c 2 :d {:x 3}}} [:a :d :x]) #_=> 3

john22:08:47

oh, that's a little different than what you wanted from select keys

john22:08:26

specter has lots of optimizations too though

lilactown22:08:44

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.

lilactown22:08:33

I’m sure that specter would be more performant but I’m going to defer that for awhile longer

lilactown22:08:37

can only learn so much at once 😛

john22:08:25

I'm not at the computer anymore, but try reducing on select-keys

john22:08:58

Naw that couldn't work...

lilactown22:08:59

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

benzap22:08:34

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.

👍 4
lilactown23:08:28

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

jjttjj23:08:08

@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

lilactown23:08:34

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

lilactown23:08:37

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

jjttjj23:08:37

yup. and even Oracle seems to be slowly backing away from JavaFX which doesn't help either

lilactown23:08:18

I do dream of a REPL-based desktop, native UI workflow /sigh

lilactown23:08:32

and then I think I’d settle for non-Electron, but AFAICT making Swing look good takes a bit of investment