#clojure log - May 04 2011

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

0:03 technomancy: amalloy: ah bugger; forgot it requires git master

0:17 or not; it was a screw-up with the clucy lib needing ancient contrib

0:17 anyway, should be ok now

0:18 brehaut: does anyone know whats involved with getting sqlite going with clojure?

0:22 dnolen: brehaut: not much, use the JDBC connector, setup your tables, querying w/ ClojureQL is fun.

0:23 http://www.zentus.com/sqlitejdbc/

0:23 brehaut: dnolen: thanks

0:23 no maven thing for it?

0:24 dnolen: brehaut: supposedly it's here http://www.jarvana.com/jarvana/search?search_type=project&project=sqlite

0:25 brehaut: dnolen: thanks

0:26 dnolen: actually those are different according to this, http://www.xerial.org/trac/Xerial/wiki/SQLiteJDBC

0:27 hiredman: why not use derby or some other java embedded sql?

0:27 dnolen: brehaut: in my case when I was playing around, I actually used the first link and just dropped the .jar in lib.

0:27 technomancy: iiiiiinteresting: http://www.cloudbees.com/foss/

0:27 hiredman: that you can get from maven

0:27 technomancy: sc

0:27 cab

0:27 geez emacs

0:28 brehaut: hiredman: ive never even heard of derby; i'll check it out

0:28 dnolen: ok sure

0:30 mreynolds: brehaut: Also known by it's Brand "JavaDB"

0:34 semperos: if you know how to administer a db already, might as well use smth you know like sqlite

0:35 brehaut: i dislike administering all the databases i know ;)

0:56 semperos: $findfn [1 2 2 3 1 4 5 6 6] [1 2 3 4 5 6]

0:56 sexpbot: [clojure.core/distinct]

1:02 amalloy: &((comp seq sorted-set) [1 2 2 3 1 4 5 6 6])

1:02 sexpbot: ⟹ ([1 2 2 3 1 4 5 6 6])

1:02 amalloy: &((comp seq sorted-set) 1 2 2 3 1 4 5 6 6)

1:02 sexpbot: ⟹ (1 2 3 4 5 6)

2:01 matthias_: hmm, why would lein repl open some random port? it used to always pick the same one

2:07 amalloy: if it did you could only have one lein repl open on your whole system at a time?

2:54 matthias_: oh, i was using lein repl instead of lein swank. don't know why :|

3:41 fortxun: $seen rhickey

3:41 sexpbot: rhickey was last seen quitting 4 days and 12 hours ago.

4:28 Kototama: hello, does anyone now why analemma has been removed from clojars?

6:17 yayitswei: hello, I'm getting "#<CompilerException while parsing a block collection expected <block end>, but found ?" in my REPL

6:17 anyone know what that error means?

6:17 fliebel: yayitswei: That you have a syntax error.

6:19 yayitswei: thanks fliebel. just realized it was a syntax error in a yml file I'm parsing. how could I have debugged that?

6:20 fliebel: yayitswei: By printing the stacktrace and looking for files that belong to your project.

6:20 It'll tell you line numbers.

6:20 yayitswei: ahh thanks. how do i print the stacktrace in the repl?

6:20 fliebel: (.printStackTrace *e)

6:22 devn: ping

6:24 yayitswei: got it. thx

8:35 fortxun: $seen rhickey

8:35 sexpbot: rhickey was last seen quitting 4 days and 17 hours ago.

8:47 clgv: $seen fortxun

8:47 sexpbot: fortxun was last seen talking on #clojure 12 minutes and 19 seconds ago.

8:58 * fortxun wonders where he might be able to get hold of Rich Hickey

8:58 chouser: fortxun: you could try the google group or his email address

8:59 or I suppose knock on his door, if you know where that is.

8:59 solussd: Anybody here made it through the 'conjure' tutorial? I am stuck on 'scaffolding', getting: JdbcSQLException: Wrong user name or password

8:59 fortxun: chouser, what is his email address?

9:01 chouser: fortxun: I would think you could find it on here somewhere: http://groups.google.com/group/clojure-dev

9:09 rak85: hi guys

9:09 i have a list of vectors in the following format -> '([2 4] [4 343] [5 500])

9:10 and I want to compare the second index from each vector and return the maximum

9:10 in this case, i would return 500

9:10 how would you do that?

9:10 i'm using reduce...

9:11 any other approach?

9:11 ejackson: ,(map (comp max second) [[2 4] [4 343] [5 500]])

9:11 clojurebot: (4 343 500)

9:11 rak85: hmmm...

9:11 ejackson: no quite....

9:11 ,(max (map second [[2 4] [4 343] [5 500]]))

9:11 clojurebot: (4 343 500)

9:11 ejackson: lol.... i should do this in my own repl....

9:11 ,(apply max (map second [[2 4] [4 343] [5 500]]))

9:11 clojurebot: 500

9:12 rak85: i forgot to tell you something...

9:12 ejackson: now you sound like my clients

9:12 rak85: i may have nil values in the second index...

9:12 hahaha

9:12 ejackson: throw a map identity in there

9:13 filter identity, rather

9:13 rak85: hmmm..thanks

9:13 ejackson: ,(apply max (filter identity (map second [[2 4] [4 _] [5 500]])))

9:13 clojurebot: java.lang.Exception: Unable to resolve symbol: _ in this context

9:14 ejackson: ,(apply max (filter identity (map second [[2 4] [4 nil] [5 500]])))

9:14 clojurebot: 500

9:14 rak85: ejackson: thanks!

9:14 ejackson: np

9:17 raek: ,(reduce max (for [[x y] [[2 4] [4 343] [5 500]] :when y] y)) ;; Another approach

9:17 clojurebot: 500

