workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
clojurians
clojure
ah, it should be `~@(for` instead of `~(for`
2017-12-17T21:15:38.000064
Berry
clojurians
clojure
<https://pragprog.com/book/shcloj3/programming-clojure-third-edition>
2017-12-18T00:07:12.000033
Daniell
clojurians
clojure
Did you guys checked <https://github.com/EntilZha/PyFunctional> ? I'm wondering if I could create a similar project with clojurescript.
2017-12-18T02:11:45.000263
Jami
clojurians
clojure
Hi, I use ``` (defn gen-handler [k] (eval `(defn ^::blocking ~(symbol (str (name k) "-handler")) [state#] (try (handlers/do-handler state#) initial-state (finally (run *agent*)))))) ``` to define function at runtime, but it appears the new `xxx-handler` function was defined at `clojure.core` namespace, not the namespace which `gen-handler` was called or defined. How to define a function at runtime at the current namespace? Thanks!
2017-12-18T02:45:23.000254
Tari
clojurians
clojure
``` (def □ 20 ) □ (comment 20) ``` so it clearly works however, according to <https://clojure.org/reference/reader#_symbols> is this guaranteed to work? in particular, it states: ``` Symbols begin with a non-numeric character and can contain alphanumeric characters and *, +, !, -, _, ', and ? (other characters may be allowed eventually). ``` and I do not know how unicode is defined wrt to alphanumeric
2017-12-18T02:49:56.000186
Berry
clojurians
clojure
<@Tari> have you considered using macro that this use case ?
2017-12-18T03:19:42.000108
Jami
clojurians
clojure
<@Jami> I am not sure, does macro different with function in this use case?
2017-12-18T03:20:30.000079
Tari
clojurians
clojure
at every thread the `agent` runs in, I use `(gen-handler k)` to generate a handler to do a specific job.
2017-12-18T03:22:02.000317
Tari
clojurians
clojure
this handler is generated using the keyword `k` so I can later using keyword `k` to get the function's name and call this function.
2017-12-18T03:23:21.000188
Tari
clojurians
clojure
do you have a specific reason to define top-level function with defn ? It might be more appropriate to create anonymous function with lambda
2017-12-18T03:24:24.000410
Jami
clojurians
clojure
like in this case, where I define two handler functions ``` (defn pipe "Create a parallel pipeline." [xf in out err] (let [n ncpu close? true to (async/chan n) from (-&gt; in line-seq async/to-chan) ln-handler (fn [x] (writeln out x)) ex-handler (fn [x] (writeln err x))] (async/go-loop [] (when-let [ln (async/&lt;! to)] (ln-handler ln) (recur))) (async/pipeline-blocking n to xf from close? ex-handler))) ```
2017-12-18T03:24:45.000188
Jami
clojurians
clojure
<@Berry> Not sure what you mean by "is it guaranteed to work"? Do you mean, will it ever change in a future version of Clojure? It is unlikely that it will change, as the Clojure core team likes to maintain backwards compatibility, but I don't think they or anyone else can make you some kind of binding promise about it.
2017-12-18T04:11:35.000062
Micha
clojurians
clojure
I believe the Eclipse Public License is pretty much a guarantee that you can use all versions of Clojure released under that as long as you want to, but that may not be what you are asking about.
2017-12-18T04:19:08.000232
Micha
clojurians
clojure
<@Micha>: re "unicode in clojure", my current understanding is: 1. unicode var names works in 1.9.0 2. unicode var names is NOT promised to work according to clojure docs 3. I'm curious whether I can rely on unicode var names working in the future
2017-12-18T06:41:33.000179
Berry
clojurians
clojure
:water_buffalo:
2017-12-18T07:46:50.000166
Sanford
clojurians
clojure
:water_buffalo:
2017-12-18T07:49:07.000159
Sanford
clojurians
clojure
Is there a way in `Pedestal` to automatically reject http requests that is not accepted by the application depending on `Content-type´? I tried the above code but I think I didn’t undestand what pedestal does ```(ns job-queue.service (:require [io.pedestal.http :as http] [io.pedestal.http.route.definition :refer [defroutes]] [io.pedestal.http.body-params :as body-params] [ring.util.response :as ring-resp] [io.pedestal.http.content-negotiation :as conneg] [io.pedestal.http.route :as route] [job-queue.api.agent-api :refer [add-agent]] [job-queue.api.job-api :refer [get-jobs]])) (def supported-types ["application/json"]) (def content-neg-intc (conneg/negotiate-content supported-types)) (defn home-page [request] (ring-resp/response {:message "pong"})) (defroutes routes [[["/" {:get home-page} ^:interceptors [(body-params/body-params) http/json-body] ;;agent api ["/v1/agents" ^:interceptors [content-neg-intc] {:post add-agent}] (def service {:env :prod ::http/routes routes ::http/resource-path "/public" ::http/type :jetty ::http/port 8080 ::http/container-options {:h2c? true :h2? false :ssl? false}}) ```
2017-12-18T08:01:04.000280
Audie
clojurians
clojure
and my `add-agent` always return `HTTP 200`` ```(defn get-jobs [r] {:status 200 :headers {"content-type" "application/json;charset=utf-8"}})```
2017-12-18T08:02:26.000283
Audie
clojurians
clojure
When I send a request with `Content-type` `text/html` the response is `HTTP 200` too
2017-12-18T08:03:34.000108
Audie
clojurians
clojure
Anyone know of any library wrapping an external queue (rabbitmq, Kafka, etc) as clojure.async channels?
2017-12-18T11:12:37.000797
Twanna
clojurians
clojure
<@Twanna> I’ve done it several times, but getting the semantics right can be tricky
2017-12-18T11:30:10.000939
Sandy
clojurians
clojure
Esp once alt! gets involved
2017-12-18T11:30:33.000504
Sandy
clojurians
clojure
Be wary of claiming to have processed a message that you have merely dumped into a channel
2017-12-18T11:30:47.000056
Hugo
clojurians
clojure
Kafka is probably the easiest since it’s immutable
2017-12-18T11:31:58.000028
Sandy
clojurians
clojure
<@Sandy> any open source library that already does it or did you implement it yourself?
2017-12-18T11:36:53.000061
Twanna
clojurians
clojure
<@Twanna> funny just opened the slack now as i was just doing some coding on this. Spent few hrs today reading through the code, but in terms of alt i still cant figure out how the handler fn callback on take! is NOT called (or is kinda rolled back) for the channels that do not end up first (in the race condition). I have done this kinda implementation few times in past, but alt i always coded myself because of this. I originally thought the mutex between channels is shared, but it does not seem so; the alt-flag locking also does not seem to do the job.... <@Sandy> if there is no available library but you still could point me to the right namespace and line of code that addresses this that would be very much appreciated ... i should be (edit: hopefully) able to figure out the rest....
2017-12-18T11:51:45.000718
Particia
clojurians
clojure
<@Particia> one way or another it would be great to have this as a library
2017-12-18T12:00:09.000573
Twanna
clojurians
clojure
The potentials are huge
2017-12-18T12:00:25.000343
Twanna
clojurians
clojure
hey folks, I want to create a series of videos in order to tech clojure in my local language to those who are interested.
2017-12-18T12:01:29.000523
Darcel
clojurians
clojure
I'm a bit dizzy about the TOC of the course.
2017-12-18T12:02:43.000133
Darcel
clojurians
clojure
do you think that the lisp concepts are important in the beginning ?
2017-12-18T12:03:18.000570
Darcel
clojurians
clojure
or do you know a good presentation or a course in English which i get inspiration from ?
2017-12-18T12:05:15.000383
Darcel
clojurians
clojure
<@Particia> I would recommend thinking about the relationship between the queue and the channels. What do you want to happen if a message is 3 channels deep into your app and the service dies?
2017-12-18T12:09:09.000065
Sandy
clojurians
clojure
What I recommend is instead passing an ack funtion with the message, and then the last thread In your channel chain calls that to tell the queue that the message ha been processed
2017-12-18T12:10:30.000239
Sandy
clojurians
clojure
In short, it’s a mistake to ack the message when it goes onto a channel. Queues are durable, channels are not.
2017-12-18T12:11:14.000049
Sandy
clojurians
clojure
Because `*ns*` is a dynamic var, the “current namespace” is not the one in which the function was defined, it’s the one in which the code is running. If the defn needs to happen in a specific namespace, use `in-ns` to make sure that’s the context. You can also use `intern` which explicitly takes a namespace as an argument.
2017-12-18T12:21:19.000295
Margaret
clojurians
clojure
```Clojure 1.9.0 (ins)user=&gt; (create-ns 'foo.bar) #object[clojure.lang.Namespace 0x5443d039 "foo.bar"] (ins)user=&gt; foo.bar/baz CompilerException java.lang.RuntimeException: No such var: foo.bar/baz, compiling:(NO_SOURCE_PATH:0:0) (ins)user=&gt; (intern 'foo.bar 'baz "hello") #'foo.bar/baz (ins)user=&gt; foo.bar/baz "hello"```
2017-12-18T12:24:24.000543
Margaret
clojurians
clojure
<@Sandy> yes, acking i do once the message is processed, keep that as a function of a message or a session. But what i struggle with is how to leverage existing implementation of alt!!.. I always implemented that myself (usually multiple threads polling/waiting on queues with a use of locking and nacking messages that arrived second) because i couldnt figure out how the take! callback would have to look like so as it would work with the core async alt implementation. So my question is what method in clojure.core.async.impl.protocols.Handler is in charge of the "rollback" in case the alt's take! from a channel finishes second?
2017-12-18T12:38:22.000608
Particia
clojurians
clojure
That’s the problem I think you can avoid. Just keep messages as data and use the default implementations of alt!
2017-12-18T12:42:38.000020
Sandy
clojurians
clojure
Don’t try to do ack as part of an alt!
2017-12-18T12:43:05.000371
Sandy
clojurians
clojure
Not only is it hard to implement, I’m not sure it’s possible to do correctly with a mutable queue.
2017-12-18T12:43:51.000305
Sandy
clojurians
clojure
Thanks guys. This is amazingly useful
2017-12-18T13:50:31.000552
Twanna
clojurians
clojure
<@Darcel> <https://www.braveclojure.com/clojure-for-the-brave-and-true/> Might want to check out <#C053AK3F9|beginners> and ask around there too
2017-12-18T14:19:54.000162
Sharlene
clojurians
clojure
datomic vs postgres for a simple-ish ecommerce site, what are your opinions? I like the temporal nature of datomic, in that if I update facts older transactions remain valid. Vs changing things in a regular rdbms where it can also change prior transactions if not done right. Also the datalog integration with clojure is really nice. But $5000/yr/system ;(
2017-12-18T14:23:15.000128
Williemae
clojurians
clojure
sql through clojure doesn’t seem great, but maybe I’m missing a critical library that helps out a bit (Is HugSQL any good?)
2017-12-18T14:24:04.000098
Williemae
clojurians
clojure
<@Williemae> HugSQL is great! I’ve been incorporating it into my projects more often lately and I love it! I’m a fan of free so I usually go Postgres but that’s just me
2017-12-18T14:27:06.000457
Sharlene
clojurians
clojure
is using `sut` as name of the system under test when creating test namespaces a bad practice?
2017-12-18T14:31:19.000309
Krystina
clojurians
clojure
that's what cider does by default when creating a new test file, but could not really see anywhere if it's a good practice or not
2017-12-18T14:31:51.000015
Krystina
clojurians
clojure
I do not prefer it, I end up changing it to whatever the pattern is for that ns in the rest of the program
2017-12-18T14:33:29.000133
Mia
clojurians
clojure
e.g. `myapp.thing :as sut` -&gt; `myapp.thing :as thing`
2017-12-18T14:33:59.000698
Mia
clojurians
clojure
so I can more easily grep for usages of `thing/foo` and other reasons
2017-12-18T14:34:38.000248
Mia
clojurians
clojure
yeah I also prefer not to use it for that reason
2017-12-18T14:39:58.000396
Krystina
clojurians
clojure
<@Williemae> checkout also `honeySQL` !
2017-12-18T14:45:04.000064
Amado
clojurians
clojure
cool, thanks for the suggestion. I’ll be doing most stuff in stored procs (if I go with postgres) but this looks like a great option for executing those.
2017-12-18T14:46:09.000155
Williemae
clojurians
clojure
er well i guess postgres is a bit different from the last time i did a sql database lol, i see they dont really do stored procs. So nevermind that then!
2017-12-18T14:47:16.000093
Williemae
clojurians
clojure
hello everyone, im trying to generate a fat jar of a main application (its not a webserver it just starts some jobs and then dies), but i keep getting errors `lein with-profile dev uberjar` produces: java.lang.IllegalArgumentException: env variable ‘:db-host’ is not set, compiling:(cfg.clj:17:1) I have a profiles.clj populated with the right env variables, it does work while working inside the repl
2017-12-18T14:47:24.000587
Amado
clojurians
clojure
<@Williemae> they do! <http://www.sqlines.com/postgresql/stored_procedures_functions>
2017-12-18T14:47:51.000198
Amado
clojurians
clojure
ah great….seems my google-fu is weak today
2017-12-18T14:48:05.000362
Williemae
clojurians
clojure
``` ;; foo.cljc (ns foo (:require [clojure.spec.alpha :as s])) (defmacro tm [&amp; lst] `(s/def ~@lst)) ;; bar.cljc (ns bar (:require [foo])) ;; notice, we don't alias spec.alpha (macroexpand-1 '(foo/tm 1 2 3)) ==&gt; (clojure.spec.alpha/def 1 2 3) ``` so it appears the `s/def` is being expanded at DEF MACRO time, not at USE MACRO time. I find this counter intuitive. Can someone explain the machanics by which this is happening ? [ I was expecintg an error saying there is no such namespace in ns bar ]
2017-12-18T15:01:32.000022
Berry
clojurians
clojure
macros are expanded at macroexpansion time
2017-12-18T15:08:33.000424
Aldo
clojurians
clojure
if you want to expand them at runtime then you need eval
2017-12-18T15:08:53.000356
Aldo
clojurians
clojure
In order to avoid capturing and re-using some symbol in `bar`, ordinary symbols are expanded before you leave `foo`. You would need ```(defmacro tm2 [&amp; lst] `(~'s/def ~@lst))``` to quote the use of `s/def` to carry that over and pick up whatever that meant in the environment you are expanding in (here, `bar`)
2017-12-18T15:08:56.000159
Heide
clojurians
clojure
<@Aldo>: is 'macroexpansion' time (1) when macro is defined or (2) when macro is used ?
2017-12-18T15:10:49.000079
Berry
clojurians
clojure
oh, except the time of expansion is not your issue here. like lukswater said you're just expecting ` to work differently to how it does
2017-12-18T15:10:59.000616
Aldo
clojurians
clojure
<@Heide>: I see the ``` `(~'s/def ``` trick now, thanks!
2017-12-18T15:11:30.000415
Berry
clojurians
clojure
` syntax-quotes a bunch of stuff given the context of its definition
2017-12-18T15:11:35.000109
Aldo
clojurians
clojure
Somewhere there’s an extensive essay on quoting in Clojure macros
2017-12-18T15:11:51.000501
Heide
clojurians
clojure
I'm sure there is, but it's the type of dry stuff that I don't expect to understand until I run into issues of "I expect FOO, but I got BAR"
2017-12-18T15:12:31.001224
Berry
clojurians
clojure
I believe this is it: <https://8thlight.com/blog/colin-jones/2012/05/22/quoting-without-confusion.html>
2017-12-18T15:13:59.000233
Heide
clojurians
clojure
thanks!
2017-12-18T15:15:41.000037
Berry
clojurians
clojure
<@Elizbeth> I was trying to do a DFS in clojure recently and had a similar problem; it didn't seem natural to recur in tail call position. I found an answer in Stuart Sierra's dependency library, it's a little bit terse but way more elegant than anything I came up with. ``` (defn- transitive "Recursively expands the set of dependency relationships starting at (get neighbors x), for each x in node-set" [neighbors node-set] (loop [unexpanded (mapcat neighbors node-set) expanded #{}] (if-let [[node &amp; more] (seq unexpanded)] (if (contains? expanded node) (recur more expanded) (recur (concat more (neighbors node)) (conj expanded node))) expanded))) ```
2017-12-18T15:24:29.000458
Kristan
clojurians
clojure
that's actually very neat
2017-12-18T15:53:10.000440
Elizbeth
clojurians
clojure
i need to examine it a bit more closely to understand it fully
2017-12-18T15:53:39.000728
Elizbeth
clojurians
clojure
thanks :slightly_smiling_face:
2017-12-18T15:54:02.000019
Elizbeth
clojurians
clojure
reminds me of some examples in the Little schemer
2017-12-18T15:54:33.000250
Elizbeth
clojurians
clojure
Oh I need to get that book, was tempted recently because the MIT Press had a 40% off black friday sale
2017-12-18T16:29:02.000616
Kristan
clojurians
clojure
<@Timika>: Great Codemesh talk - I'm loving all of your recent Datomic outreach efforts.
2017-12-18T17:00:08.000311
Rene
clojurians
clojure
thanks
2017-12-18T17:02:23.000149
Timika
clojurians
clojure
Can somebody explain this to me please?
2017-12-18T17:18:21.000227
Augusta
clojurians
clojure
both on cljs (lumo) and the JVM
2017-12-18T17:18:42.000207
Augusta
clojurians
clojure
and
2017-12-18T17:18:46.000449
Augusta
clojurians
clojure
Here's a link to the talk for anyone interested: <https://www.youtube.com/watch?v=nbMMywfBXic>
2017-12-18T17:22:07.000143
Afton
clojurians
clojure
it looks like clojurescript is confusing reduce and transduce somewhere
2017-12-18T17:26:37.000247
Rebeca
clojurians
clojure
the first example has a one item collection and the second has two items
2017-12-18T17:27:45.000399
Jonas
clojurians
clojure
the first example will never use the function to combine elements
2017-12-18T17:28:07.000089
Jonas
clojurians
clojure
because there is only one element
2017-12-18T17:28:12.000065
Jonas
clojurians
clojure
whereas the second example will
2017-12-18T17:28:23.000213
Jonas
clojurians
clojure
(yeah, I misread that)
2017-12-18T17:28:39.000555
Rebeca
clojurians
clojure
<@Augusta> that behavior is explicit in `reduce`'s docstring
2017-12-18T17:29:43.000479
Kareen
clojurians
clojure
`If coll has only 1 item, it is returned and f is not called.`
2017-12-18T17:29:54.000137
Kareen
clojurians
clojure
I understand that boot/lein uses JVM. I understand that Macro system uses JVM. Right now, in Clojure dev, I use cider to talk to a JVM repl -- is there anyway to make it practical to talk to a node.js repl instead ?
2017-12-18T17:29:55.000085
Berry
clojurians
clojure
i think you want `inf-clojure`
2017-12-18T18:09:26.000221
Willow
clojurians
clojure
No, I'm not after an emacs mode.
2017-12-18T18:22:43.000162
Berry
clojurians
clojure
CIDER is basically nREPL middleware so it's JVM only. Can you explain what you think you want to connect to a Node.js REPL?
2017-12-18T19:13:41.000235
Daniell
clojurians
clojure
<@Berry> Clojurescript projects and tools like <https://github.com/anmonteiro/lumo> will connect (transpile) your Clojurescript code to a node.js host. You can also call node.js libraries.
2017-12-18T19:29:56.000335
Evie
clojurians
clojure
Socket repls are completely possible.
2017-12-18T19:40:53.000069
Sandy
clojurians
clojure
lumo and planck both support socket repls. As does the CLR.
2017-12-18T19:41:38.000094
Sandy
clojurians
clojure
<@Daniell>: my current setup is client side = cljs; server side = clj via jvm ;; I am considering changing server side to cljs via nodejs
2017-12-18T22:05:30.000147
Berry
clojurians
clojure
but it's not clear to me how to get a 'cljs repl on nodejs' on the server side
2017-12-18T22:05:44.000147
Berry
clojurians
clojure
<@Sandy>: are those meant as dev environments, or a way to write shell scripts in cljs ?
2017-12-18T22:06:03.000241
Berry