#clojure log - Sep 25 2012

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

2:59 AustinYun: man

3:00 so i've been taking a look at Haskell web frameworks, specifically Yesod and Snap

3:00 Ring and the stuff that builds on Ring is SO. MUCH. NICER. <--- completely uneducated opinion

4:15 kral: namaste

6:03 ro_st: i 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?

6:14 Raynes: ro_st: Could you paste your code?

6:31 ro_st: comin' up

6:35 https://www.refheap.com/paste/5278

6:39 Raynes: i hope that's clear enough to describe what i'm doing

6:39 actually, that is a horrible paste.

6:40 i blame multitasking

6:45 Raynes: here you go: https://www.refheap.com/paste/5279

6:46 so 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

7:45 Raynes: i got a macro working

7:45 macroexpand-1 ftw

8:34 jocrau: I 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)?

9:05 AWizzArd: In 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…

9:07 S11001001: AWizzArd: what would you do in that catch?

9:12 AWizzArd: S11001001: report that the file doesn’t exist, that I have no read-rights, etc.

9:13 S11001001: AWizzArd: and what did contrib do?

9:15 AWizzArd: S11001001: Don’t know, I think nothing.

9:15 But contrib was nice.

9:15 S11001001: well there you go, it wasn't good

9:15 chouser: AWizzArd: I think even the original champions of read-lines ended up recommending against its use.

9:16 AWizzArd: It just gave me a lazy seq of the file, and auto-closed it after the lines were fully consumed.

9:16 chouser: because of the trickiness of the open file and the lazy seq interacting

9:16 S11001001: and what if you fail to consume all the lines?

9:16 chouser: S11001001: leak

9:16 S11001001: aside 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.

9:16 chouser: indeed

9:17 chouser: S11001001: which its docstring warned about in ALL CAPS

9:17 S11001001: who reads docs

9:17 AWizzArd: <--

9:17 :)

9:17 I did.

9:17 Of course, the low-level way allows for granural and user-friendly error messages.

9:18 The user can be informed if the file doesn’t exist, may not be accessed or is only 0 bytes long.

9:18 My own read-lines currently does this, and it also remembers the line number to report where errors occured.

9:18 It just is a bit bothersome to always write this low-level stuff :)

9:19 chouser: Plugging into reducers is an interesting idea, though.

9:20 AWizzArd: Hmm.

9:21 S11001001 and chouser: please say a few more things about using reducers for this.

9:23 chouser: I'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.

9:24 But actually I can't think about it right now. Sorry.

9:29 S11001001: AWizzArd: 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

9:30 AWizzArd: haskell iteratees are a more mature variant of controlling reads this way

9:43 AWizzArd: S11001001: more mature in what way?

9:43 S11001001: AWizzArd: in that people have known about and have been using this technique for a while, in production software even

10:16 AWizzArd: S11001001: 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:19 S11001001: AWizzArd: 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:21 AWizzArd: 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:21 augustl: is there a way to only run a specific "deftest" with clojure.test? Currently restorting to commenting out other tests..

10:49 `lein test my-namespace-test/test-method` would have rocked :)

10:54 TimMc: augustl: I believe there's a way to re-run only the tests that failed last time.

10:54 ...if that is at all helpful.

10:54 No, wait -- I'm probably thinking of JUnit in Eclipse. >_<

10:54 augustl: TimMc: sounds like adding support for running a specific test via the CLI should be farily easy

10:55 TimMc: augustl: You can do it from the REPL. :-)

10:55 boodle: I'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:06 Frozenlo`: 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:10 Sgeo: Frozenlock, leiningen might not be installed on that machine?

11:11 You 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:12 Frozenlock: I 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:13 So I type the full location each time. "./lein help" works