9:44 clgv: &(->> [[2 4] [4 343] [5 500]] (map second) (reduce max))

9:44 sexpbot: ⟹ 500

9:51 warpy: can someone point me to clojure 1.2.1 changelog?

9:51 opqdonut_: https://github.com/clojure/clojure/blob/1.2.x/changes.txt

9:52 warpy: thanks opqdonut_

9:52 opqdonut_: np

10:06 __name__: &(->> [[2 4] [4 343] [5 500]] (map second) ma)

10:06 sexpbot: java.lang.Exception: Unable to resolve symbol: ma in this context

10:06 __name__: &(->> [[2 4] [4 343] [5 500]] (map second) max)

10:06 sexpbot: ⟹ (4 343 500)

10:06 __name__: &(->> [[2 4] [4 343] [5 500]] (map second) (apply max))

10:06 sexpbot: ⟹ 500

10:06 __name__: clgv: Is that not nicer?

10:08 clgv: __name__: why should it be? the question is: nicer to which "measure"? ;)

10:08 __name__: clgv: reduce seems a bit redundant because it is more function calls.

10:08 clgv: on a pure text comparison it's just recue exchange with apply ;)

10:09 raek: the vararg version of max is implemented with reduce...

10:09 clgv: __name__: max with more the two arguments is also more than one function call ;)

10:09 * __name__ concedes.

11:59 gfrlog: so I'm using compojure and ring...

11:59 and I'm testing the server by sending it requests manually, since the server is a function...

11:59 but I'm having trouble interacting with it the same way jetty does

12:00 manutter: what kind of trouble?

12:00 gfrlog: specifically wrt form and route params

12:00 KirinDave_: gfrlog: Well yeah, jetty is a ton of environment and side effects underneath your code.

12:00 gfrlog: The way I did it was I put a capture handler that dumped out ALL the data structures for a request to file.

12:00 gfrlog: I'd reconstitute those for my tests

12:01 gfrlog: hmm

12:01 KirinDave_: gfrlog: The only trick there is you need to manually handle the body of the post, which is an input stream.

12:01 gfrlog: what I was doing was just passing in the form-params as a map

12:01 mattmitchell: is the a nice way to create a hash-map from a 2 vectors, where one vector contains the keys and the other the values?

12:02 KirinDave_: mattmitchell: zipmap

12:02 mattmitchell: KirinDave_: excellent thanks!

12:02 KirinDave_: mattmitchell: Is there some sort of challenge or homework or something? You're probably the 5th person to ask that in 24 hours

12:02 gfrlog: KirinDave_: so I was asking because I was hoping there was a not-messy way to figure this out. It sounds like you're saying it's just gonna be messy?

12:02 KirinDave_: gfrlog: It shouldn't take too long.

12:03 mattmitchell: KirinDave_: no :) guess it's just a common problem to solve

12:03 KirinDave_: mattmitchell: Well, zipmap is the answer :)

12:03 gfrlog: KirinDave_: I wouldn't expect so, it just makes me feel gross and sticky :)

12:04 manutter: gfrlog: think of it as building a mock-jetty for testing purposes :)

12:04 KirinDave_: It's weird to me that there is zipmap but no zipwith.

12:04 gfrlog: ,(zipmap (iterate inc 0) (iterate inc 1))

12:04 clojurebot: Execution Timed Out

12:04 gfrlog: manutter: I think I was hoping that the code I was missing was in compojure somewhere rather than in jetty

12:04 KirinDave_: Ahh yes

12:04 gfrlog: or ring

12:04 KirinDave_: gfrlog: The answer is no.

12:04 There is no default request content.

12:05 But you'll see

12:05 Once you have a few for inspection, you'll find modifying them is relatively easy.

12:05 gfrlog: KirinDave_: it's not all the boilerplate that I'm missing, it's the method of assembling the input

12:05 e.g., the form parameters are duplicated in the :form-params key and the :params key

12:05 KirinDave_: "assembling the input"? I don't understand

12:05 gfrlog: where :params also has the route parameters

12:05 KirinDave_: Well that's because you put a handler there I assume.

12:05 gfrlog: and maybe the query parameters as well

12:05 manutter: you mean to turn a map into an encoded string, ya?

12:06 KirinDave_: There is like a unified params handler.

12:06 gfrlog: KirinDave_: yes, the unified one works with browser/jetty

12:06 KirinDave_: If you're using that, params is assembled.

12:06 gfrlog: but when I call the app directly, that doesn't get done

12:06 KirinDave_: I'm of the opinion params is dangerous, but also devilishly convenient. :)

12:06 Indeed.

12:06 Sorry, my greyhound needs walking.

12:06 raek: gfrlog: those are usually parsed from the :url or :body by some ring middleware, but maybe compojure handles that automatically

12:06 gfrlog: you can't destructure as easily with form-params though, because it has string keys

12:06 KirinDave_: He states this by draping his body across my hands.

12:07 manutter: lol

12:07 KirinDave_: And I have to support his head with my wrists. Progressively increasingly difficult to type.

12:07 gfrlog: maybe I will try encoding my form params into the body and see if it gets handled that way

12:07 KirinDave_: okay have fun :)

12:07 thanks for the help both of you. lunch calls.

12:07 KirinDave_: gfrlog: Why not just capture some request structures? Seriously. It takes all of 5 minutes. Use curl to hit a random endpoint with the kind of requests you want.

12:08 Then you've got lightning in the bottle.

12:08 gfrlog: KirinDave_: I may not have explained myself well enough, because I don't think that's really the issue. But I think I understand things better now, so it'll be okay.

12:09 dnolen: raek: I fixed those issues from yesterday (I hope)

12:10 devn: fliebel: im here

12:11 fliebel: sorry, would have gotten back to you yesterday but was too busy flopping around on the ground (seizure)

