workspace
stringclasses
4 values
channel
stringclasses
4 values
text
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
clojurians
clojure
Nobody has mentioned elixir yet?
2017-11-09T07:39:35.000102
Merri
clojurians
clojure
I bet lumo would run on the pi as well.
2017-11-09T07:40:40.000044
Merri
clojurians
clojure
:slightly_smiling_face:
2017-11-09T07:41:17.000258
Darci
clojurians
clojure
<@Darci> lfe is quite solid/stable
2017-11-09T07:44:22.000161
Weston
clojurians
clojure
ok... so I may give that a try.
2017-11-09T07:45:03.000174
Darci
clojurians
clojure
but even tho clojerl is younger it looks more appealing, lfe inherits from a lot of common lisp idioms
2017-11-09T07:45:03.000280
Weston
clojurians
clojure
yeah... well, I can bet it'll be stable and try clojerl. No harm done in the first months anyway :slightly_smiling_face:
2017-11-09T07:45:42.000281
Darci
clojurians
clojure
it's prolly super alpha but it's moving fast it looks like
2017-11-09T07:46:02.000261
Weston
clojurians
clojure
:+1:
2017-11-09T07:46:27.000022
Darci
clojurians
clojure
<@Celina> I prefer to only have a few keys in my mongo document (basically whatever needs indexing) plus an embedded transit string
2017-11-09T07:53:19.000046
Margaret
clojurians
clojure
because this allows using all the core clojure data types (plus whatever else I implement readers / writers for as needed)
2017-11-09T07:53:45.000292
Margaret
clojurians
clojure
monger will auto-convert all map keys to strings going in, and by default will turn those into keywords coming out, which leads to terrible things like `{1 :a}` (key is a number) becoming `{:1 "a"}` (key is a terrible, illegal keyword)
2017-11-09T07:55:02.000281
Margaret
clojurians
clojure
<https://github.com/cognitect/transit-clj>
2017-11-09T07:57:02.000123
Margaret
clojurians
clojure
Thanks <@Margaret> we are converting the keys to strings befor insertion and it seems to be working
2017-11-09T07:59:41.000479
Celina
clojurians
clojure
right, my point directly to your question is that "namespaced keys" can't exist in mongo without you encoding
2017-11-09T08:00:51.000479
Margaret
clojurians
clojure
yeah I see that now
2017-11-09T08:01:06.000268
Celina
clojurians
clojure
whether it's a simple assumption like "if there's a / that's namespaced and it should be a keyword" or a more advanced usage like embedding a full encoded clojure data payload (my choice has been the latter - it simplifies a lot of things)
2017-11-09T08:01:47.000341
Margaret
clojurians
clojure
`IllegalAccessException class clojure.core$bean$fn__5975$fn__5976 cannot access a member of class sun.management.MemoryImpl (in module java.management) with modifiers "public" jdk.internal.reflect.Reflection.newIllegalAccessException (Reflection.java:361)` (i'm on java9)
2017-11-09T08:10:30.000540
Jutta
clojurians
clojure
1. In namespace foo.bar , I created a keyword ::apple 2. In namespace snip, I did (:require [foo.bar :as fb]) 3. I'm trying to use fb/:apple ... but am getting an 'no such var error 4. Is there a wa yot refer to a keyword in a namespace via the alias ?
2017-11-09T10:43:07.000674
Berry
clojurians
clojure
<@Berry> use `::fb/apple`
2017-11-09T10:44:46.000122
Daniell
clojurians
clojure
<@Daniell>: works; thanks
2017-11-09T10:45:15.000670
Berry
clojurians
clojure
The `::` auto-resolves the alias.
2017-11-09T10:45:28.000369
Daniell
clojurians
clojure
You'll see that a lot if you do XML manipulation, with the XML namespaces :wink:
2017-11-09T10:46:33.000204
Mallie
clojurians
clojure
Or use spec...
2017-11-09T10:47:53.000270
Daniell
clojurians
clojure
This is from spec use. For the past few days, I've been thinking "getting errors with deep stacks is really annoying -- wouldn't it be great if, for each function, I had two functions: one to check if the input is correct format one to actually evaluate and the check-correct-format function is run before hand" -- then I realize I just rediscovered spec
2017-11-09T10:51:36.000112
Berry
clojurians
clojure
i think you just rediscovered pre/post conditions rather than spec :)
2017-11-09T10:53:32.000071
Kareen
clojurians
clojure
<@Kareen>: good point, those all the 'pre-conditions' are checks of the form 'this var has the following shape' -- and the shapes are composable
2017-11-09T10:55:43.000416
Berry
clojurians
clojure
honestly the jvm can be hard to reason about anyway, especially when you add clojure's runtime on top of that.
2017-11-09T12:10:23.000411
Evelin
clojurians
clojure
My project depends on two libraries that both depend on respectively `some-lib 1.1.1` and `some-lib 1.1.2`. According to `lein deps :tree`, `some-lib 1.1.1` is pulled in. I thought newest version would win in this case?
2017-11-09T13:55:23.000052
Laurette
clojurians
clojure
Oh, btw, I get a warning when running `lein deps :tree` that may explain it in the concrete case: ``` [bidi "2.1.2"] -&gt; [prismatic/schema "1.1.3"] overrides [io.nervous/eulalie "0.6.11-SNAPSHOT"] -&gt; [prismatic/plumbing "0.5.5" :exclusions [org.clojure/clojure]] -&gt; [prismatic/schema "1.1.7"] ``` So how come `bidi` overrides in this case?
2017-11-09T13:59:32.000430
Laurette
clojurians
clojure
there is no “newest wins” logic - you can use :exclusions, or ensure that the the dep walking finds the version you want before the other one (including explicitly adding the one you want earlier in the list)
2017-11-09T14:00:46.000458
Margaret
clojurians
clojure
it uses the first one it finds, and it searches from the beginning of your deps vector to the end
2017-11-09T14:01:11.000456
Margaret
clojurians
clojure
<@Margaret> I tried putting `eulalie` on top without any luck. Maybe the dependency path length is taken into account?
2017-11-09T14:02:15.000431
Laurette
clojurians
clojure
hmm - that could be
2017-11-09T14:02:53.000403
Margaret
clojurians
clojure
Okay. Anyway, thanks for the pointer. I ended up adding an explicit dependency to `prismatic/schema "1.1.7"`, and I’ll ask the bidi project to bump the version
2017-11-09T14:03:40.000191
Laurette
clojurians
clojure
Hi. I have a problem with HugSQL used with Postgres (`[com.layerware/hugsql "0.4.7"]`, `[org.postgresql/postgresql "42.1.3"]`). This code: ``` (try (db/persist-job-invocation data) (catch java.sql.SQLException e (println "=================== caught java.sql.SQLException") (println (type e)) (println (type (.getCause e))) (println "===================")) (catch Exception e (println "=================== caught Exception") (println (type e)) (println (type (.getCause e))) (println "==================="))) ``` throws a useful SQL exception wrapped in a useless java.lang.Exception. ``` =================== caught Exception java.lang.Exception java.sql.BatchUpdateException =================== ``` How to catch the real wrapped exception? Do I have to unwrap and raise the exception each time I call a HugSQL-generated DB function?
2017-11-09T15:13:34.000175
Lino
clojurians
clojure
<@Lino> Take a look at the stacktrace and see what code is wrapping the exception. I _thought_ that `clojure.java.jdbc` made sure to throw bare `java.sql.SQLExceptions` wherever it could, so maybe HugSQL is catching and rewrapping it?
2017-11-09T15:24:49.000438
Daniell
clojurians
clojure
HugSQL does this in the generated DB functions: ``` (catch Exception e (adapter/on-exception a e)))))))) ``` The default adapter method: ``` (on-exception [this exception] (throw exception))) ``` Could this cause it? (I'll reproduce it and get an exception in a sec)
2017-11-09T15:26:30.000207
Lino
clojurians
clojure
<https://gist.github.com/not-raspberry/413fc99d5cc352f402770355a95568a7>
2017-11-09T15:36:57.000128
Lino
clojurians
clojure
&gt; Caused by: java.lang.Exception: Exception in :persist-job-invocation So it looks like that's hugsql.
2017-11-09T15:37:29.000066
Lino
clojurians
clojure
Found the issue in conman. <https://github.com/luminus-framework/conman/issues/44>
2017-11-09T15:40:38.000065
Lino
clojurians
clojure
Downgrading conman helped.
2017-11-09T15:45:17.000228
Lino
clojurians
clojure
does anyone know if Juxt's Clojure radar is geting an update? [ 2016 versoin: <https://juxt.pro/radar.html>]
2017-11-09T16:02:26.000115
Antonietta
clojurians
clojure
Is there any way to adjust the `:tag` metadata on a local binding?
2017-11-09T16:43:02.000072
Delois
clojurians
clojure
``` (defn len [x] (let [x (vary-meta x assoc :tag String)] (.length x))) ``` still produces a reflection warning.
2017-11-09T16:43:24.000220
Delois
clojurians
clojure
do you mean the fn arg or the let binding?
2017-11-09T16:43:59.000090
Guillermo
clojurians
clojure
for the latter I write `(let [^String x .......] ........)`
2017-11-09T16:44:50.000357
Guillermo
clojurians
clojure
Either, really - in this case I’m trying to use the let binding to adjust the meta on the fn arg.
2017-11-09T16:44:50.000675
Delois
clojurians
clojure
Yeah - thinking about it, what I’m trying to do doesn’t make sense.
2017-11-09T16:45:06.000081
Delois
clojurians
clojure
it needs to go on the left-hand-side...the way you have it written it is tagged at runtime, not at compile time
2017-11-09T16:45:36.000581
Guillermo
clojurians
clojure
I was hoping to be able to calculate the tag value at runtime, but of course that affects compilation.
2017-11-09T16:45:41.000157
Delois
clojurians
clojure
yeah you can't dynamically modify at runtime without reflection.
2017-11-09T16:46:01.000458
Guillermo
clojurians
clojure
I was up both late and early, is my excuse.
2017-11-09T16:46:02.000090
Delois
clojurians
clojure
lol. welcome to NZ
2017-11-09T16:46:08.000034
Guillermo
clojurians
clojure
Lein 2.8.0 switched Aether to a new version which has moved from Sonatype to Eclipse
2017-11-09T16:46:52.000387
Delois
clojurians
clojure
So all the package names of the classes have changed.
2017-11-09T16:47:04.000316
Delois
clojurians
clojure
Even though the code is basically the same.
2017-11-09T16:47:16.000614
Delois
clojurians
clojure
Just trying to figure out the best way to handle that.
2017-11-09T16:47:30.000484
Delois
clojurians
clojure
hi guys
2017-11-09T16:49:46.000007
Mallory
clojurians
clojure
which is better? (-&gt; ll rest butlast butlast) or (subvec ll 1 (-&gt; ll count dec dec))
2017-11-09T16:50:50.000592
Mallory
clojurians
clojure
or if there is something better than both please refer it?
2017-11-09T16:51:10.000032
Mallory
clojurians
clojure
<@Mallory> subvec should perform quite better, assuming II is a vector
2017-11-09T16:54:37.000043
Kristy
clojurians
clojure
subvec surely leverages structural sharing, my guess is it's an instant operation
2017-11-09T16:55:17.000342
Kristy
clojurians
clojure
`(-&gt; v pop pop rest)`
2017-11-09T16:55:35.000417
Guillermo
clojurians
clojure
(or subvec)
2017-11-09T16:55:45.000468
Guillermo
clojurians
clojure
`butlast` is linear
2017-11-09T16:55:56.000071
Guillermo
clojurians
clojure
like `last`
2017-11-09T16:56:00.000313
Guillermo
clojurians
clojure
thanks guys
2017-11-09T16:57:02.000351
Mallory
clojurians
clojure
another question
2017-11-09T17:03:01.000238
Mallory
clojurians
clojure
what is the best way to for ["hello" "world"] to swap first two characters in this list to get ["ehllo" "owrld"] ?
2017-11-09T17:03:50.000639
Mallory
clojurians
clojure
i can do it in ugly way
2017-11-09T17:04:28.000641
Mallory
clojurians
clojure
like:
2017-11-09T17:04:30.000512
Mallory
clojurians
clojure
(mapv (fn [w] (let [l (vec w) tmp (get l 0)] (-&gt; l (assoc 0 (get l 1)) (assoc 1 tmp) )) ["hello" "world"])
2017-11-09T17:06:34.000051
Mallory
clojurians
clojure
i feel it's ugly way to do this
2017-11-09T17:06:42.000515
Mallory
clojurians
clojure
is there elegant way to this?
2017-11-09T17:06:50.000574
Mallory
clojurians
clojure
that's exactly i have
2017-11-09T17:13:01.000269
Mallory
clojurians
clojure
(-&gt;&gt; ["hello" "world"] (mapv (fn [w] (let [l (vec w) tmp (get l 0)] (-&gt; l (assoc 0 (get l 1)) (assoc 1 tmp))))) (mapv #(apply str %)))
2017-11-09T17:13:03.000379
Mallory
clojurians
clojure
```(-&gt;&gt; ["hello" "world" ""] (map (fn [w] (let [split-index (min (count w) 2)] (str (apply str (reverse (subs w 0 split-index))) (subs w split-index))))))```
2017-11-09T17:19:48.000138
Jonas
clojurians
clojure
<@Jonas> what makes your version more elegant ?
2017-11-09T17:21:59.000159
Mallory
clojurians
clojure
it depends on who you ask
2017-11-09T17:22:15.000003
Jonas
clojurians
clojure
i want your prespective
2017-11-09T17:22:32.000320
Mallory
clojurians
clojure
I prefer this way of writing it because I think it emphasizes what you’re trying to do
2017-11-09T17:22:46.000163
Jonas
clojurians
clojure
what makes my version is less elegant in your prespective ?
2017-11-09T17:23:10.000335
Mallory
clojurians
clojure
the fact that you’re swapping letters is a little harder to see
2017-11-09T17:24:11.000499
Jonas
clojurians
clojure
and the fact that you’re using assoc and manipulating vectors makes it harder to tell you’re doing string manipulation
2017-11-09T17:24:47.000049
Jonas
clojurians
clojure
another try is ```(-&gt;&gt; ["hello" "world" ""] (map (fn [[first-letter second-letter &amp; other-letters]] (apply str second-letter first-letter other-letters))))```
2017-11-09T17:25:04.000008
Jonas
clojurians
clojure
yeah last version is better for me
2017-11-09T17:25:33.000018
Mallory
clojurians
clojure
which matches your problem description a little more closely
2017-11-09T17:25:38.000153
Jonas
clojurians
clojure
the `reverse` in my first version is a little closer to the “swap” part of “swap the first two characters”
2017-11-09T17:27:13.000456
Jonas
clojurians
clojure
&gt; what is the best way to for ["hello" "world"] to swap first two characters in this list to get ["ehllo" "owrld"] ? also worth nothing that what you really care about is the string function. dealing with vectors is trivial and a separate concern by reducing problems to their essence, you get to think more clearly :slightly_smiling_face:
2017-11-09T17:27:20.000260
Kristy
clojurians
clojure
the other thing I would consider is that in <@Mallory>’s example, the “swapping the first two letters” gets split up into two pieces
2017-11-09T17:28:35.000544
Jonas
clojurians
clojure
first the swap and then turning it back into a string
2017-11-09T17:28:44.000539
Jonas
clojurians
clojure
so even if you were going to do it that way, I would combine both pieces into one function since I think of swapping the first two letters of a string as one operation
2017-11-09T17:29:30.000091
Jonas
clojurians
clojure
like ```(-&gt;&gt; ["hello" "world"] (mapv (fn [w] (let [l (vec w) tmp (get l 0)] (-&gt; l (assoc 0 (get l 1)) (assoc 1 tmp) (-&gt;&gt; (apply str)))))))```
2017-11-09T17:30:14.000046
Jonas
clojurians
clojure
the other point I would make is that `tmp` isn’t very descriptive
2017-11-09T17:31:48.000583
Jonas
clojurians
clojure
just using good names can help readability a lot imo ```(-&gt;&gt; ["hello" "world"] (mapv (fn [w] (let [l (vec w) first-letter (first l) second-letter (second l)] (-&gt; l (assoc 0 second-letter) (assoc 1 first-letter) (-&gt;&gt; (apply str)))))))```
2017-11-09T17:33:58.000048
Jonas
clojurians
clojure
<@Jonas> as a suggestion, you can replace that let block with `(let [[first-letter second-letter] w] ...)`
2017-11-09T17:35:30.000084
Margaret
clojurians
clojure
oh, you need it to be a vector never mind
2017-11-09T17:36:08.000233
Margaret
clojurians
clojure
`(let [[first-letter second-letter &amp; trailing] w] (apply str second-letter first-letter trailing))`
2017-11-09T17:37:07.000175
Margaret
clojurians
clojure
one of my snippets above is very similar to that one
2017-11-09T17:37:25.000282
Jonas