11:14 "./lein help" starts, but exit immediatly with the message I pasted earlier :(

11:42 polycosm: Hello ! 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:44 (or more generally any library)

11:52 S11001001: polycosm: use leiningen, update project.clj to include what libraries you want

12:00 Sgeo: Trying to get Eclipse+Counterclockwise to work

12:00 Seems to be going a bit better now that I've actually seen a video about using it

12:00 But I'm getting an error when I try to open a REPL: Error occurred during initialization of VM

12:00 java/lang/ClassNotFoundException: error in opening JAR file C:\Program Files (x86)\Java\jre7\lib\rt.jar

12:03 Oh hey it worked this time

12:05 polycosm: S11001001: How to do I connect nrepl to that project.clj ?

12:06 S11001001: polycosm: be in the directory with it when you start it

12:07 polycosm: ok so I have a repl, now how do I use that library ?

12:08 (I'm really sorry to ask this, I'm looking at tutorials but I can't seem to make them work)

12:09 S11001001: add the library and version as a dependency; it is just another dependency entry like clojure itself in your project.clj

12:09 polycosm: I added it, [org.clojure/math.combinatorics "0.0.3"]

12:10 then I did : lein repl from there, now how would I use a function from that ?

12:10 S11001001: (require '[clojure.math.combinatorics as comb])

12:10 now everything in it is available under comb/...

12:10 s,as,:as,

12:11 polycosm: magic ! Thank you so much S11001001 !

12:14 Rich_Morin: I 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:08 TimMc: Negdayen: Did you ever find a lazy solution for your [x y z a b x y z a b...] splitting problem?

13:09 Negdayen: Yep, 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:11 TimMc: Wait, how did that solve your problem?

13:12 Did you apply it twice, one skipping the xyz and one skipping the ab?

13:12 Negdayen: Yep.

13:12 TimMc: I guess that works.

14:15 SrPx: Hey 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:15 eggsby: hey core.logic guys, where does the degree/ordinal symbol in relation names come from? (conso, membero, etc) -- consº memberoº

14:16 cshell_: srpx: you can check the logs here: http://clojure-log.n01se.net/

14:16 SrPx: cshell_: thank you

14:17 emezeske: SrPx: https://github.com/semperos/clj-webdriver

14:17 SrPx: emezeske: yes, that is it. Thanks.

14:29 pandeiro: is 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:30 mpan: don't remember a built-in to do specifically that, but map and destructuring should do it fine

14:32 beberlei: hello, 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:33 amalloy: pandeiro: into

14:34 weavejester: beberlei: It depends on the database. Which one are you using?

14:34 beberlei: weavejester, postgresql

14:34 amalloy: oh, misread. clojure.set/rename-keys

14:34 weavejester: beberlei: jdbc:postgresql://localhost/test?user=fred&password=secret&ssl=true

14:34 beberlei: From here: http://jdbc.postgresql.org/documentation/80/connect.html

14:35 beberlei: weavejester, thank you, trying that out directly :)

14:37 ro_st: i wrote a macro today and i am still not dead

14:38 beberlei: weavejester, sadly it still fails with "PSQLException The server requested password-based authentication, but no password was provided."

14:38 weavejester: beberlei: How are you using the DATABASE_URL variable?

14:39 beberlei: weavejester, (sql/with-connection (System/getenv "DATABASE_URL") (sql/create-table :testing [:name :text]))

14:39 and in my shell i do export DATABASE_URL="postgresql://localhost:5432/push?user=push&password=push&ssl=true" before starting lein

14:39 and just (System/getenv) prints the full string

14:39 doing jdbc: in front like you pasted leads to a ClassName0 error

14:40 weavejester: beberlei: Which version of clojure jdbc?

14:40 beberlei: hrhr, ok that might be it

14:40 the one from the tutorial

14:40 0.1.1

14:40 ro_st: aside from radagast, is there anything in the test coverage space for clojure?

14:41 beberlei: ok thats way old

14:42 weavejester: beberlei: Try updating to version 0.2.3

14:42 beberlei: And then using (sql/with-conneciton {:connection-uri (System/getenv "DATABASE_URL)} ...)

14:44 beberlei: weavejester, ok and adding the jdbc: again - now it works. thank you very much!

14:44 weavejester: beberlei: No problem - I had to fix a similar problem a month ago

14:44 beberlei: clojure apparently suffers from the "tutorials are outdated too fast" illness :)

14:46 julson: hey guys. What's a good development workflow for working on a clojure app with a clojurescript front-end?

14:47 I'm using emacs with nrepl.el and piggieback and can't seem to get it right...

14:59 juhu_chapa: peneconleche: hahaha!

14:59 peneconleche: thx

14:59 pene con leche

14:59 lol

15:00 all i could think of

15:04 Raynes: beberlei: So does every language with users who blog, unfortunately.

15:04 mpenet: julson: I know there is some repl support for clojurescript, but I find lein cljsbuild auto just fine.

15:04 very close to

15:04 normal js

15:07 julson: also for dev just use simple compilation, and chrome debugger + console are usable from there (not hard to figure out what goes wrong).

15:08 there is probably some better way, but so far I am happy

15:09 julson: mpenet: so just use cljsbuild for recompilation and just test stuff out in the browser?

15:09 mpenet: julson: pretty much yes

15:10 julson: I 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:10 mpenet: but have a look at the cljsbuild readme, there are different ways to have/use a repl

15:11 nDuff: julson: I've had very good success loading new code into a running instance connecting emacs inferior-lisp to the cljs repl

15:11 mpenet: I just test algo/code in a the parent project repl, clojurescript is very close so it is good enough for me

15:33 xeqi: julson: what issue are you having with nrepl.el+piggieback?

15:42 pisketti_: I just loooove destructuring

15:42 FYI

16:28 gfredericks: not a lot goes on here during strangeloop

16:29 abalone: gfredericks: did you already give your talk?

16:34 gfredericks: abalone: I'm not giving a talk, though now I'm curious why you thought I was :)

16:35 * gfredericks considers the possibility that he was supposed to give a talk but forgot

16:35 abalone: are you sure you're not supposed to speak? j/k. whoops i thought you told me you were giving a talk.

16:36 gfredericks: oh if I mentioned anything it was probably http://geekfest.gathers.us/events/geekfest-how-to-program-your-quantum-computer

16:36 abalone: ah ok :)

16:36 gfredericks: which makes me realize you didn't specifically qualify "at strangeloop"

16:36 so if you meant it more generally, then "yes"

16:36 abalone: hope it went well!

16:37 gfredericks: yes I think so; as well as it could have without 2 hours

16:46 TimMc: Grah, I'm trying to run `lein deps` here at work, and all the requests to Clojars are getting intercepted by a maven nexus.

16:52 lein2 won't have that kind of issue, right?

16:55 xeqi: TimMc: lein2 has a different mechanism to set a proxy, so it won't use ~/.m2/settings.xml that maven does

16:56 lein1 ends up using it more by accident of implementation then on purpose

17:48 * gfredericks watches Bret Victor

18:41 gozala: Hi folks!

18:42 I was wondering if there is a form for cljs to do something like

18:42 (.-location js/window)

18:42 but in a macro

18:42 pjstadig: clojurescript doesn't have clojurescript macros

18:43 gozala: something like `(set! (.- ~name ~target) ~value)

18:43 pjstadig well ok clojure then

18:43 pjstadig: i guess maybe create a symbol? (symbol ".-" name)

18:43 gozala: I'm actually writing subset of clojurescript compiler with macros

18:44 pjstadig: `(set! (~(symbol ".-" name) ~target) ~value)

18:44 gozala: pjstadig: hmm.. that actually might work

18:47 pjstadig: thanks it does not quite works but I might be able to workaround this

18:48 pjstadig: er

18:48 yeah

18:49 `(set! ((symbol (str ".-" name)) ~target) ~value)

18:50 ugh

18:50 `(set! (~(symbol (str ".-" name)) ~target) ~value)

18:50 you get the idea :)

19:13 Sgeo: Should I blame my inability to recur from catch on Java interop?

19:14 45PAA5LGC: recur from catch can't be done as a tail call. recur guarantees tail calls.

19:17 amalloy: well, recurring *across* catch is fundamentally impossible. recurring *inside* catch is something that should work, but last i checked it doesn't

19:19 45PAA5LGC: amalloy: when you say recur inside catch, do you mean (fn [] (try (/ 1 0) (catch Exception e (loop [] (recur)))?

19:19 amalloy: yes

19:19 pjstadig: why couldn't you recur *across* a catch when you can statically determine there is no finally clause?

19:23 amalloy: i 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:24 45PAA5LGC: http://dev.clojure.org/jira/browse/CLJ-31

19:27 arohner: bindings push onto the stack, and prevent constant space recurs

19:27 pjstadig: a bindings implicitly creates a try/finally block

19:34 amalloy: so 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:47 Raynes: amalloy: Hah, wow, that really bothers you doesn't it?

19:48 amalloy: ?

19:49 Raynes: amalloy: recuring across a catch. You've mentioned it several times before and you actually looked at bytecode. That's bloody effort.

20:09 devn: Does anyone know how to remove fx-* added to a buffer in overtone?

20:09 For instance, if I (fx-echo 0 1 1 1), how do I remove that effect

20:27 sexpGirl: In 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:28 I 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:30 It 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:31 AustinYun: you don't need an s3 bucket

20:31 Raynes: rlwrap java -cp clojure.jar:yourotherjarthatisntinamavenrepoforwhatevergodawfulreason clojure.main

20:32 AustinYun: maven install:install-file i think

20:32 i hate maven too but, yeah

20:32 Raynes: Maven 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:32 xeqi: or lein local-repo

20:32 Raynes: You're confusing tooling with Clojure, a language, being 'complected'.

20:32 xeqi: * lein-localrepo

20:32 sexpGirl: @Raynes: OK from the command-line it's fine sure, but is that going to fly with an Emacs / nrepl.el setup?

20:33 Raynes: lein localrepo is perfect for this sort of thing.

20:33 sexpGirl: @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:34 xeqi: dependency management is hard

20:34 Raynes: People are putting a lot of effort into making things easy, but we're working with Java systems.

20:34 I don't think it is particularly 'complected' though.

20:35 AustinYun: seems non-complected (aka simple) to me

20:35 Raynes: I think it is unfamiliar territory with a slight learning curve for new people.

20:36 AustinYun: simple isn't always easy

20:36 Raynes: But <insert anything new> here has the same problem.

20:37 AustinYun: each of those things has a separate responsibility which isn't braided into a different responsibility, yeah?

20:37 Raynes: The important thing is to be able to ask questions and get answers without complaining about everything in the same breath. ;)

20:37 emezeske: sexpGirl: You keep using that word... I do not think it means what you think it means!

20:38 sexpGirl: :P

20:38 AustinYun: leiningen 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:40 Raynes: I 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:40 But localrepo helps immensely.

20:40 It'd be nice if it were in leiningen itself.

20:41 I'd worry about it encouraging usage of free floating jars.

20:41 sexpGirl: @Raynes: ok so I'll add localrepo to lein

20:41 emezeske: Raynes: Like you said, if you want to avoid doing things The Right Way™ you can always just run the java command yourself

20:42 Raynes: Well, '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:44 AustinYun: well yeah but in that case you'd do the java -cp clojure.jar:otherjar clojure.main way instead of using leiningen

20:44 right?

20:44 clojurebot: to 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:44 Raynes: haha

20:45 AustinYun: whereas what leiningen is trying to do is make complicated projects with dependencies install and run like, deterministically

20:45 sexpGirl: @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:47 amalloy: Raynes: The Right Now Way. i like that. did you come up with that or steal it from somewhere?

20:47 Raynes: amalloy: I came up with it and don't recall seeing anyone else say it, but I'm not trademarking it yet. :p

20:49 AustinYun: don'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:49 Raynes: Well, no.

20:49 localrepo mostly fixes the problem I think.

20:49 Leiningen can do what she wants.

20:49 (and thus nrepl)

20:49 Sgeo_: asjdhflkasdfhlaksdfhlk I HATE HOW ECLIPSE IS A MEMORY HOG

20:50 I guess back to trying to get Emacs to work nicely

20:50 * AustinYun uses vimclojure lol

20:50 xeqi: M-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:51 but lein-localrepo is much much easier

20:52 sexpGirl: OK 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:52 AustinYun: yeah, that's pretty much it

20:53 sexpGirl: btw 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:53 xeqi: sexpGirl: 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:53 AustinYun: or deploying to heroku or something

20:54 speaking of dependencies and crap, i <3 NPM... so much

20:55 Sgeo_: Is there a recommended thing to do when JNAerator is in the pipeline?

21:12 How do I tell paredit to get out of my way?

21:12 Right now, it seems to have lost track of "

21:13 leonardoborges: Sgeo_: C+q lets you insert a new character to re-balance things. does that help?

21:13 Sgeo_: assuming you're on emacs

21:13 amalloy: Sgeo_: 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:14 Sgeo_: leonardoborges, thank you

21:14 I also have some unwanted () surrounding an expression, don't know how to get rid of it

21:14 amalloy: Sgeo_: M-s or M-r

21:14 depending on how you want to get rid of them

21:15 Sgeo_: I want to turn ((blah)) into (blah)

21:16 amalloy: they both work for that

21:16 given ((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:20 Sgeo_: Oh, I know what caused the imbalancing: Had overwrite mode on by accident

21:20 leonardoborges: Sgeo_: check out this preso: http://www.slideshare.net/mudphone/paredit-preso - great for learning paredit key bindings

21:21 Sgeo_: ...ok, weird that nrepl.el decided to put the nREPL buffer on the right rather than the bottom of the current buffer

21:36 When using emacs and nrepl.el, how do I restart the repl when I add dependencies?

21:49 Oh, ritz-nrepl is a thing that exists

21:49 So I guess I could just use that

22:02 Frozenlock: Er.. my div loses its focus when I edit it (with domina). Any way to keep the focus on it?

22:10 brehaut: setInterval(0, function() { myDiv.focus(); }); // ;)

22:12 Frozenlock: Ehhh not quite :P

23:04 AHHHH damnit! Why do I lose focus when removing a child element? And why can't I get stuck on important stuff??

23:04 lazybot: Frozenlock: What are you, crazy? Of course not!

23:15 hughfdjackson: what's the defacto emacs/clojure mode?

23:16 swank seems to think it isn't it anymore

23:16 brehaut: clojure-mode and nrepl.el ?

23:16 hughfdjackson: that's what i was wonderin' ^^

23:16 :) will check it out

23:17 brehaut: pretty sure technomancy deprecated swank / slime for clojure a couple of weks ago

23:17 http://technomancy.us/163

23:25 hughfdjackson: brehaut: reading :)

23:28 Sgeo_: Is ritz-nrepl generally good?

23:28 I really want that project.clj reloading

23:36 clj_newb_2345: is there a way to define a clojure set which defines equality by value rather than by reference?

23:37 gfredericks: don't they normally?

23:37 ,(conj #{"foo"} (str "fo" "o"))

23:37 clojurebot: #{"foo"}

23:38 clj_newb_2345: hmm; I am an idiot.

23:50 technomancy: nuclearsandwich: hey

Logging service provided by n01se.net