12:14 Ramblurr: in enlive, what is the proper way to do a conditional transform? e.g., [:selector] (if condition (content "success!") (some_other_transform))

12:19 raek: Ramblurr: the form to the right should be a function that takes a node and returns a node, so you can do it like this (fn [match] (if (pred? match) ((content "success!") match) ((some-other-transform) match)), I believe

12:19 oh, the enlive readme explains it even better: "Transformations (the right-hand parts of rules) are now plain old closures.

12:20 These functions take one arg (the selected node) and return nil, another node

12:20 or a collection of nodes."

12:20 Ramblurr: ah i saw that, it didn't click. so using a closure should work

12:20 raek: so 'content' is a function that returns a transform

12:22 dnolen: ok, nice. then I don't have to move the issue to the correct location... :)

12:23 Ramblurr: raek: you mean 'content' is a function that returns a transform function

12:23 ..right? or a col of nodes?

12:23 gonna try it out..

12:23 raek: yes, a transform function..

12:24 sorry

12:27 Ramblurr: raek: ah ive got it working

12:27 i was trying to pass match to 'content' itself

12:27 cause i thought it was content that returned the col of nodes

12:51 noidi_: Why doesn't the following form work in the ns macro: (:refer-clojure :exclude [*]) ?

12:51 Unable to resolve symbol: * in this context

12:52 excluding + doesn't work either

12:52 but e.g. excluding assoc works fine

12:52 is there something special about the math operators?

12:52 technomancy: noidi_: maybe because + and * are defined using definine?

12:54 doesn't really make sense, but it's the only thing I can think of

12:54 noidi_: ok, thanks

12:56 Raynes: noidi_: He meant definline

12:57 noidi_: they don't seem to work as method names in a protocol either :P

12:58 so there's something special about them

13:03 chouser: (ns foo (:refer-clojure :exclude [*])) works for me

13:04 of course any attempt to use * after that results in Unable to resolve symbol: * in this context

13:04 noidi_: I'm using 1.2.0

13:05 chouser: hm, that was with 1.3-something. I'll try 1.2

13:05 same result on 1.2

13:07 noidi_: oddly enough the error disappears if I remove the (:import) form from the ns call

13:08 so I have a syntax error that gets the macro confused

13:08 *maybe*

13:10 never mind that, the error was really caused by me calling * after excluding it

13:10 :P

13:11 I changed the protocol method's name from * since it didn't seem to work, but forgot to change the users back

13:15 yay, everything works now

13:16 I just had my REPL in a weird state after all the experimentation with the names

13:16 sorry about that :)

13:22 chouser: noidi_: not a problem. glad you figured it out

13:28 lawfulfalafel: okay I am trying to do what it says on this page: http://dev.clojure.org/display/doc/Getting+Started+with+Emacs and I can't get the M-x package-list-packages command to work

13:28 I think the icicles mode is overriding it

13:28 dpritchett: lawfulfalafel, are you sure you have elpa installed?

13:29 lawfulfalafel: elpa?

13:29 clojurebot: elpa is a package manager for Emacs: http://tromey.com/elpa

13:30 gfrlog: any quick/easy way to encode a map as POST params?

13:30 lawfulfalafel: okay I ran that install script

13:31 amalloy: KirinDave_: isn't zipwith just a special case of map? ##(map + (range) (range 1 10))

13:31 sexpbot: ⟹ (1 3 5 7 9 11 13 15 17)

13:31 gfrlog: ,(doc zipwith)

13:31 clojurebot: No entiendo

13:32 amalloy: gfrlog: he means the haskell/scala/whatever zipwith

13:32 gfrlog: dangit I don't know those languages

13:32 is it my map-from-fn idea?

13:32 KirinDave_: amalloy: It's just weird to have zipmap but not zipwith. :)

13:32 lawfulfalafel: dpritchett: thanks

13:32 amalloy: gfrlog: i don't know what idea you're talking about, but no

13:33 manutter: gfrlog: I wonder if clj-http has any form-encoding functions

13:33 (assuming I have the name right)

13:33 dpritchett: np lawfulfalafel

13:33 KirinDave_: amalloy: I'm sure zipmap is just an implementation optimization for a common case.

13:34 amalloy: KirinDave_: i doubt it's an implementation optimization

13:34 manutter: gfrlog: https://github.com/mmcgrana/clj-http

13:34 amalloy: &(into {} (map vector (range) (range 1 10)))

13:34 sexpbot: ⟹ {0 1, 1 2, 2 3, 3 4, 4 5, 5 6, 6 7, 7 8, 8 9}

13:34 gfrlog: KirinDave_: amalloy: it's not

13:34 KirinDave_: Weird.

13:35 gfrlog: the source just uses (loop) and goes one by one

13:35 amalloy: KirinDave_: zipmap is doing a different thing than zipwith would

13:35 KirinDave_: amalloy: Because it's a reduce.

13:35 amalloy: right

13:35 KirinDave_: Still you could do zipmap in terms of zipwith.

13:35 amalloy: obviously. i just did

13:36 KirinDave_: I guess zipmap is just the belle of the zip family. :)

13:36 So in demand, so famous, so glamorous.

13:36 dakrone: ,(apply str (interpose "&" (map (comp (partial apply str) (partial interpose "=")) {"a" "foo" "b" "bar"})))

13:36 clojurebot: "a=foo&b=bar"

13:36 manutter: heh

13:37 I think you also need to map <space> to + and special chars to, what is it %xx; format?

13:37 gfrlog: dakrone: the escaping is the hard part

13:38 dakrone: that's true

13:38 amalloy: dakrone: i like point-free as much as the next guy, but that partial stuff is kinda overdoing it ##(clojure.string/join "&" (map (fn [[k v]] (str k "=" v)) {"a" "foo" "b" "bar"}))

