2017-06-26
| 03:25 | dysfun | i'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:31 | Rovanion | dysfun: And if a conformer gives a truthy value the input is valid? |
| 04:31 | dysfun | if a conformer returns something other than ::s/invalid, it is valid |
| 04:32 | dysfun | under the hood, everything is based on conformers |
| 04:32 | Rovanion | Sounds better. |
| 04:32 | dysfun | i'm left thinking it was a mistake to make predicates the basis of declaration |
| 04:33 | dysfun | predicates can be trivially wrapped to conformer-ise them |
| 04:34 | Rovanion | I 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:34 | dysfun | but under the hood it uses conformers |
| 04:34 | dysfun | when you call s/valid? that is a call to conform and checking it didn't return ::s/invalid |
| 04:38 | Rovanion | You're absolutely correct. That is strange. |
| 04:38 | dysfun | i 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:13 | osfabibisi | ooo, you can use `conj` as a confusing synonym for `merge` |
| 05:13 | dysfun | o_O |
| 05:13 | ridcully_ | "here is my conj request" |
| 05:13 | dysfun | ,(conj {:a :b} {:c :d}) |
| 05:13 | clojurebot | {:a :b, :c :d} |
| 05:46 | dysfun | anyway, clearly the correct terminology is 'rebase request' |
| 05:48 | Rovanion | I request that you rebase your code on mine! |
| 07:57 | dysfun | https://gist.github.com/jjl/67658ccfff52a9cfb5b82f124bb2c82e # thoughts? |
| 07:58 | dysfun | (mainly from spec users) |
| 07:58 | dysfun | not finished, obviously |
| 08:12 | osfabibisi | some of your indentation is broken |
| 08:12 | osfabibisi | in the :require |
| 08:13 | osfabibisi | looks like a nice approach |
| 09:00 | dysfun | thanks |
| 09:00 | dysfun | it's changed considerably since i started it |
| 11:54 | assoc-in` | DOes anyone know how to get the pretty printing like (clojure.pprint/pprint map) to output to a log file using timbre? |
| 12:07 | justin_smith | assoc-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:21 | assoc-in | justin_smith: awesome that worked perfectly. I hadn't heard of with-out-str before |
| 12:22 | justin_smith | one 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:22 | justin_smith | which can bite you if you try to println debug |
| 15:01 | hellofunk | the 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:01 | hellofunk | so what i don't understand is why this variant with the :while doesn't short circuit immediately: |
| 15:01 | hellofunk | (for [x (range 3) y (range 3) :while (not= x y)] [ x y]) |
| 15:02 | hellofunk | instead, it returns: ([1 0] [2 0] [2 1]) |
| 15:03 | justin_smith | yeah, I've never really understood the behavior of the :while key to be honest |
| 15:03 | amalloy | :while only terminates the innermost loop |
| 15:03 | amalloy | so it gives up on finding any y fitting with x=0, and then starts over with x=1 |
| 15:04 | hellofunk | oh, so :while can cause multiple inner loops to quit, rather htan the whole for expression to quit |
| 15:05 | justin_smith | amalloy: 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:05 | hellofunk | if 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:06 | amalloy | if :while always affected the expression as a whole, it would be no more useful than wrapping the expression with take-while |
| 15:06 | amalloy | by being more fine-grained it makes itself an actually useful operator |
| 15:07 | amalloy | (albeit one that sees little use) |
| 15:11 | hellofunk | why does this return the entire sequence i give it: (take-while #(not= % %2) [[0 1] [ 0 0] [ 3 4]]) |
| 15:13 | ridcully_ | that gives an error |
| 15:13 | ridcully_ | you need some destructuring in your predicate |
| 15:13 | hellofunk | well, i'm running a cljs repl, so perhaps the behavior is different than clojure? |
| 15:13 | hellofunk | oh i see what you mean |
| 15:13 | justin_smith | oh yeah, cljs doesn't do arg length checks |
| 15:13 | amalloy | yes, javascript is comically relaxed about arglists |
| 15:13 | justin_smith | try #(apply not= %) |
| 15:13 | ridcully_ | ,(take-while (fn [[a b]] (not= a b)) [[0 1] [ 0 0] [ 3 4]]) |
| 15:13 | clojurebot | ([0 1]) |
| 15:14 | hellofunk | gotcha |
| 15:14 | justin_smith | ,(take-while #(apply not= %) [[0 1] [ 0 0] [ 3 4]]) |
| 15:14 | clojurebot | ([0 1]) |
| 15:15 | hellofunk | how 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:17 | amalloy | #clojure favors immutability |
| 15:19 | Para` | Is produced advice a side effect, though? |
| 15:20 | Para` | It is an IO process, after all. |
| 16:40 | hellofunk | in 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:42 | random_numbers | An atom is being dereferenced, so I'd presume so. |
| 16:42 | random_numbers | I think the scoping works for you in that case. |
| 16:42 | hellofunk | scoping? |
| 16:45 | random_numbers | Probably the wrong terminology. |
| 16:47 | turbofail | hellofunk: all reagent cares about is whether the atom was dereferenced during the execution of the rendering function |
| 16:47 | hellofunk | turbofail: ok, so it doesn't matter where that happened, how many "levels deep" of nested function calls the deref occurred? |
| 16:47 | turbofail | hellofunk: yeah |
| 16:47 | turbofail | hellofunk: it also means it might not work for a deref that happens within a lazy sequence |
| 16:48 | turbofail | see https://github.com/reagent-project/reagent/issues/18 |
| 16:48 | random_numbers | Interesting. |
| 16:49 | hellofunk | nice link, thanks |
| 19:32 | technomancy | what's up with people who put a newline before their arglist even if there's no docstring |
| 19:33 | xulfer | Heh don't know. I guess maybe they're planning on adding one later? :P |
| 19:33 | amalloy | regularity with functions that have docstrings, i assumed |
| 19:33 | xulfer | Though I would use a TODO for that if it were me |
| 19:46 | technomancy | I am having a hard time bringing myself to match that style for the functions I add =\ |
| 19:48 | xulfer | Same, but mostly because I've been mostly doing literate clojure lately. |
| 22:28 | Seylerius | How do you compare the runtime of two chunks of clojure code? |
| 22:30 | Seylerius | Found it. Thanks. |
| 22:31 | Seylerius | Okay. Our test conditions in `cond2` take `8.290295 msecs`, while the same test in `cond` takes `0.628934 msecs`. |
| 22:31 | Seylerius | Whoops, wrong chan. |
| 22:35 | Seylerius | Okay. I'm trying to sell someone on macros. Can y'all give me your best "Couldn't do this without a macro" examples? |
| 22:37 | matthavener | Seylerius: core.async go blocks |
| 22:38 | matthavener | Seylerius: cond-> (without tons of anonymous fns) |
| 22:38 | Seylerius | Example, matthavener? |
| 22:38 | Seylerius | Ooh, that one looks great. |
| 22:40 | TimMc | technomancy: Why would you ever add a defn without a docstring? :-) |
| 22:41 | Seylerius | TimMc: Ah, shit, are docstrings build with macros? |
| 22:42 | TimMc | Seylerius: FSVO "build", yeah, but I was responding to a different thread of conversation. |
| 22:42 | Seylerius | Heh. |