workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
clojurians
clojure
boy this is a thorny use case then
2017-11-22T12:02:05.000010
Kalyn
clojurians
clojure
it's generally impossible to test whether a sequence is lazy or not
2017-11-22T12:02:46.000058
Kareen
clojurians
clojure
I was hoping there is an idiomatic way of confirming the streaming nature of a program
2017-11-22T12:02:50.000670
Kalyn
clojurians
clojure
other than opening a profiler....
2017-11-22T12:03:02.000188
Kalyn
clojurians
clojure
there is an idiomatic way to avoid having to know that
2017-11-22T12:04:30.000111
Kareen
clojurians
clojure
use transducers and build a pipeline of transformations
2017-11-22T12:04:36.000533
Kareen
clojurians
clojure
I wouldn't use lazy seqs to build streaming pipelines
2017-11-22T12:05:35.000499
Kareen
clojurians
clojure
esp given that the clojure never guarantees *how* lazy things are
2017-11-22T12:06:02.000046
Kareen
clojurians
clojure
okay I get the picture <@Kareen> thanks :slightly_smiling_face:
2017-11-22T12:08:23.000329
Kalyn
clojurians
clojure
care to elaborate how flawed laziness is though? "esp given that the clojure never guarantees *how* lazy things are"
2017-11-22T12:08:51.000497
Kalyn
clojurians
clojure
<@Kalyn> it's really easy to go from 1-el-at-a-time to chunk-at-a-time laziness in clojure
2017-11-22T12:12:52.000470
Kareen
clojurians
clojure
<@Johnathon> come to <#C053AK3F9|beginners> and we'll dig through it
2017-11-22T12:13:02.000483
Willow
clojurians
clojure
because clojure makes no guarantees about the laziness granularity and it's free to use what's more performant
2017-11-22T12:13:15.000740
Kareen
clojurians
clojure
ok
2017-11-22T12:13:18.000178
Johnathon
clojurians
clojure
but if you're using laziness to stream, that's often not the behaviour you'd expect
2017-11-22T12:13:34.000327
Kareen
clojurians
clojure
<@Kareen> what's wrong with chunks? a chunk of 32 is orders of magnitude smaller than e.g. a file with million lines... it will guarantee 32 lines in memory at a time, compared to a million lines had the entire file been realized
2017-11-22T12:14:19.000620
Kalyn
clojurians
clojure
I am very wrong in that?
2017-11-22T12:14:25.000543
Kalyn
clojurians
clojure
nothing's wrong with chunks
2017-11-22T12:14:37.000400
Kareen
clojurians
clojure
but if your element is not an atomic value but a big expensive collection, then you might not have space for 10 elements in memory
2017-11-22T12:15:03.000354
Kareen
clojurians
clojure
understood
2017-11-22T12:15:17.000406
Kalyn
clojurians
clojure
again, it depends on what you need to do, but if you're aiming to build a streaming pipeline, reach for transducers which were designed for that (among others) use-case in mind
2017-11-22T12:15:38.000185
Kareen
clojurians
clojure
well indeed, next time I'll start with transducers, but for my simple use case this once, it seems laziness is enough, given the issue (in my use case) is collection size, not element size
2017-11-22T12:16:32.000534
Kalyn
clojurians
clojure
How do I open cider inspector with value of last expression evaluated while stepping? I tried `cider-inspect` but it does nothing
2017-11-22T13:26:18.000715
Mei
clojurians
clojure
Anyone here have much experience with <https://github.com/oliyh/martian>? I am trying to get the martian/bootstrap method working with a simple get request. Here's a simplified version of what I am seeing: ```;Works (client/get "<http://myservice/myfunction>" {:query-params {:arg 1}}) ;Fails (let [m (martian/bootstrap "<http://myservice>" [{:route-name :myservice ;Is this for path params? If so, how would I do query-params? :path-parts ["/myfunction/" :arg] :method :get :path-schema {:arg s/Int}}])] (martian/response-for m :myservice {:arg 1}))``` I can't seem to get the martian version to work. Any ideas? It seems like I should be specifying query-params instead or something like that.
2017-11-22T13:59:14.000519
Monet
clojurians
clojure
FYI: I've tried a variety of different options like ``` ;Fails (let [m (martian/bootstrap "<http://myservice>" [{:route-name :myservice :path-parts ["/myfunction/"] :query-params [:arg] :method :get}])] (martian/response-for m :myservice {:arg 1}))``` I've also tried a :path key, and others. No dice.
2017-11-22T14:15:22.000501
Monet
clojurians
clojure
FYI you only need one assoc call there, it’s vararg
2017-11-22T15:48:14.000408
Margaret
clojurians
clojure
is there a way to add dependencies to my `project.clj` without visiting github all the time and copying package name + version ?
2017-11-22T17:42:48.000148
Tameka
clojurians
clojure
I’m using vim btw
2017-11-22T17:43:03.000051
Tameka
clojurians
clojure
<@Tameka> The only thing I've seen like that is this leiningen plugin: <https://github.com/johnwalker/lein-plz>
2017-11-22T17:45:47.000074
Liza
clojurians
clojure
this is amazing! :smile:
2017-11-22T17:57:19.000159
Tameka
clojurians
clojure
I love the command too
2017-11-22T17:57:25.000208
Tameka
clojurians
clojure
thank you <@Liza>
2017-11-22T17:57:32.000285
Tameka
clojurians
clojure
No problem.
2017-11-22T17:57:43.000100
Liza
clojurians
clojure
is `reloaded.repl` supposed to run the server at the same time?
2017-11-22T19:12:00.000005
Tameka
clojurians
clojure
it says ``` Started server on 8080 :resumed ``` but then localhost:8080 isn’t working
2017-11-22T19:12:27.000026
Tameka
clojurians
clojure
that’s when I run `(reset)` in my repl
2017-11-22T19:12:42.000198
Tameka
clojurians
clojure
this is my simple `user.clj` ``` (ns ring-it.user (:require [reloaded.repl :refer [system reset stop]] [ring-it.core])) (reloaded.repl/set-init! #'ring-it.core/create-system) ```
2017-11-22T19:13:50.000090
Tameka
clojurians
clojure
has no one ever used reloaded.repl? :confused:
2017-11-22T19:45:51.000084
Tameka
clojurians
clojure
<@Tameka> I’m guessing the channel is going to be less active right now because the US has a big holiday which for many people starts with traveling tonight or early tomorrow morning
2017-11-22T19:56:52.000070
Margaret
clojurians
clojure
I bet you’ll get replies if you ask this weekend or Monday
2017-11-22T19:57:25.000086
Margaret
clojurians
clojure
*reloaded workflow* coined by stuartsierra, a clojure workflow as demonstrated with *Component* <https://cb.codes/a-tutorial-of-stuart-sierras-component-for-clojure/> weavejester adopted the workflow with <https://github.com/weavejester/reloaded.repl>, <https://github.com/weavejester/integrant>
2017-11-22T20:01:16.000051
Lovie
clojurians
clojure
<@Lovie>, I went through all of those :slightly_smiling_face: perhaps there’s an issue with the version.. thanks anyway
2017-11-22T20:09:54.000045
Tameka
clojurians
clojure
is there a way to say {:keys [ .... ]} AND assert that none of them are nil ?
2017-11-22T20:24:33.000112
Berry
clojurians
clojure
sorry, Bravi, didn't see you raise issue but a general question
2017-11-22T20:41:27.000052
Lovie
clojurians
clojure
all good, I figured it out :slightly_smiling_face:
2017-11-22T21:02:32.000077
Tameka
clojurians
clojure
thanks!
2017-11-22T21:02:37.000073
Tameka
clojurians
clojure
only default values
2017-11-22T22:23:13.000041
Marty
clojurians
clojure
<@Berry> I can't think of a way that doesn't involve duplication... can you give a bit more context?
2017-11-22T23:17:17.000079
Daniell
clojurians
clojure
For example, you can do `{:keys [a b c] :as data}` but `data` will be the whole of what you bind, not just those keys...
2017-11-22T23:17:56.000031
Daniell
clojurians
clojure
(or maybe `(every? some? [a b c])` for whatever keys you destructure?)
2017-11-22T23:29:23.000060
Daniell
clojurians
clojure
sorry, I meant to say: (let [{:keys [a b c]} ... ] (assert a) (assert b) (assert c)) ^-- is there a shorthand for this
2017-11-23T01:39:40.000076
Berry
clojurians
clojure
<@Berry> Well, I'd say `(assert (every? some? [a b c]))` is going to be clearer as the number of keys increases.
2017-11-23T01:41:58.000139
Daniell
clojurians
clojure
<@Berry> maybe try `:or` syntax: `{:keys [foo bar baz] :or {foo 42 baz 1 baz 99}}`
2017-11-23T01:42:01.000013
Verna
clojurians
clojure
<@Verna> That's not what he's asking tho' -- he doesn't want defaults, he wants failure-on-nil.
2017-11-23T01:42:30.000152
Daniell
clojurians
clojure
I don't want default values -- if a field is nil, it should assert and die, as something went wrong
2017-11-23T01:42:35.000110
Berry
clojurians
clojure
<@Daniell>: I think your solution is opt, if I try to write amacro, it becomes very messy as I have to basically parse destructuring
2017-11-23T01:43:14.000191
Berry
clojurians
clojure
Ah I see now. So, you could either to assert every value or use clojure.spec
2017-11-23T01:43:59.000025
Verna
clojurians
clojure
You could probably write a macro that expands to `(let {{:keys ~keys} ~value] (assert (every? some? ~keys)) ...)`
2017-11-23T01:44:26.000143
Daniell
clojurians
clojure
That would remove the repetition...
2017-11-23T01:44:58.000206
Daniell
clojurians
clojure
yeah, but this wouldn't play well with multi part let-destructs, like ``` (let [{:keys [...]} objA {:keys [...]} objB] ...) ```
2017-11-23T01:45:01.000087
Berry
clojurians
clojure
You'd have to have it nested... which I think logically it would need to be, given the fail-on-nil requirement?
2017-11-23T01:45:38.000052
Daniell
clojurians
clojure
oh; I'm okay with destructure all the things, then do fail on hnil
2017-11-23T01:45:58.000027
Berry
clojurians
clojure
it's okay to destructure objB even if some part of objA is nil, they're not 'nested', they're two separate objects
2017-11-23T01:46:15.000138
Berry
clojurians
clojure
Well, then write the macro to do that :slightly_smiling_face:
2017-11-23T01:46:32.000095
Daniell
clojurians
clojure
I was hoping I could to {:keys [a b c] :no-nil true} objA :slightly_smiling_face:
2017-11-23T01:46:58.000157
Berry
clojurians
clojure
But still, take a look at clojure.spec. It has useful `instrument` function that wraps another function with data checks. And having schemes declared explicitly makes your code more clear. Instead, checking data every time in place leads to spagetty code.
2017-11-23T01:49:54.000120
Verna
clojurians
clojure
<@Berry> You could indeed write such a macro... <@Verna> `instrument` has an overhead that you might not want to pay in production. It is better to be explicit with `s/valid?` or `s/assert`.
2017-11-23T01:51:34.000034
Daniell
clojurians
clojure
And relying on `instrument` when you actually want the `nil`-checks performed explicitly in production is definitely not something I'd recommend (as a heavy user of spec myself).
2017-11-23T01:52:16.000113
Daniell
clojurians
clojure
I'm familiar with spec
2017-11-23T01:53:24.000096
Berry
clojurians
clojure
I'd actually want something even morespecy- .... only allows keys taht are part of s/keys of the spec
2017-11-23T01:53:38.000037
Berry
clojurians
clojure
<@Daniell> yes, agree with your points.
2017-11-23T01:53:42.000051
Verna
clojurians
clojure
but I don't know how to formulate that
2017-11-23T01:53:43.000208
Berry
clojurians
clojure
If you have a spec with `s/keys`, you can call `s/form` on it and destructure to get the list of `:req` or `:req-un` keys. Then you can programmatically use that key list to validate the data.
2017-11-23T01:55:25.000148
Daniell
clojurians
clojure
(if the spec is more complex -- say `s/and` over `s/keys` -- then you'll need to do some work there... and maybe you'll need to parse `s/merge` etc so it depends how "smart" you might want to be?)
2017-11-23T01:56:13.000267
Daniell
clojurians
clojure
You could of course write a spec for those keys where each value was specified as non-`nil`able... but you'd still have to call `s/valid?` or something...
2017-11-23T01:57:28.000149
Daniell
clojurians
clojure
```boot.user=&gt; (s/def ::foo (s/keys :req-un [::a ::b ::c])) :boot.user/foo boot.user=&gt; (s/form ::foo) (clojure.spec.alpha/keys :req-un [:boot.user/a :boot.user/b :boot.user/c]) boot.user=&gt; (let [[_ _ keys] (s/form ::foo)] (println (map name keys))) (a b c) nil```
2017-11-23T02:02:30.000046
Daniell
clojurians
clojure
1. <@Daniell>: this is very cool, `s/form` is awesome and I will be using it in the future 2. asserting that the value associated with the key is non-nil does NOT solve my problem my problem is that I sometimes specify the wrong key -- i.e. the key doesn't even exist in the map -- that's the problem I'm trying to solve
2017-11-23T02:26:13.000067
Berry
clojurians
clojure
<@Mirna> beware though, that you might hit some surprises, especially with exception handling (exception invisible until you deref the future - unless you wrap the future body with try-catch explicitly). Check also <https://github.com/TheClimateCorporation/claypoole>
2017-11-23T02:59:15.000001
Terra
clojurians
clojure
I use s/form a lot, both in my spec serialize library, and to be able to edit a map based on the spec, it’s great.
2017-11-23T03:05:22.000093
Daine
clojurians
clojure
<@Berry> metosin/spec-tools has a s/form parser, it extracts the keys from s/keys (also s/merge ones), and utilities for dropping out undefined keys.
2017-11-23T05:10:46.000314
Alla
clojurians
clojure
Hmm, maybe `cycle` could also have an `n` argument, like `repeat` has
2017-11-23T06:07:09.000171
Johana
clojurians
clojure
<@Johana> <https://dev.clojure.org/jira/browse/CLJ-1412>
2017-11-23T06:19:35.000246
Kareen
clojurians
clojure
<@Kareen> Voted.
2017-11-23T06:20:54.000250
Johana
clojurians
clojure
<@Kareen> is 1412 like `take`? I somehow expected it to be like doing `(take (* n (count s)) (cycle s))`
2017-11-23T07:06:29.000023
Jodie
clojurians
clojure
But I'm not sure that's what it does based on reading it
2017-11-23T07:06:40.000358
Jodie
clojurians
clojure
yes that's what it does
2017-11-23T07:08:17.000026
Kareen
clojurians
clojure
so that would change its degree of laziness
2017-11-23T07:10:29.000267
Margaret
clojurians
clojure
but of course if you count on a precise amount of laziness, you are probably doing something wrong
2017-11-23T07:10:51.000386
Margaret
clojurians
clojure
what do you mean?
2017-11-23T07:11:28.000233
Kareen
clojurians
clojure
because you count the collection argument
2017-11-23T07:11:38.000060
Margaret
clojurians
clojure
so I would assume it would realize the full input if it was lazy, right away, where the original would be lazier
2017-11-23T07:12:04.000211
Margaret
clojurians
clojure
hmm, never mind, looks like cycle already forces the arg
2017-11-23T07:12:39.000194
Margaret
clojurians
clojure
oh, a chunk, of course ```+user=&gt; (def c (cycle (map print (range 1000)))) 012345678910111213141516171819202122232425262728293031#'user/c ```
2017-11-23T07:13:31.000103
Margaret
clojurians
clojure
so that would change from realizing 32 items to realizing 1000
2017-11-23T07:13:45.000077
Margaret
clojurians
clojure
hi everyone. if anyone uses spacemacs, could you tell me how to switch between open panes please? :smile: there’s literally no tutorial I could find that says this
2017-11-23T14:32:06.000054
Tameka
clojurians
clojure
<@Margaret> the impl in that ticket doesn't actually count anyway
2017-11-23T14:33:05.000138
Kareen
clojurians
clojure
I know I can mouse-click, but there’s gotta be a keyboard shortcut I think
2017-11-23T14:33:09.000125
Tameka
clojurians
clojure
Hello people! We making a study group about Clojure in Brazil. This table of contents is good to beginners learn the language? <https://github.com/training-center/clojure-study-group/blob/master/material/roadmap.md>
2017-11-23T14:59:01.000056
Bradley
clojurians
clojure
<@Bradley> maybe interacting with the JVM could be earlier? (or at least an intro to the useful stuff about figuring out how java stuff works - what to look for in javadoc for example?)
2017-11-23T15:17:31.000034
Margaret
clojurians
clojure
Maybe into second session, <@Margaret>?
2017-11-23T16:11:13.000072
Bradley