13:38 sexpbot: ⟹ "a=foo&b=bar"

13:39 amalloy: anyway this is a wheel that has been invented a lot of times. that said, i was looking for it the other day and didn't find any convenient clojure wrappers for it

13:39 dakrone: :)

13:39 gfrlog: amalloy: what is point-free?

13:40 amalloy: $google haskell point free

13:40 sexpbot: First out of 93500 results is: Pointfree - HaskellWiki

13:40 http://www.haskell.org/haskellwiki/Pointfree

13:40 KirinDave_: Point free is kinda pointless in lispy languages.

13:40 amalloy: gfrlog: tl;dr: building functions by gluing together functions without mentioning their arguments explicitly

13:41 KirinDave_: i see no evidence of that

13:41 gfrlog: that is a good formalization of a concept that's been floating around my head for a while now

13:41 KirinDave_: amalloy: It's more trouble than its worth, in my opinion. Lisp's rules for application don't facilitate it.

13:41 gfrlog: when I create point-free expressions, it gives me a bigger programming high and makes me not want to be around when a clojure-n00b has to support the code

13:41 so I do it all the time

13:42 KirinDave_: amalloy: And also they tend to be longer in clojure because you gotta use (partial ...) :)

13:42 gfrlog: yeah partial is way too long

13:42 S11001001: gfrlog: well obviously you wouldn't have made any mistakes there, so said n00b knows to look elsewhere for problems

13:42 amalloy: KirinDave_: (defalias $ partial) :P

13:42 gfrlog: S11001001: yes, that is obvious

13:42 KirinDave_: amalloy: Ha.

13:42 amalloy: and then add some greek letters

13:42 KirinDave_: What could go wrong.

13:43 gfrlog: don't tell jquery

13:43 amalloy: KirinDave_: what could go wrong is you could end up with hiredman's code-rewriting macro

13:43 KirinDave_: The upshot of a () wrapped partial call is that the binding order is way clearer

13:43 amalloy: What does that look like?

13:43 amalloy: it looks pretty cool tbh, but not a lot like lisp

13:43 KirinDave_: I thought he super-hated macros.

13:43 amalloy: i can never find the dang thing

13:43 KirinDave_: I mean, it takes a few doubletakes to resolve what x = (f .) . g

13:44 really does.

13:44 amalloy: KirinDave_: it takes me a few double takes to come up with (f .) . g when what it seems like i want is f . g

13:44 hiredman: https://github.com/hiredman/odds-and-ends/blob/master/functional.clj#L126

13:44 amalloy: hooray, thanks hiredman

13:45 KirinDave_: hiredman: Whoah

13:45 hiredman: Ha. At first i was like, "Clj doesn't have flip in the stdlib... ohhhh wait line 55)

13:45 hiredman: uncurry is still completely the opposite of the name

13:46 KirinDave_: :)

13:46 gfrlog: add an ignored argument?

13:51 mattmitchell: i know there is a "some" which will return the non-false return value from the predict. Is there anything that will return the item in the seq when the predicate returns true?

13:52 amalloy: (comp first filter)

13:53 or, write your predicate differently

13:53 mattmitchell: amalloy: aye that's pretty simple. thanks!

13:53 yeah i came up with this: (defn detect [f col] (some #(if (f %1) %1) col))

13:53 mreynolds: I've been tending towards using (partial) instead of constructing functions on-the-fly #(), are there any caveats or idiomatic reasons not to do this?

13:54 mattmitchell: then i can do (detect pred col)

13:57 amalloy: mattmitchell: fwiw, i prefer (defn detect [pred] (fn [x] (when (pred x) x))) (some (detect even?) coll)

13:58 then you're not tied to "some" and can reuse that adjusted predicate anywhere (and believe me, it's useful in a lot of places)

13:59 mreynolds: they're both fine. i like partial. but if you end up with more than a couple partials all in one place it tends to be hard to read, so split it up

13:59 mattmitchell: amalloy: ahh cool

13:59 mreynolds: amalloy: Gotcha, yeah, I've been using that same pattern for readability. Thanks.

14:00 chouser: mreynolds: fwiw, each literal #() in your code at compile time produces a new class, while (partial) does not.

14:01 on the other hand, a calling a fn created with partial may require an extra method call or two at runtime, but then again those are probably inlined away in any loop tight enough to matter.

14:01 mreynolds: chouser: Ahhh, nice to know. Have you heard of people running into problems with too many classes? I guess I could see the JVM choking on having to manage a few hundred thousand

14:02 chouser: I think the biggest real problem with lots of classes is the startup overhead for the JVM to validate all of them

14:03 but again, that's probably something to be improved in a more systemic way, rather than replacing each of your uses of #() with partial. :-P

14:04 mreynolds: hehe, yeah. So far, I haven't seen it as a problem anyway. I'm using Clojure for services and server-side stuff where startup time hasn't been an issue, neither class GC/management.

14:06 amalloy: chouser: surprisingly, i never realized partial doesn't need a new class for each use. it's clear if you think about it, but i never did

14:07 i just saw core$partial$fn__3682 and was like, yep, there goes another anonymous class

14:07 chouser: amalloy: I mention it alot because it surprised me too when I first realized that difference

14:07 alot

14:07 amalloy: haha

14:08 chouser: alots are always surprising me as they lumber on by

14:09 gfrlog: man I'm having this horrible time trying to test my compojure app without making my app code really clunky

14:09 amalloy: $dict alot

14:09 sexpbot: amalloy: noun: common misspelling of a lot.

14:09 amalloy: nice

14:09 gfrlog: $dict cleave

14:09 sexpbot: gfrlog: verb-transitive: To split with or as if with a sharp instrument. See Synonyms at tear1.

14:09 amalloy: i was hoping it was some real thing, when you said they lumber on by

14:10 gfrlog: oh is somebody referencing hyperbole and a half?

14:10 $google hyperbole half alot

14:10 sexpbot: First out of 74500 results is: Hyperbole and a Half: The Alot is Better Than You at Everything

14:10 http://hyperboleandahalf.blogspot.com/2010/04/alot-is-better-than-you-at-everything.html

14:10 mreynolds: I should probably look at the return codes from functions more often to understand the impl better

14:10 manutter: sexpbot scares me on a daily basis.

14:10 semperos: lol

14:11 amalloy: mreynolds: the return codes?

14:12 gfrlog: so compojure passes in four keys -- query-params, form-params, route-params, and params

14:12 the easiest way to do bindings in compojure is straight out of params

14:12 but if I call the app directly in my test, I can't set params up the same way that jetty? does it

14:12 because I don't have the route-params at that point

14:12 only the form params

14:13 binding to the form-params specifically in the app code is tough because it uses strings for keys

14:13 when they are merged into the main params map, they're converted to keywords

14:14 amalloy: oh my god i am in love with that article. thanks, chouser and gfrlog, for bringing it to my attention

14:14 manutter: gfrlog: by "jetty" do you mean the ring module that wraps the calls to the Jetty servlet?

14:14 gfrlog: manutter: I could mean anything

14:14 thus the question mark

14:15 I don't understand at what point the things happen

14:15 but apperently the app I get from compojure that I call from my tests does not include the functionality

14:15 amalloy: gfrlog: isn't it ring.middleware.params/wrap-params that turns the query string into a keyword map?

14:15 gfrlog: amalloy: you're welcome. I'm honored to have contributed

14:15 amalloy: or a string map

14:16 gfrlog: amalloy: maybe? would you expect that to be included in the app then?

14:16 amalloy: you can wrap your handler with that manually when you're testing

14:16 gfrlog: by app, you mean...?

14:16 gfrlog: I mean the function returned from...hmm

14:16 compojure.handler/api

14:17 I think

14:17 is what I'm passing the routes to

14:17 so my app-function I am testing by calling it as such:

14:17 mreynolds: amalloy: Er, sorry, the values as printed by pprint :) AKA function and object ids

