#clojure log - Oct 04 2014

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:02 JCvex: dbash: or anyone with lein uberjar experience.

0:02 Is anyone familiar with creating a lein uberjar and calling it from a hadoop or java command line? I run uberjar but I don't see the main class in the file. I've added the :main and :aot in the project.clj and I also have (ns project.name (:gen-class :name project.name)) in the name.clj as well as a (defn -main [])

0:27 danneu: devn: i'd force you to implement a SOAP+WSDL middleman between us until you decide to just enforce a standard data format

0:28 i dont really understand the question youre trying to get at, tho. if i call first on everything and get nil sometimes, what's wrong?

0:30 TEttinger: ,(first nil)

0:30 clojurebot: nil

1:22 dagda1_: how can I update a 2d vector like this (def a [[1 2 3] [1 2 3] [1 2 3]]), how could I update the element at [0 0] to be 3 for example

1:33 joshuafcole: ,(assoc-in [[1 2 3] [1 2 3] [1 2 3]] 0 0 3)

1:33 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (4) passed to: core/assoc-in>

1:34 joshuafcole: ,(assoc-in [[1 2 3] [1 2 3] [1 2 3]] [0 0] 3)

1:34 clojurebot: [[3 2 3] [1 2 3] [1 2 3]]

1:34 joshuafcole: dagda1_

1:34 also see update-in if you want to transform the old value into a new one

1:35 dagda1_: joshuafcole: thanks

1:35 joshuafcole: np

3:05 mantasm: wondering about core.async and pulsar: i understand that channel events are transformed into non-blocking ones, but how about things like database calls and filesystem accesses that block in java code. is there a way around that?

3:09 cfleming: mantasm: No, neither pulsar nor core.async can stop those blocking.

3:09 mantasm: They might provide an API which uses NIO behind the scenes, but you can't convert a blocking call into a non-blocking one.

3:13 mantasm: huh! that's quite bad if i need a jvm thread for every concurrent database access/file read, in something like a web server. i see the appeal of golang and node.js over clojure for highly-concurrent applications.

3:28 dbasch: what makes you think golang or node have any magic that can make blocking calls to outside services nonblocking?

3:34 mantasm: as i understand, they don't. but the calls that are implemented in them tend to be inherently non-blocking. i believe they use OS level constructs to allow for reading/writing to happen evented under the hood. in node, these events are translated into javascript events. in golang, these events turn into gothread wakeups. in clojure, all (most?) libraries rely on a blocking architecture. i can't go use sql korma and core.async toget

3:34 even if there exists a non-blocking library for postgresql (there does!).

3:39 justin_smith: mantasm: korma is just a macro layer over jdbc, and uses whichever jdbc adaptor is loaded

3:41 mantasm: those os level constructs are what java.nio uses, btw

3:42 the main hangup there is that everyone is reluctant to use a version of the jvm that isn't 8 years old

3:45 cfleming: mantasm: Right, node or golang are no different.

3:46 mantasm: justin_smith: as i understand, you can't just "add" to JDBC, i believe it's interface is inherently blocking.

3:46 cfleming: mantasm: Go threads can't magically make blocking OS calls non-blocking either - it needs lib support.

3:47 mantasm: cfleming: but that's the thing, node and go have incredible support for making everything non-blocking. whereas the clojure ecosystem doesn't have that. if i want to use nio, i'm stuck not using vast swaths of jvm libraries, because they block.

3:47 cfleming: mantasm: Which Java/Clojure is perfectly capable of supporting given the right libs. Whether they exist by default is another question.

3:48 mantasm: cfleming: oh i agree entirely, it's an issue of what exists in the libraries today. i've searched, and i can't find a single tutorial/description/anything describing a non-blocking web server making non-blocking database accesses. this is the standard in go and node.

3:48 cfleming: mantasm: btw this is a great read: http://paultyma.blogspot.co.nz/2008/03/writing-java-multithreaded-servers.html

3:48 mantasm: Threads are not that bad these days.

3:49 mantasm: i.e. I'd want to be sure that you really need NIO, after all people write very high-performance code with JDBC

3:59 mantasm: interesting! the mentioned 48k ram/thread on jvm is high compared to golangs elastic 2k ram/thread, but i guess it's not too important in the grand scheme of things. interesting. i may have just been caught up in the non-blocking hype

4:00 perhaps there's no inherent reason for greenthreads to be lighter than os threads.

4:39 dysfun: i've got a really bizarre clojure compilation error telling me that a string cannot be cast to a single. it occurs when it's loading a file with just a namespace declaration with no trimming. the generated code file shows that the namespace name has been turned into a string and then quoted and it's working off that. any ideas?

4:39 s/single/symbol/

4:39 it seems a bit intermittent and lein clean has no effect

4:55 TEttinger: dysfun, pastebin/refheap the code?

4:55 clojure not clojurescript, right?

4:55 dysfun: as i said, intermittent. it's not currently displaying

4:55 yes, clojure

4:55 but i've hit another thing anyway. i've used gen-class and i can't find the class from a clojure module

4:56 i'm using a java api that requires a class to extend an abstract class

4:56 TEttinger: :aot is compiling the ns with gen-class ?

4:56 dysfun: :aot is required for gen-class that isn't main?

4:56 TEttinger: yes

4:57 also required for main, usually

4:57 dysfun: right, with aot on it works now, thanks

4:58 TEttinger: yay

5:01 dysfun: hrm, balancing parens with lots of java imports is tedious. i should probably learn paredit

5:11 AimHere: If you're going to learn paredit ,do so immediately so you can get your fingers programmed appropriately

5:12 It's hard to unlearn your already ossified way of writing code to suit paredit's way of doing things

5:12 dysfun: it's on the list of stuff to do

5:13 but i've been using emacs without it for longer than i care to remember, it's not like i'm going to suddenly cross the line between familiar and hard-wired. that was some while ago :)

5:13 AimHere: Yeah, I find the barrier to paredit isn't so much emacs as the order that I write code in

5:14 dysfun: well i keep thinking "hrm, that operation i've just done almost certainly exists in paredit. why am i writing lisp if i'm not going to be able to transform it like my head is?"

5:36 how do i change the namespace nrepl loads into?

5:36 (from the server side)

6:07 jewhadjihad: if i talk at the speed of shit. do you have to listen

6:07 lol

6:10 philibidobuster: hey i haz a joke...if we all speakachu inkryptwalkershun...then doez mean cuz u no haz stolenz all librariez bookz into urz databzes that you cant play dis game???? go to librarios and steall all booklaotzu then come back.

6:10 lol

6:10 my AI speaks Booklao

6:13 WARdriversFTW: hi everyone. i talk to myself at night

6:13 can you respond

6:14 lol

6:14 hey did you steal my AI.?

6:14 dysfun: would you mind not filling the channel with crap?

6:14 WARdriversFTW: ohio

6:14 i didnt know there were bots in here

6:15 but wait theres more

6:17 Kilocanoe: hey man ill suck yo dick fo 5 dolluhs

6:17 Bronsa: Kilocanoe: cut it out

6:18 gefilltefish: no thank you everyones ass sleep

6:18 but wait theres more

6:18 do you have your VIP6 address

6:18 or you ADD DHD device kode?

6:19 Bronsa: slaughterkillsho: you'll get banned as soon as an op joins if you don't stop with this

6:20 slaughterkillsho: ok i have a torrential tribute problem with clojure. wat to do?

6:20 hey Bronsa

6:20 ur in the wrong internet

6:21 why u in my LAN BRUH

6:21 ?

6:21 its on like donkey kong nagger


6:55 i am so anygry because of functional programming i like much more languages like lisp and c which are not functional

6:55 mirf: dafuq?

6:55 I'll bite

6:55 small-chimp: ?

6:56 * small-chimp is confused

6:56 mirf: me too :D

6:56 lisp isn't functional?

6:57 small-chimp: is lisp is not functional true? or what are yuo talking about

6:57 gfredericks: so we need a european op now?

6:57 mirf: " i like

6:57 much more languages like lisp and c which are not

6:57 functional

6:57 " i like

6:57 much more languages like lisp and c which are not

6:57 functional

6:57 oh fuck

6:58 didn't mean to paste that so many times!

6:58 small-chimp: ?

6:59 if i was a dog i would like to chase my tail because of functional languages

6:59 mirf: recursion!

7:19 m1dnight: If I want to test in a macro is something is a variable name, how do I do that?

7:19 I want to parse "[:message var1 var2]. I want to count how many "arg" things there are.

7:20 Can't seem to test it in the repl because it says undeclared obviously

7:20 *var things

7:33 cfleming: m1dnight: Quick reminder to send me your indentation problem in Cursive, when you get a chance.

7:34 m1dnight: Right! I found it cfleming but when i tried ctrl-alt-L it worked.. so I couldn't reproduce it

7:35 cfleming: m1dnight: Hmm strange. I've had a lot of people mention indentation problems when getting started, but I've never had a bug report so maybe people work it out?

