#clojure logs

2014-10-04

00:02JCvexdbash: or anyone with lein uberjar experience.
00:02JCvexIs 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 [])
00:27danneudevn: i'd force you to implement a SOAP+WSDL middleman between us until you decide to just enforce a standard data format
00:28danneui dont really understand the question youre trying to get at, tho. if i call first on everything and get nil sometimes, what's wrong?
00:30TEttinger,(first nil)
00:30clojurebotnil
01:22dagda1_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
01:33joshuafcole,(assoc-in [[1 2 3] [1 2 3] [1 2 3]] 0 0 3)
01:33clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (4) passed to: core/assoc-in>
01:34joshuafcole,(assoc-in [[1 2 3] [1 2 3] [1 2 3]] [0 0] 3)
01:34clojurebot[[3 2 3] [1 2 3] [1 2 3]]
01:34joshuafcoledagda1_
01:34joshuafcolealso see update-in if you want to transform the old value into a new one
01:35dagda1_joshuafcole: thanks
01:35joshuafcolenp
03:05mantasmwondering 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?
03:09cflemingmantasm: No, neither pulsar nor core.async can stop those blocking.
03:09cflemingmantasm: They might provide an API which uses NIO behind the scenes, but you can't convert a blocking call into a non-blocking one.
03:13mantasmhuh! 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.
03:28dbaschwhat makes you think golang or node have any magic that can make blocking calls to outside services nonblocking?
03:34mantasmas 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
03:34mantasmeven if there exists a non-blocking library for postgresql (there does!).
03:39justin_smithmantasm: korma is just a macro layer over jdbc, and uses whichever jdbc adaptor is loaded
03:41justin_smithmantasm: those os level constructs are what java.nio uses, btw
03:42justin_smiththe main hangup there is that everyone is reluctant to use a version of the jvm that isn't 8 years old
03:45cflemingmantasm: Right, node or golang are no different.
03:46mantasmjustin_smith: as i understand, you can't just "add" to JDBC, i believe it's interface is inherently blocking.
03:46cflemingmantasm: Go threads can't magically make blocking OS calls non-blocking either - it needs lib support.
03:47mantasmcfleming: 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.
03:47cflemingmantasm: Which Java/Clojure is perfectly capable of supporting given the right libs. Whether they exist by default is another question.
03:48mantasmcfleming: 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.
03:48cflemingmantasm: btw this is a great read: http://paultyma.blogspot.co.nz/2008/03/writing-java-multithreaded-servers.html
03:48cflemingmantasm: Threads are not that bad these days.
03:49cflemingmantasm: i.e. I'd want to be sure that you really need NIO, after all people write very high-performance code with JDBC
03:59mantasminteresting! 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
04:00mantasmperhaps there's no inherent reason for greenthreads to be lighter than os threads.
04:39dysfuni'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?
04:39dysfuns/single/symbol/
04:39dysfunit seems a bit intermittent and lein clean has no effect
04:55TEttingerdysfun, pastebin/refheap the code?
04:55TEttingerclojure not clojurescript, right?
04:55dysfunas i said, intermittent. it's not currently displaying
04:55dysfunyes, clojure
04:55dysfunbut i've hit another thing anyway. i've used gen-class and i can't find the class from a clojure module
04:56dysfuni'm using a java api that requires a class to extend an abstract class
04:56TEttinger:aot is compiling the ns with gen-class ?
04:56dysfun:aot is required for gen-class that isn't main?
04:56TEttingeryes
04:57TEttingeralso required for main, usually
04:57dysfunright, with aot on it works now, thanks
04:58TEttingeryay
05:01dysfunhrm, balancing parens with lots of java imports is tedious. i should probably learn paredit
05:11AimHereIf you're going to learn paredit ,do so immediately so you can get your fingers programmed appropriately
05:12AimHereIt's hard to unlearn your already ossified way of writing code to suit paredit's way of doing things
05:12dysfunit's on the list of stuff to do
05:13dysfunbut 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 :)
05:13AimHereYeah, I find the barrier to paredit isn't so much emacs as the order that I write code in
05:14dysfunwell 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?"
05:36dysfunhow do i change the namespace nrepl loads into?
05:36dysfun(from the server side)
06:07jewhadjihadif i talk at the speed of shit. do you have to listen
06:07jewhadjihadlol
06:10philibidobusterhey 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.
06:10philibidobusterlol
06:10philibidobustermy AI speaks Booklao
06:13WARdriversFTWhi everyone. i talk to myself at night
06:13WARdriversFTWcan you respond
06:14WARdriversFTWlol
06:14WARdriversFTWhey did you steal my AI.?
06:14dysfunwould you mind not filling the channel with crap?
06:14WARdriversFTWohio
06:14WARdriversFTWi didnt know there were bots in here
06:15WARdriversFTWbut wait theres more
06:17Kilocanoehey man ill suck yo dick fo 5 dolluhs
06:17BronsaKilocanoe: cut it out
06:18gefilltefishno thank you everyones ass sleep
06:18gefilltefishbut wait theres more
06:18gefilltefishdo you have your VIP6 address
06:18gefilltefishor you ADD DHD device kode?
06:19Bronsaslaughterkillsho: you'll get banned as soon as an op joins if you don't stop with this
06:20slaughterkillshook i have a torrential tribute problem with clojure. wat to do?
06:20slaughterkillshohey Bronsa
06:20slaughterkillshour in the wrong internet
06:21slaughterkillshowhy u in my LAN BRUH
06:21slaughterkillsho?
06:21slaughterkillshoits on like donkey kong nagger
06:55small-chimpMICROSOFT WINDOWS IS GOOD
06:55small-chimpi am so anygry because of functional programming i like much more languages like lisp and c which are not functional
06:55mirfdafuq?
06:55mirfI'll bite
06:55small-chimp?
06:56mirfme too :D
06:56mirflisp isn't functional?
06:57small-chimpis lisp is not functional true? or what are yuo talking about
06:57gfredericksso we need a european op now?
06:57mirf" i like
06:57mirf much more languages like lisp and c which are not
06:57mirf functional
06:57mirf" i like
06:57mirf much more languages like lisp and c which are not
06:57mirf functional
06:57mirfoh fuck
06:58mirfdidn't mean to paste that so many times!
06:58small-chimp?
06:59small-chimpif i was a dog i would like to chase my tail because of functional languages
06:59mirfrecursion!
07:19m1dnightIf I want to test in a macro is something is a variable name, how do I do that?
07:19m1dnightI want to parse "[:message var1 var2]. I want to count how many "arg" things there are.
07:20m1dnightCan't seem to test it in the repl because it says undeclared obviously
07:20m1dnight*var things
07:33cflemingm1dnight: Quick reminder to send me your indentation problem in Cursive, when you get a chance.
07:34m1dnightRight! I found it cfleming but when i tried ctrl-alt-L it worked.. so I couldn't reproduce it
07:35cflemingm1dnight: 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?
07:35cflemingm1dnight: Anyway, glad it's working!
07:35m1dnightYeah, but if I run into one I'll make sure to notify you :)
07:35m1dnightAre you a Cursive dev?
07:35cflemingGreat, thanks.
07:35cflemingm1dnight: Yep
07:35m1dnightGreat work man, thanks! :)
07:35cflemingm1dnight: The Cursive dev, in fact, it's just me.
07:36cflemingNo problem, glad you're liking it!
08:01hellofunkin 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?
08:01hellofunk*known not "none"
08:36gfredericksoh crap I can't use ex-info in the nrepl code :(
08:36Bronsagfredericks: back compatibility?
08:37gfredericksyeah
08:37gfredericksit's set to build with 1.2
08:37Bronsagfredericks: https://github.com/clojure/tools.reader/blob/master/src/main/clojure/clojure/tools/reader/impl/utils.clj#L18-L45
08:38gfredericksomg
08:38Bronsaactually just https://github.com/clojure/tools.reader/blob/master/src/main/clojure/clojure/tools/reader/impl/utils.clj#L31-L45
08:38Bronsaand https://github.com/clojure/tools.reader/blob/master/src/main/clojure/clojure/tools/reader/impl/ExceptionInfo.clj
08:38gfredericksBronsa: is there a policy about how far back support should go? Looks like you're going to 1.3?
08:39m1dnightCan you cast a symbol to a string? I want a list of varnames to keywords but I can't seem to get it
08:39Bronsagfredericks: don't think so. some contrib even require >=1.5.1
08:39m1dnighta string to a symbol was easily found in the docs, but not the owther way around
08:39gfredericksBronsa: is that a bug that you have two definitions of `ex-info?`
08:39gfredericksBronsa: yeah; nrepl is kind of fundamental though
08:40Bronsagfredericks: no, one is for c.l.ExceptionInfo and the other is for c.t.reader.impl.ExceptionInfo
08:40gfredericksBronsa: oh I see -- the indentation is deceptive and made it look like a clobber
08:40Bronsauhm yeah, indentation looks broken there
08:42m1dnightoh, i found it :) nvm
08:42gfredericks,(str 'foo/bar)
08:42clojurebot"foo/bar"
08:43m1dnightI tried that but that didnt seem to do it..
08:43m1dnight(str ":" var) works fine
08:43m1dnight(in a macro)
08:43Bronsagfredericks: I don't think anybody would be bothered about libs dropping 1.2 support now btw, it's ancient enough
08:43gfredericksm1dnight: oh you're talking about keywords, not symbols?
08:43gfredericks,(pr-str :foo/bar)
08:43clojurebot":foo/bar"
08:43m1dnightthe var is a list of symbols, and I want to cast them to keywords in my macro
08:44m1dnightBut they are unbound variables in the code that has to be expanded, so they are keywords then?
08:44gfredericksBronsa: well it'd be 1.3 as well if I want ex-info
08:47Bronsayeah, I really wish some stuff like ex-info got backported
08:57gfredericksBronsa: we need a backport contrib library
09:01cflemingHow many people are still on 1.3, even?
09:07cflemingI'm starting to feel conservative because I'm not running 1.7 alpha - people seem to be putting that into production now.
09:08gfredericksthe oldest thing I hear of is people using storm grumbling about 1.4
09:10gfrederickshey I can fake an ex-info by using proxy and implementing IDeref :P
09:10gfredericks,(proxy [Exception clojure.lang.IDeref] ["Abort! Abort!"] (deref [] {:foo [1 2 3]}))
09:10clojurebot#<Exception$IDeref$e595a7c1@129b25c: {:foo [1 2 3]}>
09:11Bronsahow will you be able to catch that though?
09:11Bronsacatching Exception and testing for IDeref?
09:11gfredericksnobody's going to write a catch statement for this exception
09:11gfredericksbut yeah that would be the only way
09:12Bronsait's not actually too bad
09:12gfredericksI'm curious what chas would say
09:14gfredericksI think I'm going to find out :)
09:41tvanhensAnyone know how to turn off auto-jumping to errors in emacs using cider?
09:43Bronsatvanhens: 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)"
09:44tvanhensI 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
09:44nkozothere is some new approach besides the "<?" pattern introduced by David Nolen to manage exceptions in core.async go blocks?
09:46tvanhensis there any way to turn off jumping on error in the .clj buffer in emacs?
10:02martinklepschare there any specific techniques when it comes to working with data sets bigger than what fits into RAM?
10:03martinklepschdatabases seem like the solution kind of but I wonder if there might be other appraoches
10:03martinklepschbasically I'm working with a huge pile of clojure data structures
10:09jphxmartinklepsch: isn't there a book on working with data in clojure?
10:09jphxi wonder if that would cover your question
10:12martinklepschhttps://github.com/erochest/clj-data-analysis/blob/master/index.md
10:12martinklepschjphx: this is the book you're talking about I assume?
10:13martinklepschI'll take a look, thanks!
10:28gfredericksoh gracious
10:28gfredericksI don't understand this nrepl ordering thing at all
10:28gfredericksor it's buggy
10:28gfredericksbut I can't tell which
10:30martinklepschis there something like (< "abc" "efg") that would tell me if the first comes before the second when alphabetically sorted?
10:30gfredericksthere is compare, and this lib I wrote yesterday that does the < sugar for you
10:30gfredericksgithub.com/gfredericks/compare
10:31gfredericks,(compare "abc" "efg")
10:31clojurebot-4
10:31gfredericks,(compare "efg" "abc")
10:31clojurebot4
10:33martinklepschI was confused about the output of compare (apparently random numbers at first sight)
10:33gfredericksyeah :/
10:33martinklepschbut so if it's negative the first is before second and so on?
10:33m1dnightit appears that the lein repl does not properly exit.. I suddenly ran out of memory and saw an endless list of leiningen processes
10:33gfredericksyep, neg vs 0 vs pos
10:33m1dnightanyone else had that?
10:34martinklepschgfredericks: think I'm just gonna use your lib
10:35gfredericksw00h00!
10:35technomancym1dnight: on windows?
10:35m1dnightxubuntu 14.04
10:35martinklepschgfredericks: (y)
10:35technomancym1dnight: hm; I've only heard of it happening on windows
10:36m1dnightstrange.. I'll try and reproduce though
10:36m1dnightafter I commited everything
10:43gfredericksthink I'm gonna create a ticket called "middleware linearization is still weird"
11:07justin_smithm1dnight: launching the repls via your editor?
11:07m1dnightjustin_smith: nope, via terminal
11:07m1dnightI have a repl running in emacs as well though. But only started once.
11:07m1dnight.oO(emacs could be the possible source too then, I presume)
11:07justin_smithm1dnight: then it should be trivial to see if the process edited - if you get back to the shell, it is gone
11:08m1dnightYes, 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:21m1dnightheh, 2 seconds to pass send a message between actors 10k times..
11:21m1dnightnot too shabby, I guess :p
11:22m1dnights/10k/100k
11:28patrkrishi 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:29patrkristhis is for a web app specifically
11:32martinklepschpatrkris: environ is popular for that kind of stuff
11:32martinklepschit offers a few other ways to supply vars than env vars which might be what you want for testing and similar puposes
11:32patrkrismartinklepsch: i'll check it out, thanks
12:02gfredericksalmost done with a proof-of-concept for repl history
12:02offenderi am so offended because clojure is not assembler
12:05gfredericksokay now I need a better name than repl-history
12:06bbloomgfredericks: what's it do exactly?
12:06gfredericksbbloom: keeps a history of all the return values from your repl session and makes them lexically available
12:06gfredericksas &3, &4, etc
12:07gfredericksit's like *1 but absolute
12:07gfrederickserlang repl does this
12:07bbloomyes.
12:07Bronsanice!
12:07bbloomi abuse http://reference.wolfram.com/language/ref/Out.html in mathematica all the time
12:08bbloomnice to have In too
12:08gfredericksthat was the thing wolfram was apologizing for in his talk?
12:08bbloomyeah
12:08gfredericksokay I'll push this up as repl-history until I think of a better name
12:08bbloomhmm wait we can do this
12:09gfredericksa feature that seems to be too hard: make the repl prompt show the next value to be defined, as in erlang
12:09gfredericksokay I will wait
12:09bbloomsome words to work with: logs, record, history, chronology
12:10luxbockare you altering the repl-prompt as well, or how do you know which var maps to which output?
12:10bbloomsurely there's a good name in here somewhere, hit the thesaurus
12:10gfredericksin this PoC it will print to stdout just before showing the value
12:10gfrederickse.g., (inc 41) will print "&3:\n42"
12:11bbloomgfredericks: The Chronicles Of Repl
12:11gfrederickswhere the first line is stdout and the second line is the return value, so most clients format them differently
12:11gfredericksbbloom: yes clearly that is the best name
12:11luxbocknice, I'll definitely use it as well
12:11bbloomgfredericks: do you have to hack nrepl/etc to make it work? aka can i play nice with whidbey?
12:12bbloomreplog
12:12gfredericksbbloom: it's a middleware, without any real hacking; I think it works fine with whidbey, because it acts before printing
12:12bbloomok cool
12:13gfredericksbbloom: the hackiest thing it does is wrap the input code with (let [[&1 &2 ...] *thing*]\n<<real code here>>\n)
12:14gfredericksthere'll have to be configurability around naming & garbage collection and stuff I assume
12:14gfredericksreplog is not bad
12:15luxbockgfredericks: 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:16gfredericksluxbock: that's a cute idea; certainly tracking inputs as well isn't too hard
12:17allenj12hey, what is the best way to parse a get response from json to a clojure data structure?
12:17gfredericksluxbock: could be named like &42' :)
12:18luxbockhmm I think I recall seeing a cider issue around variables that contain the quote character
12:18luxbocklet me see if I can find it and see if it's relevant
12:19gfredericksbbloom: my only hesitation is that the idea of logging more readily suggests file persistence or something like session/gorilla-repl
12:19gfredericksit's tricky to avoid those associations
12:19bbloomgfredericks: well then clearly you must implement that
12:19bbloom:-)
12:19gfredericks:P
12:19gfrederickswouldn't be hard to implement an export, especially if we track inputs
12:20bbloomkovas had some voodoo in session for querying the datomic database of repl inputs/outputs
12:20bbloomwas pretty cool
12:21gfredericksalright replog it is why not
12:21luxbockgfredericks: here is the issue: https://github.com/clojure-emacs/cider/issues/713
12:21luxbockI guess it's not really relevant
12:21luxbocksince it's about eldoc
12:21gfredericksyeah I use such things all the time
12:28gfredericksokay here is the PoC code: https://github.com/gfredericks/replog
12:53luxbockgfredericks: your version of debug-repl looks really nice, I'll give it a go
12:59bbloomgfredericks: i get an attribution? aw shucks. thanks
13:00bbloomgfredericks: the GC issue is interesting. there isn't any obvious good way to decide when/what to discard
13:01bbloomdavid barbour has written some interesting stuff about "exponential decay of history"
13:04jeremyheilerfor 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:05hiredmandamn you, I just speant the last 5 minutes shovling through google looking for that
13:05hiredmanhttp://awelonblue.wordpress.com/2013/01/24/exponential-decay-of-history-improved/
13:06gfredericksbbloom: an attribution and 20% of my internet profits of course
13:06bbloomhiredman: i could have linked you to it :-P
13:06gfredericksjeremyheiler: bloom: yeah tracking usage is my only good idea for GC
13:07hiredmanbbloom: well, I didn't actually remember any of the words involved beyond exponential decay
13:07bbloomgfredericks: seems like it would be sufficient to provide a few things: clear/truncate history, evict particular entry, etc
13:07gfredericksexponential decay reminds me of probabilistic data structures
13:07hiredman(yet I still found it in google, just not before bbloom swooped in)
13:08gfredericksbbloom: yeah, definitely manual behavior as well
13:08bbloomgfredericks: http://reference.wolfram.com/language/ref/$HistoryLength.html i
13:08hiredmanthe big question is what happens to the names on eviction?
13:08gfrederickshas anybody tried replog and gotten a ClassNotFoundException printed on repl startup (with no apparent ill effect)?
13:09bbloomyou can set $HistoryLength to 0 and back again to free memory
13:09bbloomnot 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:09gfredericksinteresting
13:10bbloomi guess you can clear an individual entry with set! too
13:10bbloom(set! &2 nil)
13:10gfrederickswell they're not varn
13:10gfredericksvars*
13:10gfredericksso that wouldn't work in the current impl
13:10bbloomor (ns-unmap *ns* &2)
13:10bbloomah, ok
13:10bbloomyou'd still be leaking the var, just not its value
13:11bbloomlol this page http://reference.wolfram.com/language/tutorial/MemoryManagement.html actually recommends:
13:11gfredericksI thought about vars but it seemed bad because then they're sensitive to namespace switches, and they're not session local
13:11bbloomUnprotect[Out]; Out[2]=.
13:11gfredericksthose might not be big enough deals, maybe vars are better
13:11bbloomheh, apparently . is a value that causes undefining to occur... learned some more mathematica
13:12bbloomhttp://reference.wolfram.com/language/ref/Unset.html
13:12bbloomsheesh, so much stuff
13:12gfredericksI can't figure out why entering `:foo :bar :baz` at the repl isn't broken
13:13bbloom,:foo :bar :baz
13:13clojurebot:foo
13:13bbloomheh, in my local repl it prints all 3
13:13bbloomwacky
13:13gfredericksin a normal repl it returns 3 values
13:13hiredmangfredericks: 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:13gfredericksbut I would think my hack of wrapping the code string would break that; somehow it doesn't
13:13bbloomgfredericks: but *1 is just the last one
13:13gfrederickshiredman: yeah somebody mentioned inputs already
13:13hiredman(of course then you are high and dry until clients start speaking the new command)
13:14bbloom1 2 3 seems to work too, seems like it's reading until eof or something
13:14gfrederickshiredman: I could add nrepl commands but don't know enough about hacking clients to tap into it
13:14hiredmanright
13:14gfredericksbbloom: yeah that's normal; I just can't figure out why replog doesn't break it
13:14gfredericksit should be rewriting to (let [...] 1 2 3)
13:15hiredmanI actually installed and fiddled with gorilla repl the first time the other day, seems neat
13:17arrdemcouldn'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:17gfrederickswhat.
13:18gfredericksI can't possibly imagine whatever that means being easier than what I did
13:19arrdemoh it wouldn't be easier but it does something about bbloom's raised GC issue(s).
13:19arrdemnot sure you can actually do that however... &3 as a bare symbol wouldn't be legal without some serious legwork
13:19gfrederickshuh? what's not legal about it?
13:19luxbockyou could keep track of only the inputs and then eval them when you encounter it's matching var
13:20ltwIs 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:21disclojureso 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:21gfredericksluxbock: so no side effects allowed?
13:21arrdemltw: (for [[k vals] $MAP v vals] [k v])
13:21disclojureif so i got a few big mouths
13:21luxbockgfredericks: yeah I guess you'd lose that :/
13:21disclojureand some speedKracKKEd keyboards
13:21arrdemdisclojure: wrong channel?
13:22gfredericksarrdem: &3 is a legal symbol
13:22ltwarrdem: thanks a heap!
13:22gfredericksat least according to the reader and the compiler
13:22arrdemgfredericks: 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:23hiredman& is too
13:23lazybotjava.lang.RuntimeException: Unable to resolve symbol: is in this context
13:23hiredman,(let [& 1] &)
13:23clojurebot1
13:23hiredman,(let [% 1] %)
13:23clojurebot1
13:24gfrederickshiredman: not only is it legal I think it's totally unambiguous alongside normal destructuring/varargs usage
13:38WilduckHas 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:45bbloomi'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:45arrdemno but someone else asked about exactly this yesterday
13:46arrdemdon't remember if they got a fix or not tho...
13:48bbloomi don't think he got a solution really
13:48bbloombut hiredman's comment is a hint: "replacing" a function
13:48bbloomnot sure where/how i'm doing that... since i'm not using with redefs or anything
13:48borkdudetoday I did a go workshop: nice to see where clojure got the go/channel idea from :)
13:49bbloomborkdude: go certainly inspired/influenced core.async, but both of them got it from some ancient literature
13:49sineerborkdude: ain't golang tutorial sweet? :-) i'm trying to finish Pipelining is very cool.
13:50borkdudesineer I haven't yet tried that
13:51sineerfunc 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:52bbloomhiredman: 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:53arrdembbloom: 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:54arrdembut that's all that I can tell from the error message
13:55bbloomhm ok, gonna try to track that down
13:59Bronsa,(defn x ^long [] 1)
13:59Bronsa,(defn y [] (x))
13:59clojurebot#'sandbox/x
13:59clojurebot#'sandbox/y
13:59Bronsa,(with-redefs [x (fn [] 1)] (y))
13:59clojurebot#<ClassCastException java.lang.ClassCastException: sandbox$eval71$fn__72 cannot be cast to clojure.lang.IFn$L>
13:59Bronsabbloom: ^
14:00Bronsathis is why that happens
14:00bbloomBronsa: i'm not doing any redefs though...
14:00Bronsaalso this is the third time somebody asks about this in 3 days
14:00csd_Can someone please tell me what might be going wrong here? http://pastebin.com/XcXshaFZ
14:00arrdemOh. Right. OLO means (λ Object → Long) → Object
14:00bbloomand i can't even figure out which function is the one being called
14:00Bronsabbloom: maybe no with-redefs, binding is dorked in the same way
14:00bbloomarrdem: no, there's no currying
14:00bbloomBronsa: no binding either
14:01arrdembbloom: right I'm just abusing the notation
14:01Bronsabbloom: I really don't think that can be the case though
14:01bbloomBronsa: there are zero dynamic vars or with-redefs in this project
14:01bbloomi just grepped to be sure :-P
14:01Bronsa.invokePrim is only inserted for defns invokes
14:02bbloommaybe i copy/pasted a defn and left the original around?
14:03Bronsabbloom: 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:03borkdudeanyone tried https://github.com/runexec/possibledb yet? I just saw it on reddit
14:03bbloomBronsa: i've looked at every ^long in my program and none of those functions even take 3 arguments...
14:04BronsaOLO is ^Object [^long x ^Object y]
14:04arrdembbloom: two arguments. not three. that's what I was trying to say.
14:04bbloomooo
14:04bbloomhm
14:05bbloomwell none of two argument ones take ^long as the first argument anyway
14:05bbloomheh
14:07Bronsabbloom: yeah sorry, its Object (Object,long)
14:07bbloomoh, the last thing is the return value?
14:07arrdemyep
14:07bbloomsheesh, OL_to_O would have been nice
14:08bbloomthanks guys
14:10uptownhello 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:10csd_0.4.0 is the latest korma
14:11uptownoh ha ha
14:11bbloomBronsa: arrdem: seems like the problem is primitive type hints on protocols
14:11csd_the korma docs are woefully poor and their .com addy is out of date
14:11csd_that might not be the source of your problem though
14:12uptowni took sqlkorma.com's word for the version. doh http://sqlkorma.com/docs
14:12csd_https://github.com/korma/Korma
14:12csd_yeah its confusing
14:13csd_try putting [korma "0.4.0"] in your project.clj instead
14:17bbloomBronsa: arrdem: i switched from a protocol to an interface & it works now
14:24Bronsabbloom: were you using extend by any chance?
14:24bbloomno
14:25bbloomi 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:25bbloomswitched from protocol to interface, everything works
14:25bbloommake a few more tweaks, now it's all gone all together, just passing a function through by itself
14:25bbloomall good :-)
14:26bbloomalthough i guess maybe now it's boxing?
14:26bbloom*shrug* will profile/fix later
14:26Bronsauh
14:26Bronsalooks like it's a bug
14:26uptownokay, 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:26hiredmanbbloom: 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:26bbloomBronsa: i found an old thread that said protocols don't support primitive hints
14:27hiredmanthat is correct
14:27Bronsahiredman: that's exactly what's going on
14:27bbloommakes sense
14:27bbloomcan we concoct a minimal repo then pretty easily?
14:27bbloom,(defprotocol P (f [^long x]))
14:27clojurebotP
14:28bbloom,(deftype T [] P (f [x] x))
14:28clojurebotsandbox.T
14:28bbloom,(f (T.) 5)
14:28clojurebot#<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:28bbloom,(deftype T [] P (f [_ x] x))
14:28clojurebot#<CompilerException java.lang.IllegalArgumentException: Can't define method not in interfaces: f, compiling:(NO_SOURCE_PATH:0:0)>
14:28bbloomargh.
14:28hiredmannot enough args in your protocol function
14:28bbloom,(defprotocol P (f [this ^long x]))
14:28clojurebotP
14:28bbloom,(deftype T [] P (f [_ x] x))
14:28clojurebotsandbox.T
14:28bbloom,(f (T.) 5)
14:28clojurebot#<ClassCastException java.lang.ClassCastException: sandbox$eval155$fn__156$G__146__163 cannot be cast to clojure.lang.IFn$OLO>
14:28bbloomyup!
14:28bbloomhiredman: yeah, i was just using definterface which has implicit this, so i got confused
14:28bbloomheh
14:29hiredmanright
14:29hiredmanalso proxy
14:29hiredmanthat all is confusing
14:30bbloomfiled this: http://dev.clojure.org/jira/browse/CLJ-1548
14:31bbloommetadata: the cause and solution to all of clojure's problems
14:32hiredmanI imagine rich will just say "primitves aren't supported on protocols so stop type hinting them as primitives"
14:32bbloomhiredman: in that case, i may just submit a patch that dissocs tag from the symbols
14:33hiredmanbbloom: silently ignoring the hints? that doesn't seem great
14:33bbloombetter than not working :-P
14:33bbloomactually no
14:33Bronsahow about throwing an exception if you provide a prim hint?
14:33bbloomif protocols get type hinting support later, it could break
14:33hiredmanmaybe an error message when defining the protocol would be better
14:33hiredmanyeah
14:34hiredmanand, actually, throwing when defining with tags could break existing code
14:35hiredmanif someone only has higher order usage of some protocol function
14:35hiredman(but, well, why the heck would you tag that?)
14:35bbloomiirc i had to remove :tag from some metadata in some wacky macro stuff for some reason not too long ago
14:35bbloombut i forget why
14:36hiredmansimilar 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:37bbloomoh yeah, the lack of namespaces on method names is confusing at first
14:37bbloomthen you remember "holy shit. how did i live without namespaced methods back when i wrote java/c#/c++ ?????"
14:37bbloomnamespaced functions, imean
14:38gfredericksyeah the ruby people are always building their objects by mixing all sorts of modules together and just crossing their fingers
14:39bbloomfrom the zen of python: "Namespaces are one honking great idea -- let's do more of those!"
14:41uptownwhich 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:42uptowncan someone help me run this down?
14:43justin_smithuptown: why would cider effect this at all?
14:43hiredmanhttps://twitter.com/hiredman_/status/518465805378273280
14:46uptowni 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:47justin_smithuptown: your issue was that you had a dep on korma and could not use a specific korma namespace, right?
14:47uptowncorrect
14:48justin_smithcider does not do namespace dependency management, at all
14:48justin_smithhave you restarted your repl since adding the dependency to your namespace, or used a tool like alembic that loads new deps at runtime?
14:49uptowni restarted emacs entirely, just to be sure
14:50justin_smithin the repl, if you run "lein deps tree" in the project directory, do you see some version of korma being pulled in?
14:50uptownand i will gladly do that again, and also delete this code and start over if it will help
14:50justin_smiththe only thing that effects whether korma is available will be your project.clj
14:50uptownyes, when i updated to korma 0.4.0 i saw it get downloaded
14:51uptownand the error message changed
14:51justin_smithif you run "lein repl" in that directory, is it possible to use that namespace?
14:52uptownjust for clarity, from a shell command line?
14:52justin_smiththat's the only way to run lein repl, yes
14:52csd_uptown: try running cider-jack-in off the project.clj loaded in emacs
14:52borkdudewe did a workshop today. a lot of windows users who had trouble installing leiningen :(
14:53justin_smithborkdude: there is a chicken/egg problem with no clojure users on windows / clojure tooling not working on windows
14:53arrdemborkdude: technomancy's official line is that windows support is accidental :/
14:53borkdudewe got it to work on some machines, but it took some precious time
14:54justin_smithcsd_: easier way to diagnose that problem: does (.getCanonicalPath (java.io.File. ".")) return the top of the project directory?
14:54uptownokay, i did both 'lein repl' and restarted emacs and did cider-jack-in from the project
14:55justin_smithuptown: in the lein repl, try using the korma ns
14:55uptownnamespace 'korma.db' not found
14:55borkdudecfleming 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:56arrdemuptown: ... if you read the current korma docs on github, does korma.db still exist?
14:57uptowngah i've been following the example on the sqlkorma webiste. will look at git now.
14:57arrdemuptown: beat you to it. korma.db still exists.
14:57justin_smithuptown: arrdem: it should exist https://github.com/korma/Korma/blob/master/src/korma/db.clj
14:57arrdemjustin_smith: u 2 slow
14:58arrdemuptown: ... and you're booting your repl normally from within a dir with a project.clj listing korma as a dep?
14:58justin_smithuptown: 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:58uptownhave i got this right in my core.clj? (ns sqltest.core (:use (korma core db)))
14:59justin_smithno, absolutely not
14:59justin_smiththat is very wrong
14:59justin_smithin that repl, try (use 'korma.db)
14:59uptownone of my five lines
14:59arrdemuptown: if your project.clj doesn't include [korma "0.4.0"] you won't be able to use korma.
14:59justin_smitharrdem: I think that namespace declaration is the problem, we verified he is pulling in korma
14:59arrdemuptown: first things first, you do have the dep in place.
14:59uptownkorma is in my project dependencies
14:59arrdemjustin_smith: okay just making sure.
15:00justin_smithuptown: that ns declaration is fucked
15:01borkdudewhat kind of installer is this: http://leiningen-win-installer.djpowell.net/ - what leiningen version will it install
15:01borkdudesome guy tried it, but I wasn't sure if it worked
15:02Jaoodborkdude: you could go the 'java -cp clojure.jar' route
15:02borkdudeJaood neh, we needed people to run lein ring server + lein cljsbuild auto
15:02justin_smithborkdude: pulls in raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein.bat
15:02justin_smithas I see in https://bitbucket.org/djpowell/leiningen-win-installer/src/9c971dd33439158233624f2d9daac5fdc833e82a/leiningen-installer.iss?at=bitbucket-master
15:03borkdudejustin_smith cool, that should've worked then. I think the only problem then was putting the bin folder on the path maybe
15:03uptownokay, i unfucked the ns decl and now (use 'korma.db) gets me No such var: jdbc/db-set-rollback-only!
15:04justin_smithweird - what jdbc backend are you using?
15:04csd_did you put your jdbc driver in your deps?
15:04Jaoodborkdude: or maybe dockerized the setup
15:04justin_smiththe way jdbc works, it can use various adaptors, you need to ask for one of the adaptors in project.clj
15:04uptowni did and i can tell by looking at it now that it's outdated stuff from the website
15:04borkdudeJaood yes, docker on windows?
15:05csd_which db
15:05uptownpostgres
15:05justin_smithuptown: leaps and bounds
15:05justin_smithoh, thought you said "progress" at first, lol
15:06borkdudeJaood 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:06Jaoodborkdude: yeah, you need some vm
15:06csd_so you have something like [postgresql/postgresql "8.4-702.jdbc4"] in your deps?
15:07Jaoodborkdude: how about using putty and giving them ssh access to a linux box?
15:07justin_smithJaood: depends on how many TB of ram he has
15:08gfredericksterabarrels
15:08gfredericksteraboxes
15:08gfredericksterabison
15:08borkdudeJaood 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:08Jaoodjustin_smith: 1GB per user!
15:10justin_smithJaood: he mentioned he was having them each run a ring app
15:10uptown updated to [postgresql "9.3-1102.jdbc41"] but i get the same error message
15:11justin_smithJaood: (also I was mostly just being silly and joking about Clojure's heap usage)
15:11stuartsierraDoes anyone know who coined the phrase "Getting SLIMEd"?
15:12stuartsierraThe oldest references I can find are from technomancy on #clojure and the mailing list around 2010.
15:12Jaoodjustin_smith: yeah, I know ;)
15:12borkdudeI guess we could provide a VirtualBox image
15:12borkdudenext time
15:12uptownre: slimed, other than peter venkman?
15:13amalloystuartsierra: that's the oldest i can find too. i'm surprised no common lispers had that issue
15:13csd_uptown: unfortunately my laptop battery is dying so i have to drop off. this doesnt look like a cider issue though.
15:13Jaoodborkdude: I hear vagrant is good for that stuff
15:13stuartsierraamalloy: The issue was definitely known in Common Lisp, but I first heard the phrase related to Clojure.
15:13amalloyamazingly, 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:14amalloy>> 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:14stuartsierrauptown: specifically related to SLIME, http://common-lisp.net/project/slime/
15:14stuartsierraamalloy: :)
15:14stuartsierraEmacs reaches everywhere. :)
15:16justin_smithuptown: 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:16uptowni've used it in the other context
15:16stuartsierraNot to be confused with the current finicky to configure and often broken ways to use Clojure with Emacs.
15:16uptownheh
15:16amalloystuartsierra: 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:17gfredericksclojurebot: emacs is finicky to configure and often broken
15:17clojurebotIk begrijp
15:18borkdudehe talks Dutch / Afrikaans?
15:18justin_smithsometimes irish too
15:18amalloyjustin_smith: welsh
15:18justin_smithahh, sorry
15:19stuartsierraamalloy: That link seems to be using "slimed" to mean "brought into the coterie of SLIME users".
15:21uptownso it seems that i am caught in a korma + postgres bug, right?
15:22Jaoodthey share a bug? :)
15:22justin_smithuptown: yeah - check out the versions you are actually getting (via "lein deps tree")
15:23justin_smithI don't think this is a korma issue at all - korma is just a macro layer over clojure.java.jdbc
15:23uptownhm i get no output from that at all
15:23justin_smithuptown: running it in your project directory?
15:23uptowni am, yes
15:23justin_smiththat should print out a tree of all deps for that project, and what versions are being pulled in
15:25justin_smithan error I would understand - but no output at all is deeply weird
15:25uptowndeps has never returned anything for me. i don't know why. in an earlier, less tragic experiment i installed pprint and that worked
15:25uptownlet me do that again
15:25justin_smithno, not lein deps
15:25justin_smithlein deps :tree
15:25justin_smith:tree is part of the command
15:26uptownthe colon is significant to a noob
15:26justin_smithand it is part of the command
15:27justin_smithlein deps :tree
15:30uptowni had earlier played with [lobos "1.0.0-SNAPSHOT"] which was causing a jdbc version collison. fixed now. no errors at all
15:31justin_smithuptown: discovered via the deps tree I assume :)
15:31uptownyes, exactly. thanks for helping me along the agonizing process of clj de-noobification
15:32justin_smithno problem - I really wish we had a smoother and less surprise-filled onboarding process to the ecosystem
15:32justin_smithoh god I said onboarding non-ironically what is wrong with me
15:32uptownthere are lots of web resources that led me down various garden paths, yes
15:33justin_smithclojure moves to fast for top google hits to be helpful :(
15:35uptownyes, but part of de-noobification is learning how to find the clarifying information
15:36uptowndeps :tree was well hidden heh
16:11cflemingborkdude: I don't use windows, which script do you mean?
16:11borkdudecfleming I was aiming at something I said before, but I understand you miss context
16:12borkdudecfleming today I gave a workshop with leiningen + cursive. the windows users lost time by installing leiningen, which didn't go smooth
16:12borkdudecfleming it would be great if they could execute tasks from within intellij without installing lein.bat
16:13borkdudecfleming probably hasn't much priority, but maybe it would be easier for some beginners
16:14cflemingborkdude: yes, that's definitely on my list.
16:15cflemingborkdude: They would need to be able to create projects and run arbitrary tasks, right?
16:15cflemingborkdude: Anything else?
16:15borkdudecfleming yes, things like lein ring server + lein ring cljsbuild
16:15ajmccluskeyI 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:16borkdudecfleming do you think that would be possible without an external lein installation?
16:16cflemingborkdude: Ok. I'm planning a lein-focused release soon.
16:16cflemingborkdude: Yes definitely, Cursive bundles lein.
16:16borkdudecfleming that's great then
16:16ajmccluskeyShould my example code be considered the same bug, given that the argument to recur isn't using loop?
16:17ajmccluskeyI'm not across the internals of Clojure's compiler, so not sure if it's worth raising my example anywhere.
16:18amalloyajmccluskey: no, yours is not the same bug
16:19amalloyyour problem is that a boxed Byte is not the same as a primitive byte
16:20ajmccluskeyso it's not so much an issue as my misunderstanding of boxed vs primitive Bytes?
16:20amalloyyeah
16:20amalloythe compiler thinks you want to avoid boxing and unboxing, since you use a primitive byte as your recur arg
16:20amalloybut then you call first on a seq, which can't possibly return a primitive, and try to recur with it
16:21amalloyone approach, if you want to avoid boxing, would be to use a byte-array and aget, instead of a seq and first
16:21dbaschor wrap it in (byte …)
16:21amalloyright, that's the solution if you don't mind boxing
16:22ajmccluskeydbasch: 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:22ajmccluskeyamalloy: thanks, your explanation makes sense
16:23dbaschthat’s actually a pretty decent error message for clojure standards :)
16:25ajmccluskeydbasch: haha, it was certainly easier than some of the others I've managed to generate
16:26joobusdoes anyone know what happened to jark? https://github.com/icylisper/jark
16:26joobusand if there is something similar to jark now?
16:27justin_smithborkdude: https://twitter.com/HackerNewsOnion/status/518495442225479680 apropos
16:27borkdudejustin_smith lol
16:30borkdudecfleming awesome addition on key bindings!
16:32cflemingborkdude: Thanks! It's about time I got that in there.
17:23bbloomso sad that when i work on concurrency/async/etc i'm back in the blindfolded world i lived in prior to clojure
17:23bbloomthere's no "snapshot all the state right now" button
17:23bbloomi have to dig in to closured over values and other such nonsense
17:23bbloom:-(
17:24bblooms/values/objects
17:25bbloomsince 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:25bbloombut the state of the channels & other queues aren't as pleasant
17:25bbloomor hidden atoms too
17:39borkdudeso cool that these things type check with core.typed https://www.refheap.com/91169
17:50cddrIt 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:50cddrs/en/edn/
17:54borkdudewhat is the best way to include core.type checks in a continous integration, as a separate step or as part of lein test?
18:01borkdudeprobably easiest via lein typed
18:17johnny_mckDoes anyone have any good programming challenges for newbies to clojure?
18:17johnny_mckMost 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:18johnny_mckquit
18:45technomancyarrdem: "windows support is accidental" isn't the official status anymore
18:45technomancyFWIW
18:45technomancy(it's now only unofficial)
18:48bbloomborkdude: union types >>> sum types !!!
18:49tickingI think `as->` implementation is flawed. As it breaks recur.
18:49ticking,(macroexpand '(as-> x % (recur %)))
18:49clojurebot(let* [% x % (recur %)] %)
18:50ticking,(macroexpand '(-> x (recur)))
18:50clojurebot(recur x)
18:53dbaschwhy would aot compilation not find clojure.set?
18:56dbaschI cannot aot this in a default project with the latest leiningen https://www.refheap.com/91175
19:02gfrederickstechnomancy: so I guess officially windows is officially supported but unofficially it is only unofficially supported?
19:02gfredericksbbloom: welp now I know that union types are (apparently) not the same thing as sum types.
19:04bbloomgfredericks: 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:04bbloomgfredericks: 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:05bbloomgfredericks: disjoint sums are important for "principal types" and H-M inference
19:05bbloomand help with exhaustiveness checks
19:05bbloomnone of which i care about :-P
19:06sineerCan 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:07gfredericksbbloom: so that means that for a sum type defining ABC as AB or BC is illegal?
19:08sineerThat part: (assoc (hash-map (rest %1)) :completed
19:08sineer checked) I
19:08bbloomjulia> Union(Union(Int8, Int16), Union(Int16, Int32))
19:08bbloomUnion(Int16,Int32,Int8)
19:08bbloomgfredericks: ^^^
19:08legittalonOkay. So here's the plan: ClojureOS
19:09sineererr sorry, I'm trying to say that expression always return {:completed true} instead and ignore this part (hash-map (rest %1))
19:09sineerlegittalon: ClojureEmacs?
19:09gfredericksbbloom: I need to play with more type systems :/
19:11legittalonsineer: 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:12sineerhrmm 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:13sineerfor 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:14sineer(into {} (map #(hash-map (first %1) (assoc (hash-map (rest %1)) :completed true)) todos))
19:14dbaschsineer: you probably want assoc-in
19:15sineeroh yeah I bet you that's what I'm trying to reimplement hehe
19:16gfredericks,(assoc-in nil (range 10) :haha-what)
19:16clojurebot{0 {1 {2 {3 {4 {5 {6 {7 {8 {9 :haha-what}}}}}}}}}}
19:17sineerThanks guys.. I'd like to understand why it is my crazy implementation didn't work just to learn more too
19:18gfrederickssineer: ##(let [kv-pair [:foo 12]] {:rest (rest kv-pair) :second (second kv-pair)})
19:18lazybot⇒ {:rest (12), :second 12}
19:20sineergfredericks thanks.. does it work with nested maps too? I had it working earlier with kv-pair just not with nested hash-maps
19:21gfrederickssineer: my point is that `rest` isn't nearly as helpful as `second` or `val`, which do the same thing in this case
19:23technomancygfredericks: officially neither supported nor unsupported?
19:27dbaschanyway, why would this fail to aot-compile? https://www.refheap.com/91175
19:27gfredericksWindows 10 comes with leiningen pre-installed
19:49gfredericks"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:50sineerHrmm. how do I use assoc-in on multiple nested keys/hashmaps ?
19:50sineerLike, {:1 {:foo "bar} :2 {:foo "bar"}}
19:50gfrederickswhat do you want to get out of it?
19:51sineer(assoc-in [:foo] "baz") but that's nt what I want..
19:51gfredericksyou want to change both of the bars to baz?
19:51sineerI want to get {:1 {:foo "baz"} {:2 {:foo "baz"}}
19:51sineergfredericks correct
19:51gfredericksso 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:52sineerall top-level
19:52sineererr no all one level-deep
19:52sineerI'm forced to build and pass it list of all keys?
19:53gfredericksthat can be helpful; see reduce
19:53gfredericksthere are also some utility libraries, e.g. plumbing.core/map-vals
19:54vIkSiThi all
19:55vIkSiTwhen using clojurescript/om, how do I use om/root to specify a path into the cursor?
19:55vIkSiTI keep getting an "Uncaught Error: Vector's key for assoc must be a number. " by doing this:
19:56vIkSiThttps://gist.github.com/viksit/485bccd8be2d9d572052
19:58vIkSiTah, 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:07sineer(let [keys (map #(first %1) todos)] (map #(assoc-in todos [% :completed] checked) keys))
20:07sineerany ideas why it doesn't do anything to modify :completed in my nested hashmaaps?
20:08sineerkeys list has all the keywords inside todo nested hashmap
20:08sineeryet it doesn't modify {:1 {:completed false} :2 {completed: true}...}
20:09justin_smithdbasch: you need to require the namespace, right?
20:10dbaschyes, it makes no difference
20:10justin_smithbecause I have had similar errors with clojure.pprint (I thought it was automatic, but only because the repl had preloaded it)
20:16dbaschactually when I require the namespace it works, my bad
20:26vIkSiThrm, anyone use om here?
20:27sineerI'm trying hard to right now..
20:38sineerYES!!!!!! (into {} (map #(hash-map (first %) (assoc (second %) :completed checked)) todos)) that's what I needed... any better way to do that?
20:38sineerjust trying to read it hurt my brain
20:39dnolen_vIkSiT: a few people do, but also good to ask in #clojurescript, also the ClojureScript Google Group
20:42turbofail(into {} (for [[k v] todos] [k (assoc v :completed checked)]))
20:54sineerturbofail YES! Thank you very much friend!!
20:55gfrederickssineer: if you had map-vals, it'd be (map-vals #(assoc % :completed checked) todos)
20:56sineergfredericks nice.. and it's just a macro that does exactly what turbofail tought me except in a more readable way?
20:56gfredericksnot even a macro
20:56sineerwhat do you mean not even a macro? ain't reader macro what would be best to do that?
20:57gfredericks,(defn map-vals [f m] (into {} (for [[k v] m] [k (f v)])))
20:57clojurebot#'sandbox/map-vals
20:57gfredericks,(map-vals #(assoc % :completed true) {:foo {} :bar {1 2}})
20:57clojurebot{:foo {:completed true}, :bar {:completed true, 1 2}}
20:59sineergfredericks wouldn't a reader macro save a fn call? I just asking to learn more about reader macro :-)
21:00gfredericksI 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:00gfredericksit makes your code a lot more complicated
21:01dbaschthis particular case has absolutely nothing to do with macros
21:01sineerdoes 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:01gfredericksdbasch: you could save the call to f
21:02dbaschgfredericks: if you have to do performance optimization with macros, you probably know what you’re doing anyway
21:03dbaschso I’d just say no
21:04dbaschI mean, saving a function call… what do you have to be doing for it to be worth saving a function call?
21:04gfredericksI did say "almost never worth it"
21:05dbaschsince 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:06dbaschand found it to be about 50 times slower than using the reference java implementation
21:06dbaschI optimized it to be only 10 times slower and gave up
21:06dbasch(all for no particular reason)
21:07dbaschin particular just doing (apply str some-vector) is slower than the entire java code that creates a geohash
21:16justin_smithdbasch: 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:16dbaschjustin_smith: yes, I replaced all that by loops
21:16clojurebotI don't understand.
21:16justin_smithdbasch: ahh, that was the original, not the optimized, got it :)
21:16dbaschbrought an encoding from 11 us to 2.5 us
21:17dbaschthe java version takes 400 ns
21:17justin_smithanother thing to consider is using arrays instead of lazy-seqs or vectors for data that does not escape local scope
21:17justin_smith(if it does not change in length)
21:18justin_smiththat's not very clojurey but it performs well
21:18dbaschjustin_smith: this is where I got bored https://www.refheap.com/91181
21:20dbaschlong-to-hash is slower than the entire java impl, might as well use a StringBuffer
21:20dbaschthis is the java version https://github.com/kungfoo/geohash-java/blob/master/src/main/java/ch/hsr/geohash/GeoHash.java
21:20justin_smithyou know the size beforehand, it would be hard to beat just creating an array of that size and filling it
21:22dbaschjustin_smith: yes, but at that point I realized that there was no reason to do this when the java implementation works just fine
21:22justin_smithhell, even creating a transient vector of that size and assoc onto each index would perform better
21:22dbaschmight as well just do a wrapper
21:22justin_smithdbasch: why translate code that already works in your runtime? as an exercise I guess. But yeah, good point.
21:23dbaschI found that implementation and wondered why it even existed, as it was written after the java one
21:23justin_smithinteresting
21:24justin_smith(= (more clojure) (more better)) obviously
21:24dbaschand only 50x slower :P
21:24dbaschfor applications that use geohashes, performance is probably a concern
21:42sineerARRgg.. anyone please tell me why this don't merge/conj the hash-maps it just keeps last hashmap :(
21:42justin_smithgot a paste?
21:43sineerjustin_smith http://pastebin.com/HAjnE6yF
21:44arrdemtechnomancy: on sweet
21:44justin_smithsineer: that's not how you merge maps
21:44justin_smithsineer: do you want todos to be a sequence or a map?
21:45arrdemanyone know of a Ring analytics middleware? I only see one that injects google analytics nothing that does session tracking/logging.
21:45sineerjustin_smith a map
21:45justin_smithwith what key?
21:45sineerall the keys from both map
21:45justin_smithyou aren't handing it anything that would act as a key
21:45justin_smithuhh
21:45justin_smithno
21:46justin_smithsineer: can you give an example of what app-state should end up looking like?
21:46justin_smith(conj (conj {} {:a 0 :b 1}) {:a 1 :b 2}) ; this is what it is doing right now
21:46justin_smith,(conj (conj {} {:a 0 :b 1}) {:a 1 :b 2}) ; this is what it is doing right now
21:47clojurebot{:a 1, :b 2}
21:47arrdemjustin_smith: uhm.... conj is defined to be merge on maps?
21:47sineerwhy not? app-state { :showing :all, :todos {:1 {:id :1 :title "foo"} :2 {:id :2 :title "bar
21:47sineer"}}
21:47justin_smithconj a map onto another map just does a dumb merge, with any new key replacing an old one
21:47arrdem&(conj {} [:a :b])
21:47lazybot⇒ {:a :b}
21:47justin_smithsineer: OK, then you don't want conj, you want assoc
21:48sineerwhat you said conj does is exactly what I want...
21:48sineerdumb merge is find with me..
21:48justin_smith(swap! app-state update-in [:todos] assoc (:id new-todo) new-todo)
21:48turbofaildbasch: well, performance golf in high level languages is a great way to procrastinate from doing real work
21:48turbofaildbasch: that's my main reason for doing it
21:48arrdemsineer: conj does a nonrecursive merge, assoc creates an association. if you're just adding one key, assoc is the idiom not conj
21:48justin_smithsineer: no, what you are doing will not give you that result
21:48justin_smiththat's not how conj on maps works
21:49sineerok... thanks
21:49turbofailthat said whoever wrote that geohash implementation clearly wasn't even doing that
21:51sineerjustin_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:51dbaschturbofail: one nice thing about Java is that you have to try hard to implement an ok algorithm with terrible performance
21:51sineerthey both return hash-map don't they?
21:51dbaschit’s much easier to write hideously slow code in clojure
21:51justin_smithsineer: you wanted your data to be key/ val and you were just handing it all the keys and vals in your new element
21:52justin_smithsineer: so the combining was happening at the wrong structural level
21:52justin_smith,(assoc {} 1 {:id 1 :value 42})
21:52clojurebot{1 {:value 42, :id 1}}
21:52justin_smith,(conj {} {:id 1 :value 42})
21:52clojurebot{:id 1, :value 42}
21:53justin_smithboth are valid, they do very different things
21:53turbofaildbasch: yeah, it'd be nice if clojure could provide ways to accelerate the idiomatic cases
21:53myguidingstarhi 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:53sineerjustin_smith ok thanks a lot! I think I get it..
21:53turbofaildifficult to pull off though
21:54myguidingstarI mean how to share paths between sibling projects
21:54justin_smithsineer: 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:54sineeryeah I understand that :-)
21:54justin_smithboth work, one works out to be a bit more useful
21:55sineerI 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:56justin_smithsineer: that's not all you were doing, you were also learning about proper usage of data structures in clojure
21:56justin_smiththat's a one time cost :)
21:56sineertrue hehe.. I wouldn't say one time cost too.. I'm still very confused :-/
21:57justin_smithheh, it's still a one time thing to learn it, even if you have only partially learned so far
21:59sineerNext 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:59justin_smitherrand planner?
22:00sineerkinda I guess :-) Shared too using firebase pub/sub a la backbone...
22:00sineerjust proof of concept of course google map does that already :-)
22:01sineerI find extending todoMVC an awesome way to learn any lang..
22:03sineerAlso I think mixing up clojure immutability with Polymer through react to gain the "time travel" ability with webcomopnents must be really powerful!
22:10dbaschjustin_smith: this still takes twice as long as the entire java version of encode https://www.refheap.com/91184
22:11justin_smithinteresting
22:13dbaschjustin_smith: https://www.refheap.com/91185
22:14amalloydbasch: the quot there could be a bitwise operation
22:14amalloyremember from our recent discussion that the jvm can't optimize that out for you
22:14dbaschamalloy: tried that, made no difference
22:15dbaschit does make a difference for the mod, that shaves about 200 ns
22:15amalloywhat is encode-char?
22:16dbaschamalloy: see https://www.refheap.com/91181
22:16amalloyhashmap lookup on boxed Character objects!? that can't be fast
22:16dbaschit’s a boredom-fueled attempt to optimize https://github.com/talkto/geohash
22:17dbaschI hadn’t gotten to that part
22:17amalloydbasch: but it's the part that's slowing down the function you're trying to optimize :P
22:17dbaschtrue
22:18dbaschstill, it’s only 25% of the total encode function time
22:18amalloymy guess would be, inline it as something that macroexpands to (case n 0 \0 1 \1 ...)
22:18dbaschthe encode function in the above link takes about 11 us
22:18dbaschin the refheap, about 2.5
22:18dbaschthe java version about 400 ns
22:19dbaschit’s completely pointless anyway
22:24hiredmanan array would be faster
22:27dbaschhiredman: true, looking up the numbers 0 to 31 in a map is silly
22:28dbaschespecially a constant map for the range
22:29amalloyhiredman: 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:31hiredmanthat is my thinking
22:45sineerAnyone can tell whats wrong with this: (swap! app-state update-in [:todos]
22:45sineer (fn [todos] (into {} (map #(assoc-in % [:completed] not) todos))))
22:45sineerI get an Uncaught Error: Vector's key for assoc must be a number.
22:46sineertodos is a nested {:1 {:id :1 :title "foo"} :2 {...}} and I'm trying to update :completed within each nested {}
22:49dbaschamalloy hiredman aget from a ^chars array makes it slightly faster, but each aget still takes 40 ns
22:51amalloythat's hard to believe, dbasch. you must be doing some accidental boxing; on my POS desktop, aget from a char[] takes 6ns
22:54ToBeReplacedsineer: your function is calling (assoc-in [:1 {:id :1 :title "foo"}] [:completed] not)
22:54amalloymake sure the ints you're looking up are ints rather than longs, too
22:54dbaschamalloy: https://www.refheap.com/91188
22:55dbaschamalloy: (def a2 (char-array "0123456789bcdefghjkmnpqrstuvwxyz"))
22:56amalloy$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:56lazybotMessage saved.
22:58amalloy$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:58lazybotMessage saved.
22:59sineerToBeReplaced: I believe you but I just don't see how :-( I may be too tired
22:59sineerI tried this version instead and it just won't do what I want not sure why
22:59sineer(swap! app-state update-in [:todos] (fn [todos] (into {} (for [[k v] todos] [k (assoc v :completed (not v))])))))
23:01sineerwon'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:01sineeroh I think I see and error on the (not v)
23:02sineerright... got it! (not (:completed v))
23:02sineerthis is crazy hard!
23:03alexyzwhat'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:04ToBeReplacedsineer: maybe... you might want (update-in v :completed not); not sure what you are looking for
23:04ToBeReplacedsineer: generally, break it down further thoguh... and dealing with nested maps is painful; consider other data structures
23:05ToBeReplacedalexyz: there are a few content negotiation libraries, if that's what you mean
23:06sineerThe 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:06alexyzToBeReplaced 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:06ToBeReplacedif 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:06ToBeReplacedalexyz: multimethods
23:07sineeri.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:07alexyzToBeReplaced: gonna read about that
23:07alexyzthanks
23:10alexyzToBeReplaced at the first glance multimethods look exactly as what I was looking for
23:11ToBeReplacedcool, good luck
23:20amalloyalexyz: you're talking about your client responding to a server's message, right? not like writing your own server with ring?
23:21amalloymultimethods 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:42ToBeReplacedamalloy: why is that better?
23:43ToBeReplacedit has to cascade through handlers, and it's closed off
23:44amalloyToBeReplaced: 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:45amalloymultimethods 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:45amalloyand they can't close over locals like functions can
23:48ToBeReplacedi think we've had this discussion before; for me, i haven't (ever?) felt the need to close over locals before dispatch
23:49ToBeReplacedyou 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