14:18 gfrlog: (app {:request-method ..., :uri ..., :body "foo=bar"})

14:18 amalloy: gfrlog: i think so, but you can look at the compojure source and see

14:19 https://github.com/weavejester/compojure/blob/master/src/compojure/handler.clj#L15

14:23 gfrlog: amalloy: my app is seeing the :body attr exactly as I passed it in, and the :form-params attribute an empty map

14:24 amalloy: I guess this is enough to dig into it on my own, thanks

14:24 amalloy: gfrlog: earlier you said you only had the form params, not the route params. which is it you have and which do you wish you had?

14:24 gfrlog: I as the tester only have the form params. so I want to pass them in either as a :body or as :form-params, and I want them to be merged into :params along with the :route-params

14:25 when I try this, my app only sees the :route-params included in the :params map

14:26 (on a side note, the alot article is apparently the top google hit for "alot")

14:27 looking at the wrap-params method in the ring middleware...

14:32 amalloy: gfrlog: try just having your app output the request map it receives as the response map. then you can see exactly what it's getting and try fixing that

14:32 gfrlog: I can see exactly what it's getting

14:32 I am logging the request map

14:33 the naive "fix" would be to just set "params" myself

14:33 but then it would not include the route-params

14:35 maybe I need to set the content type

14:35 and then it will decode the body for me

14:35 * gfrlog putters off to try it

14:38 gfrlog: it will decode it for me if I make it slurpable

14:38 how can I use $findfn to figure out how to make (slurp (f "foo")) return "foo"?

14:38 amalloy: $findarg slurp (% "foo") "foo"

14:38 sexpbot: []

14:38 amalloy: no, i guess not

14:39 still, you probably want ##(slurp (StringReader. "foo"))

14:39 sexpbot: java.lang.IllegalArgumentException: Unable to resolve classname: StringReader

14:39 amalloy: still, you probably want ##(slurp (java.io.StringReader. "foo"))

14:39 sexpbot: ⟹ "foo"

14:39 gfrlog: very good :)

14:39 thx

14:41 amalloy: I think all my problems just went away

14:41 amalloy: you're just not looking closely enough. additional problems abound

14:41 gfrlog: if it's small, does it really exist?

14:42 man that's full of interpretations?

14:42 s/?//

14:48 fliebel: devn: Still around? I was away all day. To bad about the seizure.

15:00 devn: fliebel: im here yes

15:00 fliebel: (sort of) working remotely on some stuff in another terminal

15:02 fliebel: devn: Okay, just that your website seems to be down, and that I am interested in the status of your baker. And while I'm asking questions anyway, could you shed some light on the defn/devn confusion?

15:12 devn: fliebel: ive moved to devn permanently

15:12 fliebel: defn, although i used it before doing clojure, started to look a little fanboyish

15:12 fliebel: and also, my twitter handle was devn, so there is some unity now in my handles

15:13 fliebel: the status of my baker is...slow... im working with luke vanderhart on a templating library that i want to use, so what i have done so far is not very exciting

15:15 fliebel: devn: What kind of templating? PHP style, or something exotic?

15:19 carllerche: What's the backing data structure for clojure's sorted set?

15:20 fliebel: carllerche: Some sort of tree for sure… I think the sorted ones use something binary.

15:22 devn: fliebel: google closure templates

15:22 fliebel: https://github.com/levand/scribe

15:24 S11001001: what should I call this? (fn [x & _] x)