7:35 m1dnight: Anyway, glad it's working!

7:35 m1dnight: Yeah, but if I run into one I'll make sure to notify you :)

7:35 Are you a Cursive dev?

7:35 cfleming: Great, thanks.

7:35 m1dnight: Yep

7:35 m1dnight: Great work man, thanks! :)

7:35 cfleming: m1dnight: The Cursive dev, in fact, it's just me.

7:36 No problem, glad you're liking it!

8:01 hellofunk: in Om what is the scope of the #js :ref feature -- it appears to be none only to other dom elements within the same Om component, but not other components. is this correct?

8:01 *known not "none"

8:36 gfredericks: oh crap I can't use ex-info in the nrepl code :(

8:36 * gfredericks grumbles about primitive clojure

8:36 Bronsa: gfredericks: back compatibility?

8:37 gfredericks: yeah

8:37 it's set to build with 1.2

8:37 Bronsa: gfredericks: https://github.com/clojure/tools.reader/blob/master/src/main/clojure/clojure/tools/reader/impl/utils.clj#L18-L45

8:38 gfredericks: omg

8:38 Bronsa: actually just https://github.com/clojure/tools.reader/blob/master/src/main/clojure/clojure/tools/reader/impl/utils.clj#L31-L45

8:38 and https://github.com/clojure/tools.reader/blob/master/src/main/clojure/clojure/tools/reader/impl/ExceptionInfo.clj

8:38 gfredericks: Bronsa: is there a policy about how far back support should go? Looks like you're going to 1.3?

8:39 m1dnight: Can you cast a symbol to a string? I want a list of varnames to keywords but I can't seem to get it

8:39 Bronsa: gfredericks: don't think so. some contrib even require >=1.5.1

8:39 m1dnight: a string to a symbol was easily found in the docs, but not the owther way around

8:39 gfredericks: Bronsa: is that a bug that you have two definitions of `ex-info?`

8:39 Bronsa: yeah; nrepl is kind of fundamental though

8:40 Bronsa: gfredericks: no, one is for c.l.ExceptionInfo and the other is for c.t.reader.impl.ExceptionInfo

8:40 gfredericks: Bronsa: oh I see -- the indentation is deceptive and made it look like a clobber

8:40 Bronsa: uhm yeah, indentation looks broken there

8:42 m1dnight: oh, i found it :) nvm

8:42 gfredericks: ,(str 'foo/bar)

8:42 clojurebot: "foo/bar"

8:43 m1dnight: I tried that but that didnt seem to do it..

8:43 (str ":" var) works fine

8:43 (in a macro)

8:43 Bronsa: gfredericks: I don't think anybody would be bothered about libs dropping 1.2 support now btw, it's ancient enough

8:43 gfredericks: m1dnight: oh you're talking about keywords, not symbols?

8:43 ,(pr-str :foo/bar)

8:43 clojurebot: ":foo/bar"

8:43 m1dnight: the var is a list of symbols, and I want to cast them to keywords in my macro

8:44 But they are unbound variables in the code that has to be expanded, so they are keywords then?

8:44 gfredericks: Bronsa: well it'd be 1.3 as well if I want ex-info

8:47 Bronsa: yeah, I really wish some stuff like ex-info got backported

8:57 gfredericks: Bronsa: we need a backport contrib library

9:01 cfleming: How many people are still on 1.3, even?

9:07 I'm starting to feel conservative because I'm not running 1.7 alpha - people seem to be putting that into production now.

9:08 gfredericks: the oldest thing I hear of is people using storm grumbling about 1.4

9:10 hey I can fake an ex-info by using proxy and implementing IDeref :P

9:10 ,(proxy [Exception clojure.lang.IDeref] ["Abort! Abort!"] (deref [] {:foo [1 2 3]}))

9:10 clojurebot: #<Exception$IDeref$e595a7c1@129b25c: {:foo [1 2 3]}>

9:11 Bronsa: how will you be able to catch that though?

9:11 catching Exception and testing for IDeref?

9:11 gfredericks: nobody's going to write a catch statement for this exception

9:11 but yeah that would be the only way

9:12 Bronsa: it's not actually too bad

9:12 gfredericks: I'm curious what chas would say

9:14 I think I'm going to find out :)

9:41 tvanhens: Anyone know how to turn off auto-jumping to errors in emacs using cider?

9:43 Bronsa: tvanhens: from the README: "Configure whether the error buffer with stacktraces should be automatically shown on error: Don't show on error:(setq cider-show-error-buffer nil)"

9:44 tvanhens: I don't mind the error buffer popping up its just that it jumps my .clj buffer to the ns declaration so I lose the space I was working

9:44 nkozo: there is some new approach besides the "<?" pattern introduced by David Nolen to manage exceptions in core.async go blocks?

9:46 tvanhens: is there any way to turn off jumping on error in the .clj buffer in emacs?

10:02 martinklepsch: are there any specific techniques when it comes to working with data sets bigger than what fits into RAM?

10:03 databases seem like the solution kind of but I wonder if there might be other appraoches

10:03 basically I'm working with a huge pile of clojure data structures

10:09 jphx: martinklepsch: isn't there a book on working with data in clojure?

10:09 i wonder if that would cover your question

10:12 martinklepsch: https://github.com/erochest/clj-data-analysis/blob/master/index.md

10:12 jphx: this is the book you're talking about I assume?

10:13 I'll take a look, thanks!

10:28 gfredericks: oh gracious

10:28 I don't understand this nrepl ordering thing at all

10:28 or it's buggy

10:28 but I can't tell which

10:30 martinklepsch: is there something like (< "abc" "efg") that would tell me if the first comes before the second when alphabetically sorted?

10:30 gfredericks: there is compare, and this lib I wrote yesterday that does the < sugar for you

10:30 github.com/gfredericks/compare

10:31 ,(compare "abc" "efg")

10:31 clojurebot: -4

10:31 gfredericks: ,(compare "efg" "abc")

10:31 clojurebot: 4

10:33 martinklepsch: I was confused about the output of compare (apparently random numbers at first sight)

10:33 gfredericks: yeah :/

10:33 martinklepsch: but so if it's negative the first is before second and so on?

10:33 m1dnight: it appears that the lein repl does not properly exit.. I suddenly ran out of memory and saw an endless list of leiningen processes

10:33 gfredericks: yep, neg vs 0 vs pos

10:33 m1dnight: anyone else had that?

10:34 martinklepsch: gfredericks: think I'm just gonna use your lib

10:35 gfredericks: w00h00!

10:35 technomancy: m1dnight: on windows?

10:35 m1dnight: xubuntu 14.04

10:35 martinklepsch: gfredericks: (y)

10:35 technomancy: m1dnight: hm; I've only heard of it happening on windows

10:36 m1dnight: strange.. I'll try and reproduce though

10:36 after I commited everything

10:43 gfredericks: think I'm gonna create a ticket called "middleware linearization is still weird"

11:07 justin_smith: m1dnight: launching the repls via your editor?

11:07 m1dnight: justin_smith: nope, via terminal

11:07 I have a repl running in emacs as well though. But only started once.

11:07 .oO(emacs could be the possible source too then, I presume)

11:07 justin_smith: m1dnight: then it should be trivial to see if the process edited - if you get back to the shell, it is gone

11:08 m1dnight: Yes, i'm just continueing working and after a while, if I have a lot of them I'll kill them one by one. But i ran out of ram now so I had to kill them all at once to continue working :p

11:21 heh, 2 seconds to pass send a message between actors 10k times..

11:21 not too shabby, I guess :p

11:22 s/10k/100k

11:28 patrkris: hi folks. can you give me some suggestions around storing and retrieving environment-specific configuration? e.g. configuration that specifies database server for test and production environments.

11:29 this is for a web app specifically

11:32 martinklepsch: patrkris: environ is popular for that kind of stuff

11:32 it offers a few other ways to supply vars than env vars which might be what you want for testing and similar puposes

11:32 patrkris: martinklepsch: i'll check it out, thanks

12:02 gfredericks: almost done with a proof-of-concept for repl history

12:02 offender: i am so offended because clojure is not assembler

12:05 gfredericks: okay now I need a better name than repl-history

12:06 bbloom: gfredericks: what's it do exactly?

12:06 gfredericks: bbloom: keeps a history of all the return values from your repl session and makes them lexically available

12:06 as &3, &4, etc

12:07 it's like *1 but absolute

12:07 erlang repl does this

12:07 bbloom: yes.

12:07 * bbloom wants

12:07 Bronsa: nice!

12:07 bbloom: i abuse http://reference.wolfram.com/language/ref/Out.html in mathematica all the time

12:08 nice to have In too

12:08 gfredericks: that was the thing wolfram was apologizing for in his talk?

12:08 bbloom: yeah

12:08 gfredericks: okay I'll push this up as repl-history until I think of a better name

12:08 bbloom: hmm wait we can do this

12:09 gfredericks: a feature that seems to be too hard: make the repl prompt show the next value to be defined, as in erlang

12:09 okay I will wait

12:09 bbloom: some words to work with: logs, record, history, chronology

12:10 luxbock: are you altering the repl-prompt as well, or how do you know which var maps to which output?

12:10 bbloom: surely there's a good name in here somewhere, hit the thesaurus

12:10 gfredericks: in this PoC it will print to stdout just before showing the value

12:10 e.g., (inc 41) will print "&3:\n42"

12:11 bbloom: gfredericks: The Chronicles Of Repl

12:11 gfredericks: where the first line is stdout and the second line is the return value, so most clients format them differently

12:11 bbloom: yes clearly that is the best name

12:11 luxbock: nice, I'll definitely use it as well

12:11 bbloom: gfredericks: do you have to hack nrepl/etc to make it work? aka can i play nice with whidbey?

12:12 replog

12:12 gfredericks: bbloom: it's a middleware, without any real hacking; I think it works fine with whidbey, because it acts before printing

12:12 bbloom: ok cool

12:13 gfredericks: bbloom: the hackiest thing it does is wrap the input code with (let [[&1 &2 ...] *thing*]\n<<real code here>>\n)

12:14 there'll have to be configurability around naming & garbage collection and stuff I assume

12:14 replog is not bad

12:15 luxbock: gfredericks: how about tracking inputs as well and mapping those to the outputs? then you could write your program in the repl using those shortcuts, and then later reverse it back to working code

12:16 gfredericks: luxbock: that's a cute idea; certainly tracking inputs as well isn't too hard

12:17 allenj12: hey, what is the best way to parse a get response from json to a clojure data structure?

12:17 gfredericks: luxbock: could be named like &42' :)

12:18 luxbock: hmm I think I recall seeing a cider issue around variables that contain the quote character

12:18 let me see if I can find it and see if it's relevant

12:19 gfredericks: bbloom: my only hesitation is that the idea of logging more readily suggests file persistence or something like session/gorilla-repl

12:19 it's tricky to avoid those associations

12:19 bbloom: gfredericks: well then clearly you must implement that

12:19 :-)

