#clojure logs

2012-09-25

02:59AustinYunman
03:00AustinYunso i've been taking a look at Haskell web frameworks, specifically Yesod and Snap
03:00AustinYunRing and the stuff that builds on Ring is SO. MUCH. NICER. <--- completely uneducated opinion
04:15kralnamaste
06:03ro_sti want to fn, with-foo-state, that does a whole bunch of (binding), does some work inside that binding context, and then runs some passed in fn which i want to have happen in the same binding context. i've done this by simply passing in a fn to the one that does the binding, but it's not picking the bindings up. i'm guessing this with-foo-state fn actually needs to be a macro?
06:14Raynesro_st: Could you paste your code?
06:31ro_stcomin' up
06:35ro_sthttps://www.refheap.com/paste/5278
06:39ro_stRaynes: i hope that's clear enough to describe what i'm doing
06:39ro_stactually, that is a horrible paste.
06:40ro_sti blame multitasking
06:45ro_stRaynes: here you go: https://www.refheap.com/paste/5279
06:46ro_stso i want the fn to execute in the context of the binding, and it doesn't appear to be doing that. presumably, with-worksheet needs to be a macro, but i'm not sure how to alter the with-worksheet fn to work as a macro
07:45ro_stRaynes: i got a macro working
07:45ro_stmacroexpand-1 ftw
08:34jocrauI would like to include cljs source files from a jar on my class path in my ClojureScript (:advanced) compilation. What's the best way to do this (using lein-clsjbuild)?
09:05AWizzArdIn the old Clojure Contrib there was a (duck-streams) `read-lines` function. Is there by now some high-level equivalent available? The current (with-open [r (try (clojure.java.io/reader ...) (catch ...))] (read-lines r)) is a bit chatty…
09:07S11001001AWizzArd: what would you do in that catch?
09:12AWizzArdS11001001: report that the file doesn’t exist, that I have no read-rights, etc.
09:13S11001001AWizzArd: and what did contrib do?
09:15AWizzArdS11001001: Don’t know, I think nothing.
09:15AWizzArdBut contrib was nice.
09:15S11001001well there you go, it wasn't good
09:15chouserAWizzArd: I think even the original champions of read-lines ended up recommending against its use.
09:16AWizzArdIt just gave me a lazy seq of the file, and auto-closed it after the lines were fully consumed.
09:16chouserbecause of the trickiness of the open file and the lazy seq interacting
09:16S11001001and what if you fail to consume all the lines?
09:16chouserS11001001: leak
09:16S11001001aside from that lack of error reporting, read-lines that opens and closes the file for you is not great, because you don't get to read the contents lazily and be sure of a close. One that interacted with a supplied reducer would be better.
09:16S11001001chouser: indeed
09:17chouserS11001001: which its docstring warned about in ALL CAPS
09:17S11001001who reads docs
09:17AWizzArd<--
09:17AWizzArd:)
09:17AWizzArdI did.
09:17AWizzArdOf course, the low-level way allows for granural and user-friendly error messages.
09:18AWizzArdThe user can be informed if the file doesn’t exist, may not be accessed or is only 0 bytes long.
09:18AWizzArdMy own read-lines currently does this, and it also remembers the line number to report where errors occured.
09:18AWizzArdIt just is a bit bothersome to always write this low-level stuff :)
09:19chouserPlugging into reducers is an interesting idea, though.
09:20AWizzArdHmm.
09:21AWizzArdS11001001 and chouser: please say a few more things about using reducers for this.
09:23chouserI'm trying to understand the idea right now. The lack of laziness sounds right, but reducers are meant to be able to run in arbitrary order, so I'm concerned about how that would work with line splitting.
09:24chouserBut actually I can't think about it right now. Sorry.
09:29S11001001AWizzArd: you pass a function to read-lines that transforms a reducible that represents the lines of the stream to whatever reducible you really want; read-lines itself folds the reducible before returning it
09:30S11001001AWizzArd: haskell iteratees are a more mature variant of controlling reads this way
09:43AWizzArdS11001001: more mature in what way?
09:43S11001001AWizzArd: in that people have known about and have been using this technique for a while, in production software even
10:16AWizzArdS11001001: How does the read-lines approach in Haskell work? Does it return you a lazy seq of the lines, and you don’t have to care about opening/closing the file? Or is it instead a function that takes a function, which is applied to each line in the specified file?
10:19S11001001AWizzArd: you can just read a string lazily in haskell, bracketed by the http://hackage.haskell.org/packages/archive/base/latest/doc/html/System-IO.html#g:4; but the iteratee approach is more flexible, and is closer, but not quite, like the second thing you said
10:21S11001001AWizzArd: in the former, the third argument's IO action is bracketed by the open and close, so the type system prevents you from accidentally reading after close
10:21augustlis there a way to only run a specific "deftest" with clojure.test? Currently restorting to commenting out other tests..
10:49augustl`lein test my-namespace-test/test-method` would have rocked :)
10:54TimMcaugustl: I believe there's a way to re-run only the tests that failed last time.
10:54TimMc...if that is at all helpful.
10:54TimMcNo, wait -- I'm probably thinking of JUnit in Eclipse. >_<
10:54augustlTimMc: sounds like adding support for running a specific test via the CLI should be farily easy
10:55TimMcaugustl: You can do it from the REPL. :-)
10:55boodleI'm trying to get vim working with nrepl and wondering if nrepl is "swank" compatible? (trying to use slimv to connect to nrepl from vim)
11:06Frozenlo`I'm trying to start a repl in a remote machine (./lein repl) but I get this message "which: no lein in (/bin:/usr/bin:/usr/sbin:/usr/local/bin)" Normal? Is there a way to start a repl without an access to these folders?
11:10SgeoFrozenlock, leiningen might not be installed on that machine?
11:11SgeoYou could set up leiningen as a user and add it to your path (or not add it to your path if you don't mind typing the full location out)
11:12FrozenlockI have the lein script and I've set it to executable. The only thing I did not do was to put it in the /bin folder.
11:13FrozenlockSo I type the full location each time. "./lein help" works
11:14Frozenlock"./lein help" starts, but exit immediatly with the message I pasted earlier :(
11:42polycosmHello ! I can't seem to find how to do something easy: how do I import/install math.combinatorics in emacs/nrepl, can anyone explain to me how that is done ? Is it part of the standard library ?
11:44polycosm(or more generally any library)
11:52S11001001polycosm: use leiningen, update project.clj to include what libraries you want
12:00SgeoTrying to get Eclipse+Counterclockwise to work
12:00SgeoSeems to be going a bit better now that I've actually seen a video about using it
12:00SgeoBut I'm getting an error when I try to open a REPL: Error occurred during initialization of VM
12:00Sgeojava/lang/ClassNotFoundException: error in opening JAR file C:\Program Files (x86)\Java\jre7\lib\rt.jar
12:03SgeoOh hey it worked this time
12:05polycosmS11001001: How to do I connect nrepl to that project.clj ?
12:06S11001001polycosm: be in the directory with it when you start it
12:07polycosmok so I have a repl, now how do I use that library ?
12:08polycosm(I'm really sorry to ask this, I'm looking at tutorials but I can't seem to make them work)
12:09S11001001add the library and version as a dependency; it is just another dependency entry like clojure itself in your project.clj
12:09polycosmI added it, [org.clojure/math.combinatorics "0.0.3"]
12:10polycosmthen I did : lein repl from there, now how would I use a function from that ?
12:10S11001001(require '[clojure.math.combinatorics as comb])
12:10S11001001now everything in it is available under comb/...
12:10S11001001s,as,:as,
12:11polycosmmagic ! Thank you so much S11001001 !
12:14Rich_MorinI just tried using ClojureScript One (per http://clojurescriptone.com/getting-started.html). When I tried "lein bootstrap", I got "'bootstrap' is not a task." Suggestions? FWIW, I see "./src/leiningen/bootstrap.clj"
13:08TimMcNegdayen: Did you ever find a lazy solution for your [x y z a b x y z a b...] splitting problem?
13:09NegdayenYep, I did. I ended up spending awhile creating my own generic solution, but ending up discovering the 'partition' function this morning, which solved the problem quite nicely.
13:11TimMcWait, how did that solve your problem?
13:12TimMcDid you apply it twice, one skipping the xyz and one skipping the ab?
13:12NegdayenYep.
13:12TimMcI guess that works.
14:15SrPxHey guys, I am sorry. Yesterday someone linked me to a selenium wrapper for clojure. I thought I bookmarked it but I didnt. Cant find on google. What was the link again?
14:15eggsbyhey core.logic guys, where does the degree/ordinal symbol in relation names come from? (conso, membero, etc) -- consº memberoº
14:16cshell_srpx: you can check the logs here: http://clojure-log.n01se.net/
14:16SrPxcshell_: thank you
14:17emezeskeSrPx: https://github.com/semperos/clj-webdriver
14:17SrPxemezeske: yes, that is it. Thanks.
14:29pandeirois there a fn that will take a map and a sequence of old-key new-key pairs and produce the same map with new keys?
14:30mpandon't remember a built-in to do specifically that, but map and destructuring should do it fine
14:32beberleihello, i am working through https://devcenter.heroku.com/articles/clojure-web-application but i cant get the DATABASE_URL connection string working with a username and password. it always fails saying it needs password based auth, but no password given. does anyone know the syntax for password based conn strings?
14:33amalloypandeiro: into
14:34weavejesterbeberlei: It depends on the database. Which one are you using?
14:34beberleiweavejester, postgresql
14:34amalloyoh, misread. clojure.set/rename-keys
14:34weavejesterbeberlei: jdbc:postgresql://localhost/test?user=fred&password=secret&ssl=true
14:34weavejesterbeberlei: From here: http://jdbc.postgresql.org/documentation/80/connect.html
14:35beberleiweavejester, thank you, trying that out directly :)
14:37ro_sti wrote a macro today and i am still not dead
14:38beberleiweavejester, sadly it still fails with "PSQLException The server requested password-based authentication, but no password was provided."
14:38weavejesterbeberlei: How are you using the DATABASE_URL variable?
14:39beberleiweavejester, (sql/with-connection (System/getenv "DATABASE_URL") (sql/create-table :testing [:name :text]))
14:39beberleiand in my shell i do export DATABASE_URL="postgresql://localhost:5432/push?user=push&password=push&ssl=true" before starting lein
14:39beberleiand just (System/getenv) prints the full string
14:39beberleidoing jdbc: in front like you pasted leads to a ClassName0 error
14:40weavejesterbeberlei: Which version of clojure jdbc?
14:40beberleihrhr, ok that might be it
14:40beberleithe one from the tutorial
14:40beberlei0.1.1
14:40ro_staside from radagast, is there anything in the test coverage space for clojure?
14:41beberleiok thats way old
14:42weavejesterbeberlei: Try updating to version 0.2.3
14:42weavejesterbeberlei: And then using (sql/with-conneciton {:connection-uri (System/getenv "DATABASE_URL)} ...)
14:44beberleiweavejester, ok and adding the jdbc: again - now it works. thank you very much!
14:44weavejesterbeberlei: No problem - I had to fix a similar problem a month ago
14:44beberleiclojure apparently suffers from the "tutorials are outdated too fast" illness :)
14:46julsonhey guys. What's a good development workflow for working on a clojure app with a clojurescript front-end?
14:47julsonI'm using emacs with nrepl.el and piggieback and can't seem to get it right...
14:59juhu_chapapeneconleche: hahaha!
14:59peneconlechethx
14:59peneconlechepene con leche
14:59peneconlechelol
15:00peneconlecheall i could think of
15:04Raynesbeberlei: So does every language with users who blog, unfortunately.
15:04mpenetjulson: I know there is some repl support for clojurescript, but I find lein cljsbuild auto just fine.
15:04mpenetvery close to
15:04mpenetnormal js
15:07mpenetjulson: also for dev just use simple compilation, and chrome debugger + console are usable from there (not hard to figure out what goes wrong).
15:08mpenetthere is probably some better way, but so far I am happy
15:09julsonmpenet: so just use cljsbuild for recompilation and just test stuff out in the browser?
15:09mpenetjulson: pretty much yes
15:10julsonI see. I guess that's fine for now then. I found working with Clojure and its repl to be quite pleasant. I was hoping to find something similar with clojurescript for non-browser related testing
15:10mpenetbut have a look at the cljsbuild readme, there are different ways to have/use a repl
15:11nDuffjulson: I've had very good success loading new code into a running instance connecting emacs inferior-lisp to the cljs repl
15:11mpenetI just test algo/code in a the parent project repl, clojurescript is very close so it is good enough for me
15:33xeqijulson: what issue are you having with nrepl.el+piggieback?
15:42pisketti_I just loooove destructuring
15:42pisketti_FYI
16:28gfredericksnot a lot goes on here during strangeloop
16:29abalonegfredericks: did you already give your talk?
16:34gfredericksabalone: I'm not giving a talk, though now I'm curious why you thought I was :)
16:35abaloneare you sure you're not supposed to speak? j/k. whoops i thought you told me you were giving a talk.
16:36gfredericksoh if I mentioned anything it was probably http://geekfest.gathers.us/events/geekfest-how-to-program-your-quantum-computer
16:36abaloneah ok :)
16:36gfrederickswhich makes me realize you didn't specifically qualify "at strangeloop"
16:36gfredericksso if you meant it more generally, then "yes"
16:36abalonehope it went well!
16:37gfredericksyes I think so; as well as it could have without 2 hours
16:46TimMcGrah, I'm trying to run `lein deps` here at work, and all the requests to Clojars are getting intercepted by a maven nexus.
16:52TimMclein2 won't have that kind of issue, right?
16:55xeqiTimMc: lein2 has a different mechanism to set a proxy, so it won't use ~/.m2/settings.xml that maven does
16:56xeqilein1 ends up using it more by accident of implementation then on purpose
18:41gozalaHi folks!
18:42gozalaI was wondering if there is a form for cljs to do something like
18:42gozala(.-location js/window)
18:42gozalabut in a macro
18:42pjstadigclojurescript doesn't have clojurescript macros
18:43gozalasomething like `(set! (.- ~name ~target) ~value)
18:43gozala pjstadig well ok clojure then
18:43pjstadigi guess maybe create a symbol? (symbol ".-" name)
18:43gozalaI'm actually writing subset of clojurescript compiler with macros
18:44pjstadig`(set! (~(symbol ".-" name) ~target) ~value)
18:44gozalapjstadig: hmm.. that actually might work
18:47gozalapjstadig: thanks it does not quite works but I might be able to workaround this
18:48pjstadiger
18:48pjstadigyeah
18:49pjstadig`(set! ((symbol (str ".-" name)) ~target) ~value)
18:50pjstadigugh
18:50pjstadig`(set! (~(symbol (str ".-" name)) ~target) ~value)
18:50pjstadigyou get the idea :)
19:13SgeoShould I blame my inability to recur from catch on Java interop?
19:1445PAA5LGCrecur from catch can't be done as a tail call. recur guarantees tail calls.
19:17amalloywell, recurring *across* catch is fundamentally impossible. recurring *inside* catch is something that should work, but last i checked it doesn't
19:1945PAA5LGCamalloy: when you say recur inside catch, do you mean (fn [] (try (/ 1 0) (catch Exception e (loop [] (recur)))?
19:19amalloyyes
19:19pjstadigwhy couldn't you recur *across* a catch when you can statically determine there is no finally clause?
19:23amalloyi assumed the jvm bytecode has some required structure that makes it impossible; but maybe it's just that there's no language construct for doing it in java
19:2445PAA5LGChttp://dev.clojure.org/jira/browse/CLJ-31
19:27arohnerbindings push onto the stack, and prevent constant space recurs
19:27pjstadiga bindings implicitly creates a try/finally block
19:34amalloyso after a look at the bytecode for exception handling, i think it would be possible to recur across a catch if no finally clauses exist, but it would probably take someone with intimate knowledge of both clojure's assembly internals and the bytecode spec
19:47Raynesamalloy: Hah, wow, that really bothers you doesn't it?
19:48amalloy?
19:49Raynesamalloy: recuring across a catch. You've mentioned it several times before and you actually looked at bytecode. That's bloody effort.
20:09devnDoes anyone know how to remove fx-* added to a buffer in overtone?
20:09devnFor instance, if I (fx-echo 0 1 1 1), how do I remove that effect
20:27sexpGirlIn various of his talk Rich Hickey talks about things being too "complected" and the need to get rid of all this complection... Now is it just me or is the entire Clojure tools world totally and utterly complected?
20:28sexpGirlI mean, I'm trying something which I thought was simple: open Emacs, start a REPL (nrepl.el) and... Import a "free floating jar" (a proprietary .jar which is not in a repo).
20:30sexpGirlIt turns out it's very, very hard to do: because everything seems to so complected (Leiningen requires Maven, Maven doesn't like free-floating jars so you have to create your own private s3 bucket!? What the heck!?). This seems totally complected to me. The same thing using plain old Java / Ant is trivial. With Clojure / lein / Maven it seems an exercise in complection.
20:31AustinYunyou don't need an s3 bucket
20:31Raynesrlwrap java -cp clojure.jar:yourotherjarthatisntinamavenrepoforwhatevergodawfulreason clojure.main
20:32AustinYunmaven install:install-file i think
20:32AustinYuni hate maven too but, yeah
20:32RaynesMaven doesn't like free floating jars because it makes builds unrepeatable. You want everything in a maven repo somewhere. All you have to do to work with it locally (and easily) is get it installed in your local maven repo.
20:32xeqior lein local-repo
20:32RaynesYou're confusing tooling with Clojure, a language, being 'complected'.
20:32xeqi* lein-localrepo
20:32sexpGirl@Raynes: OK from the command-line it's fine sure, but is that going to fly with an Emacs / nrepl.el setup?
20:33Rayneslein localrepo is perfect for this sort of thing.
20:33sexpGirl@Raynes: I'm not confusing... My point was that it's ironic to see so much completion around "Clojure the tools" when "Clojure the philosophy" is to get rid of complection ; )
20:34xeqidependency management is hard
20:34RaynesPeople are putting a lot of effort into making things easy, but we're working with Java systems.
20:34RaynesI don't think it is particularly 'complected' though.
20:35AustinYunseems non-complected (aka simple) to me
20:35RaynesI think it is unfamiliar territory with a slight learning curve for new people.
20:36AustinYunsimple isn't always easy
20:36RaynesBut <insert anything new> here has the same problem.
20:37AustinYuneach of those things has a separate responsibility which isn't braided into a different responsibility, yeah?
20:37RaynesThe important thing is to be able to ask questions and get answers without complaining about everything in the same breath. ;)
20:37emezeskesexpGirl: You keep using that word... I do not think it means what you think it means!
20:38emezeskesexpGirl: :P
20:38AustinYunleiningen does dependency management, so if you have a free jar, you should stick it in a repo because just sticking free-floating jars around is bad from an ops perspective
20:40RaynesI understand her desire to get up and running quickly though. The problem is that leiningen and the rest of the tooling is optimized for doing things properly all-around.
20:40RaynesBut localrepo helps immensely.
20:40RaynesIt'd be nice if it were in leiningen itself.
20:41RaynesI'd worry about it encouraging usage of free floating jars.
20:41sexpGirl@Raynes: ok so I'll add localrepo to lein
20:41emezeskeRaynes: Like you said, if you want to avoid doing things The Right Way™ you can always just run the java command yourself
20:42RaynesWell, 'The Right Way' is rather irrelevant for something like her case where you just want a repl with a random free floating jar. But optimizing for that means confusing The Right Way with The Right Now Way, which is bad, and probably why localrepo isn't in leiningen itself.
20:44AustinYunwell yeah but in that case you'd do the java -cp clojure.jar:otherjar clojure.main way instead of using leiningen
20:44AustinYunright?
20:44clojurebotto be fair I dunno that I've ever had code out right rejected, it just sits in jira or assembla or where ever, or if I ask if there is any interest (before writing any code) I get told to go write alioth benchmarks
20:44Rayneshaha
20:45AustinYunwhereas what leiningen is trying to do is make complicated projects with dependencies install and run like, deterministically
20:45sexpGirl@AustinYun: I don't mind spending time doing things "the correct way" but... For a quick test, if I want to try the command line workaround, shall I still be able to work from my REPL (nrepl) from Emacs?
20:47amalloyRaynes: The Right Now Way. i like that. did you come up with that or steal it from somewhere?
20:47Raynesamalloy: I came up with it and don't recall seeing anyone else say it, but I'm not trademarking it yet. :p
20:49AustinYundon't use emacs so just from a quick glance, it seems nrepl is the part you're having trouble with because nrepl depends on leiningen
20:49RaynesWell, no.
20:49Rayneslocalrepo mostly fixes the problem I think.
20:49RaynesLeiningen can do what she wants.
20:49Raynes(and thus nrepl)
20:49Sgeo_asjdhflkasdfhlaksdfhlk I HATE HOW ECLIPSE IS A MEMORY HOG
20:50Sgeo_I guess back to trying to get Emacs to work nicely
20:50xeqiM-x nrepl could connect to a nrepl server started by a non-lein process, but that process would not be easy to start from a `java -cp ...`
20:51xeqibut lein-localrepo is much much easier
20:52sexpGirlOK so for now lein-localrepo it shall be. The part that confused me (before coming asking here) was that: "... While it's possible to install them locally with things like lein-localrepo, doing so adds the requirement of a manual step to your build, which is counter to our goals of repeatability and automation."
20:52AustinYunyeah, that's pretty much it
20:53sexpGirlbtw I'd like to point out that we've got fully deterministic builds (for our Java stuff) even though we're not using Maven: we do commit the free-floating jars in our DVCS and that's it :-/
20:53xeqisexpGirl: for quick testing that doesn't matter; but if you wanted to hand it off to someone else it is annoying to have that extra step
20:53AustinYunor deploying to heroku or something
20:54AustinYunspeaking of dependencies and crap, i <3 NPM... so much
20:55Sgeo_Is there a recommended thing to do when JNAerator is in the pipeline?
21:12Sgeo_How do I tell paredit to get out of my way?
21:12Sgeo_Right now, it seems to have lost track of "
21:13leonardoborgesSgeo_: C+q lets you insert a new character to re-balance things. does that help?
21:13leonardoborgesSgeo_: assuming you're on emacs
21:13amalloySgeo_: i think the only way it can lose track is if you paste things that aren't well-balanced. so, just be aware that if you do that you may need to patch things up
21:14Sgeo_leonardoborges, thank you
21:14Sgeo_I also have some unwanted () surrounding an expression, don't know how to get rid of it
21:14amalloySgeo_: M-s or M-r
21:14amalloydepending on how you want to get rid of them
21:15Sgeo_I want to turn ((blah)) into (blah)
21:16amalloythey both work for that
21:16amalloygiven ((a b)), M-s would give you (a b), and M-r would give you either (a) or (b) depending where you do it
21:20Sgeo_Oh, I know what caused the imbalancing: Had overwrite mode on by accident
21:20leonardoborgesSgeo_: check out this preso: http://www.slideshare.net/mudphone/paredit-preso - great for learning paredit key bindings
21:21Sgeo_...ok, weird that nrepl.el decided to put the nREPL buffer on the right rather than the bottom of the current buffer
21:36Sgeo_When using emacs and nrepl.el, how do I restart the repl when I add dependencies?
21:49Sgeo_Oh, ritz-nrepl is a thing that exists
21:49Sgeo_So I guess I could just use that
22:02FrozenlockEr.. my div loses its focus when I edit it (with domina). Any way to keep the focus on it?
22:10brehautsetInterval(0, function() { myDiv.focus(); }); // ;)
22:12FrozenlockEhhh not quite :P
23:04FrozenlockAHHHH damnit! Why do I lose focus when removing a child element? And why can't I get stuck on important stuff??
23:04lazybotFrozenlock: What are you, crazy? Of course not!
23:15hughfdjacksonwhat's the defacto emacs/clojure mode?
23:16hughfdjacksonswank seems to think it isn't it anymore
23:16brehautclojure-mode and nrepl.el ?
23:16hughfdjacksonthat's what i was wonderin' ^^
23:16hughfdjackson:) will check it out
23:17brehautpretty sure technomancy deprecated swank / slime for clojure a couple of weks ago
23:17brehauthttp://technomancy.us/163
23:25hughfdjacksonbrehaut: reading :)
23:28Sgeo_Is ritz-nrepl generally good?
23:28Sgeo_I really want that project.clj reloading
23:36clj_newb_2345is there a way to define a clojure set which defines equality by value rather than by reference?
23:37gfredericksdon't they normally?
23:37gfredericks,(conj #{"foo"} (str "fo" "o"))
23:37clojurebot#{"foo"}
23:38clj_newb_2345hmm; I am an idiot.
23:50technomancynuclearsandwich: hey