15:24 amalloy: call it (comp first list)

15:25 S11001001: ick

15:25 amalloy: carllerche: red-black tree

15:25 i think

15:25 fliebel: amalloy: The sorted ones?

15:25 amalloy: fliebel: yeah

15:26 or at least, that's what java's is. i suppose there is probably some changes necessary to handle persistence

15:26 fliebel: oh, nice. But I was right about the binary tree:)

15:26 amalloy: fliebel: definitely

15:27 gfrlog: (defn (comp first list) [x & _] x)

15:28 amalloy: yeah, it's still red/black

15:28 S11001001: gfrlog: surely that only works with two-element lists whose firsts are 'setf

15:34 gfrlog: ,(doc setf)

15:34 clojurebot: Cool story bro.

15:43 fliebel: devn: Oh, good luck with that. Not my taste of templating. I am of the opinion that if you want to invent mini languages (for a dynamic repl environment), you might as well write it in the language itself. Therefore I prefer systems like Genshi, Enlive or even whatever became of compojure.html.

15:45 Ah, Hiccup. I know it is terrible in a lot of ways, but I still love it.

15:50 thorwil: what are those terrible ways?

15:51 brehaut: thorwil: it doesnt escape text by default

15:51 fliebel: thorwil: It becomes very unmanageable for larger projects I've been told.

15:52 And while every list can be expressed as an xml structure, not every xml structure can be expressed beautifully as a list.

15:53 thorwil: ah. so far i only stepped of enlive for a small snippet, where i simply used text to create tags

15:54 fliebel: thorwil: enlive != hiccup

15:54 thorwil: fliebel: yes, that one case just made me wonder if i should look into hiccup in addition

15:55 fliebel: thorwil: hiccup is for sure a lot less mind-bending than enlive for small snippets.

15:56 thorwil: my mind will already never be the same again ^^

15:57 though i still havn't found out how to substitute the tags around desired content with enlive

16:07 semperos: thorwil: what do you mean by "around"? code example?

16:09 thorwil: semperos: say i have <span>Previous</span> in my html template, and want to turn that into <a href="/foo">Previous</a> within an enlive html-snippet (depending on some condition)

16:10 semperos: understood

16:15 thorwil: gotta run, good night!

16:18 mattmitchell: someone wanna give me a hand with this? https://gist.github.com/955947

16:19 semperos: if thorwil had waited two more seconds...

16:19 net.cgrand.enlive-html/substitute

16:19 mattmitchell: i'm close to whacking my head and going home if i can't figure this out! :(

16:22 Touqen: I think I'd just convert items into an actual tree datastructure, then figure out what I want to keep, and then re-flatten it

16:22 semperos: mattmitchell: could you explain the relationship between [1 2] and the other collection in your own words?

16:23 I see the result, but not sure I understand the exact relationship

16:23 amalloy: semperos: it's magic, duh

16:23 mattmitchell: semperos: sure. the [1 2] are id values

16:23 duncanm: is there a way to tell lein uberjar to *not* clear out the lib directory?

16:23 mattmitchell: amalloy: and yes it's magic! :)

16:23 duncanm: i have a jar that i want to use, and i really don't want to go about putting it in my maven repo

16:23 semperos: amalloy: more in the line of my stupid questions :)

16:23 amalloy: $google lein disable implicit clean

16:23 sexpbot: First out of 413 results is: how to use a jar not in a repository or project.clj? lein jar ...

16:23 mattmitchell: semperos: in otherwords... the [1 2] match the one of the :id values

16:23 sexpbot: http://groups.google.com/group/leiningen/browse_thread/thread/6cee060588793e97

16:24 semperos: mattmitchell: ok, they correspond to the :id values

16:24 amalloy: srsly mattmitchell you're conflating too many concepts. separate out the "collapse parents and children" step from the "filter out IDs" step, i think

16:24 mattmitchell: semperos: yes exactly

16:24 semperos: duncanm: if you have the source, you can put it in the "checkouts" folder of your project layout, and leiningen will treat that like a jar

16:25 mattmitchell: amalloy: i'm not sure what you mean (sorry)

16:25 duncanm: it's a java project from netbeans, with its own dependencies

16:25 semperos: so it's not that simple

16:25 semperos: it's not up in any repo?

16:25 manutter: mattmitchell: I just tried (into {} (map (juxt :id identity) items)) and got some results that might interest you

16:25 duncanm: sigh

16:25 amalloy: mattmitchell: you want (magic-fn) to not only combine multiple entities into one, but also filter out entities that don't meet some criteria

16:26 semperos: duncanm: sorry if these are repeat questions

16:26 amalloy: if you separate this enormous task into smaller tasks it will be easier to work with

16:26 duncanm: semperos: nah, i have it locally

16:26 mattmitchell: amalloy: i see what you mean, i will try to think of it that way

16:26 manutter: awesome i'll see what that does!

16:26 amalloy: manutter: isn't that clojure.set/index?

16:26 &(doc clojure.set/index)

16:26 sexpbot: ⟹ "([xrel ks]); Returns a map of the distinct values of ks in the xrel mapped to a set of the maps in xrel with the corresponding values of ks."

16:27 amalloy: not that i can ever read the #$% docs for clojure.set

16:27 manutter: amalloy: Is it? I'm such a noob!

16:27 semperos: duncanm: worst case scenario, you can always copy and paste whatever jars you need into your project's lib folder :)

16:27 duncanm: semperos: that's what i'm doing, and if i run uberjar, it first cleans up the lib folder

16:27 semperos: yep

16:27 it sure does

16:27 duncanm: and so it doesn't work ;-(

16:27 i was hoping there's a no cleanup flag

16:28 manutter: duncanm: wonder if you could make a separate lein project consisting only of the dependencies, "lein jar" that, and then use the result in your real project?