12:19 gfredericks: :P

12:19 wouldn't be hard to implement an export, especially if we track inputs

12:20 bbloom: kovas had some voodoo in session for querying the datomic database of repl inputs/outputs

12:20 was pretty cool

12:21 gfredericks: alright replog it is why not

12:21 luxbock: gfredericks: here is the issue: https://github.com/clojure-emacs/cider/issues/713

12:21 I guess it's not really relevant

12:21 since it's about eldoc

12:21 gfredericks: yeah I use such things all the time

12:28 okay here is the PoC code: https://github.com/gfredericks/replog

12:29 * gfredericks walks off to the playground

12:53 luxbock: gfredericks: your version of debug-repl looks really nice, I'll give it a go

12:59 bbloom: gfredericks: i get an attribution? aw shucks. thanks

13:00 gfredericks: the GC issue is interesting. there isn't any obvious good way to decide when/what to discard

13:01 david barbour has written some interesting stuff about "exponential decay of history"

13:04 jeremyheiler: for gc, maybe you could keep track of the last time a result was used, and only discarding ones after their last use is older than a certain threshold?

13:05 hiredman: damn you, I just speant the last 5 minutes shovling through google looking for that

13:05 http://awelonblue.wordpress.com/2013/01/24/exponential-decay-of-history-improved/

13:06 gfredericks: bbloom: an attribution and 20% of my internet profits of course

13:06 bbloom: hiredman: i could have linked you to it :-P

13:06 gfredericks: jeremyheiler: bloom: yeah tracking usage is my only good idea for GC

13:07 hiredman: bbloom: well, I didn't actually remember any of the words involved beyond exponential decay

13:07 bbloom: gfredericks: seems like it would be sufficient to provide a few things: clear/truncate history, evict particular entry, etc

13:07 gfredericks: exponential decay reminds me of probabilistic data structures

13:07 hiredman: (yet I still found it in google, just not before bbloom swooped in)

13:08 gfredericks: bbloom: yeah, definitely manual behavior as well

13:08 bbloom: gfredericks: http://reference.wolfram.com/language/ref/$HistoryLength.html i

13:08 hiredman: the big question is what happens to the names on eviction?

13:08 gfredericks: has anybody tried replog and gotten a ClassNotFoundException printed on repl startup (with no apparent ill effect)?

13:09 bbloom: you can set $HistoryLength to 0 and back again to free memory

13:09 not that i've ever needed to do that, since i restart the mathematica kernel whenever i get confused about what state things are in

13:09 gfredericks: interesting

13:10 bbloom: i guess you can clear an individual entry with set! too

13:10 (set! &2 nil)

13:10 gfredericks: well they're not varn

13:10 vars*

13:10 so that wouldn't work in the current impl

13:10 bbloom: or (ns-unmap *ns* &2)

13:10 ah, ok

13:10 you'd still be leaking the var, just not its value

13:11 lol this page http://reference.wolfram.com/language/tutorial/MemoryManagement.html actually recommends:

13:11 gfredericks: I thought about vars but it seemed bad because then they're sensitive to namespace switches, and they're not session local

13:11 bbloom: Unprotect[Out]; Out[2]=.

13:11 gfredericks: those might not be big enough deals, maybe vars are better

13:11 bbloom: heh, apparently . is a value that causes undefining to occur... learned some more mathematica

13:12 http://reference.wolfram.com/language/ref/Unset.html

13:12 sheesh, so much stuff

13:12 gfredericks: I can't figure out why entering `:foo :bar :baz` at the repl isn't broken

13:13 bbloom: ,:foo :bar :baz

13:13 clojurebot: :foo

13:13 bbloom: heh, in my local repl it prints all 3

13:13 wacky

13:13 gfredericks: in a normal repl it returns 3 values

13:13 hiredman: gfredericks: well, really for history you want to save the inputs and the outputs, and expose the whole thing via some new nrepl commands, not just eval

13:13 gfredericks: but I would think my hack of wrapping the code string would break that; somehow it doesn't

13:13 bbloom: gfredericks: but *1 is just the last one

13:13 gfredericks: hiredman: yeah somebody mentioned inputs already

13:13 hiredman: (of course then you are high and dry until clients start speaking the new command)

13:14 bbloom: 1 2 3 seems to work too, seems like it's reading until eof or something

13:14 gfredericks: hiredman: I could add nrepl commands but don't know enough about hacking clients to tap into it

13:14 hiredman: right

13:14 gfredericks: bbloom: yeah that's normal; I just can't figure out why replog doesn't break it

13:14 it should be rewriting to (let [...] 1 2 3)

13:15 hiredman: I actually installed and fiddled with gorilla repl the first time the other day, seems neat

13:17 arrdem: couldn't you just track the set of input expressions as a sequence of SSA terms and simply generate/run an appropriate term generating program rather than hold a ref to each generated value?

13:17 gfredericks: what.

13:18 I can't possibly imagine whatever that means being easier than what I did

13:19 arrdem: oh it wouldn't be easier but it does something about bbloom's raised GC issue(s).

13:19 not sure you can actually do that however... &3 as a bare symbol wouldn't be legal without some serious legwork

13:19 gfredericks: huh? what's not legal about it?

13:19 luxbock: you could keep track of only the inputs and then eval them when you encounter it's matching var

13:20 ltw: Is there an easy way to turn {1 [1 2 3] 2 [1 2]} into [[1 1][1 2][1 3][2 1][2 2]]?

13:21 disclojure: so hypothetically if i warp into the SnakeBar with my VIP6 address and dont get instanced out, does that mean incessant ramblings must be read by those mods?

13:21 gfredericks: luxbock: so no side effects allowed?

13:21 arrdem: ltw: (for [[k vals] $MAP v vals] [k v])

13:21 disclojure: if so i got a few big mouths

13:21 luxbock: gfredericks: yeah I guess you'd lose that :/

13:21 disclojure: and some speedKracKKEd keyboards

13:21 arrdem: disclojure: wrong channel?

13:22 gfredericks: arrdem: &3 is a legal symbol

13:22 ltw: arrdem: thanks a heap!

13:22 gfredericks: at least according to the reader and the compiler

13:22 arrdem: gfredericks: right your system will handle &3 just fine, I'm wondering if I could do it using input expression tracking rather than result tracking without hacking the evaluator.

13:23 hiredman: & is too

13:23 lazybot: java.lang.RuntimeException: Unable to resolve symbol: is in this context

13:23 hiredman: ,(let [& 1] &)

13:23 clojurebot: 1

13:23 hiredman: ,(let [% 1] %)

13:23 clojurebot: 1

13:24 gfredericks: hiredman: not only is it legal I think it's totally unambiguous alongside normal destructuring/varargs usage

13:38 Wilduck: Has anyone here used Overtone much? I’m trying to demo an instrument I’ve made, but the sound keeps playing until stopped. See: http://pastebin.com/rqBkBsbL . Is there any way to demo a custom instrument?

13:45 bbloom: i'm getting "cannot be cast to clojure.lang.IFn$OLO" from deep in some macro code. any ideas on what to do about that?

