Fork me on GitHub
#clojure
<
2017-05-24
>
Oliver George00:05:28

I'm looking for an Edn library for .net.

tbaldridge02:05:40

@olivergeorge almost all non Clojure(Script) edn readers are unusable. That's one of the key reasons Transit was written: https://github.com/cognitect/transit-format

tbaldridge02:05:26

Nevermind that Transit is a lot faster than EDN

Oliver George04:05:13

tbaldridge: Thanks. I hadn't considered that. We're looking for something to define our data schema / configuration which means human readable/editable is important. Was hoping for something nicer than JSON or XML... Edn seemed like a perfect candidate.

tbaldridge04:05:23

If you have to use edn, look at the LispReader code in Clojure-CLR. that will probably mean loading most of the Clojure runtime, but I've done that before in projects, and having a full set of immutable data structures in C# isn't bad either.

tbaldridge04:05:48

look for usages of this file in Clojure-CLR and that should give you a overview of how to use it: https://github.com/clojure/clojure-clr/blob/master/Clojure/Clojure/Lib/LispReader.cs

Oliver George04:05:56

Sounds a bit heavy handed (if tempting). Thanks for the feedback.

matan03:05:46

I had asked here about the fine print at https://clojure.org/reference/transducers yesterday, and got a link to a youtube video featuring very heavy accent and in general hard to follow. Can anyone recommend a good resource to learn about these caveats of transducers? > If you have a new context for applying transducers, there are a few general rules to be aware of: > • If a step function returns a reduced value, the transducible process must not supply any more inputs to the step function. The reduced value must be unwrapped with deref before completion. > • A completing process must call the completion operation on the final accumulated value exactly once. > • A transducing process must encapsulate references to the function returned by invoking a transducer - these may be stateful and unsafe for use across threads.

matan03:05:59

I am concerned at going into transducers without apt understanding of these issues, as the guy with the heavy accent said in the beginning of his video, not understanding these cause him great grief and frustration, something I cannot afford as they translate to zero productivity.

matan03:05:00

Perhaps you can recommend a book or resource specifically addressing these or more broadly the safety rules or must knows for transducers?

danielgrosse07:05:30

Can I serve files with compojure, which are not in the resources folder?

noisesmith17:05:23

danielgrosse: if the files exist on the classpath or file system sure - how would the server be finding the files?

jumar07:05:05

@matan I'd start with "Transducers by Rich Hickey": https://www.youtube.com/watch?v=6mTbuzafcII (If you haven't seen it yet) and then continue with "Inside transducers": https://www.youtube.com/watch?v=4KqUvG8HPYo One good example that I've recently seen is also https://tech.grammarly.com/blog/building-etl-pipelines-with-clojure

martinklepsch07:05:30

needed to strip some non-printable things from an ex-data thing, ended up with this but listing things like that feels like a certain way to miss things:

(defn strip-non-serializable [m]
  (walk/postwalk (fn [x]
                   (if-not (or (string? x)
                               (keyword? x)
                               (number? x)
                               (symbol? x)
                               (map? x)
                               (vector? x)
                               (list? x))
                     :ommitted-not-serializable
                     x))
                 m))
Anyone a smart alternative to suggest?

pesterhazy07:05:29

@martinklepsch I suspect that's the best you can do

martinklepsch07:05:49