16:28 or lein install it

16:28 mattmitchell: amalloy: aye, could you give me an example of what you mean by separating things a bit?

16:28 duncanm: manutter: still have to put it somewhere

16:28 oh, maybe i can just lein install my java jar

16:28 hmm

16:28 sigh

16:29 mattmitchell: amalloy: you mean, for example a fn for only applying the parent code? and then another for attaching the parent items?

16:29 duncanm: i'm actually porting this clojure code from NetBeans/Ant to lein

16:29 maybe i should just go back to ant, sucky as it may be

16:30 raek: duncanm: you can put :disable-deps-clean false in your project.clj

16:30 amalloy: (defn find-parent-of [all-data the-element] (first (filter (comp #{(:parent_id the-element)} :id) all-data)))) or something

16:30 duncanm: raek: oh?

16:30 nice!

16:30 raek: false, or true?

16:31 semperos: doh

16:31 I just found that in the source too :)

16:31 it's actually part of leiningen's project.clj

16:31 checks for it here: https://github.com/technomancy/leiningen/blob/master/src/leiningen/uberjar.clj#L74

16:31 raek: https://github.com/technomancy/leiningen/blob/master/sample.project.clj

16:32 I think this file contains all leiningen core options

16:34 duncanm: doesn't seem to work, that option

16:34 lein deps still clears the directory

16:35 raek: duncanm: which lein version are you using?

16:35 duncanm: Leiningen 1.4.2 on Java 1.6.0_24 Java HotSpot(TM) 64-Bit Server VM

16:35 carllerche: can leiningen compile java classes as well (If I want a very simple java class?)

16:36 oops, i should have RTFM closer :( sorry

16:36 duncanm: raek: i upgraded to 1.5.2

16:36 raek: duncanm: current stable version is 1.5.2. maybe this was added recently

16:37 duncanm: okay

16:37 raek: yeah, upgrading worked

16:37 thanks

16:37 raek: carllerche: yes, if you set :java-source-path "src" in your project.clj, .java files in src/ will be compiled too

16:38 you can trigger the compilation with "lein javac", I think

16:38 carllerche: thanks

16:38 semperos: duncanm: did you set it to true or false?

16:38 raek: (this happens automatically when you do lein jar)

16:38 * fliebel thinks Cake should have a sample project with all the options cake supports.

16:38 duncanm: semperos: true

16:38 semperos: k

16:39 raek: oh, I accidentally inverted that one... sorry! :)

16:41 semperos: no worries, I didn't see that duncanm needed to upgrade his leiningen version

16:41 before I asked that question

16:43 devn: fliebel: link me to genshi?

16:43 fliebel: devn: Not Clojure: http://genshi.edgewall.org/

16:44 devn: Basically, the template language is written with xml attributes.

16:50 duncanm: is there a way to declare required arguments using clojure.contrib.command-line?

16:55 S11001001: duncanm: make the default expr throw?

17:08 devn: fliebel: im sort of inclined to continue with my ridiculous idea i had awhile back

17:08 fliebel: devn: Which one?

17:09 devn: fliebel: the idea of making each template its own ns

17:09 or dynamically name a template based on its namespace or something like that

17:09 i have code...somewhere

17:09 fliebel: devn: This is with the closure thing?

17:09 devn: nah, that's different

17:10 Google Closure templates are a good fit for clojure because they're composable

17:10 or...they will be

17:10 when we're done with them

17:11 fliebel: that sound cool, although I still don't like the mini language these templates invent.

17:11 devn: So what's with the namespaces? You want to (use 'template)?

17:11 devn: fliebel: im trying to remember now! :)

17:12 fliebel: the idea was you write some piece collection of template pieces in different namespaces

17:13 err some collection of template pieces in a namespace

17:13 so doctype, etc. falls under a namespace, and then you would mix in at a lower namespace

17:13 xian: Hi, I installed slime, slime-repl and clojure-mode via ELPA (I am using the Emacs Starter Kit) on Emacs 23.2.1 and installed swank-clojure via leiningen. Slime and swank seem to work generally, but when executing C-c C-c (slime-compile-defun), I get a "no such namespace" error (details: http://pastebin.com/brsZ0pns).

17:14 hugod: xian, compile the file (C-c C-k) at least once to define the namespace

17:15 devn: or C-x C-e at the end of the (ns)| macro

17:15 xian: hugod: Compiling the file works, but unfortunately I get the same error again when calling slime-compile-defun.

17:16 devn: fliebel: really all i want it haml but with the ability to use clojure inside of it

17:16 s/it/is

17:16 sexpbot: <devn> fliebel: really all i want is haml but wish the abilisy to use clojure inside of is

17:16 fliebel: devn: Sounds fun. I need to sleep now though. See you later. You might want to check these: http://thinkslate.com/ http://code.google.com/p/molehil/ https://github.com/nakkaya/static

17:16 hugod: xian, then slime has failed to parse the namespace declaration

17:17 devn: fliebel: why thinkslate? :)

17:17 fliebel: devn: Because that seems to be your website, and it also seems to be down.

17:17 devn: :D

17:17 xian: hugod: I'm probably too much of a clojure noob, but I don't even have an explicit namespace declaration in my source file, just a single defun.

17:17 devn: fliebel: im migrating that domain to google apps

17:18 fliebel: but yes you're quite right

17:18 xian: Oh I mean defn of course, sorry.

17:18 devn: i need to get my damned websites up

17:18 xian: then you should be able to compile that into the user namespace

17:18 fliebel: devn: Me too, that is why I'm doing bakers again :)

17:18 devn: fliebel: :)

17:18 gotta run, talk to you soon fliebel

17:18 fliebel: bye