13:45 arrdem: no but someone else asked about exactly this yesterday

13:46 don't remember if they got a fix or not tho...

13:46 * bbloom checks log

13:48 bbloom: i don't think he got a solution really

13:48 but hiredman's comment is a hint: "replacing" a function

13:48 not sure where/how i'm doing that... since i'm not using with redefs or anything

13:48 borkdude: today I did a go workshop: nice to see where clojure got the go/channel idea from :)

13:49 bbloom: borkdude: go certainly inspired/influenced core.async, but both of them got it from some ancient literature

13:49 sineer: borkdude: ain't golang tutorial sweet? :-) i'm trying to finish Pipelining is very cool.

13:50 borkdude: sineer I haven't yet tried that

13:51 sineer: func getStatus(urls []string) <-chan Scan { ... } then the pipeline Fn: func processStatus(in <-chan Scan) <-chan Scan { ... } note how it receives and returns a buffered channel :-)

13:52 bbloom: hiredman: any other ideas about the $OLO thing? by commenting out random code it seems it has to do w/ trying to call a protocol function

13:53 arrdem: bbloom: it means you're trying to call a type hinted function where the second argument is a long when the call target doesn't provide a primitive second argument implementation.

13:54 but that's all that I can tell from the error message

13:55 bbloom: hm ok, gonna try to track that down

13:59 Bronsa: ,(defn x ^long [] 1)

13:59 ,(defn y [] (x))

13:59 clojurebot: #'sandbox/x

13:59 #'sandbox/y

13:59 Bronsa: ,(with-redefs [x (fn [] 1)] (y))

13:59 clojurebot: #<ClassCastException java.lang.ClassCastException: sandbox$eval71$fn__72 cannot be cast to clojure.lang.IFn$L>

13:59 Bronsa: bbloom: ^

14:00 this is why that happens

14:00 bbloom: Bronsa: i'm not doing any redefs though...

14:00 Bronsa: also this is the third time somebody asks about this in 3 days

14:00 csd_: Can someone please tell me what might be going wrong here? http://pastebin.com/XcXshaFZ

14:00 arrdem: Oh. Right. OLO means (λ Object → Long) → Object

14:00 bbloom: and i can't even figure out which function is the one being called

14:00 Bronsa: bbloom: maybe no with-redefs, binding is dorked in the same way

14:00 bbloom: arrdem: no, there's no currying

14:00 Bronsa: no binding either

14:01 arrdem: bbloom: right I'm just abusing the notation

14:01 Bronsa: bbloom: I really don't think that can be the case though

14:01 bbloom: Bronsa: there are zero dynamic vars or with-redefs in this project

14:01 i just grepped to be sure :-P

14:01 Bronsa: .invokePrim is only inserted for defns invokes

14:02 bbloom: maybe i copy/pasted a defn and left the original around?

14:03 Bronsa: bbloom: all I can safely say is that that error means that some function was compiled when some `f` was a prim-fn, and now isn't

14:03 borkdude: anyone tried https://github.com/runexec/possibledb yet? I just saw it on reddit

14:03 bbloom: Bronsa: i've looked at every ^long in my program and none of those functions even take 3 arguments...

14:04 Bronsa: OLO is ^Object [^long x ^Object y]

14:04 arrdem: bbloom: two arguments. not three. that's what I was trying to say.

14:04 bbloom: ooo

14:04 hm

14:05 well none of two argument ones take ^long as the first argument anyway

14:05 heh

14:07 Bronsa: bbloom: yeah sorry, its Object (Object,long)

14:07 bbloom: oh, the last thing is the return value?

14:07 arrdem: yep

14:07 bbloom: sheesh, OL_to_O would have been nice

14:08 thanks guys

14:08 * bbloom keeps digging

14:10 uptown: hello out there. iama clj noob trying to get emacs + cider to work. cider-jack-in message: ; CIDER 0.8.0alpha (package: 20141003.518) (Java 1.7.0_65, Clojure 1.6.0, nREPL 0.2.6) so i'm on the latest afaict but with [korma "0.3.0"] in my project :dependencies, (use 'korma.core) in cider gets a file not found

14:10 csd_: 0.4.0 is the latest korma

14:11 uptown: oh ha ha

14:11 bbloom: Bronsa: arrdem: seems like the problem is primitive type hints on protocols

14:11 csd_: the korma docs are woefully poor and their .com addy is out of date

14:11 that might not be the source of your problem though

14:12 uptown: i took sqlkorma.com's word for the version. doh http://sqlkorma.com/docs

14:12 csd_: https://github.com/korma/Korma

14:12 yeah its confusing

14:13 try putting [korma "0.4.0"] in your project.clj instead

14:17 bbloom: Bronsa: arrdem: i switched from a protocol to an interface & it works now

14:24 Bronsa: bbloom: were you using extend by any chance?

14:24 bbloom: no

14:25 i was refactoring code and wanted to decouple two components, so introduced a single method protocol so that i could move some stuff around prior to tottally decoupling that dependency

14:25 switched from protocol to interface, everything works

14:25 make a few more tweaks, now it's all gone all together, just passing a function through by itself

14:25 all good :-)

14:26 although i guess maybe now it's boxing?

14:26 *shrug* will profile/fix later

14:26 Bronsa: uh

14:26 looks like it's a bug

