#clojure logs

2017-06-26

03:25dysfuni'm starting to think spec would be better if they just gave up on predicates as being the basic thing and moved to conformers being the basic thing
04:31Rovaniondysfun: And if a conformer gives a truthy value the input is valid?
04:31dysfunif a conformer returns something other than ::s/invalid, it is valid
04:32dysfununder the hood, everything is based on conformers
04:32RovanionSounds better.
04:32dysfuni'm left thinking it was a mistake to make predicates the basis of declaration
04:33dysfunpredicates can be trivially wrapped to conformer-ise them
04:34RovanionI can imagine that the reason why its not already is because conformers (I imagine) are slower than predicates. But you always want your sequential data structures to be reformed as tagged such or maps?
04:34dysfunbut under the hood it uses conformers
04:34dysfunwhen you call s/valid? that is a call to conform and checking it didn't return ::s/invalid
04:38RovanionYou're absolutely correct. That is strange.
04:38dysfuni know i'm correct, i've spent the last few days trying to understand spec's internals because i'm writing another library for it
05:13osfabibisiooo, you can use `conj` as a confusing synonym for `merge`
05:13dysfuno_O
05:13ridcully_"here is my conj request"
05:13dysfun,(conj {:a :b} {:c :d})
05:13clojurebot{:a :b, :c :d}
05:46dysfunanyway, clearly the correct terminology is 'rebase request'
05:48RovanionI request that you rebase your code on mine!
07:57dysfunhttps://gist.github.com/jjl/67658ccfff52a9cfb5b82f124bb2c82e # thoughts?
07:58dysfun(mainly from spec users)
07:58dysfunnot finished, obviously
08:12osfabibisisome of your indentation is broken
08:12osfabibisiin the :require
08:13osfabibisilooks like a nice approach
09:00dysfunthanks
09:00dysfunit's changed considerably since i started it
11:54assoc-in`DOes anyone know how to get the pretty printing like (clojure.pprint/pprint map) to output to a log file using timbre?
12:07justin_smithassoc-in: I'm not sure if there's anything pre-rolled, but you could make your own macro using (with-out-str (pprint m)) inside a log macro
12:21assoc-injustin_smith: awesome that worked perfectly. I hadn't heard of with-out-str before
12:22justin_smithone thing to look out for is that with-out-str exposes how printing is a side effect - if anything inside your call prints, it will become part of the generated string
12:22justin_smithwhich can bite you if you try to println debug
15:01hellofunkthe first item in the seq returned by this statement has both elements of the vector equal: (for [x (range 3) y (range 3)] [ x y])
15:01hellofunkso what i don't understand is why this variant with the :while doesn't short circuit immediately:
15:01hellofunk(for [x (range 3) y (range 3) :while (not= x y)] [ x y])
15:02hellofunkinstead, it returns: ([1 0] [2 0] [2 1])
15:03justin_smithyeah, I've never really understood the behavior of the :while key to be honest
15:03amalloy:while only terminates the innermost loop
15:03amalloyso it gives up on finding any y fitting with x=0, and then starts over with x=1
15:04hellofunkoh, so :while can cause multiple inner loops to quit, rather htan the whole for expression to quit
15:05justin_smithamalloy: oh, now that I look at the docs, the inner-loop behavior is not explicitly described but it is evident in the output of the example given
15:05hellofunkif you had three loop parameters instead of my two, and the while did not address the value of the third parameter, hm... (goes to test that out)
15:06amalloyif :while always affected the expression as a whole, it would be no more useful than wrapping the expression with take-while
15:06amalloyby being more fine-grained it makes itself an actually useful operator
15:07amalloy(albeit one that sees little use)
15:11hellofunkwhy does this return the entire sequence i give it: (take-while #(not= % %2) [[0 1] [ 0 0] [ 3 4]])
15:13ridcully_that gives an error
15:13ridcully_you need some destructuring in your predicate
15:13hellofunk well, i'm running a cljs repl, so perhaps the behavior is different than clojure?
15:13hellofunkoh i see what you mean
15:13justin_smithoh yeah, cljs doesn't do arg length checks
15:13amalloyyes, javascript is comically relaxed about arglists
15:13justin_smithtry #(apply not= %)
15:13ridcully_,(take-while (fn [[a b]] (not= a b)) [[0 1] [ 0 0] [ 3 4]])
15:13clojurebot([0 1])
15:14hellofunk gotcha
15:14justin_smith,(take-while #(apply not= %) [[0 1] [ 0 0] [ 3 4]])
15:14clojurebot([0 1])
15:15hellofunkhow interesting that i can leave this channel for a couple years, come back and its the same guys giving out the same quality wisdom. almost like there is some consistency and stability in the universe
15:17amalloy#clojure favors immutability
15:19Para`Is produced advice a side effect, though?
15:20Para`It is an IO process, after all.
16:40hellofunkin reagent, a component is scheduled for a re-render if you deref an atom in a component function. is reagent smart enough to follow this if you call a function inside your component, and that other function does the deref?
16:42random_numbersAn atom is being dereferenced, so I'd presume so.
16:42random_numbersI think the scoping works for you in that case.
16:42hellofunkscoping?
16:45random_numbersProbably the wrong terminology.
16:47turbofailhellofunk: all reagent cares about is whether the atom was dereferenced during the execution of the rendering function
16:47hellofunkturbofail: ok, so it doesn't matter where that happened, how many "levels deep" of nested function calls the deref occurred?
16:47turbofailhellofunk: yeah
16:47turbofailhellofunk: it also means it might not work for a deref that happens within a lazy sequence
16:48turbofailsee https://github.com/reagent-project/reagent/issues/18
16:48random_numbersInteresting.
16:49hellofunknice link, thanks
19:32technomancywhat's up with people who put a newline before their arglist even if there's no docstring
19:33xulferHeh don't know. I guess maybe they're planning on adding one later? :P
19:33amalloyregularity with functions that have docstrings, i assumed
19:33xulferThough I would use a TODO for that if it were me
19:46technomancyI am having a hard time bringing myself to match that style for the functions I add =\
19:48xulferSame, but mostly because I've been mostly doing literate clojure lately.
22:28SeyleriusHow do you compare the runtime of two chunks of clojure code?
22:30SeyleriusFound it. Thanks.
22:31SeyleriusOkay. Our test conditions in `cond2` take `8.290295 msecs`, while the same test in `cond` takes `0.628934 msecs`.
22:31SeyleriusWhoops, wrong chan.
22:35SeyleriusOkay. I'm trying to sell someone on macros. Can y'all give me your best "Couldn't do this without a macro" examples?
22:37matthavenerSeylerius: core.async go blocks
22:38matthavenerSeylerius: cond-> (without tons of anonymous fns)
22:38SeyleriusExample, matthavener?
22:38SeyleriusOoh, that one looks great.
22:40TimMctechnomancy: Why would you ever add a defn without a docstring? :-)
22:41SeyleriusTimMc: Ah, shit, are docstrings build with macros?
22:42TimMcSeylerius: FSVO "build", yeah, but I was responding to a different thread of conversation.
22:42SeyleriusHeh.