2016-05-10
| 00:35 | TEttinger | ...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:50 | tolstoy | Maybe just make a small inlein (or whatever) script and try the hardest problem and see what it looks like? |
| 00:57 | TEttinger | I guess. trying to remember what inlein is |
| 00:58 | TEttinger | ah, windows may make that tricky :) |
| 01:02 | tolstoy | Ah. |
| 01:03 | tolstoy | I 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:03 | tolstoy | Helps if you know the problem, I guess. |
| 01:54 | ilevd | dysfun, mpg raise an error java.lang.IllegalArgumentException: No matching clause: int4 then I'm trying insert {:a 1 :b 2} to jsonb field |
| 01:54 | ilevd | *when |
| 02:03 | dysfun | ilevd: hrm? |
| 02:04 | dysfun | paste code? |
| 02:05 | ilevd | (reference.data.pages/add-page (:jdbc t1) "4" "class" "url" {:a 1 :b 2} ) |
| 02:05 | ilevd | IllegalArgumentException No matching clause: int4 mpg.data/patch/fn--19517 (data.clj:47) |
| 02:06 | ilevd | (insert! jdbc :pages {:url url |
| 02:06 | ilevd | :type type |
| 02:06 | ilevd | :content content |
| 02:06 | ilevd | :full_name url |
| 02:06 | ilevd | :version_id version-id})) |
| 02:06 | dysfun | can you pastebin enough code that i can make it fail please? |
| 02:07 | ilevd | Sec |
| 02:09 | dysfun | and i have literally just woken up, so bear with me :) |
| 02:11 | amalloy | you 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:14 | dysfun | thing is, as that's during insertion, it should be taking the type (against which the case is performed) from jdbc |
| 02:15 | dysfun | https://github.com/mpg-project/mpg/blob/master/src/mpg/data.clj#L47 |
| 02:17 | dysfun | the only way i could see that failing was if you tried to shove a map in an int column |
| 03:13 | ilevd | dysfun, https://www.refheap.com/118885 |
| 03:14 | ilevd | Something wrong with order when using jsonb |
| 03:17 | dysfun | thanks, let me play with it a bit |
| 03:17 | ilevd | *without "references .." |
| 03:30 | dysfun | sorry, what precisely is 'jdbc' here? |
| 03:30 | dysfun | i wrapped the clojure.java.jdbc api so i didn't have to deal with all the intricacies |
| 03:32 | ilevd | #reference.components.jdbc.JDBC{:config {:subprotocol "postgresql", |
| 03:32 | ilevd | :subname "//localhost:5432/db", |
| 03:32 | ilevd | :classname "org.postgresql.Driver", |
| 03:32 | ilevd | :user "user", |
| 03:32 | ilevd | :password "pass", |
| 03:32 | ilevd | :stringtype "unspecified"}, |
| 03:32 | ilevd | :conn {:datasource #object[com.mchange.v2.c3p0.ComboPooledDataSource |
| 03:32 | ilevd | 0x28be5ba2 |
| 03:32 | ilevd | "com.mchange.v2.c3p0.ComboPooledDataSource[ identityToken -> z8kfsx9g16hbakekppxyi|28be5ba2, dataSourceName -> z8kfsx9g16hbakekppxyi|28be5ba2 ]"]}} |
| 03:32 | luma | please use pastebin or similar instead of pasting directly to the channel |
| 03:32 | dysfun | okay, in future please pastebin anything longer than a couple of lines |
| 03:33 | ilevd | Ok) |
| 03:33 | dysfun | https://gist.github.com/jjl/0f71cbbecf8169d51366aaf624c31ae9 |
| 03:34 | dysfun | this is why i find jdbc infuriating |
| 03:39 | namra | greetings |
| 03:39 | ronbonert | no u |
| 03:45 | namra | i 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:53 | kwladyka | namra 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:54 | kwladyka | namra just see what request return, it will help you a lot |
| 03:54 | namra | kwladyka: thanks alot |
| 03:55 | namra | but the problem was caused by a (reload!) |
| 03:55 | namra | running 'lein ring server' |
| 03:55 | namra | and as soon as i change something and do a reload |
| 03:55 | namra | the tests fail with that error |
| 04:06 | hamid | :O |
| 04:11 | dysfun | how is it that postgres can have versions of every docs ever live for the database but only HEAD docs for the jdbc bindings? |
| 04:12 | dysfun | i mean who the hell is deploying an under-development release of postgres to production? |
| 04:12 | dysfun | or the jdbc drivers even |
| 09:38 | Rovanion | A 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:40 | ridcully_ | you want to replace the key or the value? |
| 09:41 | Rovanion | The value. |
| 09:41 | ridcully_ | assoc |
| 09:41 | Rovanion | Thanks! |
| 09:43 | ridcully_ | but note, when using `when` you return nil, if the key is not there |
| 09:48 | justin_smith | yeah, (if (contains? m k) (assoc m k v) m) is probably what you want |
| 09:49 | Rovanion | Yes, that looks more like it. Thank you both! |
| 09:50 | justin_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:50 | clojurebot | {:a :foo} |
| 09:53 | Rovanion | Ah, a chaining of conditions all evaluated independently. |
| 09:54 | justin_smith | the conditions are independent, but the transforms are additive (if applied) |
| 09:54 | justin_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:54 | clojurebot | {:a :foo, :b :bar, :c 2} |
| 09:55 | Rovanion | Cool |
| 09:56 | abrunberaud | Yop |
| 10:10 | dysfun | https://gist.github.com/jjl/d92dc6f7675cd23d0f1c870e72443f8f # finally finished my monster of a macro faking the state monad |
| 10:13 | justin_smith | dysfun: what about replacing (map #(symbol (str "r" %)) (range (count clauses))) with (repeatedly (count clauses) #(gensym "r")) |
| 10:14 | dysfun | ooh that would shorten it |
| 10:15 | justin_smith | also wouldn't break if the user had symbols like r0 in their form |
| 10:15 | justin_smith | ,(gensym "r") |
| 10:15 | clojurebot | r27 |
| 10:15 | justin_smith | haha, well |
| 10:15 | dysfun | yes, though i considered it unlikely |
| 10:16 | dysfun | and it makes it more annoying verifying the correctness for output :) |
| 10:16 | justin_smith | ,(= r28 (gensym "r")) |
| 10:16 | clojurebot | #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:16 | justin_smith | ergh |
| 10:16 | justin_smith | ,(= 'r28 (gensym "r")) |
| 10:16 | clojurebot | false |
| 10:16 | dysfun | and i just realised i can replace the (gensym "state") with `state# |
| 10:16 | justin_smith | that's a good one too |
| 10:17 | dysfun | okay, well it still appears to work :) |
| 10:18 | dysfun | https://gist.github.com/jjl/d92dc6f7675cd23d0f1c870e72443f8f |
| 10:18 | dysfun | (same gist) |
| 10:18 | justin_smith | 👍 |
| 10:19 | dysfun | nice. apparently lxterminal doesn't like unicode |
| 10:19 | justin_smith | it was just a thumbs-up |
| 10:19 | dysfun | it's still long and ugly |
| 10:21 | justin_smith | dysfun: what about postgrey.squirrel.util/init - I would expect to see 123 instead of that |
| 10:21 | dysfun | aha yes |
| 10:22 | dysfun | i was about to use it, so i'd have soon found that ;) |
| 10:22 | justin_smith | dysfun: 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:22 | justin_smith | though ~@ can be handy |
| 10:22 | dysfun | yes, i'm quoting precisely because of interpolation |
| 10:23 | dysfun | it's like a sort of fucked up template language |
| 10:23 | justin_smith | haha |
| 10:24 | dysfun | okay, now interpolating the initial value as well |
| 10:24 | dysfun | and all looks good enough for actually trying to use it |
| 10:24 | dysfun | then again i said that a minute ago... |
| 11:45 | sdegutis | Why come this does not work, |
| 11:46 | sdegutis | ,(> (java.util.Date.) (java.util.Date.)) |
| 11:46 | clojurebot | #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:46 | luma | > can only compare numbers |
| 11:46 | justin_smith | compare, on the other hand |
| 11:47 | justin_smith | ,(compare (java.util.Date.) (java.util.Date.)) |
| 11:47 | clojurebot | 0 |
| 11:49 | sdegutis | ,(->> #(compare (java.util.Date.) (java.util.Date.)) (repeatedly 100000) (distinct)) |
| 11:49 | clojurebot | (0 -1) |
| 11:49 | sdegutis | haha clojure you so craaazay |
| 11:49 | sdegutis | So, you know about Ken M right? |
| 11:49 | justin_smith | of course |
| 11:50 | justin_smith | best idiot ever |
| 11:50 | sdegutis | It doesn't work so well on Reddit https://www.reddit.com/user/___kenm |
| 11:51 | sdegutis | They're too good of a target audience, they just downvote him, which hides his comments. |
| 11:51 | sdegutis | It only works on Yahoo News and Facebook because comments are listed there in chronological order. |
| 11:52 | sdegutis | I wonder if Datomic's < and > use (compare) internally. |
| 12:02 | ilevd | <offtop> Elm 0.17 is appeared http://elm-lang.org/blog/farewell-to-frp </offtop> |
| 12:02 | sdegutis | Why doesn't Clojure's > and < use compare internally? |
| 12:02 | ridcully_ | ,(.before (java.util.Date. 0) (java.util.Date.)) |
| 12:02 | clojurebot | true |
| 12:02 | sdegutis | Also <= and => that would make it nicer. |
| 12:03 | sdegutis | ridcully_: unfortunately there is no .beforeOrEqual, it just must be .before with the arguments reversed |
| 12:03 | justin_smith | sdegutis: the numeric method is faster |
| 12:03 | sdegutis | or (or (.before) (.equal)) |
| 12:03 | sdegutis | justin_smith: now I understand this |
| 12:06 | ridcully_ | ,(>= (.getTime (java.util.Date.)) (.getTime (java.util.Date.))) |
| 12:06 | clojurebot | true |
| 12:16 | OscarZ | is 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:17 | luma | there's (or (my-func xxx) default-value, but that also evaluates to default-value if (myfunc xxx) is false (in addition to nil) |
| 12:18 | OscarZ | thanks luma, i think that works for me |
| 12:18 | justin_smith | OscarZ: also, there is fnil |
| 12:18 | justin_smith | ,((fnil inc 0) nil) |
| 12:18 | clojurebot | 1 |
| 12:18 | justin_smith | ,((fnil inc 0) 2) |
| 12:18 | clojurebot | 3 |
| 12:21 | OscarZ | justin_smith, yeah was looking at fnil but didnt understand it first.. now i do :) |
| 12:27 | justin_smith | OscarZ: 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:28 | OscarZ | so fnil identity would be what i want? |
| 12:30 | OscarZ | yes, seems to work |
| 12:31 | justin_smith | but or is more straightforward than (fnil identity default) |
| 12:31 | OscarZ | i 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:56 | sdegutis | justin_smith: wow another use for fnil |
| 12:56 | sdegutis | OscarZ: will myfunc ever return false? |
| 12:59 | sdegutis | I've not once used fnil in my code. It's usually overkill because false rarely turns up alongside nil. |
| 12:59 | sdegutis | Oh wait, no, we use fnil three times. |
| 12:59 | sdegutis | But every single time it's (fnil inc 0) |
| 13:00 | dysfun | fnil fnil fnil? is that like flatmap flatmap flatmap? |
| 13:00 | justin_smith | sdegutis: (fnil conj #{}) and (fnil conj []) are also very useful |
| 13:00 | sdegutis | justin_smith: hmm interesting |
| 13:02 | justin_smith | ,(reduce (fn [m [k v]] (update m k (fnil conj #{}) v)) {} '[[a 0][b 1][b 2][a 0][c 3]]) |
| 13:02 | clojurebot | {a #{0}, b #{1 2}, c #{3}} |
| 13:16 | sdegutis | justin_smith: I wonder if reduce-kv can be used there |
| 13:16 | justin_smith | sdegutis: well, the input isn't a value hash-map |
| 13:16 | justin_smith | (and wasn't meant to be) |
| 13:20 | sdegutis | ok |
| 13:27 | sdegutis | Mustery solved: |
| 13:27 | sdegutis | Found in stack trace: java.util.Date/compareTo, clojure.lang.Util/compare, datomic.extensions/< |
| 13:27 | sdegutis | Hooray |
| 13:29 | dysfun | those bizarre errors sure do sell datomic to me |
| 13:29 | sdegutis | dysfun: no no that's me truncating the stack trace to show the lineage |
| 13:30 | sdegutis | dysfun: (cont'd) lineage which proves that < does in fact use clojure's compare function |
| 13:31 | sdegutis | well not technically, but basically |
| 13:31 | sdegutis | since clojure.core/compare uses clojure.lang.Util/compare internally |
| 13:31 | dysfun | you 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:33 | justin_smith | sdegutis: datomic's < you mean |
| 13:34 | sdegutis | in my cont'd statment yes |
| 13:34 | sdegutis | dysfun: how is that embarrassing |
| 13:34 | sdegutis | i mean, yes, we all know technically correct is the best kind of correct |
| 13:34 | sdegutis | but basically correct is also acceptable often |
| 13:35 | dysfun | well it seems to me that this is quite clearly a falsificable fact, ergo they're the same thing |
| 14:08 | ben_vulpes | if 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:31 | kwladyka | anybody 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:31 | ridcully_ | you might have confused 2017 with 2037 |
| 15:31 | ridcully_ | or some windows version goes boom soon |
| 15:31 | marcy-- | 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:32 | justin_smith | marcy--: that works, if all your deps are in that cp |
| 15:32 | justin_smith | marcy--: for example, you probably want the directory with your source-files to be in that cp arg |
| 15:32 | justin_smith | eg java -cp clojure.jar:src:dependency.jar clojure.main |
| 15:32 | justin_smith | the "" is not needed |
| 15:33 | justin_smith | (unless your deps paths have wierd names, of course) |
| 15:33 | engblom | kwladyka: 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:34 | engblom | kwladyka: 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:40 | justin_smith | require only works with an ns form, otherwise (load-file ...) will handle anything you throw at it |
| 15:40 | justin_smith | anything that would work in a repl, of course |
| 15:41 | justin_smith | one could also nitpick about *file* not being bound, and that thing that makes gen-class work... |
| 15:42 | dysfun | yeah, so it's actually not all that clear cut |