14:26 uptown: okay, replaced with korma 0.4.0, restarted, cider-jack-in, C-c M-n gets me the right namespace in my prompt, but then (use 'korma.db) gets me namespace 'korma.db' not found

14:26 hiredman: bbloom: likely the actual protocol function doesn't implement the primitve interfaces, but the arg list is being copied to the var or something so clojure is trying to compile call sites as primitive calls

14:26 bbloom: Bronsa: i found an old thread that said protocols don't support primitive hints

14:27 hiredman: that is correct

14:27 Bronsa: hiredman: that's exactly what's going on

14:27 bbloom: makes sense

14:27 can we concoct a minimal repo then pretty easily?

14:27 ,(defprotocol P (f [^long x]))

14:27 clojurebot: P

14:28 bbloom: ,(deftype T [] P (f [x] x))

14:28 clojurebot: sandbox.T

14:28 bbloom: ,(f (T.) 5)

14:28 clojurebot: #<CompilerException java.lang.IllegalArgumentException: No single method: f of interface: sandbox.P found for function: f of protocol: P, compiling:(NO_SOURCE_PATH:0:0)>

14:28 bbloom: ,(deftype T [] P (f [_ x] x))

14:28 clojurebot: #<CompilerException java.lang.IllegalArgumentException: Can't define method not in interfaces: f, compiling:(NO_SOURCE_PATH:0:0)>

14:28 bbloom: argh.

14:28 hiredman: not enough args in your protocol function

14:28 bbloom: ,(defprotocol P (f [this ^long x]))

14:28 clojurebot: P

14:28 bbloom: ,(deftype T [] P (f [_ x] x))

14:28 clojurebot: sandbox.T

14:28 bbloom: ,(f (T.) 5)

14:28 clojurebot: #<ClassCastException java.lang.ClassCastException: sandbox$eval155$fn__156$G__146__163 cannot be cast to clojure.lang.IFn$OLO>

14:28 bbloom: yup!

14:28 hiredman: yeah, i was just using definterface which has implicit this, so i got confused

14:28 heh

14:29 hiredman: right

14:29 also proxy

14:29 that all is confusing

14:30 bbloom: filed this: http://dev.clojure.org/jira/browse/CLJ-1548

14:31 metadata: the cause and solution to all of clojure's problems

14:32 hiredman: I imagine rich will just say "primitves aren't supported on protocols so stop type hinting them as primitives"

14:32 bbloom: hiredman: in that case, i may just submit a patch that dissocs tag from the symbols

14:33 hiredman: bbloom: silently ignoring the hints? that doesn't seem great

14:33 bbloom: better than not working :-P

14:33 actually no

14:33 Bronsa: how about throwing an exception if you provide a prim hint?

14:33 bbloom: if protocols get type hinting support later, it could break

14:33 hiredman: maybe an error message when defining the protocol would be better

14:33 yeah

14:34 and, actually, throwing when defining with tags could break existing code

14:35 if someone only has higher order usage of some protocol function

14:35 (but, well, why the heck would you tag that?)

14:35 bbloom: iirc i had to remove :tag from some metadata in some wacky macro stuff for some reason not too long ago

14:35 but i forget why

14:36 hiredman: similar to an issue I had a while back, I had a protocol that I was only calling as a higher order function and it worked great, but as soon as I added a direct call it would blow up, because it was called wait, and that conclicts with Object's wait

14:37 bbloom: oh yeah, the lack of namespaces on method names is confusing at first

14:37 then you remember "holy shit. how did i live without namespaced methods back when i wrote java/c#/c++ ?????"

14:37 namespaced functions, imean

14:38 gfredericks: yeah the ruby people are always building their objects by mixing all sorts of modules together and just crossing their fingers

14:39 bbloom: from the zen of python: "Namespaces are one honking great idea -- let's do more of those!"

14:41 uptown: which brings me back to my noob question heh. either cider's namespacing isn't working or it doesn't do what i think it does

14:42 can someone help me run this down?

14:43 justin_smith: uptown: why would cider effect this at all?

14:43 hiredman: https://twitter.com/hiredman_/status/518465805378273280

14:46 uptown: i freely admit i might be wrong, but i've added five lines to a new app and i'm getting errors in baby step examples

14:47 justin_smith: uptown: your issue was that you had a dep on korma and could not use a specific korma namespace, right?

14:47 uptown: correct

14:48 justin_smith: cider does not do namespace dependency management, at all

14:48 have you restarted your repl since adding the dependency to your namespace, or used a tool like alembic that loads new deps at runtime?

14:49 uptown: i restarted emacs entirely, just to be sure

14:50 justin_smith: in the repl, if you run "lein deps tree" in the project directory, do you see some version of korma being pulled in?

14:50 uptown: and i will gladly do that again, and also delete this code and start over if it will help

14:50 justin_smith: the only thing that effects whether korma is available will be your project.clj

14:50 uptown: yes, when i updated to korma 0.4.0 i saw it get downloaded

14:51 and the error message changed

14:51 justin_smith: if you run "lein repl" in that directory, is it possible to use that namespace?

14:52 uptown: just for clarity, from a shell command line?

14:52 justin_smith: that's the only way to run lein repl, yes

14:52 csd_: uptown: try running cider-jack-in off the project.clj loaded in emacs

14:52 borkdude: we did a workshop today. a lot of windows users who had trouble installing leiningen :(

14:53 justin_smith: borkdude: there is a chicken/egg problem with no clojure users on windows / clojure tooling not working on windows

14:53 arrdem: borkdude: technomancy's official line is that windows support is accidental :/

14:53 borkdude: we got it to work on some machines, but it took some precious time

14:54 justin_smith: csd_: easier way to diagnose that problem: does (.getCanonicalPath (java.io.File. ".")) return the top of the project directory?

14:54 uptown: okay, i did both 'lein repl' and restarted emacs and did cider-jack-in from the project

14:55 justin_smith: uptown: in the lein repl, try using the korma ns

14:55 uptown: namespace 'korma.db' not found

14:55 borkdude: cfleming it would be great if cursive would also enhance windows users experience (i.e. not need the script to be installed). would be a big win I think

14:56 arrdem: uptown: ... if you read the current korma docs on github, does korma.db still exist?

14:57 uptown: gah i've been following the example on the sqlkorma webiste. will look at git now.

14:57 arrdem: uptown: beat you to it. korma.db still exists.

14:57 justin_smith: uptown: arrdem: it should exist https://github.com/korma/Korma/blob/master/src/korma/db.clj

14:57 arrdem: justin_smith: u 2 slow

14:58 uptown: ... and you're booting your repl normally from within a dir with a project.clj listing korma as a dep?

14:58 justin_smith: uptown: if you look at the output of "lein deps :tree" in your repl, what version of korma does it say it is pulling in?

14:58 uptown: have i got this right in my core.clj? (ns sqltest.core (:use (korma core db)))

14:59 justin_smith: no, absolutely not

14:59 that is very wrong

14:59 in that repl, try (use 'korma.db)

14:59 uptown: one of my five lines

14:59 arrdem: uptown: if your project.clj doesn't include [korma "0.4.0"] you won't be able to use korma.

14:59 justin_smith: arrdem: I think that namespace declaration is the problem, we verified he is pulling in korma

14:59 arrdem: uptown: first things first, you do have the dep in place.

14:59 uptown: korma is in my project dependencies

14:59 arrdem: justin_smith: okay just making sure.

15:00 justin_smith: uptown: that ns declaration is fucked

15:01 borkdude: what kind of installer is this: http://leiningen-win-installer.djpowell.net/ - what leiningen version will it install

15:01 some guy tried it, but I wasn't sure if it worked

15:02 Jaood: borkdude: you could go the 'java -cp clojure.jar' route

15:02 borkdude: Jaood neh, we needed people to run lein ring server + lein cljsbuild auto

15:02 justin_smith: borkdude: pulls in raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein.bat

15:02 as I see in https://bitbucket.org/djpowell/leiningen-win-installer/src/9c971dd33439158233624f2d9daac5fdc833e82a/leiningen-installer.iss?at=bitbucket-master

15:03 borkdude: justin_smith cool, that should've worked then. I think the only problem then was putting the bin folder on the path maybe

15:03 uptown: okay, i unfucked the ns decl and now (use 'korma.db) gets me No such var: jdbc/db-set-rollback-only!

15:04 justin_smith: weird - what jdbc backend are you using?

15:04 csd_: did you put your jdbc driver in your deps?

15:04 Jaood: borkdude: or maybe dockerized the setup

15:04 justin_smith: the way jdbc works, it can use various adaptors, you need to ask for one of the adaptors in project.clj

15:04 uptown: i did and i can tell by looking at it now that it's outdated stuff from the website

15:04 borkdude: Jaood yes, docker on windows?

15:05 csd_: which db

15:05 uptown: postgres

15:05 justin_smith: uptown: leaps and bounds

15:05 oh, thought you said "progress" at first, lol

15:06 borkdude: Jaood I see that is possible, but then we would have to "support" Docker on Windows, something I don't want to get into either I think ;)

15:06 Jaood: borkdude: yeah, you need some vm

15:06 csd_: so you have something like [postgresql/postgresql "8.4-702.jdbc4"] in your deps?

15:07 Jaood: borkdude: how about using putty and giving them ssh access to a linux box?

15:07 justin_smith: Jaood: depends on how many TB of ram he has

15:08 gfredericks: terabarrels

15:08 teraboxes

15:08 terabison

15:08 borkdude: Jaood I want them to run clojure apps on their own machine. It's possible, but these things take up first 30 minutes of a workshop

15:08 Jaood: justin_smith: 1GB per user!

15:09 * Jaood checks top and looks for the lein repl

15:10 justin_smith: Jaood: he mentioned he was having them each run a ring app

15:10 uptown: updated to [postgresql "9.3-1102.jdbc41"] but i get the same error message

15:11 justin_smith: Jaood: (also I was mostly just being silly and joking about Clojure's heap usage)

15:11 stuartsierra: Does anyone know who coined the phrase "Getting SLIMEd"?

15:12 The oldest references I can find are from technomancy on #clojure and the mailing list around 2010.

15:12 Jaood: justin_smith: yeah, I know ;)

15:12 borkdude: I guess we could provide a VirtualBox image

15:12 next time

15:12 uptown: re: slimed, other than peter venkman?

15:13 amalloy: stuartsierra: that's the oldest i can find too. i'm surprised no common lispers had that issue

15:13 csd_: uptown: unfortunately my laptop battery is dying so i have to drop off. this doesnt look like a cider issue though.

15:13 Jaood: borkdude: I hear vagrant is good for that stuff

15:13 stuartsierra: amalloy: The issue was definitely known in Common Lisp, but I first heard the phrase related to Clojure.

15:13 amalloy: amazingly, there are google hits that include "emacs" and "slimed" on the same page, where slime is referring to nickelodeon or whatever, not emacs at all

15:14 >> Project for the week: Learn "Emacs" without getting help. >> :A noble goal ..... or "To tell the truth" where apparently the major object is to get the panelists slimed.

15:14 stuartsierra: uptown: specifically related to SLIME, http://common-lisp.net/project/slime/

15:14 amalloy: :)

15:14 Emacs reaches everywhere. :)

15:16 justin_smith: uptown: slime is the legacy finicky to configure and often broken way to use clojure with emacs, we've had a couple of others since then

15:16 uptown: i've used it in the other context

15:16 stuartsierra: Not to be confused with the current finicky to configure and often broken ways to use Clojure with Emacs.

15:16 uptown: heh

15:16 amalloy: stuartsierra: http://t14822.lisp-slime-development.lisptalks.info/slime-user-survey-t14822-80.html might be using the term, but it's hard to tell

15:17 gfredericks: clojurebot: emacs is finicky to configure and often broken

15:17 clojurebot: Ik begrijp

15:18 borkdude: he talks Dutch / Afrikaans?

15:18 justin_smith: sometimes irish too

15:18 amalloy: justin_smith: welsh

15:18 justin_smith: ahh, sorry

15:19 stuartsierra: amalloy: That link seems to be using "slimed" to mean "brought into the coterie of SLIME users".

15:21 uptown: so it seems that i am caught in a korma + postgres bug, right?

15:22 Jaood: they share a bug? :)

15:22 justin_smith: uptown: yeah - check out the versions you are actually getting (via "lein deps tree")

15:23 I don't think this is a korma issue at all - korma is just a macro layer over clojure.java.jdbc

15:23 uptown: hm i get no output from that at all

15:23 justin_smith: uptown: running it in your project directory?

15:23 uptown: i am, yes

15:23 justin_smith: that should print out a tree of all deps for that project, and what versions are being pulled in

15:25 an error I would understand - but no output at all is deeply weird

15:25 uptown: deps has never returned anything for me. i don't know why. in an earlier, less tragic experiment i installed pprint and that worked

15:25 let me do that again

15:25 justin_smith: no, not lein deps

15:25 lein deps :tree

15:25 :tree is part of the command

15:26 uptown: the colon is significant to a noob

15:26 justin_smith: and it is part of the command

15:27 lein deps :tree

15:30 uptown: i had earlier played with [lobos "1.0.0-SNAPSHOT"] which was causing a jdbc version collison. fixed now. no errors at all

15:31 justin_smith: uptown: discovered via the deps tree I assume :)

