#clojure logs

2013-02-21

00:12muhoooh yeah.... i've seen this before ,but forgot wtf it was about: "{"cn":"tOsgmP16Sh","tp":null,"osh":null,"ppu":"http://localhost:8080/robots.txt","lpu":"http://localhost:9000/robots.txt"}"
00:29technomancycallenbot: in the case of conkeror it's not to much "write an extension" as it is "dump a bunch of JS into an init file"
00:29technomancysince conkeror doesn't make the useless distinction between user extensions and the browser itself
00:42devnoh, if conkeror didn't suck...
00:42technomancyall software sucks
00:43technomancyit's a unit vector; if you're lucky you can find some that sucks in a direction you find less disagreeable
00:43devntechnomancy: that's true, but the age-old editor holy war still dictates that we compare all things emacs to all things vim
00:44devnvimperator and the like are maintained
00:44technomancyactually gecko vs chrome has interesting parallels to emacs vs vim
00:44devnconkeror, if you join the irc channel and ask about versions of xulrunner -- they'll tell you something like: "uh, good luck. you could try X.Y.Z and see if that works..."
00:44technomancygecko does the right thing and builds a runtime, then implements the application using the runtime, while chrome screws it up and hard-codes everything in C++
00:46devnconkeror also may as well just be vimperator in a whole mess of ways. a good number of the chords that are emacs-like act basically like: leader + char + char + char +char
00:46devnmight as well just use vimperator at that point
00:46technomancysome of the focus commands are weird
00:47technomancythe only thing that's ever really bothered me is the fact that github steals certain bindings in a way that I've never figured out how to override
00:47devn*nod*
00:47devnI gave up on conkeror awhile ago just because upgrading seemed like an exercise in futility
00:47technomancypretty minor pain point compared to reprogramming my brain stem
00:47devnagain, maintainership is the real problem
00:47devnthe wiki is badly out of date
00:47technomancyI dunno... at some point it's more or less done.
00:48devntechnomancy: the instructions on the wiki are flat out wrong for OSX
00:48technomancyit's so far ahead of anything else I've tried that it doesn't need any actual further development
00:48devnand have been for almost a year
00:48technomancythat's horrible... it's a wiki.
00:48technomancydon't OS X users actually bother to fix it?
00:49devni guess it's mostly anecdotal from my point of view, but my experience has been that people in the community quietly acknowledge that no one cares about it
00:49devnand by community i mean #conkeror
00:49technomancyoh, I didn't know it had its own channel
00:49technomancyI've gotten lots of help in #emacs
00:50devntechnomancy: do you actually use it as your primary?
00:50devn(browser i mean)
00:50technomancyyeah, I use it for everything except sensitive work stuff that runs under a separate unix user
00:50devnyou're a better man than me,
00:50technomancybut I don't do any web development
00:50devnah!
00:50devnyeah, chrome won
00:51devnalso, the latest builds of firefox. there's cool stuff in there. stuff that i had 0 access to in conkeror.
00:51technomancyluckily it fits my requirements perfectly, except for the whole "you have to write javascript to hack it" part
01:00muhoosolution found: https://www.refheap.com/paste/11583
01:00muhooneermind piggieback and nrepl, doesn't work. regular cljsbuild repl-listen *does* work, so, yay
01:15vurmaA little question here.. Iv been writing most of my code in C, and for its speed, i really think its the way to go for what im working on.
01:16vurmaSo, is there any way, besides clojurec or going through Java that i can interface clojure with C ?
01:19vurmaI guess i could go with swig on that as well..
01:19vurmaIdeas?
01:29Sgeovurma, Jnaerator?
01:33vurmaSgeo, how did i manage not to run into that one?
01:33vurmaThanks a bunch :3
01:33vurma(munch munch)
01:33Sgeoyou're welcome
01:38nightfly\
01:39vurmaSgeo, i was thinking about going with swig first, but i dont have any experience with how hard i would be to use it for larger projects (the native compiling process and all that).
01:40nightfly\\\\\\\\\\\\\\\\\\\\\\
01:40nightflysorry...
01:40ivancat owner detected
01:56wei_is there a good way to splice items conditionally into a list? e.g. [1 (when true *[2 3]) 4] => [1 2 3 4]
02:03amalloy&`[1 ~@(when true [2 3]) 4]
02:03lazybot⇒ [1 2 3 4]
02:04wei_oh! awesome
02:10wei_&`[1 ~@(when false [2 3]) 4]
02:10lazybot⇒ [1 4]
02:10wei_does it work in clojurescript too?
02:16amalloytry it and see
02:22devnJavellin is really cool
02:22devn"Spreadsheet-like programming" is such a great way to explain FRP
02:23devnJavelin*
02:23devnhttps://github.com/tailrecursion/javelin
02:23piranhadevn: indeed it's a good analogy! :)
02:24devnbtw, is anyone working up an rxjava clojure wrapper?
02:25devnnevermind. of course daveray beat me.
02:28muhoofrp?
02:28clojurebotFRP is functional reactive programming, or maybe fiberglass reinforced plastic
02:30muhooevent.cljs, net.cljs, and repl.cljs are either brilliant or bizarre or both. i think i have a week of reading up on google closure xhr to figure out how it all works.
02:31piranhadevn: but then having no eventstreams, what's the best way of handling clicks and other instant user input? Still trying to figure this out...
02:32piranhaI should probably ask alandipert, but he's likely to be in so different timezone that it would be hard to catch him :)
02:32alandipertpiranha: sup!
02:33piranhaalandipert: oh wow :) so the question is how do you plan to handle clicks and all that with javelin
02:33pppaul& *[1]
02:33lazybot⇒ #<core$_STAR_ clojure.core$_STAR_@1234ce5>
02:34piranhaalandipert: I was playing with Flapjax and did all that by having behavior for a whole form which contained something like {:submit false}, which was becoming true for a single animation frame on click :)) not sure that's the best way though
02:34alandipertpiranha: wb! have you seen the demos? https://github.com/tailrecursion/javelin-demos
02:34piranhaargh, my connection is not that good
02:34alandipertpiranha: that's the way
02:34piranhaah cool! :)
02:34alandipertpiranha: part of the javelin worldview is that event streams are a lie, and you should always work with values
02:35alandipertjamming events into concrete values ASAP so you can write code in terms of values instead of streams
02:35piranhathis is very good, this means I'm not a heretic ))
02:35alandipertno we both are ;-)
02:35piranhaI was just arguing with colleagues about that a month or so ago
02:35piranhawell two heretics make a sect, which good enough for me
02:36alandipertlol
02:36piranhaalandipert: thank you for the library though! It's much nicer to use in CLJS than Flapjax :)
02:36alandipertpiranha: thank you! don't hesitate to ping w/ questions
02:37alandipertpiranha: another helpful idea might be that at any given time, the page has one state
02:38alandipertand you want to represent that state w/ a minimum # of cells that take raw events, and model the page state beyond that "backbone" as formulas
02:39alandipertpiranha: anyway i retreat to my timezone, thanks again for compliments and good luck. would love to see whatever you come up with
02:50callenbotyogthos: just ignore him
02:50callenbotyogthos: maybe he'll go away
02:50callenbotI think he's deranged.
02:58Raynesxeqi: Was that you that haxxored lazybot earlier?
02:58RaynesMaybe TimMc?
02:58RaynesProbably xeqi, since I said he should feel bad.
02:58Raynes:p
04:09augustlwhat's the best way to use lein-ring without a singleton handler that's created when the file compiles?
04:09augustlI want to pass a function or something, so that the handler isn't created until lein ring actually needs it
04:10augustlI do side effects such as reading config files in order to create the handler, so I would prefer that to be lazy so it's possible to compile the code without having config files for ring available :)
04:11hiredmanhttps://github.com/weavejester/lein-ring/issues/53
04:21clgvIs it somehow possible to get the output of `pr` pretty-printed?
04:22amalloy$google clojure pretty print
04:22clgvthat would be pretty useful for serialization of config files
04:22lazybot[Pretty print in Clojure - Stack Overflow] http://stackoverflow.com/questions/295458/pretty-print-in-clojure
04:23clgvamalloy: well normal clojure pprint does not really serialize. it wont handle records and such correctly
04:24amalloyand if what you care about is serializing, why would you bother to pprint? a program is writing to its own config file, but you expect humans to also modify it from time to time?
04:24clgvamalloy: exactly
04:25amalloyi'd just tell the humans to paste the dang thing into emacs, personally
04:26clgvamalloy: thats pretty complicated then, since usually those configs are on remote machines. so copying here and back again would be necessary
04:26amalloy$google ssh tramp emacs
04:26lazybot[EmacsWiki: Tramp Mode] http://emacswiki.org/emacs/TrampMode
04:27amalloyi mean, what you're asking for is not unreasonable, but it doesn't exist. as far as i know, it would not be easy to add that feature to either pprint or pr
05:55clgvamalloy: I'd like to have that addition but I do not know who else does ;)
05:56marcellus1is there a recent guide to getting started in incanter with all the project.clj deps listed?
05:57clgvmarcellus1: what do you want to do? if you want all incanter libs, just add the single incanter dep
05:58clgvmarcellus1: [incanter "1.4.1"] will draw all incanter libs in your project
05:58marcellus1clgv: awesome that's what i was looking for thanks!
05:58clgvI hope I found the most recent^^
05:59marcellus1yep looks like it should be
06:00thheller,[1 2 (comment 3) 4]
06:00clojurebot[1 2 nil 4]
06:00thhellershould that be [1 2 4]? :P
06:00clgv,[1 2 #_3 4]
06:00clojurebot[1 2 4]
06:01thhellerah thx
06:01clgvthheller: no. `comment` is a macro that expands to nil
06:04thhellerright, forgot about reader vs macro expansion
06:23michaelr525hello
08:56silasdavisyogthos: Hello.. luminus' project.clj as a missing closing '}' at :profiles
08:57yogthossilasdavis: I think I fixed that last night
08:57yogthossilasdavis: have you tried the latest template?
09:01silasdavisyogthos: cloned yesterday - yes fixed now :)
09:02yogthossilasdavis: what happened was I accepted a pull request to fix a trimming issue, and ended up with off by one when doing a substring on the project :)
09:06xeqiRaynes: it was me
09:28clgvecho you?
09:28lazybotyou?
09:28clojurebotYOU WILL LIKE OVERTONE & CLOJURE
09:28deg(just wondering) Why is there no update function, for symmetry with update-in, assoc-in, and assoc?
09:28bbloomdeg: deg what would it do?
09:28bbloom~update
09:28clojurebotNo entiendo
09:29degbbloom: Like update-in, but at the top level.
09:29bbloom(doc update-in)
09:29clgvdeg: you are right^^ there is also no dissoc-in and no contains-in?
09:29clojurebot"([m [k & ks] f & args]); 'Updates' a value in a nested associative structure, where ks is a sequence of keys and f is a function that will take the old value and any supplied args and return the new value, and returns a new nested structure. If any levels do not exist, hash-maps will be created."
09:29bbloomdeg: wouldn't (update x f) just be (f x) ?
09:30clgvbbloom: (update {:a 1} :a inc) => {:a 2}
09:30degclgv: But here, there is the -in method method, but no the simple one.
09:31clgvdeg: I just wanted to point out that symmetry was never a goal for these map functions it seems
09:31bbloomclgv: oh, so it updates at the FIRST level? *shrug* (update-in {:a 1} [:a] inc) works precisely the same.
09:31clgvI'd like it better if it was
09:32degclgv: I guess that just begs my question. Why was symmetry not a goal? As folks learn the language, these assymetries get in the way.
09:32clgvbbloom: well for this reasoning we would not need `assoc` at all since assoc-in does its job as well ;)
09:32bbloomit's also a trivial function to write if you find you need it frequently: (defn update [m k f & args] (assoc m k (apply f (m k) args)))
09:33clgvbbloom: that's nor agument. the point is clojure.core is not symmetric for these two function classes ^^
09:33degbbloom: Sure. And, equally, can just wrap an extra pair of braces. But, it's the learning curve that I'm asking about, I guess.
09:35hyPiRionthe problem is this: what signature should update have?
09:36bbloomthe signature of assoc allows for multiple values to be assoced
09:36bblooman 'update function couldn't have symmetry with that
09:36deghyPiRion: [m k f & args], no?
09:36bbloom(doc assoc)
09:36clojurebot"([map key val] [map key val & kvs]); assoc[iate]. When applied to a map, returns a new map of the same (hashed/sorted) type, that contains the mapping of key(s) to val(s). When applied to a vector, returns a new vector that contains val at index. Note - index must be <= (count vector)."
09:36hyPiRion(update {:a 1 :b 2} :a inc :b dec) or (update (update {:a 1 :b 2} :a inc) :b dec)
09:37deg(oh, right. my last line was a second too fast.)
09:39clgvhyPiRion: noo.this one [m k f & args],
09:39bbloomalso, for dissoc-in, there's a question of what it's behavior should be
09:39bbloomit's been discussed plenty here in IRC, check the logs
09:39clgvbbloom: I had a ticket for it on jira ;)
09:39hyPiRionclgv: the last one, right.
09:40clgvbbloom: but apparently I'd need to create one in core.incubator^^
09:40clgvI lost motivation then...
09:40bbloomclgv: there is also https://github.com/flatland/useful
09:41bbloomclojure core doesn't just add functions willy nilly on purpose. consider the 'remove function that every lisp has had for lists forever
09:41bbloomit's O(N) so core just doesn't have it
09:41bbloomfinger-trees do, however, since they can provide better than O(N)
09:42clgvbbloom: which remove do you mean? there is a ##(doc remove)
09:42lazybot⇒ "([pred coll]); Returns a lazy sequence of the items in coll for which (pred item) returns false. pred must be free of side-effects."
09:42bbloomclgv: sorry, i mean remove-nth
09:42clgv,(doc drop-nth)
09:42clojurebotExcuse me?
09:42bbloomhttp://www.lispworks.com/documentation/HyperSpec/Body/f_rm_rm.htm
09:45bblooma better example is 'insert into a vector at an index
09:46bbloomwhich is also another symmetry missing from assoc/dissoc
09:46clgvhmm `assoc` is not the best name for the vector case, right
09:46bbloom,(assoc [:x :y :z] 1 :w)
09:46clojurebot[:x :w :z]
09:46bbloom,(dissoc [:x :y :z] 1)
09:46clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.IPersistentMap>
09:46bbloomtrying to maintain symmetry is a thing that feels like a good idea, but actually isn't
09:47bbloommost mathematical functions & their inverses aren't entirely bijective
09:47bbloomhttp://en.wikipedia.org/wiki/Bijection
09:47clgvthats unfortunate indeed since it removes the "map-vector-transparency" assoc provides...
09:47bbloomclgv: unless you're not deleting anything.. :-)
09:48bbloombut even the simplest of functions require absurd caveats to be made bijective
09:48bbloomor to define inverses,r ather
09:48clojurebotGabh mo leithscéal?
09:48bbloomconsider the multiplication operator
09:48bbloom,(* -5 -5)
09:48clojurebot25
09:48clgvyeah but if you really use the transparency you'll delete something sooner or later since maps support it ;)
09:48bbloom,(Math/sqrt 25)
09:48clojurebot5.0
09:49bbloomit's a functional programming language, not a relational one :-) http://en.wikipedia.org/wiki/Relation_(mathematics)
09:49clgvwell the symmetry demand I made was for completeness of the api provided and it can be done easily here
09:50clgvbbloom: you dont need to teach me math - I had plenty of it as undergraduate :P
09:50degbbloom: I'm not following. What is the connection between symmetry and invertability?
09:51clgvdeg: good question. I just ignored the invertability argument since it didnt seem to fit ;)
09:51bbloom#(assoc % :x :y) and #(dissoc % :x) are inverse functions, that is the nature of their symmetry....
09:51bbloomsymmetry is a geometric concept, not an algebraic one, so inverses are the closest algebraic idea :-P
09:51clgvbbloom: the current asymmetry is assoc, dissoc <=> assoc-in, update-in ;)
09:52clgvbbloom: thats wron. symmetry is also algebraic. read your link about relations above^^
09:53hyPiRionassoc and dissoc aren't inverse functions
09:53bbloomclgv: heh, ok fine :-)
09:53hyPiRion(dissoc (assoc x y z) y) -> identity
09:54hyPiRion(assoc (dissoc x y) y z) -> assoc
09:54bbloomhyPiRion: yeah, they aren't bijective :-)
09:54hyPiRion(As far as I understand mathematics)
09:55hyPiRionoh right.
09:55bbloombut the whole point i was trying to make is that if it's not 100% obvious what the quasi-inverse/symentric function should do or how it would do it efficiently, then it's totally OK to not have perfect symmetry
09:58clgvbbloom: well for the discussed case it is very obvious. edge-cases are induced by the existing counterparts
09:59clgvbbloom: for dissoc-in there was discussion whether it should remove empty-maps. looking at assoc-in which creates maps, I'd say it should remove empty maps
10:00bbloomclgv: what do you do about records?
10:01clgvbbloom: regarding what exactly?
10:01bbloomi guess you wouldn't have a record with only one entry...
10:01bbloomso it would never make it empty... ok
10:02clgvbbloom: a record is converted to a map if you dissoc one of its "attribute keys"
10:02TimMcRaynes: I messed up lazybot a few weeks back, yeah. Remember, you were mad at me for wanting to perfect the trick before telling you? :-P
10:02hyPiRionclgv: There's a loss of data though
10:03bbloomyeah so (dissoc-in #Foo{:x {},:y 1} [:x :y])
10:03hyPiRion(assoc-in {:a {:b {}}} [:a :b :c] x) == (assoc-in {:a {}} [:a :b :c] x)
10:03bbloomor [:x :z] or whatever
10:04hyPiRion(dissoc-in {:a {:b {:c foo}}} [:a :b :c]) == ???
10:04lazybothyPiRion: Oh, absolutely.
10:04hyPiRionBut yeah, there's been some discussion around that.
10:04hyPiRion:p
10:05bbloomthe one time i needed dissoc-in, i later discovered that i really wanted dissoc-in-up-to-some-limit
10:05clgvbbloom: well it is an implementation choice if it is important to keep the data as record or not. if this is more important dissoc-in should not be allowed to delete empty maps for uniformity reasons
10:06bbloomclgv: this is the whole point i'm trying to make: the behavior 1) isn't obvious 2) you actually extremely rarely need this function and 3) it's trivial to write exactly teh behavior you want
10:06bbloomany variation of dissoc-in will only be 5ish lines of code
10:06TimMchyPiRion: Definitely {:a {:b {}}}
10:06clgvbbloom: being easy to write is no argument. there are lots of easy to write functions in core ;)
10:07bbloomclgv: it's no COMPLETE argument
10:07bbloomclgv: there are 2 other reasons in that argument i've made lol
10:07clgvbbloom: the implementation of disso-in is obvious but one needs to make the right decision for the edge case of emptying a map
10:08TimMc,(update-in {:a {:b {:c :foo}}} [:a :b] dissoc :c)
10:08clojurebot{:a {:b {}}}
10:08hyPiRionTimMc: That's no data loss at least.
10:09hyPiRionBut I've not really had issues related to this.
10:09TimMc(update-in ds [:a :b] dissoc :c) = (dissoc-in ds [:a :b :c])
10:09hyPiRionupdate-in should've just been kalled `in`
10:09clgvbbloom: in fact it was suggested to implement dissoc-in in core-incubator first^^
10:09hyPiRion(in ds [:a :b] dissoc c)
10:10hyPiRionThen there's no need for dissoc-in either. or assoc.
10:10hyPiRionassoc-in*
10:11TimMcNice.
10:11TimMcI like it. Any bad corner cases?
10:12abp`A smooth sailin.
10:12TimMcIt has a dangerously short name, of course.
10:12abp`Developing Clojure full time now for a few weeks. :)
10:13TimMcabp`: Me too! Well, starting March 4.
10:13clgvhyPiRion: looks nice since it extracts the common pattern. but it would probably create map level for dissoc in if they do not exist. or it would not do that for assoc as well
10:13TimMcPumped.
10:13kryftDeveloping Clojure as in developing the language itself?
10:13TimMcNot I.
10:13kryftOr as in writing stuff in Clojure
10:13abp`TimMc: It's like a dream. Everything fitting perfectly fine into deadlines, producing minimal code straight to the point.
10:14hyPiRionclgv: yeah, update-in create new maps too.
10:14abp`kryft: Nope wep service and backend.
10:14kryftI should clearly get started writing clojure. I'm sure not trying to learn haskell at the same time would help :P
10:14clgvhyPiRion: but that would be counter-intuitive for dissoc-in ;)
10:14clgvhyPiRion: maybe it needs some kind of option.
10:15TimMckryft: I mean, other than the fact that when programming in a Lisp, you're constantly refining the boundary between language and program. :-) (Where is that quote from?)
10:15kryftTimMc: Hehe
10:15TimMc*redefining, perhaps
10:15abp`TimMc: Don't know but it's neat.
10:15TimMcSOunds like a Let Over Lambda kind fo quote.
10:16hyPiRionclgv: This is why I'm not the head of the "new features"-department in Clojure.
10:16TimMcNo, of course it's Paul Graham: http://www.paulgraham.com/progbot.html
10:16TimMc"Language and program evolve together. Like the border between two warring states, the boundary between language and program is drawn and redrawn, until eventually it comes to rest along the mountains and rivers, the natural frontiers of your problem. In the end your program will look as if the language had been designed for it."
10:33AtKaaZhow can we print and/or use the &env inside the macro? in the ` part
10:34bbloomAtKaaZ: syntax-quote isn't magical in any way, nor is it specific to macros
10:34bbloomAtKaaZ: you can use &env just like any other local name
10:35bbloom,(let [&env :foo] `(identity ~&env))
10:35clojurebot(clojure.core/identity :foo)
10:35AtKaaZbbloom: but I can't even print it due to it looks like: {b #<LocalBinding clojure.lang.Compiler$LocalBinding@4cd671a1>}
10:36AtKaaZ(defmacro a [] (prn &env)) (let [b 1] (a))
10:36bbloomAtKaaZ: yeah, that's b/c &env is implementation specific & the JVM implementation has a bunch of private java objects
10:36bbloomAtKaaZ: if you really need a portable/useful/printable &env, you can use ambrose's analyze library
10:36bbloom(i think)
10:36AtKaaZk
10:38AtKaaZ,(defmacro a [] (get &env 'b)) (let [b 1] (a))
10:38clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
10:46edoloughlinI'm returning to a dormant project and migrating it to 1.4. I've discovered that in the CCW repl I can no longer redefine functions. The (defn) or (defn-) evaluates and returns ok but the functions are not changed - whatever was loaded when the repl started is still executed. Any ideas?
10:47AtKaaZbbloom: oh i googled, found it: http://blog.jayfields.com/2011/02/clojure-and.html basically this: (defmacro show-env [] (println (keys &env)) `(println ~@(keys &env))) ... (let [band "zeppelin" city "london"] (show-env))
11:21Marble68o/
11:22Marble68Is anyone in here looking for work? I have a client that hired a guy to write a web app for her. He wrote it in clojure, then he quit. I'm looking for someone interested in a few hours a week to help maintain it.
11:23Marble68Serious
11:23marcellus1maybe, what kind of web app?
11:24Marble68It's a web app that has a roles based access. It manages secret shoppers
11:24Marble68I have all the source in git
11:25Marble68I don't know Clojure - but I had someone look at it and they said the code is nice and clean
11:25Marble68well commented, etc.
11:30ToxicFrogMarble68: if you'd asked that a year ago I'd be down, but I'm about to graduate and start full time work. Sorry.
11:36Marble68thanks, ToxicFrog :)
11:36Marble68I think it'd only be a month or two - maybe three
11:37ToxicFrogBy "about to" I mean I defend on monday and start work the following week.
11:38ToxicFrogPlease go back in time and mention this to Past Me when I had two months to kill waiting for the defence to be scheduled~
11:38Marble68ha :)
11:40pepijndevosWhat is the nicest way to use webscokets in clojurescript?
11:40tomojI think a new closure has websocket support somewhere?
11:41pepijndevostomoj, oh yea, I think I saw that somewhere... hmmm
11:41abp`pepijndevos: http://thegeez.net/2012/04/03/why_browserchannel.html
11:41abp`Maybe
11:42pepijndevoslol, amsterdam clojurians seem to have written 90% of everything websocket in the clojure landscape
11:48pepijndevosabp`, tomoj, I think I'll use alephs webockets with googles thing. There doesn;t seems to be a nice wrapper on hte client side.
12:00pbostrompepijndevos: websockets in cljs is just a few lines of javascript interop: (reset! sock (js/WebSocket. ws-url)) (set! (.-onmessage @sock) msg-hdlr)
12:01pbostromusing an atom to store the socket
12:01pbostromthen write your handlers in cljs
12:01pepijndevospbostrom, why would I put a socket in an atom?
12:01pbostromto keep a reference to it
12:01pbostromin case you want to close it
12:02pbostromalso to send msgs out on it
12:02pepijndevospbostrom, yea, but a socket is just a mutable value right? So why can't I just def it?
12:03pbostrompepijndevos: yeah, you could do that, but say the socket gets closed for some reason like a flaky connection, you'll have to redef with a new websocket value
12:03pepijndevosah, I see
12:12frenchyphi
12:12frenchypSo, I have a let form where I bind 4 different symbols to expressions. The 4th symbol is calculated from the 3rd, which is calculated from the 2nd, etc...
12:12frenchypIn this particular case, the 1st symbol contains a database row and can be null if the query didn't return any matching row.
12:12frenchypThe expression for the 2nd symbol triggers a null pointer exception if its input (symbol 1) is nil.
12:12frenchypWhat is the idiomatic way to rewrite my let to account for this case?
12:14frenchypshould I nest a let in a if-let?
12:14alandipertfrenchyp: if-let at top level i think
12:15pbostromfrenchyp: that's what I tend to do in those cases, not sure if that's the best way
12:15frenchypalandipert: pbostrom ok, that will work for my case
12:16frenchypbut it won't if it's the 2nd symbol that can be null for example
12:16frenchypwell, would be awkward
12:16alandipertfrenchyp: there are nil-guarding flavors of let that nil guard, often featured in monad tutorials
12:17frenchypactually i started writting this with the maybe-m monad
12:17alandipertfrenchyp: i think that's legit
12:17frenchypbut a) it seemed that something was wrong with my understanding to have to resort to a powerful construct like that in this case
12:18frenchypb) i couldn't get the domonad form to return the value of its last expression, which might just be the way monads work
12:18frenchypi have never used monads before
12:18alandipertwell, personally i keep my maybe-nil op (always IO) at the top and find i don't run into this
12:19alandipertif there are multiple IO things involved that may collectively return nil i put them in a function that i consume via if/when-let elsewhere
12:19alandipertand thus rarely resort to maybe-m
12:20frenchypmakes sense, that seems like the practical solution
12:20Chousukefor a moment I thought this was #haskell and wondered "what's the problem, just use Maybe" :P
12:20frenchypthank you
12:20alandipertno prob
12:20Chousukebut yeah, monads in clojure aren't quite as convenient. there are however, threading operators and other things that short circuit on nil
12:21frenchypChousuke: oh? which one?
12:21alandipertand functions that eat nil without indigestion, like +
12:21Chousuke don't remember the exact names :/
12:21tomojsome-> and some->> ?
12:22alandipert?-> i think
12:23frenchypha, can't imagine worse google nightmare than ?->
12:23alandipertfrenchyp: https://github.com/clojure/core.incubator/blob/master/src/main/clojure/clojure/core/incubator.clj#L29
12:24frenchypawesome!
12:25frenchypthat seems perfect
12:25frenchypthank you
12:26alandipertsure!
12:26tomojthat is named some-> in 1.5
12:26tomoj(and it's in core)
12:26frenchyptomoj: even better
12:26technomancywait, some-> is nil-safe ->?
12:26alandipertoh right, https://github.com/clojure/clojure/blob/master/changes.md#24-new-threading-macros
12:27technomancyI thought some-> had something to do with some.
12:27tomoj"When expr is not nil, threads it into the first form (via ->), and when that result is not nil, through the next etc"
12:27frenchypis that what people do? use 1.5.0RCX?
12:29alandipertfrenchyp: dunno, but it's right around the corner
12:40TimMcfrenchyp: symbolhound
12:42frenchypTimMc: yep: http://symbolhound.com/?q=-%3F%3E+github+clojure
12:42frenchypthanks
12:43frenchypthis chan has a high problem solving rate
12:43tomojsweet
12:44frenchypI have a very different and completely open ended question, feel free to shut down:
12:44frenchypI have a fairly hairy (for me at least) imperative algorithm from a paper
12:45frenchypmutates state all over the place, uses globals, etc...
12:45FrozenlockBurn it with fire!
12:45jodarowow
12:45Chousuke:P
12:45frenchyphow would I even start 'translating' it to a functional algorithm?
12:45jodarosymbolhound
12:46Chousukefrenchyp: first figure out what it does
12:46frenchypor rather, in broad strokes, what do people do in this situation
12:46Chousukeie. when you give it input A, what is the result
12:46Ember-and try to understand *why* it does what it does
12:46Chousukein general merely translating imperative algorithms to functional ones results in an inefficient algorithm though
12:47Chousukebecause presumably the mutation is done for efficiency
12:48Chousukethe first step is to make all the state explicit though.
12:48Chousukeinstead of using globals, pass around parameters
12:48Chousukeand capture modifications
12:48Chousukethen again, clojure is not a pure functional language. you might be okay with just implementing the imperative algorithm :P
12:49frenchypthan you for all the suggestions so far
12:49frenchypI implemented it in java, but boy, it's messy
12:50frenchyphopefully, trying to make it functional would help
12:50ToBeReplacedfrenchyp: why not just leave it in java then?
12:50Chousukefrenchyp: generally functional solutions to problems result in completely different algorithms
12:51frenchypToBeReplaced: well, I never said I was a practical guy :)
12:51Chousukefrenchyp: it's good practice though. just don't start with 2"
12:51Chousukeoops
12:51Chousukewith "I need to translate this"
12:51Chousukestart with "I need something that has the same end result"
12:51frenchypToBeReplaced: plus, it's so inelegant, it hurts
12:51frenchypChousuke: yes, I think you are right
12:52frenchypI can try to keep the same methods (algo is expressed as several methods), and translate them to func
12:52Chousukeand sometimes imperative algorithms get complicated precisely because they are mutable
12:52frenchypor, try to really dig in and understand, but that might be too ambitious for my little brain
12:52Chousukeespecially when you have to remember past values
12:53Chousukein a functional language with immutability, all you do to remember a previous value is to keep a reference to it :P
12:54frenchypwould Purely Functional Data Structures by Okasaki, or his thesis, help? or is that too academic?
13:14frommorfanyone here?
13:15technomancynope
13:25mr_rm'0
13:27mr_rm`0
13:29mr_rmwhat is the leading string to get the bot to evaluate something?
13:30gfredericks,0
13:30clojurebot0
13:30gfredericks&0
13:30lazybot⇒ 0
13:30mr_rm,((apply some-fn [even? neg?]) 1)
13:30clojurebotfalse
13:30mr_rm,((apply some-fn '(even? neg?)) 1)
13:30clojurebotnil
13:31mr_rmdoes anyone know why i can't apply some-fn to a list?
13:31tomoj&((apply some-fn '(even? neg?)) {'neg? 42})
13:31lazybot⇒ 42
13:32tomoj&((apply some-fn (list even? neg?)) 1)
13:32lazybot⇒ false
13:32tomoj&('neg? {'neg? 42})
13:32lazybot⇒ 42
13:32mr_rmtomoj: why does that work but the '() syntax doesn't?
13:32tomoj&(map type '(even? neg?))
13:32lazybot⇒ (clojure.lang.Symbol clojure.lang.Symbol)
13:32tomoj&(map type (list even? neg?))
13:32lazybot⇒ (clojure.core$even_QMARK_ clojure.core$neg_QMARK_)
13:33mr_rm&(map type (list even? neg?))
13:33lazybot⇒ (clojure.core$even_QMARK_ clojure.core$neg_QMARK_)
13:33mr_rmahh, ok
13:33mr_rmdoesn't evaluate anything inside '()
13:34tomoj' means quote
13:34mr_rm&(map type (quote even? neg?))
13:34lazybotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol
13:34tomojwell, '(foo) means (quote (foo))
13:34mr_rm&(map type (quote (even? neg?)))
13:34lazybot⇒ (clojure.lang.Symbol clojure.lang.Symbol)
13:34tomoji.e. \' says "quote the next form"
13:35mr_rmok thanks
13:35tomoji.e. "don't evaluate the next form"
13:39FrozenlockIs there a way to catch all subclass? (cath some-library.exception.* ... ?
13:39Frozenlock/s/cath/catch
13:40technomancyFrozenlock: subclasses are different from every class under a given package
13:40technomancysubclasses will be handled by catch, but what you described above isn't possible (might be using slingshot though)
13:41ohpauleezYou can only catch subclasses if they have a common parent - as technomancy said, it looks like you're just talking about a certain level in the package
13:45TimMcDoes the JVM's try/catch handling only do hierarchy matching, or can you inject arbitrary byte code to determine whether a catch clause is to be triggered?
13:46Frozenlockso if I have "direct known subclasses: ..." in the exception class, I can't catch them all in a big swoop?
13:46abp`Frozenlock: Sure via the one your looking at?
13:46abp`you're
13:47Frozenlockabp`: I tried, but the subclasses error seem to just pass through :(
14:00abp`Frozenlock: Strange
14:01gfredericksdoes anybody have any experience setting clojure.tools.logging/*logger-factory* manually?
14:01gfredericksI'm trying to use log4j (while datomic has the commons logging)
14:01gfredericksfor some reason the loggers all end up disabled
14:05tomojgfredericks: I assume you already followed http://docs.datomic.com/configuring-logging.html#sec-3 ?
14:05jcromartieI just realized a great way to test middleware in the REPL
14:05jcromartie((wrap-whatever identity) {:uri "whatever/" :foo :bar})
14:08jcromartienREPL is fun
14:08jcromartieam I missing the automatic arg suggestion from SLIME though?
14:08gfrederickstomoj: no, that looks helpful, thanks
14:15AdamCHi, don't know if anyone's interested, but I just made a thing for emacs which when given a library name (say "digest" or "incanter") will go off, look up the latest version number on clojars and insert into the buffer e.g. [incanter "1.4.1"].
14:15tomojfucking brilliant
14:15AdamCand then asks you if you want to use pomegranate to automatically add it to the classpath of your running repl
14:15tomoj!
14:15AdamCgot sick of nrepl restarts
14:16AdamCand could never remember what to import for pomegranate
14:16AdamChttps://github.com/AdamClements/latest-clojure-libraries
14:16technomancyAdamC: huh, cool
14:16AdamCit's a little hacky getting the latest version from clojars
14:16AdamC(very hacky)
14:16technomancyAdamC: can you re-use lein's indices?
14:17AdamCthat's what I wanted to do, but i have never been able to get them to work
14:17tomojwould you then have to reimplement semver?
14:17AdamC(you mean like lein search uses, rcight?
14:17technomancyAdamC: right. also getting a connection from Emacs to Leiningen's own process is a bit trickier.
14:17AdamCwhen i say haven't been able to get them to work, i mean even to do a lein search, or lein outdated
14:18technomancyAdamC: ideally you could have something that would add it into project.clj and pomegranate at the same time
14:18technomancyso you could keep your repl process vaguely in sync with project.clj
14:18Raynes$latest me.raynes/laser
14:18lazybot[me.raynes/laser "0.1.27"] -- https://clojars.org/me.raynes/laser
14:18RaynesAdamC, tomoj: ^
14:18RaynesIf you used ERC you already had this feature. ;)
14:18TimMc:-P
14:19AdamCit sort of does, so at the moment, it puts the vector under your cursor, so the idea is you go to your project.clj and open up your deps, and it'll type it automatically. I was going to try insert it automatically, but there's so much danger of messing up the formatting
14:19technomancyAdamC: oh, cool
14:19RaynesHaha, grep. You're pretty cool, AdamC.
14:20AdamCand then yeah, just a "want to add this to your classpath y/n"
14:20technomancyAdamC: the only reason I haven't written that myself is that until recently it was impossible to read project.clj, alter it, and spit it back out in a way that preserved comments
14:20technomancybut now you can do it with sjacket
14:20tomojthe link to the list of commands in lazybot's readme goes to the wrong place
14:20AdamCnot heard of sjacket
14:21RaynesThe command list is crazy out of date anyways, tomoj.
14:21tomojand doesn't include latest, but I should have guess that from the start..
14:21Raynestomoj: I used to have a way to generate a list of commands at runtime.
14:21RaynesI need to re-add it.
14:21Rayneshttps://github.com/flatland/lazybot/blob/develop/src/lazybot/plugins/clojure.clj#L225 is the $latest command
14:23AdamCah, so you are actually pulling teh clojars page, not using lein's indices?
14:24RaynesNo.
14:24RaynesEr, yes.
14:24RaynesUsing lein's indices would be horrific. At least for a bot.
14:24RaynesIt also assumes that the indices are up to date.
14:25AdamCindeed, which sort of defeats the point
14:25AdamCis there any sort of api for this kind of thing on clojars, and if not, should there be?
14:25technomancylein supports partial updates of indices; so you it's pretty cheap to just ask it to refresh
14:28AdamCtechnomancy: oh! lein search and lein outdated work now. I've tried them a few times over the past months and the search index never downloads
14:29AdamCperhaps I'll give that a try
14:29technomancyAdamC: yeah, during the previews there was some nasty breakage
14:29technomancybut unless you want to just launch a new process you have to deal with connecting to the Leiningen JVM
14:29technomancyyou could try lein.el
14:29AdamChmmm
14:30AdamCthe other nice thing about this way, i've just found when adding lein-outdated into my profiles.clj
14:30AdamCis that it doesn't actually need lein to be running, or to be in a project
14:31AdamCWouldn't some REST api be cheaper in the long run than having everyone download the full index to search? I don't know what's going on behind this search index
14:32AdamCgiven the use case of wanting most up to date, so probably trying to update every time it's used
14:32technomancyAdamC: it's not actually downloading the full indices; lein2 is able to just get the changes since the last time it checked
14:33technomancybut being able to do fully-local searches and search when offline is great
14:33technomancyplus this functionality already exists for performing the searches client-side, so it keeps the clojars codebase simpler
14:35AdamCyeah, I can see that, the big initial download is just a bit of an annoying barrier to entry. I'll have a go at hooking into the running lein process and see if I can get anything working client side
14:39antares_two new releases today: Welle 1.4 (http://blog.clojurewerkz.org/blog/2013/02/21/welle-1-dot-4-0-is-released/) and Monger 1.5.0-beta1 (http://blog.clojurewerkz.org/blog/2013/02/21/monger-1-dot-5-0-beta1-is-released/)
14:43jcromartiehow can I see the println output from my Jetty handler when running in nREPL
14:44Raynesantares_: Hi.
14:44antares_Raynes: hey
14:45Raynesantares_: I noticed you've got comments on all the pagination spots in refheap that it should be using some built in pagination support. Was there a particular reason you didn't do that (just wondering if I should or not).
14:45RaynesDelete last period, insert question mark.
14:45antares_Raynes: sorry, what comments?
14:46antares_Monger has built-in pagination support in monger.query but I don't remember implementing pagination in refheap
14:46antares_so I guess I just quickly ported things the most direct way
14:46Raynesantares_: https://github.com/Raynes/refheap/blob/master/src/refheap/models/paste.clj#L137
14:46RaynesYeah, that's what I was thinking.
14:46RaynesI just wanted to make sure there wasn't some technical problem in monger that precluded using that functionality.
14:47antares_Raynes: yes, feel free to just use pagination there, it should be in the docs
14:47RaynesCool. Thanks!
14:50jcromartieso how do I get println output from another thread to show up in my nREPL
14:50jcromartieI know I need proper logging at some point
14:51jcromartiebut right now I am just spinning up a little dev server, and it completely hides any exceptions that happen during request handling
14:53jcromartiehm https://github.com/kingtim/nrepl.el/issues/83
14:56sisciaVery quickly, and very stupid question...
14:56sisciaI extend a type (extend-type) on a java interface
14:56sisciain a particular namespace
14:56sisciawritting several function on the particular interface
14:57sisciawhat/how i need to import to call those functions ?
15:04borkdudeorg-mode question: https://www.refheap.com/paste/11613
15:05borkdudemaybe a can use org-babel to keep a counter or smth?
15:07dnolen_siscia: not sure I understand, you just call the functions. Load the require/use namespace where you make those modifications, and require/use the protocols fns.
15:10sisciadnolen_, hi, I was thinking the same... But it doesn't work... It may be because I am extending an interface instead of a real class ?
15:12dnolen_siscia: you can extend-type on interfaces just fine.
15:12dnolen_siscia: you should paste your code somewhere
15:15borkdudefollow up on my org-mode question: http://stackoverflow.com/questions/15011355/org-mode-counter-for-items-visible-in-export
15:17sisciadnolen_, I have the extend-type at line 48 here https://github.com/siscia/parallel-colt-matrix/blob/master/src/parallel_colt_matrix/core.clj
15:17sisciadnolen_, and a stupid test here https://github.com/siscia/parallel-colt-matrix/blob/master/test/parallel_colt_matrix/core_test.clj
15:18hiredman:( those :imports can collapsed
15:18hiredmancan be
15:19sisciait (lein test) raise excepetion at line 13, saying that "No such var: pc/implementation-key"
15:19sisciahiredman, you say that the problem could be the imports ?
15:19hiredmanno
15:19hiredmanI am just saying it makes me sad to see that
15:20sisciahiredman, I don't love it neither, but I work better with those... I will collapse them as soon as I finish...
15:21sisciahiredman, thanks thought
15:22hiredmansiscia: yeah, so that error message is correct
15:22hiredmanparallel-colt-matrix.core doesn't contain any protocols
15:22hiredmanthe function implementation-key only exists in the namespace where the protocol it is part of is defined
15:23sisciahiredman, ahhhh i didn't know it... thanks
15:23siscianow the problem... the protocols are defined in another library...
15:24hiredmanso?
15:24sisciaclojure.core.matrix.protocols (line 2 of core.clj)
15:24sisciaI need to import it in the test ?
15:24hiredmanit is just like any other function
15:24hiredmanrequire the namespace, use the function
15:25hiredmanprotocols create groups of functions
15:25sisciahiredman, hummm i am follow... let me try... thanks
15:25hiredmanlike, you call functions from other namespaces right?
15:25hiredmanjust do that
15:26sisciaok
15:28sisciahiredman, I don't even need to require the core but only the protocols... it is possible ?
15:28hiredmansiscia: maybe you should sit down with a basic clojure tutorial
15:28hiredmanI hear there are good books
15:29sisciahiredman, it sound really weird for me...
15:29sisciawell, thank you...
15:29sisciayeah I definitely need to study more...
15:31lynaghkIs there some way to dynamically bind the value of a compojure route when starting the server? I tried using vars, but then realized that because the server is running on a different thread that solution won't fly.
15:40siscialynaghk, just wonder why you want to do so ?
15:41uvtcDoes Clojure come with a way to check if a string contains some given substring, without using regexes?
15:41abp`lynaghk: Could you pass the fn to execute by the dynamic route via the request-map from a middleware, probably?
15:41lynaghksiscia: the backend serves data specific to different sites, which are defined in config files. Ideally you could launch multiple servers on different ports in the same JVM with, e.g., (start-server! 8080, site-A)
15:41hiredmanuvtc: String has a .contains method
15:41omarkjAm I right to say the Clojure does not allow me to do bit ops on bignums (like BigInteger)?
15:42lynaghksiscia: and the route "/site-config" would return that data to clients.
15:42uvtchiredman: Thanks. (After searching online, noticed that there used to be a `substring?` in an old string contrib lib.)
15:43uvtcSeems like there should be a clojure.string/contains.
15:43lynaghkabp`: not sure. I assume that everything including the middleware is run on another thread, so dynamic bindings won't work.
15:43uvtc(or similar)
15:43ibdknoxlynaghk: I can't think of a way, but a simple solution would be to use middleware to prepend a dir to the url: /foo -> /site1/foo and then just use contexted routes
15:44lynaghkibdknox: nah, then the frontends would need to know which site they were at
15:45lynaghkibdknox: because they'd all need to know to hit a special URL.
15:45ibdknoxwhy?
15:45clojurebotwhy is the ram gone
15:45ibdknoxlynaghk: not if you mapped urls to sites in the middleware?
15:45abp`lynaghk: (wrap-site-config handler site-a) .. for each server doesn't work?
15:45ibdknoxsounds like you should just run nginx though :)
15:46lynaghkibdknox: ah, I see what you're saying.
15:46abp`So I did not understood what you are trying most likely. :)
15:46lynaghkibdknox: yeah, totally that's what I'd like to do, which is why I'm trying to figure out a nice way to start up a bunch of servers with different configs without tangling the code
15:47ibdknoxlynaghk: I just run them on different ports and then use nginx to reverse proxy
15:47ibdknoxlynaghk: are you going to need to dynamically add them?
15:47lynaghkibdknox: add what?
15:47ibdknoxlynaghk: servers
15:48muhooi'm pretty happy with just running lein cljsbuild repl-listen, but i'm curious why running piggieback in nrepl locks up
15:48muhoothe port 9000 is opened, the browser is connecting to it (sniffing packet confirms this), but there is no response from nrepl/piggieback
15:49lynaghkibdknox: nah, probably not. I think middleware might be the way to go---it's more than I'd like to write, but I don't think dynamic vars are going to work
15:49jcromartiedoes it make sense to keep objects as a hash map of ids to values, or just a set of maps containing the ID as normal
15:49ibdknoxlynaghk: yeah, I can't think of a way to do binding like that :/
15:49jcromartieand use a map as an index if necessary
15:49muhoowhereas, running 'lein trampoline cljsbuild repl-listen", works perfectly, 9000 opens, browser connects, cljs repl responds, etc
15:50sirvalianceWhat is the proper way to test if a argument was passed into a function with &
15:51sirvalianceThat is, (defn foo [a & b] (if (b) (print b)))
15:51TimMc(if (seq b) ...)
15:51sirvalianceThe question really is, what should I be using instead of (if (b)
15:51sirvalianceAhh
15:51TimMcsirvaliance: Well, (b) calls b as a function.
15:51ibdknoxmuhoo: are you refreshing the browser once piggieback connects?
15:51drorbemetHi, I am having trouble to find out which role ":fin" plays in these code examples from the Clojure Koans. https://github.com/functional-koans/clojure-koans/blob/master/src/koans/16_atoms.clj
15:52muhooibdknox: yes, remember, i'm packet sniffing, i see all this happening. i don't think this is an "are you sure you plugged it in?" situation
15:52sirvalianceTimMC, Yeah, that was a dumb example. Something likt (exists? b)
15:53muhoothough i never underestimate my ability to do something stupid, in this case, it really is an A/B: with cljsbuild, it works, with exact same steps, with piggieback, it does not.
15:53sirvalianceTimMc: So even if I pass in a string for b, is it going to be of type seq no master what?
15:53drorbemetThe example explains the atom construct.
15:54TimMcsirvaliance: b will always be nil or a seq.
15:54gfredericksif I want to extend a class and call super in a method, I need gen-class, right?
15:54TimMcsirvaliance: That's what rest-args are.
15:55amalloygfredericks: proxy can do those things
15:55TimMcproxy-super?
15:55gfredericksthe docstring for proxy made me think it couldn't o_O
15:55sirvalianceTimMc: If I know I will always be passing in a single string, would I be better off overloading via (defn foo ([a] (println a)) ( [a b] (println a b)))
15:56gfredericksTimMc: okay cool, thanks
15:59TimMcsirvaliance: Yes.
15:59borkdudesolved my org-mode problem with dynamic blocks (had to find out they exist)
15:59muhooi do get this interesting thing though: https://www.refheap.com/paste/11616 . i probably need to try to get a minimal failing case and then submit it somewhere
15:59TimMcAnd you can chain them, if appropriate. (defn foo ([a] (foo a "default")) ([a b] ...))
16:00sirvalianceTimMc: Thanks
16:00sirvalianceTimMc: Ahhh :)
16:07muhoohuh that warning looks like an internal inconsistency inside cljs 1552, oddly. https://www.refheap.com/paste/11617 am i all screwd up or is this an actual bug in cljs?
16:07gfrederickswhen calling interop on a java-varargs function, I always have to pass an array?
16:07amalloyyes
16:07gfredericksI guess I don't do this very often.
16:15dnolen_muhoo: hmm that's a good catch
16:16muhoodnolen_: glad to be of service. thanks for doing so much to kep cljs moving forward
16:18dnolen_muhoo: are you working off master?
16:21dnolen_muhoo: though I'm surprised that you get that warning at all (array) macroexpands to (js* "[]")
16:53weavejesterI have a queue/consumer project, and I'm just wondering how to arrange it
16:54weavejesterI have a "client" namespace for pushing things onto the queue, and a "worker" namespace for consuming it
16:54weavejesterI guess the natural thing to do is to divide it up into two projects
16:54weavejesterBut I've been wondering whether using two profiles in the same project could be an alternative
17:04callenbotyusssss. Found a good reason to use monads in Python again.
17:23clojure-newbhey guys, how can I get the index at which an element is present in a sorted-set ?
17:24clojure-newbin my case the items in my sorted-set are #inst
17:24vijaykiranns
17:24muhoodnolen_: i was trying to get piggieback running with lein-cljsbuild in the same project. it seems they disagree on which cljs version to use. that error was in 1552 . i suspect the warning was coming from piggieback or nrepl or such.
17:25dnolen_muhoo: yeah, seems weird to me
17:26hugodwould anyone have any tricks for creating guava TypeLiteral instances from clojure (they seem to rely on generics...)?
17:26muhooi strongly suspect dependency conflict somewhere. weird indeed.
17:26kencauseyclojure-newb: I think you are not asking the right question. Perhaps I'm mistaken but the terms set and index don't go together as far as I'm aware. What is the real problem you are trying to solve?
17:27TimMchugod: What method or constructor are you trying to use?
17:27clojure-newbkencausey: I've got a sorted-set with a bunch of #inst items in… and I'd like to know where in the list a given #inst is… first, last etc
17:27tomojclojure-newb: binary search?
17:28tomojthere is an .entryKey on Sorted which appears to give you the element for an index
17:28tomojused to implement subseq
17:28TimMchugod: Generics are erased in the compile process.
17:28tomojwell
17:28kencauseyPerhaps I'm wrong, but I think you are not using the right data structure for the problem.
17:29clojure-newbtomoj: I think I need to do it the other way round… pass in an element, and determine its index
17:29tomoj(first (subseq sset = key)) ? :/
17:29clojure-newbkencausey: very possible :-)
17:29tomojyes, with a binary search :)
17:30tomojwait
17:30tomoj.entryKey doesn't do that
17:30clojure-newbI need the collection whatever it is to be sorted, and only have unique items in...
17:30tomojeverything I just said is rubbish
17:31clojure-newbthen I need to pass an element in to some computation which gets me its index in the list
17:31kencauseyWhat do you do with the index?
17:31turbofailyou search for something at that index
17:31clojure-newbno
17:31turbofailredis's sorted sets have that, for example
17:31turbofailor the other way around
17:32TimMcSorted sets really should provide a "where would this be inserted" function.
17:32clojure-newbI figure out business logic later for other stuff later on depending on where the element is in the list… one rule for most recent item… (first in list) etc etc, and another rule for other items
17:32hugodTimMc: TypeLiteral somehow encodes the generics info into a class
17:33clojure-newbmust admit I am slightly confused that I cannot get an index on something that is sorted… too newb I suppose
17:34amalloyTimMc: why?
17:34turbofailclojure-newb: a lot of sorted-set implementations don't let you do that. b-tree indices in databases usually don't, for example
17:35clojure-newbturbofail: fair enough… is there a clojure way to do this ? some other data structure I should use that will do the job ?
17:36turbofaildon't think so
17:36TimMcamalloy: Because they know how to do it efficiently and I want the answer. :-P
17:36clojure-newbis it as simple as turning my sorted-set into a vector ?
17:36turbofaila vector won't give you efficient insertion for something that's supposed to be in the middle
17:36amalloybut what answer would it give? the position an item would go into? you can't do anything useful with that position, and it's not free to maintain
17:37turbofailit's sometimes useful to know how many elements in the set are less than / greater than some element
17:37TimMcMaybe some kind of sorted tree would be good?
17:37clojure-newbI'm not going to insert anything into my collection once I have retrieved it the first time
17:37clojure-newbI just need the position an item is at
17:38turbofailsure you could use a vector and then do a binary search
17:38turbofailin that case
17:38clojure-newb(.indexOf (vec ss) #inst "2013-01-21T20:30:06.437-00:00") ?
17:38clojure-newbor is that not going to preserve order necessarily once I convert to a vector ?
17:38TimMcamalloy: You can then look at that position and check if it has the thing you're looking for.
17:38turbofailor even a linear search if you don't really care
17:39amalloyTimMc: sorted sets aren't nthable quickly
17:39turbofailamalloy: if you're using a balanced tree and keep counts at each node, then they are
17:40amalloysure, you can basically implement finger trees
17:41turbofailno it's way simpler than a finger tree
17:41TimMcAre finger-trees sorted?
17:42turbofailit's basically exactly the same as a normal search tree, except there's an extra "count" attribute
17:43turbofailer. well i guess that's one variety of finger tree
17:44turbofailminus the amortized constant time business
17:58jcromartieshould I not use assert in dosync?
17:58jcromartielike, (dosync (assert some-precondition) (alter …))
18:00jcromartiehm, I see, assertions are not covered by try/catch are they?
18:00jcromartieer
18:00jcromartieI mean (catch Exception ...
18:00jcromartiebecause they aren't Exceptions
18:01alandipertjcromartie: the macro expands into something that throws a java.lang.AssertionError
18:01jcromartieyeah
18:02alandipertyou're not finding that catchable?
18:02jcromartieI see what's happening… the code that I'm expecting to catch my assertions is not, becuase it's doing (catch Exception e …)
18:02jcromartieand that won't catch an assertion error
18:02jcromartiesilly
18:02jcromartieor should I not be using assertions?
18:02alandipertor you can catch Throwable t instead
18:03jcromartieyeah, this is a library
18:03jcromartieI'll put in a pull request at least
18:03alandipertah, bummer
18:07ravsterhello all
18:08ohpauleezhello
18:26seangroveIs it a good idea to create a bunch of function name from an array of strings?
18:26seangroveI'm wrapping the mailchimp api, and I'd like to have them available as "real" functions that can be tab-completed in the repl
18:27jcromartiesomebody help me see Compojure exceptions in nREPL please!
18:27jcromartieit's a total silent death
18:28muhoojcromartie: http://github.com/kenrestivo/firealarm ?
18:30Raynesmuhoo: Is that noir specific?
18:30alandipertseangrove: i say go for it!
18:30jcromartiemuhoo: it's a bit specific… not too general purpose
18:31jcromartiebut thanks for the tip
18:31muhooRaynes: nope
18:31jcromartieI can see the stacktraces in "lein repl"
18:31jcromartiebut not in nREPL from Emacs
18:31Raynesmuhoo: You might want to not mention noir in the readme.
18:31Raynesmuhoo: Oh, never mind.
18:31muhooRaynes: thanks, i should edit that.
18:31RaynesI could have swore I read something that implied it was noir specific.
18:32muhooit's just a middleware, works with ring or anything
18:32muhooi wrote it to deal with noir, originally, yes.
18:32RaynesYeah, but you've updated the README to mention compojure and stuff too.
18:32RaynesSo it's fine.
18:32RaynesYou could remove the Noir stuff if you wanted to though, since Noir is deader than Elvis.
18:33muhooelvis is not dead!
18:36jcromartieugh this is insane
18:36jcromartieso I've got my handler wrapped in middleware that catches exceptions
18:37jcromartiefirst exception: OK, returns 500 and an error, I see the stacktrace I expect
18:37jcromartienow the same HTTP request yields no response at all, and a DIFFERENT stacktrace in the log
18:37jcromartiethen the next (same again) request yields no response, and NO stacktrace in the log
18:38muhoojcromartie: i forsee hours of bisecting in your future.
18:38jcromartieyeah
18:39jcromartiethis is the stacktrace I get in "lein repl" (invisible in nREPL in Emacs)
18:39jcromartiehttps://gist.github.com/jcromartie/721501a9369ccc996791
18:39muhoook, stacktraces caused by web failures won't show up in nrepl or emacs, normally. that's why i wrote firealarm.
18:39jcromartieyes, and thanks for that :)
18:39jcromartieI'm working on that aspect
18:39muhooi have firealarm dump the errors, and then i open the buffer in emacs, and auto-revert-mode it
18:40jcromartiebut this is weirder than just that
18:40jcromartieyou see that at clojure.stacktrace$print_trace_element.invoke(stacktrace.clj:30)
18:40muhoomaybe your stacktrace handler is stacktracing
18:41jcromartieit is
18:41jcromartieit's clojure.stacktrace
18:41muhooalways wonderd how people debug debuggers.
18:47jcromartieglargbh
18:47jcromartiesomebody save me before I got back to Rails
18:57amalloymuhoo: same way you compile compilers
18:57jcromartieI have to make a new project and try to narrow this down
18:58amalloyjcromartie: i can't stand clojure.stacktrace, for exactly this reason: a debugging tool that doesn't *always* work is unacceptable
18:58jcromartiethe same thing happened with clj-stacktrace
19:00amalloyyep. can't abide any of them
19:01jcromartieamalloy: so… what do you use?
19:01amalloyjava stacktraces?
19:01jcromartieah
19:01jcromartiethat would work
19:01jcromartiebut they print to stderr, have to do some stuff to capture them eh
19:02amalloyhttp://docs.oracle.com/javase/6/docs/api/java/lang/Throwable.html#printStackTrace(java.io.PrintStream)
19:03amalloyi generally just look at stderr myself, but you can have an exception print to wherever you want
19:09jcromartiethis is so weird, it's like it gets stuck
19:15mroweevanb: matt suggested 'smbpasswd -r win.int.realestate.com.au -U <username>'
19:15mrowedoh, wrong channel sorry
19:16jcromartieI think it's this one exception…
19:16jcromartie,(re-seq #"" nil)
19:16seangroveI'm having a hard time un-quoting this macro properly: https://www.refheap.com/paste/11627
19:16clojurebot#<NullPointerException java.lang.NullPointerException>
19:16jcromartiefor some reason this blows up on me
19:17hyPiRion,(re-seq #"" "")
19:17clojurebot("")
19:17hyPiRion,(re-seq #"" "abc")
19:17clojurebot("" "" "" "")
19:17jcromartieI'm not trying to make re-seq work
19:17jcromartieI'm trying to figure out the invisible stacktrace of doom
19:17hyPiRionoh
19:17seangroveThe current eval-and-unpack is there from a bunch of different tweaks, not necessarily supposed to work
19:18jcromartiethis is output in my REPL https://gist.github.com/jcromartie/4753cd3304f340ea8b66
19:18jcromartiewhat the flying heck
19:20ivantry passing something other than nil?
19:20ivan(pst) will get you a real traceback
19:20jcromartieuser=> (re-seq #"" 0)
19:20jcromartieClassCastException java.lang.Long cannot be cast to java.lang.CharSequence clojure.core/re-matcher (core.clj:4286)
19:21jcromartienot with this :) ivan
19:21seangroveAh, I see my problem, I need to pass in the array directly
19:21jcromartietry it: (re-seq #"" nil) (pst)
19:21ivan,(doc re-seq)
19:21clojurebot"([re s]); Returns a lazy sequence of successive matches of pattern in string, using java.util.regex.Matcher.find(), each such match processed with re-groups."
19:21seangrovejcromartie: https://www.refheap.com/paste/11629
19:22jcromartieI KNOW HOW TO USE re-seq!
19:22jcromartieit's about the mystery invisible stacktrace
19:22ivanI see what seangrove sees
19:23seangrovejcromartie: Chill out
19:23seangroveI pasted the stacktrace I see for you
19:23Apage43huh
19:24Apage43I get the invisible one after I run the same thing ~15 times
19:24Apage43maybe it's a JIT thing?
19:24seangroveAh, same here after several attemps
19:24Apage43https://www.refheap.com/paste/11630
19:27Apage43https://www.refheap.com/paste/11631
19:27Apage43also with (inc nil)
19:27Apage43feels like a JIT thing
19:28seangroveSounds right
19:28ivan-XX:+PrintCompilation to see what gets compiled when it starts breaking
19:30ivanI can't repro with 64-bit jdk7u13, Clojure 1.5 RC16, -server
19:33ivanokay, I see it with 1.4 and 1.5RC16 on Ubuntu, default lein repl
19:36ivanjcromartie: this looks like a -XX:+TieredCompilation bug (which lein sadly sets by default), if you add :jvm-opts [] to your project.clj it will work
19:36amalloyseangrove: that looks like a macro that meant to be a function
19:43ivanwhen I was looking at JIT activity with TieredCompilation enabled a week ago, I knew it was bound to be buggier than just the -server compiler, but I am surprised to find my suspicions confirmed so soon
19:55ivanjcromartie: in case you missed it <ivan> jcromartie: this looks like a -XX:+TieredCompilation bug (which lein sadly sets by default), if you add :jvm-opts [] to your project.clj it will work
19:56jcromartieivan: ah! Thank you… that's really crazy
19:56jcromartiewhat's that all about anyway?
19:56jcromartie(I'm reading up on it)
19:57ivansee "Starting from early versions of JDK 6" https://gist.github.com/rednaxelafx/1165804
19:59jcromartieah ha… so the JIT must optimize out the failing code and never even run it? or something like that?
20:01jcromartiethanks guys, that was going to ruin my day
20:01jcromartiebecause it was actually masking other errors
20:02jcromartieso when things freak out and are not predictable like this, suspect JIT?
20:02jcromartiebecause yeah, (inc nil) should be pretty darn predictable :P
20:03frozenlockIs there a tutorial on how to publish documentation to github? codox + gh-pages?
20:03Apage43jcromartie: or at least, when something that should have no state seems to change behavior over time
20:03jcromartieyeah
20:04Apage43especially if it's a pattern like we saw where the behavior seems to change after doing it some number of times
20:06jhulten_heyall
20:07Apage43also if you see the pattern we have here where the behavior change seems to happen in related stuff that shares no state
20:08Apage43that is, if you play with it, you'll see that once (inc nil) starts having [trace missing], so does (+ 1 nil)
20:08Apage43and once (re-seq #"" nil) starts having [trace-missing], so does (re-matches #"" nil)
20:17frozenlockweavejester: codox-> "Could not generate documentation for my-project.core" Could you give me a hint as to what might be causing this?
20:18weavejesterFrozenlock: Usually that means it can't load the namespace, i.e. that there's a syntax error or something.
20:20frozenlockweavejester: ah! Indeed, my repl fails to restart. Thanks :)
20:57yogthosweavejester: I noticed that when you add or remove routes sometimes they don't get picked up without having to restart, is there a pattern to what causes that?
20:58weavejesteryogthos: Which version of lein-ring are you using?
20:58yogthosweavejester: ah I haven't noticed it recently, is it something that got fixed? :)
20:59yogthosweavejester: I remember it happening with 0.8 believe
20:59weavejesterThere have been a fair few bug fixes. Also I need to make a new release of ns-tracker, which might help solve things.
21:00yogthosweavejester: ah ok I'll try pay attention if I notice it and under what conditions next time
21:00yogthosweavejester: I noticed that it's most likely to get out of sync if there's any compilation errors
21:07seangroveHey all, I have to deal with tons of different api's (~30 right now), all of which give more or less similar data, but screwed up enough to make it painful.
21:08seangroveI'm wondering about declarative approaches to data normalization
21:09sshackTwo questions. Is anyone working on better error messages for clojure?
21:09seangroveJust in case anyone has any experience or thoughts on how to make normalization less painful and eye0gougingly ugle
21:09sshackand second, with is wrong with this? http://pastebin.com/VknAVVgn
21:09Iceland_jacksshack: Read the assertion message
21:10Iceland_jackException in thread "main" java.lang.AssertionError: Assert failed: (vector? (:dependencies project []))
21:10sshackYes, I have. One of the dependencies isn't a vector.
21:10ravstershould I just use log4j or is the slf4j abstraction worth it?
21:10seangrovesshack: probable best to paste on refheap as well
21:11seangroveIf just for the ease of scanning for others
21:11ravsterI'm new to logging, so I don't know how complicated things could get
21:11sshackseangrove: That's much easier to read, yes
21:11sshackhttps://www.refheap.com/paste/11632
21:14sshackseangrove: Any help?
21:15seangrovesshack: Looking...
21:15sshackThanks. I'm missing something obvious. i'm sure.
21:16seangroveNo, just a google
21:16sshack?
21:17sshackThe only changes I made were adding some depdenencies, and adding speclj.
21:17seangroveUpdate lein-ring to 0.8.2
21:17seangroveTry it, anyway..
21:18sshackWell that works.
21:18weavejestersshack: That error indicates that you have Lein 2.0.0 final, but some dependency is pulling in an old version of lein-jacker
21:18seangroveYeah, looks like a problem with lein-jacker
21:18seangroveBeat by a few milliseconds
21:19sshackweavejester: Okay. So I should double down on my question. Is anyone working on clear error messages?
21:19weavejesterClear error messages for what?
21:19seangroveThe error message was right...
21:20weavejesterI mean, it's not a straightforward problem, because an error is, by its nature, something unexpected.
21:20sshackThe error message was accurate. But not helpful.
21:21weavejesterA better error message would require some prescience on behalf of the library writer
21:21brehautlein-pedantic might catch the multiple versions of the same lib as a general problem?
21:21seangroveWell, a better response would be, what would have wanted it to say sshack ?
21:21weavejesterThe author of lein-jacker would need to know that the way dependencies are presented would change.
21:21brehaut( https://github.com/xeqi/lein-pedantic )
21:22ambrosebsI'm trying to track down a weird bug with Trammel. Could someone confirm that `mvn test` fails with an assertion error in this project? https://github.com/frenchy64/mvn-test
21:22technomancyweavejester: alternatively: time travel
21:22ambrosebsNot sure if it's just my config.
21:22sshackweavejester: That's part of what I'm getting at useful error messages and debugging tools are a very difficult task.
21:22weavejesterIn this case, the best error message would be "Lein-Ring 0.7.5 uses a version of Lein-Jacker that is incompatible with Lein 2.0.0's data structure"
21:23weavejesterBut that would require knowing that Lein's dependencies would change
21:23sshackI might have liked "This isn't the data structure I was expecting. I got foo, but was expecting something like bar"
21:23technomancyit's probably safe to drop leinjacker at this point, right? users of lein1 can just use older versions of a given plugin
21:24technomancyit seems unreasonable to refuse to upgrade Leiningen but demand newer plugins
21:24weavejestertechnomancy: Well, in this case it was an old plugin that didn't work with the new version of Lein.
21:25weavejesterI mean, we could be very explicit about version numbers; i.e., plugin x.y.z will *only* work with Lein x.y.z
21:25weavejesterBut that would require way too much work, on both the library developer, and the people maintaining the deps
21:26weavejesterIf people adopted perfect semantic versioning it might work
21:26technomancyyeah, we have a min-lein-version, but no max-lein-version
21:26technomancyeven that's for projects, not plugins
21:26weavejesterBut again, that tends to be tricky to do flawlessly.
21:26weavejesterI think it's just a difficult problem to solve for all cases.
21:27ravsterI'm trying to get tools.logging installed. lein deps is saying it can't find javax.jms, com.sun.jmx and com.sun.jdmk. is there somewhere else I could find these?
21:27ravster... on maven.org and clojars.org
21:28weavejesterAlthough… I wonder if one could make a function that looks up an error message in a remote DB. So common error messages could have an explanation. There would need to be some fuzzy matching, of course...
21:30sshackweavejester: Like old mainframe error message manuals?
21:31sshackError: 3444 " -> walk to library and lookup error.
21:31weavejesterMaybe. I don't know if it's a good idea.
21:31rationalrevolt,
21:31clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
21:32rationalrevolt,(Math/signum 5)
21:32clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: signum>
21:32sshackIf there's a way for that knowledge to get back into the tool, it's an excellent idea. If it ends up as yet another disjoint repository of incomplete knowledge, not so much.
21:32rationalrevoltcan someone tell me why this doesn't work?
21:33brehaut,(Math/signum 5.0)
21:33clojurebot1.0
21:33brehaut,(Math/signum (double 5))
21:33clojurebot1.0
21:33rationalrevoltalright
21:34brehautrationalrevolt: look at the typesig; it takes specifically a float or a double, not any number shaped thing
21:34brehaut(http://docs.oracle.com/javase/6/docs/api/java/lang/Math.html)
21:35rationalrevoltyup - this is because autoboxing doesnt apply on reflection invokes?
21:35brehautthat is not autoboxing; thats type coercion
21:36rationalrevoltsorry, right
21:37brehaut,(Math/signum (Double. 1.0))
21:37clojurebot1.0
21:37brehautthe autoboxing works find
21:37brehautfine
21:38tomoj"Normally, as a Clojure open source developer, you just don't walk into the Oracle office, but we invited her over anyway and told the infrastructure orcs to stay under their desks"
21:38tomojhttps://blogs.oracle.com/nashorn/entry/clojurescript_repl_if_you_build
21:38jcromartiehttp://www.quickmeme.com/meme/3t3c6d/
21:38rationalrevolthmm, now i'm confused - doesn't clojure treat numbers are Doubles automatically?
21:39rationalrevoltsorry!
21:39rationalrevoltgot it
21:39brehautrationalrevolt: im pretty sure that since 1.2 or 1.3 clojure used primative numbers by default
21:39rationalrevoltI was confusing the double signature as a long
21:43rationalrevolthmm, why doesn't type coersion apply in this case?
21:44frozenlockweavejester: I need your help, again... Following this https://github.com/weavejester/codox/wiki/Deploying-to-GitHub-Pages, I get this error "error: pathspec 'gh-pages' did not match any file(s) known to git." when trying `git checkout gh-pages'. :(
21:45weavejesterFrozenlock: You ran through all the instructions, right?
21:45weavejesterFrozenlock: Especially git symbolic-ref HEAD refs/heads/gh-pages
21:45frozenlockyes
21:45frozenlockCopy paste. Exaaaactly as it is.
21:46weavejesterWhat's your git version?
21:46frozenlock1.7.9.5
21:46weavejesterSimilar to mine. I'm not sure what went wrong except some kind of typo
21:47weavejesterI've run those instructions quite a few times without issue, and they're essentially taken from GitHub's own official instructions
21:48frozenlockhmm.. perhaps eshell is playing some tricks behind my back then. I'll try directly in my terminal.
21:48weavejesterAlthough, it looks like the latest GitHub instructions have changed
21:48weavejesterhttps://help.github.com/articles/creating-project-pages-manually
21:48weavejestergit checkout --orphan gh-pages
21:48weavejesterSeems to be the new
21:48weavejestergit symbolic-ref HEAD refs/heads/gh-pages
21:48weavejesterIt probably does exactly the same thing behind the scenes, though.
23:40seangroveHrm, what's usually the problem if korma can't connect to postgres locally, while psql and rails are just fine?
23:40seangroveI'm getting "CannotAcquireResourceException"
23:44arohnerseangrove: can you gist the whole stacktrace?
23:45seangroveSure, one second
23:45seangrovehttps://www.refheap.com/paste/11638
23:47seangroveThe server seems to be running on the default port, accepting connections from localhost (either with or without a user/pass combo)
23:49amalloyseangrove: that's not the stacktrace
23:49seangroveThat's the entire output
23:51seangroveAh, hold on
23:51seangroveRestarted the process to try again... https://www.refheap.com/paste/11639