#clojure logs

2016-05-10

00:35TEttinger...yeah screw Kotlin. apparently I'm hitting a compiler bug that is scheduled to be fixed in 1.0.2, but there's no workaround currently?
00:50tolstoyMaybe just make a small inlein (or whatever) script and try the hardest problem and see what it looks like?
00:57TEttingerI guess. trying to remember what inlein is
00:58TEttingerah, windows may make that tricky :)
01:02tolstoyAh.
01:03tolstoyI guess I was advising what I wish I did more often: timebox a bit on the hardest problem and see what it looks like.
01:03tolstoyHelps if you know the problem, I guess.
01:54ilevddysfun, mpg raise an error java.lang.IllegalArgumentException: No matching clause: int4 then I'm trying insert {:a 1 :b 2} to jsonb field
01:54ilevd*when
02:03dysfunilevd: hrm?
02:04dysfunpaste code?
02:05ilevd(reference.data.pages/add-page (:jdbc t1) "4" "class" "url" {:a 1 :b 2} )
02:05ilevdIllegalArgumentException No matching clause: int4 mpg.data/patch/fn--19517 (data.clj:47)
02:06ilevd (insert! jdbc :pages {:url url
02:06ilevd :type type
02:06ilevd :content content
02:06ilevd :full_name url
02:06ilevd :version_id version-id}))
02:06dysfuncan you pastebin enough code that i can make it fail please?
02:07ilevdSec
02:09dysfunand i have literally just woken up, so bear with me :)
02:11amalloyyou have a (case ...), where the value being dispatched on is "int4", or something that prints like that, and there's no clause in the case matching it
02:14dysfunthing is, as that's during insertion, it should be taking the type (against which the case is performed) from jdbc
02:15dysfunhttps://github.com/mpg-project/mpg/blob/master/src/mpg/data.clj#L47
02:17dysfunthe only way i could see that failing was if you tried to shove a map in an int column
03:13ilevddysfun, https://www.refheap.com/118885
03:14ilevdSomething wrong with order when using jsonb
03:17dysfunthanks, let me play with it a bit
03:17ilevd*without "references .."
03:30dysfunsorry, what precisely is 'jdbc' here?
03:30dysfuni wrapped the clojure.java.jdbc api so i didn't have to deal with all the intricacies
03:32ilevd#reference.components.jdbc.JDBC{:config {:subprotocol "postgresql",
03:32ilevd :subname "//localhost:5432/db",
03:32ilevd :classname "org.postgresql.Driver",
03:32ilevd :user "user",
03:32ilevd :password "pass",
03:32ilevd :stringtype "unspecified"},
03:32ilevd :conn {:datasource #object[com.mchange.v2.c3p0.ComboPooledDataSource
03:32ilevd 0x28be5ba2
03:32ilevd "com.mchange.v2.c3p0.ComboPooledDataSource[ identityToken -> z8kfsx9g16hbakekppxyi|28be5ba2, dataSourceName -> z8kfsx9g16hbakekppxyi|28be5ba2 ]"]}}
03:32lumaplease use pastebin or similar instead of pasting directly to the channel
03:32dysfunokay, in future please pastebin anything longer than a couple of lines
03:33ilevdOk)
03:33dysfunhttps://gist.github.com/jjl/0f71cbbecf8169d51366aaf624c31ae9
03:34dysfunthis is why i find jdbc infuriating
03:39namragreetings
03:39ronbonertno u
03:45namrai want to write some tests for an http api that uses compojure as a routing library and ring-mock to mock http requests but i get the following error (with example code): http://pastebin.com/7Eric6SK
03:53kwladykanamra as i see you try to mock the route, you should use some url to also test a route. Like in the original example https://github.com/ring-clojure/ring-mock
03:54kwladykanamra just see what request return, it will help you a lot
03:54namrakwladyka: thanks alot
03:55namrabut the problem was caused by a (reload!)
03:55namrarunning 'lein ring server'
03:55namraand as soon as i change something and do a reload
03:55namrathe tests fail with that error
04:06hamid:O
04:11dysfunhow is it that postgres can have versions of every docs ever live for the database but only HEAD docs for the jdbc bindings?
04:12dysfuni mean who the hell is deploying an under-development release of postgres to production?
04:12dysfunor the jdbc drivers even
09:38RovanionA function of mine takes a map. I want to check if the map contains a key - and then replace it with something else - before passing on the map. So (when (contains? map :key) do what exactly?)
09:40ridcully_you want to replace the key or the value?
09:41RovanionThe value.
09:41ridcully_assoc
09:41RovanionThanks!
09:43ridcully_but note, when using `when` you return nil, if the key is not there
09:48justin_smithyeah, (if (contains? m k) (assoc m k v) m) is probably what you want
09:49RovanionYes, that looks more like it. Thank you both!
09:50justin_smith,(let [m {:a 0}] (cond-> m (contains? m :a) (assoc :a :foo) (contains? m :b) (assoc :b :bar))) ; if you are doing this with multiple keys
09:50clojurebot{:a :foo}
09:53RovanionAh, a chaining of conditions all evaluated independently.
09:54justin_smiththe conditions are independent, but the transforms are additive (if applied)
09:54justin_smith,(let [m {:a 0 :b 1 :c 2}] (cond-> m (contains? m :a) (assoc :a :foo) (contains? m :b) (assoc :b :bar))) ; if you are doing this with multiple keys
09:54clojurebot{:a :foo, :b :bar, :c 2}
09:55RovanionCool
09:56abrunberaudYop
10:10dysfunhttps://gist.github.com/jjl/d92dc6f7675cd23d0f1c870e72443f8f # finally finished my monster of a macro faking the state monad
10:13justin_smithdysfun: what about replacing (map #(symbol (str "r" %)) (range (count clauses))) with (repeatedly (count clauses) #(gensym "r"))
10:14dysfunooh that would shorten it
10:15justin_smithalso wouldn't break if the user had symbols like r0 in their form
10:15justin_smith,(gensym "r")
10:15clojurebotr27
10:15justin_smithhaha, well
10:15dysfunyes, though i considered it unlikely
10:16dysfunand it makes it more annoying verifying the correctness for output :)
10:16justin_smith,(= r28 (gensym "r"))
10:16clojurebot#error {\n :cause "Unable to resolve symbol: r28 in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: r28 in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: r28 in this conte...
10:16justin_smithergh
10:16justin_smith,(= 'r28 (gensym "r"))
10:16clojurebotfalse
10:16dysfunand i just realised i can replace the (gensym "state") with `state#
10:16justin_smiththat's a good one too
10:17dysfunokay, well it still appears to work :)
10:18dysfunhttps://gist.github.com/jjl/d92dc6f7675cd23d0f1c870e72443f8f
10:18dysfun(same gist)
10:18justin_smith👍
10:19dysfunnice. apparently lxterminal doesn't like unicode
10:19justin_smithit was just a thumbs-up
10:19dysfunit's still long and ugly
10:21justin_smithdysfun: what about postgrey.squirrel.util/init - I would expect to see 123 instead of that
10:21dysfunaha yes
10:22dysfuni was about to use it, so i'd have soon found that ;)
10:22justin_smithdysfun: I don't think there is any symbol to qualify in that form starting on line 21 - it's all values generated in the containing let, so you don't need ` there
10:22justin_smiththough ~@ can be handy
10:22dysfunyes, i'm quoting precisely because of interpolation
10:23dysfunit's like a sort of fucked up template language
10:23justin_smithhaha
10:24dysfunokay, now interpolating the initial value as well
10:24dysfunand all looks good enough for actually trying to use it
10:24dysfunthen again i said that a minute ago...
11:45sdegutisWhy come this does not work,
11:46sdegutis,(> (java.util.Date.) (java.util.Date.))
11:46clojurebot#error {\n :cause "java.util.Date cannot be cast to java.lang.Number"\n :via\n [{:type java.lang.ClassCastException\n :message "java.util.Date cannot be cast to java.lang.Number"\n :at [clojure.lang.Numbers gt "Numbers.java" 229]}]\n :trace\n [[clojure.lang.Numbers gt "Numbers.java" 229]\n [sandbox$eval25 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval25 invoke "NO_SOURCE_FILE" -1]\n [cloj...
11:46luma> can only compare numbers
11:46justin_smithcompare, on the other hand
11:47justin_smith,(compare (java.util.Date.) (java.util.Date.))
11:47clojurebot0
11:49sdegutis,(->> #(compare (java.util.Date.) (java.util.Date.)) (repeatedly 100000) (distinct))
11:49clojurebot(0 -1)
11:49sdegutishaha clojure you so craaazay
11:49sdegutisSo, you know about Ken M right?
11:49justin_smithof course
11:50justin_smithbest idiot ever
11:50sdegutisIt doesn't work so well on Reddit https://www.reddit.com/user/___kenm
11:51sdegutisThey're too good of a target audience, they just downvote him, which hides his comments.
11:51sdegutisIt only works on Yahoo News and Facebook because comments are listed there in chronological order.
11:52sdegutisI wonder if Datomic's < and > use (compare) internally.
12:02ilevd<offtop> Elm 0.17 is appeared http://elm-lang.org/blog/farewell-to-frp </offtop>
12:02sdegutisWhy doesn't Clojure's > and < use compare internally?
12:02ridcully_,(.before (java.util.Date. 0) (java.util.Date.))
12:02clojurebottrue
12:02sdegutisAlso <= and => that would make it nicer.
12:03sdegutisridcully_: unfortunately there is no .beforeOrEqual, it just must be .before with the arguments reversed
12:03justin_smithsdegutis: the numeric method is faster
12:03sdegutisor (or (.before) (.equal))
12:03sdegutisjustin_smith: now I understand this
12:06ridcully_,(>= (.getTime (java.util.Date.)) (.getTime (java.util.Date.)))
12:06clojurebottrue
12:16OscarZis there something like (if-not-nil (myfunc xxx) default-value) which would evaluate to (myfunc xxx) if its not nil, and otherwise to default-value ?
12:17lumathere's (or (my-func xxx) default-value, but that also evaluates to default-value if (myfunc xxx) is false (in addition to nil)
12:18OscarZthanks luma, i think that works for me
12:18justin_smithOscarZ: also, there is fnil
12:18justin_smith,((fnil inc 0) nil)
12:18clojurebot1
12:18justin_smith,((fnil inc 0) 2)
12:18clojurebot3
12:21OscarZjustin_smith, yeah was looking at fnil but didnt understand it first.. now i do :)
12:27justin_smithOscarZ: the only difference from what you asked for is that it returns a new function, and you provide a default input, not a default result
12:28OscarZso fnil identity would be what i want?
12:30OscarZyes, seems to work
12:31justin_smithbut or is more straightforward than (fnil identity default)
12:31OscarZi was sure there was something like what i asked as "nil" seems to be pretty special value and often used like that... i guess "or" is very close though
12:56sdegutisjustin_smith: wow another use for fnil
12:56sdegutisOscarZ: will myfunc ever return false?
12:59sdegutisI've not once used fnil in my code. It's usually overkill because false rarely turns up alongside nil.
12:59sdegutisOh wait, no, we use fnil three times.
12:59sdegutisBut every single time it's (fnil inc 0)
13:00dysfunfnil fnil fnil? is that like flatmap flatmap flatmap?
13:00justin_smithsdegutis: (fnil conj #{}) and (fnil conj []) are also very useful
13:00sdegutisjustin_smith: hmm interesting
13:02justin_smith,(reduce (fn [m [k v]] (update m k (fnil conj #{}) v)) {} '[[a 0][b 1][b 2][a 0][c 3]])
13:02clojurebot{a #{0}, b #{1 2}, c #{3}}
13:16sdegutisjustin_smith: I wonder if reduce-kv can be used there
13:16justin_smithsdegutis: well, the input isn't a value hash-map
13:16justin_smith(and wasn't meant to be)
13:20sdegutisok
13:27sdegutisMustery solved:
13:27sdegutisFound in stack trace: java.util.Date/compareTo, clojure.lang.Util/compare, datomic.extensions/<
13:27sdegutisHooray
13:29dysfunthose bizarre errors sure do sell datomic to me
13:29sdegutisdysfun: no no that's me truncating the stack trace to show the lineage
13:30sdegutisdysfun: (cont'd) lineage which proves that < does in fact use clojure's compare function
13:31sdegutiswell not technically, but basically
13:31sdegutissince clojure.core/compare uses clojure.lang.Util/compare internally
13:31dysfunyou know, in several channels i hang out in, if you said "well not technically, but basically", someone would change the topic to quote you and embarrass you
13:33justin_smithsdegutis: datomic's < you mean
13:34sdegutisin my cont'd statment yes
13:34sdegutisdysfun: how is that embarrassing
13:34sdegutisi mean, yes, we all know technically correct is the best kind of correct
13:34sdegutisbut basically correct is also acceptable often
13:35dysfunwell it seems to me that this is quite clearly a falsificable fact, ergo they're the same thing
14:08ben_vulpesif anyone's looking for short-term contract work, i'd like a hand with a postback clojure app over the next 4 weeks. PM for details, introductions happily accepted. local to portland would make me giddy, although possible to work around.
15:31{blake}You know, I had it in my head that that one was going to happen in 2016 or 2017. Couldn't figure out why I hadn't heard anything abou it.
15:31kwladykaanybody with good emacs experience and Intellij Idea + Cursive can say something clever? :) I consider to learn emacs, because it is like religion.... society demand it in some way, it determine how others see you :) If you use emacs you are pro :) Bla bla... back to my question, somebody use both and can say something in topic?
15:31ridcully_you might have confused 2017 with 2037
15:31ridcully_or some windows version goes boom soon
15:31marcy--can someone tell me how to get a clojure repl up with a dependency without relying on lein/boot? calling `require` after `java -cp "clojure.jar:dependency.jar" clojure.main` is not working.
15:31{blake}ridcully: Yeah, might be. There's some kind of twist on the Mayan-end-of-the-world thing that falls on 2017, too.
15:32justin_smithmarcy--: that works, if all your deps are in that cp
15:32justin_smithmarcy--: for example, you probably want the directory with your source-files to be in that cp arg
15:32justin_smitheg java -cp clojure.jar:src:dependency.jar clojure.main
15:32justin_smiththe "" is not needed
15:33justin_smith(unless your deps paths have wierd names, of course)
15:33engblomkwladyka: I am in the minority as I do not use Emacs for programming. I have many times been giving it a chance and it is very decent for developing programs in any Lisp dialect. Personally I am using the "rivalling" editor which is called vim.
15:34engblomkwladyka: Regardless if you go with emacs or vim (both are getting the task done), you will have to experience a steep learning curve that will pay off later
15:40justin_smithrequire only works with an ns form, otherwise (load-file ...) will handle anything you throw at it
15:40justin_smithanything that would work in a repl, of course
15:41justin_smithone could also nitpick about *file* not being bound, and that thing that makes gen-class work...
15:42dysfunyeah, so it's actually not all that clear cut