15:31 uptown: yes, exactly. thanks for helping me along the agonizing process of clj de-noobification

15:32 justin_smith: no problem - I really wish we had a smoother and less surprise-filled onboarding process to the ecosystem

15:32 oh god I said onboarding non-ironically what is wrong with me

15:32 uptown: there are lots of web resources that led me down various garden paths, yes

15:33 justin_smith: clojure moves to fast for top google hits to be helpful :(

15:35 uptown: yes, but part of de-noobification is learning how to find the clarifying information

15:36 deps :tree was well hidden heh

16:11 cfleming: borkdude: I don't use windows, which script do you mean?

16:11 borkdude: cfleming I was aiming at something I said before, but I understand you miss context

16:12 cfleming today I gave a workshop with leiningen + cursive. the windows users lost time by installing leiningen, which didn't go smooth

16:12 cfleming it would be great if they could execute tasks from within intellij without installing lein.bat

16:13 cfleming probably hasn't much priority, but maybe it would be easier for some beginners

16:14 cfleming: borkdude: yes, that's definitely on my list.

16:15 borkdude: They would need to be able to create projects and run arbitrary tasks, right?

16:15 borkdude: Anything else?

16:15 borkdude: cfleming yes, things like lein ring server + lein ring cljsbuild

16:15 ajmccluskey: I was just looking at http://dev.clojure.org/jira/browse/CLJ-701, because I seem to have a related issue. Example code: http://pastebin.com/eHV2rJLN

16:16 borkdude: cfleming do you think that would be possible without an external lein installation?

16:16 cfleming: borkdude: Ok. I'm planning a lein-focused release soon.

16:16 borkdude: Yes definitely, Cursive bundles lein.

16:16 borkdude: cfleming that's great then

16:16 ajmccluskey: Should my example code be considered the same bug, given that the argument to recur isn't using loop?

16:17 I'm not across the internals of Clojure's compiler, so not sure if it's worth raising my example anywhere.

16:18 amalloy: ajmccluskey: no, yours is not the same bug

16:19 your problem is that a boxed Byte is not the same as a primitive byte

16:20 ajmccluskey: so it's not so much an issue as my misunderstanding of boxed vs primitive Bytes?

16:20 amalloy: yeah

16:20 the compiler thinks you want to avoid boxing and unboxing, since you use a primitive byte as your recur arg

16:20 but then you call first on a seq, which can't possibly return a primitive, and try to recur with it

16:21 one approach, if you want to avoid boxing, would be to use a byte-array and aget, instead of a seq and first

16:21 dbasch: or wrap it in (byte …)

16:21 amalloy: right, that's the solution if you don't mind boxing

16:22 ajmccluskey: dbasch: yeah, that seems to be a workaround. Code is just for fun/learning, so not concerned with any overhead of boxing/casting. I was just curious if it was an issue, or something I misunderstood.

16:22 amalloy: thanks, your explanation makes sense

16:23 dbasch: that’s actually a pretty decent error message for clojure standards :)

16:25 ajmccluskey: dbasch: haha, it was certainly easier than some of the others I've managed to generate

16:26 joobus: does anyone know what happened to jark? https://github.com/icylisper/jark

16:26 and if there is something similar to jark now?

16:27 justin_smith: borkdude: https://twitter.com/HackerNewsOnion/status/518495442225479680 apropos

16:27 borkdude: justin_smith lol

16:30 cfleming awesome addition on key bindings!

16:32 cfleming: borkdude: Thanks! It's about time I got that in there.

17:23 bbloom: so sad that when i work on concurrency/async/etc i'm back in the blindfolded world i lived in prior to clojure

17:23 there's no "snapshot all the state right now" button

17:23 i have to dig in to closured over values and other such nonsense