(eventually it goes into cheshire but cheshire doesn’t seem to have a jsonable? type thing

pesterhazy07:05:51

java.util.Date is also printable

pesterhazy07:05:50

I've needed a function like this many times by the way

martinklepsch07:05:19

You can have it 😛

pesterhazy07:05:20

to "sanitize" a data structure for serialization/priting

pesterhazy07:05:35

thanks!!!! 🎁

martinklepsch07:05:03

would be nice if serialization libs (I’ll also need this for nippy) expose a “serializable?” predicate to let you do this kind of thing

martinklepsch07:05:15

(maybe nippy has this, haven’t checked)

pesterhazy07:05:30

alternatively a flag to just skip over/replace all non-serializable values

martinklepsch07:05:42

that’d be “nicer” but a predicate would just get the job done w/o much consideration of impact on public APIs etc https://github.com/dakrone/cheshire/issues/118

pesterhazy08:05:36

it would also be faster..

mpenet11:05:01

@martinklepsch I think nippy is protocol based, so in theory you can use satisifes?

mpenet11:05:30

(didn't check)

martinklepsch11:05:47

@mpenet yeah could be. Didn’t get to nippy yet anyways

Lambda/Sierra13:05:42

@martinklepsch Use seq? instead of list? since lots of data structures end up as seqs that aren't actually lists

chrishacker15:05:02

Is there a way to get a .cljc file to hot reload while developing? prior to adding it, we had our .clj code hot reloading anytime we made a change. We're using lein and immutant, among lots of other libraries. Using emacs/cider to develop, and even C-c C-k doesn't recompile the cljc code.

ddeaguiar17:05:25

Can anyone recommend a good Cursive cheatsheet. I’m helping someone who uses Intellij and a quick google didn’t produce anything I liked. Intellij is not my goto ide…

ddeaguiar17:05:03

They’d prefer to use the default bindings

curlyfry18:05:12

Anyone here have a favourite way of working with elasticsearch through Clojure? https://github.com/clojurewerkz/elastisch seems a bit outdated. https://github.com/mpenet/spandex ? Raw http requests? Something else?

noisesmith18:05:35

based on crossclj I’d say elastisch is more mature and better supported / more widely used

mpenet18:05:07

Wrong assumption :) but I am biaised

curlyfry18:05:47

elastisch seems to lag behind in elasticsearch versions though

mpenet18:05:55

I am not sure elastish will work with 2.4+ too

mpenet18:05:23

Spandex is quite new, so crossclj doesnt paint a clear pic. It s been running millions of queries per day in prod without hiccups

noisesmith18:05:55

@mpenet I hope it didn’t look like I was comparing their merits. Of course “better supported” is speculation but clojurewerkz has been around for a while and that counts for something. No disparagement meant toward your project of course.

mpenet18:05:21

noisesmith: np

ghadi18:05:29

what differences does the transport protocol vs the HTTP protocol offer?

ghadi18:05:44

i've never actually used transport

mpenet18:05:26

Persistent cnx and binary proto plus few other things. But it's going the way of the dodo for clients

mpenet18:05:07

And perf is nearly identical between the new http client and legacy native now

mpenet18:05:40

The readme of spandex links to a blog post from elastic talking about that

mpenet18:05:01

(On my phone sorry)

curlyfry18:05:11

@mpenet I'll take a look at spandex then! 🙂

rauh18:05:24

Been using spanex, works great! I'd choose it over elastisch again (Which I also used).

joshjones19:05:56

have only used elastisch, but it was quite nice

bballantine20:05:43

@curlyfry I have also only used elastich and found it worked great, but it’s been about a year since I was doing that work.

hansen-pansen20:05:06

@ztellman Do you ever sleep? I thank you very much for the effort you put into your software. I really do enjoy #aleph and #manifold. Thank you very much!

cfleming21:05:55

Note that I don’t think his windows bindings are the defaults, although I may make them the defaults due to https://github.com/cursive-ide/cursive/issues/1139

adamfrey22:05:07

has anyone considered a development mode for clojure where when you evaluated

(def some-user {:first-name "Adam"})

...

(:firrst-name some-user) ;; => Exception

an exception would be thrown if the key is not found in the map, in order to quickly spot typo'd keywords?

adamfrey22:05:18

Obviously you could do something similar with spec and making sure that maps conform to having those keys, but I would like to try something with minimal effort on the programmer's part.

adamfrey22:05:07

the IFn interface for Keywords is in the clojure source as Java.

hiredman22:05:41

because things read, then evaluated

hiredman22:05:06

so the data returned by the data reader there is passed through the compiler after the read is done

bronsa22:05:58

x/y1 reads 3 and evals it to 3 x/y2 reads (+ 1 2) and evals it to 3 x/y3 reads (quote (+ 1 2)) and evals it to (+ 1 2)

moxaj22:05:44

@hiredman @bronsa I see. I was looking at the built in stuff (uuid and inst) and none of those seems to be quoted anywhere

moxaj22:05:02

but, based on the above, they could be quoted once and still be correct, right?

hiredman22:05:10

because they return data that evaluates to itself

hiredman22:05:34

no, if they returned quoted data, it could change what macros see

hiredman22:05:40

when foo3 is invoke, it does return a quoted thing, it returns a list

hiredman22:05:40

the quotation, when foo2 is compiled, tells the compiler to compile generate code that creates a list object at runtime, not compile the list as a function call

hiredman22:05:49

so what foo2 is returns is a list

hiredman22:05:05

and data returned by a data reader is as if the reader returned that data

hiredman22:05:33

so if you evaluate a list returned by the reader, well we do that all the time and we know how lists evaluate

moxaj22:05:06

@hiredman I think I understand

moxaj22:05:45

what seems strange to me is that a macro then, if passed #inst ..., sees not some literal data, but an object

noisesmith22:05:53

reader-macros are expanded before regular macros are

moxaj22:05:58

we need to go deeper. pre-read time 😄

noisesmith22:05:13

pre-read, what you have is an inputstream