17:19 hugod: xian, you need a (ns ...) form for C-c C-c to work

17:21 raek: xian: I think C-M-x work even without an ns form. it evaluates the topmost form that contains the point.

17:21 xian: Ah all right. I just added (ns user) and it magically worked. Thank you both very much, hugod and devn, for helping a noob out.

17:21 raek: ...but you should of course look into namespaces sooner or later

17:22 this is a great guide: http://blog.8thlight.com/articles/2010/12/6/clojure-libs-and-namespaces-require-use-import-and-ns

17:22 xian: raek: Yeah, I found out about that too, but I just like to use C-c C-c (it's quite easy to reach).

17:23 I'm going to look into that, thanks.

19:29 miwillhite: I'm brand new to clojure and trying to understand this:

19:29 (java.io.File. logs-path)

19:29 whats with that dot after File

19:30 brehaut: miwillhite: it treats it as a constructor

19:30 otherwise java.io.File is a reference to the class

19:30 miwillhite: so thats like instantiating a new File object?

19:30 brehaut: thats exactly what it is

19:30 miwillhite: and the dot triggers that?

19:30 brehaut: yes

19:30 miwillhite: great, thank you

19:30 is that a clojurism?

19:31 brehaut: yes

19:31 (java.net.URL. "http://example.com")

19:31 ,(java.net.URL. "http://example.com/&quot;)

19:31 clojurebot: #<URL http://example.com/&gt;

19:31 miwillhite: ah wow, cool

19:31 brehaut: theres also an older form you might enocunter in the wild

19:31 ,(new java.net.URL "http://example.com/&quot;)

19:31 clojurebot: #<URL http://example.com/&gt;

19:31 miwillhite: the comma

19:32 ?

19:32 oh the 'new'

19:32 nm

19:32 whats the comma do?

19:32 brehaut: the comma tells clojurebot to eval the sexp

19:32 miwillhite: oh haha

19:33 well thanks a lot

19:33 I've found this room to be very helpful when I have questions

19:33 brehaut: likewise

19:34 pdk: yeah

19:34 we've found you very helpful too like brehaut said :)

19:35 brehaut: haha

20:00 lawfulfalafel: I am trying to test code in the clojure repl and I keep getting classpath errors

20:00 such as:

20:00 java.io.FileNotFoundException: Could not locate clojure/contrib/duck_streams__init.class or clojure/contrib/duck_streams.clj on classpath: (NO_SOURCE_FILE:0)

20:01 I've tried creating a .clojure file that points to /usr/share/java/clojure-contrib.jar

20:01 amalloy: $google getting started with clojure raynes

20:01 sexpbot: First out of 72 results is: An indirect guide to getting started with Clojure » Bathroom ...

20:01 http://blog.raynes.me/%3Fp%3D48

20:01 amalloy: argh. i always forget that url is broken

20:01 http://blog.raynes.me/?p=48

20:02 lawfulfalafel: long story short, use lein or cake. even for teeny tiny one-file "projects", having a build tool makes your life easier

20:03 miwillhite: Another question if you don't mind…can someone explain the [x# ~x] in the snippet below?:

20:03 (defmacro dbg[x] `(let [x# ~x] (println "dbg:" '~x "=" x#) x#))

20:03 I don't understand what the # does

20:03 or the ~

20:04 Somelauw: # makes an anynomous function with implicit parameter %

20:04 miwillhite: I've read that the ~ "unquotes", but I'm not sure I understand that either

20:04 lawfulfalafel: amalloy: really? I have never used one of those before, so it's hard for me to imagine the benefits

20:04 which one would you reccomend?

20:05 Somelauw: But I don't understand how it is used there either.

20:06 miwillhite: Somelauw, I've seen #() as an anon function

20:06 Somelauw: I think it is just a regular variable.

20:06 miwillhite: but never after a variable

20:06 Somelauw: with a symbol in its name

20:06 so x# is the variable name

20:06 miwillhite: ah, I think you are right

20:06 thats weird

20:07 technomancy: ,`x#

20:07 clojurebot: x__1650__auto__

20:07 technomancy: generates a unique symbol to prevent accidental variable capture in a macro

20:10 amalloy: i've used cake for quite a while but i think i have to recommend lein

20:11 miwillhite: user=> `(1 2 (list 3 4))

20:11 (1 2 (clojure.core/list 3 4))

20:11 user=> `(1 2 ~(list 3 4))

20:11 (1 2 (3 4))

20:11 user=> `(1 2 ~@(list 3 4))

20:11 (1 2 3 4)

20:11 that makes sense

20:11 looking at unquote

20:36 lawfulfalafel: sorry, but how does one add the lein self-install bin to bash?

20:37 I am trying to be able to do the "lein new blah" command

20:37 technomancy: lawfulfalafel: just put it anywhere on your $PATH. /usr/local/bin/lein if you like

20:40 lawfulfalafel: technomancy: thank you

20:41 technomancy: np

20:52 joshua__: Ouch. It seems I don't have a summer internship =/ I'm a little surprised I didn't even get a phone interview anywhere.

21:41 amalloy: joshua__: come work on 4clojure! nobody will pay you a cent but you can tell people you worked on 4clojure

23:24 bhenry: is anybody using this? https://github.com/overtone/live-coding-emacs

23:26 there is a rather annoying "feature" that shows lambdas and f(expr) notations. http://i.imgur.com/MvOHU.png

23:26 i'd like to know where in .emacs.d i have to go to turn it off.

23:32 tomoj: grep -r λ .

23:44 bhenry: tomoj thank you. i couldn't figure out how to search the contents of .el files.

23:56 amalloy: find -name '*.el' | xargs grep whatever

23:56 would be a little more fine-grained

Logging service provided by n01se.net