17:23 :-(

17:24 s/values/objects

17:25 since most of my go-loops operate a single immutable map of state and have a common control channel, i like to make them respond to ":snapshot" messages so that I can get all that state in one request during debugging

17:25 but the state of the channels & other queues aren't as pleasant

17:25 or hidden atoms too

17:39 borkdude: so cool that these things type check with core.typed https://www.refheap.com/91169

17:50 cddr: It seems that ring-middleware-format only parses request bodies when using the en format. Is that because it's probably a bad idea to dump edn into the request query params?

17:50 s/en/edn/

17:54 borkdude: what is the best way to include core.type checks in a continous integration, as a separate step or as part of lein test?

18:01 probably easiest via lein typed

18:17 johnny_mck: Does anyone have any good programming challenges for newbies to clojure?

18:17 Most of my newbie programs for a new language include _lots_ of state... Not so good for functional stuff when you want to sharpen your skills.

18:18 quit

18:45 technomancy: arrdem: "windows support is accidental" isn't the official status anymore

18:45 FWIW

18:45 (it's now only unofficial)

18:48 bbloom: borkdude: union types >>> sum types !!!

18:49 ticking: I think `as->` implementation is flawed. As it breaks recur.

18:49 ,(macroexpand '(as-> x % (recur %)))

18:49 clojurebot: (let* [% x % (recur %)] %)

18:50 ticking: ,(macroexpand '(-> x (recur)))

18:50 clojurebot: (recur x)

18:53 dbasch: why would aot compilation not find clojure.set?

18:56 I cannot aot this in a default project with the latest leiningen https://www.refheap.com/91175

19:02 gfredericks: technomancy: so I guess officially windows is officially supported but unofficially it is only unofficially supported?

19:02 bbloom: welp now I know that union types are (apparently) not the same thing as sum types.

19:04 bbloom: gfredericks: depending on who you ask, you may get different definitions, but i think it's relatively well agreed upon that sum types are *disjoint* union types

19:04 gfredericks: that is if you had some data type AB which can be A or B and some data type BC which can be B or C, you're using B in both AB and BC, which makes them not disjoint

19:05 gfredericks: disjoint sums are important for "principal types" and H-M inference

19:05 and help with exhaustiveness checks

19:05 none of which i care about :-P

19:06 sineer: Can soneone please tell me what I'm doing wrong here: (into {} (map #(hash-map (first %1) (assoc (hash-map (rest %1)) :completed checked)) todos))

19:07 gfredericks: bbloom: so that means that for a sum type defining ABC as AB or BC is illegal?

19:08 sineer: That part: (assoc (hash-map (rest %1)) :completed

19:08 checked) I

19:08 bbloom: julia> Union(Union(Int8, Int16), Union(Int16, Int32))

19:08 Union(Int16,Int32,Int8)

19:08 gfredericks: ^^^

19:08 legittalon: Okay. So here's the plan: ClojureOS

19:09 sineer: err sorry, I'm trying to say that expression always return {:completed true} instead and ignore this part (hash-map (rest %1))

19:09 legittalon: ClojureEmacs?

19:09 gfredericks: bbloom: I need to play with more type systems :/

19:11 legittalon: sineer: Idk I am just spinning up RuntimeJS for fun and I hopped in here to silently leach knowledge and thought, why not mix the two events.

19:12 sineer: hrmm when I (map fn hash-map) in fn, (first %1) gives me the key but (rest %1) gives me what exactly I'm confused

19:13 for a vector I understand.. but what about a map? I have a hash-map of hash-map... how do I iterate and rebuild it with a single assoc into each hash-maps is what I'm trying todo..

19:14 (into {} (map #(hash-map (first %1) (assoc (hash-map (rest %1)) :completed true)) todos))

19:14 dbasch: sineer: you probably want assoc-in

19:15 sineer: oh yeah I bet you that's what I'm trying to reimplement hehe

19:16 gfredericks: ,(assoc-in nil (range 10) :haha-what)

19:16 clojurebot: {0 {1 {2 {3 {4 {5 {6 {7 {8 {9 :haha-what}}}}}}}}}}

19:17 sineer: Thanks guys.. I'd like to understand why it is my crazy implementation didn't work just to learn more too

19:18 gfredericks: sineer: ##(let [kv-pair [:foo 12]] {:rest (rest kv-pair) :second (second kv-pair)})

19:18 lazybot: ⇒ {:rest (12), :second 12}

19:20 sineer: gfredericks thanks.. does it work with nested maps too? I had it working earlier with kv-pair just not with nested hash-maps

19:21 gfredericks: sineer: my point is that `rest` isn't nearly as helpful as `second` or `val`, which do the same thing in this case

19:23 technomancy: gfredericks: officially neither supported nor unsupported?

19:27 dbasch: anyway, why would this fail to aot-compile? https://www.refheap.com/91175

19:27 gfredericks: Windows 10 comes with leiningen pre-installed

19:49 "Click the start button, and under 'Applications' select 'Leiningen'. Then click on the 'Profiles' tab and scroll down to the ':user' profile. Click 'Add new plugin', and ..."

19:50 sineer: Hrmm. how do I use assoc-in on multiple nested keys/hashmaps ?

19:50 Like, {:1 {:foo "bar} :2 {:foo "bar"}}

19:50 gfredericks: what do you want to get out of it?

19:51 sineer: (assoc-in [:foo] "baz") but that's nt what I want..

19:51 gfredericks: you want to change both of the bars to baz?

19:51 sineer: I want to get {:1 {:foo "baz"} {:2 {:foo "baz"}}

19:51 gfredericks correct

19:51 gfredericks: so that depends on whether you want to do this for every entry in your top-level map, or you have an explicit list of keys ([:1 :2] in this case)

19:52 sineer: all top-level

19:52 err no all one level-deep

19:52 I'm forced to build and pass it list of all keys?

19:53 gfredericks: that can be helpful; see reduce

19:53 there are also some utility libraries, e.g. plumbing.core/map-vals

19:54 vIkSiT: hi all

19:55 when using clojurescript/om, how do I use om/root to specify a path into the cursor?

19:55 I keep getting an "Uncaught Error: Vector's key for assoc must be a number. " by doing this:

19:56 https://gist.github.com/viksit/485bccd8be2d9d572052

19:58 ah, yogthos! while you're here :) do you know of an issue where changing the route of a luminus app doesn't autoreload your application in dev mode?

20:07 sineer: (let [keys (map #(first %1) todos)] (map #(assoc-in todos [% :completed] checked) keys))

20:07 any ideas why it doesn't do anything to modify :completed in my nested hashmaaps?

20:08 keys list has all the keywords inside todo nested hashmap

20:08 yet it doesn't modify {:1 {:completed false} :2 {completed: true}...}

20:09 justin_smith: dbasch: you need to require the namespace, right?

20:10 dbasch: yes, it makes no difference

20:10 justin_smith: because I have had similar errors with clojure.pprint (I thought it was automatic, but only because the repl had preloaded it)

20:16 dbasch: actually when I require the namespace it works, my bad

20:26 vIkSiT: hrm, anyone use om here?

20:27 sineer: I'm trying hard to right now..

20:38 YES!!!!!! (into {} (map #(hash-map (first %) (assoc (second %) :completed checked)) todos)) that's what I needed... any better way to do that?

20:38 just trying to read it hurt my brain

20:39 dnolen_: vIkSiT: a few people do, but also good to ask in #clojurescript, also the ClojureScript Google Group

20:42 turbofail: (into {} (for [[k v] todos] [k (assoc v :completed checked)]))

20:54 sineer: turbofail YES! Thank you very much friend!!

20:55 gfredericks: sineer: if you had map-vals, it'd be (map-vals #(assoc % :completed checked) todos)

20:56 sineer: gfredericks nice.. and it's just a macro that does exactly what turbofail tought me except in a more readable way?

20:56 gfredericks: not even a macro

20:56 sineer: what do you mean not even a macro? ain't reader macro what would be best to do that?

20:57 gfredericks: ,(defn map-vals [f m] (into {} (for [[k v] m] [k (f v)])))

20:57 clojurebot: #'sandbox/map-vals

20:57 gfredericks: ,(map-vals #(assoc % :completed true) {:foo {} :bar {1 2}})

20:57 clojurebot: {:foo {:completed true}, :bar {:completed true, 1 2}}

20:59 sineer: gfredericks wouldn't a reader macro save a fn call? I just asking to learn more about reader macro :-)

21:00 gfredericks: I think you mean "macros" instead of "reader macros"; yes, you can usually save function calls with macros, and it's almost never worth it

21:00 it makes your code a lot more complicated

21:01 dbasch: this particular case has absolutely nothing to do with macros

21:01 sineer: does it? cool thanks... I'm used to #define in C but it bemes a statement and there's no such thing in clojure ugh..

21:01 gfredericks: dbasch: you could save the call to f

21:02 dbasch: gfredericks: if you have to do performance optimization with macros, you probably know what you’re doing anyway

21:03 so I’d just say no

21:04 I mean, saving a function call… what do you have to be doing for it to be worth saving a function call?

21:04 gfredericks: I did say "almost never worth it"

21:05 dbasch: since we’re on the topic of optimization, I tried this code earlier today https://github.com/talkto/geohash/blob/master/src/geohash/core.clj

21:05 * gfredericks tries to avoid being patronizing

21:06 dbasch: and found it to be about 50 times slower than using the reference java implementation

21:06 I optimized it to be only 10 times slower and gave up

21:06 (all for no particular reason)

21:07 in particular just doing (apply str some-vector) is slower than the entire java code that creates a geohash

21:16 justin_smith: dbasch: calling map repeatedly in long-to-hash is causing a lot of sequence creation and walking that does not need to happen, you could use comp and map once

21:16 dbasch: justin_smith: yes, I replaced all that by loops

21:16 clojurebot: I don't understand.

21:16 justin_smith: dbasch: ahh, that was the original, not the optimized, got it :)

21:16 dbasch: brought an encoding from 11 us to 2.5 us

21:17 the java version takes 400 ns

21:17 justin_smith: another thing to consider is using arrays instead of lazy-seqs or vectors for data that does not escape local scope

21:17 (if it does not change in length)

21:18 that's not very clojurey but it performs well

21:18 dbasch: justin_smith: this is where I got bored https://www.refheap.com/91181

21:20 long-to-hash is slower than the entire java impl, might as well use a StringBuffer

21:20 this is the java version https://github.com/kungfoo/geohash-java/blob/master/src/main/java/ch/hsr/geohash/GeoHash.java

21:20 justin_smith: you know the size beforehand, it would be hard to beat just creating an array of that size and filling it

21:22 dbasch: justin_smith: yes, but at that point I realized that there was no reason to do this when the java implementation works just fine

21:22 justin_smith: hell, even creating a transient vector of that size and assoc onto each index would perform better

21:22 dbasch: might as well just do a wrapper

21:22 justin_smith: dbasch: why translate code that already works in your runtime? as an exercise I guess. But yeah, good point.

21:23 dbasch: I found that implementation and wondered why it even existed, as it was written after the java one

21:23 justin_smith: interesting

21:24 (= (more clojure) (more better)) obviously

21:24 dbasch: and only 50x slower :P

21:24 for applications that use geohashes, performance is probably a concern

21:42 sineer: ARRgg.. anyone please tell me why this don't merge/conj the hash-maps it just keeps last hashmap :(

21:42 justin_smith: got a paste?

21:43 sineer: justin_smith http://pastebin.com/HAjnE6yF

21:44 arrdem: technomancy: on sweet

21:44 justin_smith: sineer: that's not how you merge maps

21:44 sineer: do you want todos to be a sequence or a map?

21:45 arrdem: anyone know of a Ring analytics middleware? I only see one that injects google analytics nothing that does session tracking/logging.

21:45 sineer: justin_smith a map

21:45 justin_smith: with what key?

21:45 sineer: all the keys from both map

21:45 justin_smith: you aren't handing it anything that would act as a key

21:45 uhh

21:45 no

21:46 sineer: can you give an example of what app-state should end up looking like?

21:46 (conj (conj {} {:a 0 :b 1}) {:a 1 :b 2}) ; this is what it is doing right now

21:46 ,(conj (conj {} {:a 0 :b 1}) {:a 1 :b 2}) ; this is what it is doing right now

21:47 clojurebot: {:a 1, :b 2}

21:47 arrdem: justin_smith: uhm.... conj is defined to be merge on maps?

21:47 sineer: why not? app-state { :showing :all, :todos {:1 {:id :1 :title "foo"} :2 {:id :2 :title "bar

21:47 "}}

21:47 justin_smith: conj a map onto another map just does a dumb merge, with any new key replacing an old one

21:47 arrdem: &(conj {} [:a :b])

21:47 lazybot: ⇒ {:a :b}

21:47 justin_smith: sineer: OK, then you don't want conj, you want assoc

21:48 sineer: what you said conj does is exactly what I want...

21:48 dumb merge is find with me..

21:48 justin_smith: (swap! app-state update-in [:todos] assoc (:id new-todo) new-todo)

21:48 turbofail: dbasch: well, performance golf in high level languages is a great way to procrastinate from doing real work

21:48 dbasch: that's my main reason for doing it

21:48 arrdem: sineer: conj does a nonrecursive merge, assoc creates an association. if you're just adding one key, assoc is the idiom not conj

21:48 justin_smith: sineer: no, what you are doing will not give you that result

21:48 that's not how conj on maps works

21:49 sineer: ok... thanks

21:49 turbofail: that said whoever wrote that geohash implementation clearly wasn't even doing that

21:51 sineer: justin_smith it does work but it bugs me I spent like an hour trying to figure it out and I haven't got a clue why that dumb merge/conj don't work :-(

21:51 dbasch: turbofail: one nice thing about Java is that you have to try hard to implement an ok algorithm with terrible performance

21:51 sineer: they both return hash-map don't they?

21:51 dbasch: it’s much easier to write hideously slow code in clojure

21:51 justin_smith: sineer: you wanted your data to be key/ val and you were just handing it all the keys and vals in your new element

21:52 sineer: so the combining was happening at the wrong structural level

21:52 ,(assoc {} 1 {:id 1 :value 42})

21:52 clojurebot: {1 {:value 42, :id 1}}

21:52 justin_smith: ,(conj {} {:id 1 :value 42})

21:52 clojurebot: {:id 1, :value 42}

21:53 justin_smith: both are valid, they do very different things

21:53 turbofail: dbasch: yeah, it'd be nice if clojure could provide ways to accelerate the idiomatic cases

21:53 myguidingstar: hi all, I have some leiningen projects that depend on each other. What's the best way to organize them? When developing, I don't want to run 'lein install' in each

21:53 sineer: justin_smith ok thanks a lot! I think I get it..

21:53 turbofail: difficult to pull off though

21:54 * arrdem interested in the answer to myguidingstar's question

21:54 myguidingstar: I mean how to share paths between sibling projects

21:54 justin_smith: sineer: analogy: putting your money and credit cards in your pocket with your wallet, rather than putting them in the wallet, and putting that in your pocket

21:54 sineer: yeah I understand that :-)

21:54 justin_smith: both work, one works out to be a bit more useful

21:55 sineer: I just spend pretty much a days worth of time just to modify Om's TodoMVC to use a hash-map instead of a vector to store the todos...

21:56 justin_smith: sineer: that's not all you were doing, you were also learning about proper usage of data structures in clojure

21:56 that's a one time cost :)

21:56 sineer: true hehe.. I wouldn't say one time cost too.. I'm still very confused :-/

21:57 justin_smith: heh, it's still a one time thing to learn it, even if you have only partially learned so far

21:59 sineer: Next I want to plugin google-map and add geo marker to them todos and mix Om/react with Polymer/webcomponents... and use Pani/firebase with GeoFire to store that in Firebase db :-)

21:59 justin_smith: errand planner?

22:00 sineer: kinda I guess :-) Shared too using firebase pub/sub a la backbone...

22:00 just proof of concept of course google map does that already :-)

22:01 I find extending todoMVC an awesome way to learn any lang..

22:03 Also I think mixing up clojure immutability with Polymer through react to gain the "time travel" ability with webcomopnents must be really powerful!

22:10 dbasch: justin_smith: this still takes twice as long as the entire java version of encode https://www.refheap.com/91184

22:11 justin_smith: interesting

22:13 dbasch: justin_smith: https://www.refheap.com/91185

22:14 amalloy: dbasch: the quot there could be a bitwise operation

22:14 remember from our recent discussion that the jvm can't optimize that out for you

22:14 dbasch: amalloy: tried that, made no difference

22:15 it does make a difference for the mod, that shaves about 200 ns

22:15 amalloy: what is encode-char?

22:16 dbasch: amalloy: see https://www.refheap.com/91181

22:16 amalloy: hashmap lookup on boxed Character objects!? that can't be fast

22:16 dbasch: it’s a boredom-fueled attempt to optimize https://github.com/talkto/geohash

22:17 I hadn’t gotten to that part

22:17 amalloy: dbasch: but it's the part that's slowing down the function you're trying to optimize :P

22:17 dbasch: true

22:18 still, it’s only 25% of the total encode function time

22:18 amalloy: my guess would be, inline it as something that macroexpands to (case n 0 \0 1 \1 ...)

22:18 dbasch: the encode function in the above link takes about 11 us

22:18 in the refheap, about 2.5

22:18 the java version about 400 ns

22:19 it’s completely pointless anyway

22:24 hiredman: an array would be faster

22:27 dbasch: hiredman: true, looking up the numbers 0 to 31 in a map is silly

22:28 especially a constant map for the range

22:29 amalloy: hiredman: faster than the case i suggested? i'd guess the jvm optimizes the case down to a jump-table, but i guess it's probably better to look up in the array yourself

22:31 hiredman: that is my thinking

22:45 sineer: Anyone can tell whats wrong with this: (swap! app-state update-in [:todos]

22:45 (fn [todos] (into {} (map #(assoc-in % [:completed] not) todos))))

22:45 I get an Uncaught Error: Vector's key for assoc must be a number.

22:46 todos is a nested {:1 {:id :1 :title "foo"} :2 {...}} and I'm trying to update :completed within each nested {}

22:49 dbasch: amalloy hiredman aget from a ^chars array makes it slightly faster, but each aget still takes 40 ns

22:51 amalloy: that's hard to believe, dbasch. you must be doing some accidental boxing; on my POS desktop, aget from a char[] takes 6ns

22:54 ToBeReplaced: sineer: your function is calling (assoc-in [:1 {:id :1 :title "foo"}] [:completed] not)

22:54 amalloy: make sure the ints you're looking up are ints rather than longs, too

22:54 dbasch: amalloy: https://www.refheap.com/91188

22:55 amalloy: (def a2 (char-array "0123456789bcdefghjkmnpqrstuvwxyz"))

22:56 amalloy: $mail dbasch the call to rand-int is taking up most of your time: it has to box up a long to a Long, then do some random stuff, then unbox Long into long, then coerce to int...

22:56 lazybot: Message saved.

22:58 amalloy: $mail dbasch also, try like (quick-bench (do (whatever) nil)), so that you don't pay the cost of boxing up the return value. not sure if it's relevant here, but can help

22:58 lazybot: Message saved.

22:59 sineer: ToBeReplaced: I believe you but I just don't see how :-( I may be too tired

22:59 I tried this version instead and it just won't do what I want not sure why

22:59 (swap! app-state update-in [:todos] (fn [todos] (into {} (for [[k v] todos] [k (assoc v :completed (not v))])))))

23:01 won't update-in pass current value of :todos to my (fn ...) and that fn walk eack todos and toggle :completed ... that's what I want but it doesnt work :-(

23:01 oh I think I see and error on the (not v)

23:02 right... got it! (not (:completed v))

23:02 this is crazy hard!

23:03 alexyz: what's the idiomatic/recommended way of dealing with the following scenario: an HTTP response which depending on its content-type should be processed in different ways. I assume it's not a bunch of ifs

23:04 ToBeReplaced: sineer: maybe... you might want (update-in v :completed not); not sure what you are looking for

23:04 sineer: generally, break it down further thoguh... and dealing with nested maps is painful; consider other data structures

23:05 alexyz: there are a few content negotiation libraries, if that's what you mean

23:06 sineer: The goal is to hook up that nested map with firebase pub/sub and sync them todos overthewire.. I can't think of a way to do that without nested maps :-(

23:06 alexyz: ToBeReplaced the question is more generic, in the sense: you have a hashmap and you want to apply different functions depending on the value of a key

23:06 ToBeReplaced: if you're talking about dealing with different Accept headers... clojure support is very poor; liberator does okay with it, and i wrote a library to at least solve part of the problem in hopes that someone else would continue doing more of the work

23:06 alexyz: multimethods

23:07 sineer: i.e. each todos need guid cause another remote user may edit that todo live and pub/sub will notify you (walking a seq of todos would be inneficient I assume)

23:07 alexyz: ToBeReplaced: gonna read about that

23:07 thanks

23:10 ToBeReplaced at the first glance multimethods look exactly as what I was looking for

23:11 ToBeReplaced: cool, good luck

23:20 amalloy: alexyz: you're talking about your client responding to a server's message, right? not like writing your own server with ring?

23:21 multimethods work fine in either case, but if you're writing a ring server you can do better by writing handlers like (fn handle-text [req] (when (text? (content-type req)) (...))), and then gluing them together with compojure/routes

23:42 ToBeReplaced: amalloy: why is that better?

23:43 it has to cascade through handlers, and it's closed off

23:44 amalloy: ToBeReplaced: it's a reusable solution: you can write something like (defn content-type-dispatch [content-type->handler] (routes ...)), which takes a map from type to handler. compare this to having to write a brand-new defmulti every time you need to do something different based on content types

23:45 multimethods aren't things you can work with as first-class values; you have to write a defmulti and N defmethods for every function call that you want to do dispatch

23:45 and they can't close over locals like functions can

23:48 ToBeReplaced: i think we've had this discussion before; for me, i haven't (ever?) felt the need to close over locals before dispatch

23:49 you don't have to write a new defmulti for each dispatch, but you do have to come up with a dispatch heirarchy -- i view multimethods as more clear for that than chained functions, but i get the other side... i think in both cases you write N new methods/functions, as you should

Logging service provided by n01se.net