#clojure log - Oct 04 2011

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

1:06 michaelr525: hello

3:01 fliebel: How is IDE support at the moment? I need to wade through some Java code, so I thought I'd check the clojure plugin for whatever IDE I'm going to use.

3:03 khaliG: fliebel, they say Counterclockwise for eclipse is pretty good, i'm just trying to use it at the moment

3:13 pyr: i have a bit of chicken and egg program

3:14 problem, rather

3:14 say you have a protocol defined in a project

3:14 and you want to allow external lib to implement it

3:14 to be able to let users of the software provide an implementation

3:14 (say, for a transport or serializer)

3:15 how do you manage the cross dependency ?

3:17 cark: hum i don't see a problem ... the library user requires the namespace where you defined the protocol, and that's it

3:17 your library only refers to the namespace where the protocol was defined

3:17 there's no cross-dependency

3:17 pyr: hmm let me be more clear

3:18 i have a daemon, not a library that relies on transport

3:18 and i want to be able to switch transports from the configuration

3:18 the daemon defines the transport protocol

3:19 oh, I guess i see a way of having this work

3:19 ok

3:19 cark: ok well : file1 = define your protocol

3:19 file2 : define your demon

3:20 file3 : define your transport

3:20 files 2 and 3 are using file 1

3:20 pyr: with files i'm alright

3:20 it's libraries that get me confused

3:21 but yeah

3:21 cark: that's the same thing =P

3:21 pyr: it works that way

3:24 rimmjob: is there a style guide for clojure?

3:25 ive never really writen lisp that other humans had to read..

3:26 mostly just for my own use

3:27 pepuchoZ: quit

3:28 pyr: rimmjob: sp indent, let emacs or vim show the way

3:30 rimmjob: i mean like, after when to newline after a parens

3:30 pyr: if you look at existing code a bit

3:30 rimmjob: ill just look at

3:30 ok

3:30 pyr: you'll see there's no definite style

3:31 rimmjob: oh

3:31 pyr: not at all like C / Java / Ruby

3:31 because the lack of syntax in clojure makes it almost pointless

3:32 I tend to newline after "block" calls (doseq, do, when, dosync, ...)

3:33 using the (defn foo \n "" \n [args]) syntax forces you to put some text in that docstring

3:34 rimmjob: ok, i guess that makes sense. thanks

3:42 dbushenko: hi

3:42 what's the difference between fn* and fn?

3:42 Blkt: good morning everyone

3:53 raek: dbushenko: fn* is the "real" more primitive special form. I think it's like fn, but doesn't do destructuring or something.

3:53 dbushenko: it's not meant to be used directly

3:55 dbushenko: raek, yep, but I just want to dig in the sources of clojure and don't get what for is fn*

3:56 so, thanks for your explanaition

4:24 pyr: is there a way to pass a class around and let another function instantiate it ?

4:25 i.e: (deftype Foo [x y]) (let [class user.Foo] (instantiate-with class :some :args)))

4:43 michaelr525: pyr: you can use java stuff: (Class/forName "java.lang.String")

4:44 pyr: michaelr525: yep, but then there's no instantiation possible

4:46 (eval `(new ~(symbol class-as-string) arg1 arg2))

4:46 that works

4:46 michaelr525: it feels like cheating ;)

4:47 terom: pyr: classes can be instantiated with reflection, also (but it's certainly more complicated than eval)

4:48 raek: pyr: you can use (import 'clojure.lang.Reflector) (Reflector/invokeConstructor class (object-array parameters))

4:48 the Reflector class makes this much simpler compared to java's reflection api

4:49 eval is uncessary here. it will just generate code that calls the invokeConstructor method in this case.

4:50 oh, and 'class' here is an instance of java.lang.Class (the thing you get from "class literals" in clojure)

4:50 pyr: (Reflector/invokeConstructor (Class/forName "user.Foo") (to-array [:a :b]))

4:50 works

4:51 nice

4:53 raek: i looked for clojure reflect api earlier

4:54 raek: no clear doc

5:03 srdjan: why doesn't the following thing work in clojure 1.3: (-> 4 #(* 10 %)), but (* 10 4) works?

5:04 I get the following error: #<CompilerException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.ISeq, compiling:(NO_SOURCE_PATH:1)>

5:05 and the following thing forks: (#(* 10 %) 4)

5:05 and does clojure support macros inside of macros, or macros in clojure are not composable?

5:06 Blafasel: ,(-> 4 (* 10))

5:06 clojurebot: 40

5:07 Blafasel: In other words: Your #() is unnecessary and potentially (I'm clueless) wrong.

5:07 srdjan: Blafasel: please, can you explain me why it has to be written in that way?

5:07 Blafasel: -> already does the magic for you, inserting the current value into the forms

5:07 ,(4 (println "foo" "bar"))

5:07 clojurebot: #<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>

5:08 Blafasel: ,(-> 4 (println "foo" "bar"))

5:08 clojurebot: 4 foo bar

5:08 Blafasel: ,(->> 4 (println "foo" "bar"))

5:08 clojurebot: foo bar 4

5:08 Blafasel: Spot what happens.

5:09 -> inserts the current value into all forms as first argument. ->> as a last argument.

5:10 raek: srdjan: #(* 10 %) is a shorthand for (fn [%] (* 10 %)) and this translation is done at readtime (before macroexpansion time)

5:10 Chousuke: ,'(-> 4 #(* 10 %)); srdjan, spot the problem

5:10 clojurebot: (-> 4 (fn* [p1__131#] (* 10 p1__131#)))

5:11 Chousuke: you're basically asking for (fn 4 [x] (* 10 x))

5:11 raek: srdjan: (-> 4 #(* 10 %)) ---> (-> 4 (fn [%] (* 10 %))) --> (fn 4 [%] (* 10 %))

5:12 Chousuke: macros inside macros work just fine, too

5:12 raek: srdjan: another approach for this case is (->> 4 (* 10))

5:12 srdjan: thanks for the explanation

5:13 raek: to thread functions of one argument you can use comp. (it takes the function in the reverse order compared to -> though)

5:14 srdjan: raek: how is you exaple different wiht mine? (using ->> instead of using -> )

5:14 Blafasel: See my println examples. The argument order is different.

5:14 srdjan: Blafasel: thanks

5:14 Blafasel: ->> inserts as last element. -> as first argument

5:14 srdjan: i see now

5:14 Blafasel: Doesn't matter of course for *

5:15 raek: ,((comp #(- % 1) #(- 10 %)) 5)

5:15 clojurebot: 4

5:16 raek: same as (- (- 10 5) 1)

5:22 srdjan: I was writing SKI evlauator in clojure, as an excercise. I am alowed to discuss the pieces of the code in the chat? (the pieces of the code are about 5 lines each)

5:23 Am I alowed*

5:26 Fossi: it's better to use a pastebin

5:26 raek: srdjan: it's perhaps simpler paste the complete code at gist.github.com and the refer to the lines

5:31 srdjan: I have my small SKI evaluator on the http://pastebin.com/Pp33AuNh

5:31 I have 3 questions related with my code.

5:32 in line 50. I have function 'ff' that evaluates S, K, and I rules.

5:33 can anybody suggest me how can this code be improved?

5:33 in line 58. I have function 'ap' that tries to apply rule 'ff' recursively.

5:33 is it better to combine functions 'ff' and 'ap' in one function?

5:34 I have noticed that if I have 'recur' in the pattern matching, the compiler complains.

5:35 in the line 66 i have function 'st' that walks the SKI tree and appies the SKI rules to each subtree

5:35 this give in the end the minimal SKI tree

5:35 is function 'st' idiomatic clojure, or I can simplify it?

5:36 raek: ff and ap looks fine to me

5:36 but (reduce conj ...) = (into ...)

5:36 srdjan: function 'f' was my first try to implement the SKI evaluator, is is to verbose comapred to 'ff'

5:37 raek: I see that the '(reduce conj ...)' stinks a little, but I don't know how to improve it.

5:38 raek: I have barely used zippers at all, so I can't give you any feedback on the st function except for that it look small, which is a good thing, I think

5:39 srdjan: also (dorun (for ...)) = (doseq ...)

5:39 srdjan: raek: i have never used zippers in my life, until now, and I don't find the difficult to use (actually, it is the only way that I know to transform the trees in functional language)

5:39 raek: (dorun (for [x tests] (do ...))) = (doseq [x tests] ...)

5:41 you could perhaps make a recusively defined transformation function

5:42 srdjan: raek: you mean to combine 'ff' and 'ap'?

5:43 'st' kind of stinks too. I would say that this look like a common pattern in tree transformation.

5:43 raek: no I was thinking about the zippers

5:44 what does st do?

5:44 srdjan: I mean. The common thing is to apply the rule on the subtrees until we come to the end of the zipper, and then return the zip/root. I would expect that there is some function in clojure.zip that does exaclty this, but I could find it. :(

5:45 raek: 'st' stans for 'ski-transform-tree'

5:45 it walkd the tree in and applies the SKI rules on the subtrees. This gives you the minimal SKI tree.

5:46 Example: (st '[S [I I]]) returns [S I], buy applying recuding [I I] to I

5:48 raek: are you looking for something like (st '[S [I I]]) --> (ap ['S (ap [(ap 'I) (ap 'I)])]) ?

5:48 srdjan: raek: 'st' takes the location in zipper, takes the node, applies the rules, replaces the node on the current location, and goes to the next node

5:49 raek: 'st' works for me, but the question is if other people can understand the code. (I know that I didn't put the commetns, and that the function names are cryptic)

5:49 raek: 'st' goes to S node, applies 'ap'

5:49 goes to [I I] node, applies 'ap'

5:50 and in the end goes to [S I] and applies 'ap' (the I in this expression is actually the recudtion of [I I] from the previous step)

5:51 raek: srdjan: srdjan can you describe how the resulting tree should be constructed for the '[S [I I]] case using symbols, vector literals and calls to ap?

5:51 srdjan: what is the common way in clojure to represent product types like in ocaml?

5:52 raek: srdjan: a map or a vector, depending on whether you want to name the slots or not

5:52 srdjan: the expression '[S [I I]] is a tree

5:53 you can think of '[S [I I]] as a '(S (I I))

5:53 raek: yeah, that is clear

5:54 srdjan: raek: http://people.cs.uchicago.edu/~odonnell/Teacher/Lectures/Formal_Organization_of_Knowledge/Examples/combinator_calculus/

5:54 on this link you can see how the tree is represented

5:54 I just use clojure vectors to represent the trees

5:54 probably I could use clojure list, and do the pattern patchin on them

5:54 the end resut doesn't change

5:55 raek: maybe it's simpler to transform the expression in to full parenthesis form first

5:55 and then apply the rules

5:55 srdjan: raek: please, can you elaborate on that?

5:56 raek: now you have examples like '[S x y z w], which really means '[[[[S x] y] z] w]

5:58 srdjan: raek: yes

5:59 raek: the representation that I use is easier to use in pattern matching

5:59 the end result is the same

6:51 ZabaQ: commas are whitespace!

6:52 can't decide if thats genius or madness.

7:01 thorwil: depends on how you feel about using ~ to unquote, instead of the comma

7:02 can it be that apply doesn't like macros?

7:24 ordnungswidrig: thorwil: you can't apply macros.

7:24 thorwil: ok, wiser about that now after going through http://osdir.com/ml/clojure/2010-01/msg01242.html

7:24 ordnungswidrig: *g*

7:44 pyninja: Has anyone else had problems with clj-http? Any time I try to do a POST request that works perfectly with curl, it never works. (dakrone are you here?)

7:50 napping: I haven't tried it yet, but I was planning to use it soon

7:51 pyninja: ok cool, looks like they fixed whatever was wrong. i updated it to 0.2.1 and it works now!

7:53 kij:

8:33 napping: why is there a not-any? but not an any?

8:34 clgv: napping: english language? there is a 'some though

8:34 cark: ,(some even? [1 2 3])

8:34 clojurebot: true

8:35 clgv: &(some identity [nil 2 3])

8:35 lazybot: ⇒ 2

8:36 cark: ,(some #{1 2 3 4} [1 6])

8:36 clojurebot: 1

8:36 cark: =)

8:39 napping: I see it's the only one of the four which makes sense without a ?, but the name still seems a bit funny

8:57 srdjan: ,(clojure-version)

8:57 clojurebot: "1.3.0-master-SNAPSHOT"

9:23 mattmitchell: I'm using Ring... and I'm curious to know if there is an elegant way to benchmark individual middleware layers?

9:31 napping: to set up a benchmark for them, or to instrument your server?

9:53 mattmitchell: napping: To benchmark all of them

10:31 darq: Hello. What's the best way to combine 2 vectors? Actually I want [elem] + elem + [elem] . Is there a nice way to add them together to a vector?

10:32 clgv: darq: how about ##(apply conj [1 2 3] 4 [5 6 7 8])

10:32 lazybot: ⇒ [1 2 3 4 5 6 7 8]

10:34 darq: Thx clgv :)

10:42 TimMc: clgv: Whoa!

10:42 ,(doc conj)

10:42 clojurebot: "([coll x] [coll x & xs]); conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' may happen at different 'places' depending on the concrete type."

10:43 clgv: ,(doc apply)

10:43 clojurebot: "([f args] [f x args] [f x y args] [f x y z args] [f a b c d ...]); Applies fn f to the argument list formed by prepending intervening arguments to args."

10:43 TimMc: No unary conj. That precludes (apply conj base more) when more might be 0-length.

10:44 ilyak: ,(conj [1 2 3])

10:44 clojurebot: #<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core$conj>

10:45 wink: What's the easiest way to persist some data? jdbc+h2db? or is there anything simpler? Basically just a cache for some maps identified by a primary key

10:46 TimMc: THere are a lot of core functions missing degenerate cases.

10:46 clgv: wink: I used java serialization in some cases

10:46 TimMc: ,(doc pr)

10:46 clojurebot: "([] [x] [x & more]); Prints the object(s) to the output stream that is the current value of *out*. Prints the object(s), separated by spaces if there is more than one. By default, pr and prn print in a way that objects can be read by the reader"

10:46 duck1123: wink: redis is pretty easy

10:46 ilyak: TimMc: Why not (concat base more)?

10:46 I agree with you, tho

10:47 wink: duck1123: I'm not inclined to even try to get redis running on windows, sorry :P

10:47 TimMc: ilyak: concat behaves differently than conj -- it uses cons

10:47 clgv: ilyak: concat does return a lazy seq and no vector

10:47 ilyak: Clojure could have less fns but more orthogonal ones

10:47 TimMc: ,(concat [] '(1 2 3 4 5))

10:47 clojurebot: (1 2 3 4 5)

10:47 TimMc: ,(concat () '(1 2 3 4 5))

10:47 clojurebot: (1 2 3 4 5)

10:48 TimMc: ,(apply conj [] '(1 2 3 4 5))

10:48 clojurebot: [1 2 3 4 5]

10:48 TimMc: ,(apply conj () '(1 2 3 4 5))

10:48 clojurebot: (5 4 3 2 1)

10:48 TimMc: If you know that base is a vector, it's fine.

10:50 ilyak: TimMc: (conj base (apply vector more))

10:50 Oops, no

10:51 I don't really understand the performance profile of those operations, so I can't figure out the best way

10:52 I guess I rarely need vectors

10:53 clgv: ilyak: (conj base (apply vector more)) should have 2*N runtime if more has N elements

10:54 ilyak: btw, there is vec which can be used as (vec more)

10:54 ilyak: clgv: It won't work because conj doesn't expect vector as second param

10:55 clgv: ilyak: hm what do you mean?

10:55 ilyak: I'm yet to find a vector concatenation

10:55 jbwiv: can someone tell me how to change the working directory of the repl from within the repl?

10:55 ilyak: something like haskell's ++

10:55 clgv: conj is (conj vec x & xs)

10:56 raek: ilyak: into

10:56 ,(into [1 2 3] [4 5 6])

10:56 clojurebot: [1 2 3 4 5 ...]

10:56 ilyak: Perhaps

10:56 TimMc:

10:57 raek: but this does not (and can not) use the fact that the second argument is a vector

10:58 it simply treats it as a sequence and constructs a new vector with those elements added

10:58 the new vector will share structure with the first element, but not the second

10:59 if you want something that can share structure with both arguments, you need another data structure (finger trees can do this)

11:00 khaliG: raek, what's the story with finger trees, are they part of core?

11:00 raek: they are in the "new contrib" I think

11:01 ilyak: raek: Neither does (apply conj)

11:01 khaliG: i'm interested in why they /cannot/ share structure with both arguments

11:01 raek: darq: this is how I would do it (into (conj left center) right)

11:03 khaliG: have you read about how persistent vectors organize their data internally?

11:03 khaliG: raek, nope not yet

11:03 TimMc: raek: Why is that better than (conj left center right)?

11:03 raek: (conj left center right) does not do the same thing

11:04 ,(conj [1 2 3] 4 [5 6 7])

11:04 clojurebot: [1 2 3 4 [5 6 7]]

11:04 TimMc: err, throw an apply in there

11:06 jbwiv: is there a clojure debugger with which you can set breakpoints and inspect variable values?

11:06 raek: TimMc: hm, the fact that you cannot call conj with only one argument is not a problem there. I guess they are equivalent then.

11:06 zerokarmaleft: khaliG: http://blog.higher-order.net/2009/02/01/understanding-clojures-persistentvector-implementation/

11:08 TimMc: raek: Fancy. I guess this means that subvec doesn't need the whole tree, just some relevant subtrees. Allows more GC.

11:13 zerokarmaleft: jbwiv: https://github.com/GeorgeJahad/debug-repl

11:14 clgv: zerokarmaleft: that thing is pretty awesome. I use it about 50times a week

11:16 zerokarmaleft: i just discovered it a few days ago...and just read hugod' post about integrating into swank...now i need to look into why i can't examine locals in stack traces

11:16 jbwiv: zerokarmaleft, cool...thanks

11:17 duck1123: I've never managed to get it working very well

11:28 mattmitchell: I'm attempting to use the "time" function in my app. I'm finding it difficult to know which "time" call I'm seeing in stdout. Is there a way to wrap time so that it displays a label along with the time taken?

11:31 TimMc: You could print to *out* or whatever just before time is called.

11:32 Or do somethign tricky so that time prints to a capturing writer.

11:33 Raynes_: &(println "Labeled:" (with-out-str (time (range 3))))

11:33 lazybot: ⇒ Labeled: "Elapsed time: 0.513915 msecs" nil

11:33 Raynes_: Hardly tricky.

11:34 TimMc: Raynes_: It would have to be done to all calls to time.

11:34 Also, any other output would be captured.

11:34 mattmitchell: Raynes_: The only problem with that the code that's being timed doesn't return the value to the caller

11:34 dnolen: given the existence of JSCocoa, programming iOS devices with ClojureScript is trivial.

11:34 mattmitchell: err sorry, in other words.. I need still need the return value

11:34 TimMc: mattmitchell: Use a let.

11:35 Oh, wait... I see.

11:35 Raynes: Yeah, he can't really get the result while wrapping it in with-out-str.

11:36 mattmitchell: exactly

11:36 Raynes: He could rebind *out* to a writer himself though.

11:36 llasram: &(source time)

11:36 TimMc: Right.

11:36 llasram: &(source time)

11:36 lazybot: java.lang.Exception: Unable to resolve symbol: source in this context

11:36 llasram: Haha

11:36 Anyway, it's about 4 lines of code

11:36 Could just re-write it

11:36 TimMc: http://clojuredocs.org/clojure_core/clojure.core/time has source

11:36 duck1123: you could assign it to an atom or some such, but that would affect timings

11:37 TimMc: You also have to account for recursive calls.

11:37 If A calls B and both use time, you only want to capture the time output from each level separately.

11:38 mattmitchell: right

11:38 duck1123: right, this atom would be local to the time2 macro

11:38 TimMc: mattmitchell: (let [ret (time ...)] (println "Foo done.") ret)

11:38 Macroize that.

11:39 duck1123: ,(time (+ 1 1))

11:39 clojurebot: "Elapsed time: 0.086 msecs"

11:39 2

11:40 TimMc: Printing a label to *out* before calling time is trouble, since an inferior call may also print to time.

11:40 Printing afterwards is fine.

11:40 mattmitchell: TimMc: yes that's right. I'll try your let code out.

11:41 TimMc: mattmitchell: Or, as llasram pointed out... just rewrite time. :-)

11:42 duck1123: just not any of the fixed points

11:42 TimMc: fixed points?

11:43 Is this some Haskelly nonsense?

11:43 duck1123: Doctor Who reference

11:43 TimMc: ah

11:44 got it

11:44 llasram: Ha, the phrase "rewrite time" made me think the same sort of thing, but not a Dr. Who fan, so missed the ref

11:44 duck1123: sorry, you're talking about re-writing time, I couldn't resist

11:45 TimMc: mattmitchell: Write with-time, taking a function that accepts the time string and does something with it.

11:45 (with-time ... #(println "Foo: " %))

11:46 or (with-time ... #(str "Foo: " %)) with the expectation that the fn's return is printed.

11:51 duck1123: it would be cool if with-time accepted a callback fn that receives info about the run in a future

11:51 clgv: incanter question: somehow $join with three keys does not work like expected. e.g. [[:a :b :c] [:a :b :c]] - it just ignores :c somehow

11:53 mattmitchell: TimMc: You mean the string would act as a template, and with-time would fill it in with "format" or something?

11:58 TimMc: yeah

11:58 err

11:58 Not really. Depends how you write it.

11:58 You could pass a format string, a prefix, a string-building function, or a function that can even print all by itself

11:59 Write the simplest thing for now (accept a label) and expand it later as needed.

11:59 robermann: just resolved Gus' Quinundrum problem (http://www.4clojure.com/problem/125) after 4 days of tries - now, after seeing amalloy's solution, I consider myself totally dumb! :)

12:00 amcnamara's solution uses a fn*

12:00 what is it?

12:00 TimMc: Compiler primitive. It is what fn uses.

12:00 ,(macroexpand-all `(fn [x y] (+ x y))

12:00 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>

12:01 TimMc: ugh

12:01 &(macroexpand-all `(fn [x y] (+ x y)))

12:01 lazybot: java.lang.Exception: Unable to resolve symbol: macroexpand-all in this context

12:01 TimMc: &(macroexpand-1 `(fn [x y] (+ x y)))

12:01 lazybot: ⇒ (fn* ([clojure.core/x clojure.core/y] (clojure.core/+ clojure.core/x clojure.core/y)))

12:03 robermann: thank you

12:18 duck1123: Here's a version of with-time that I came up with https://github.com/duck1123/ciste/blob/master/src/ciste/debug.clj#L13

12:18 it takes a function to receive the timing data

12:19 mattmitchell: duck1123: awesome, I will need to study that for a bit :)

12:20 TimMc: mattmitchell: most of it is the same as time

12:20 mattmitchell: ok

12:20 TimMc: duck1123: Why a separate thread?

12:21 duck1123: to not interfere with the rest of the flow. I guess that might not be needed

12:21 TimMc: Could be confusing if the timing statements print out of order.

12:22 duck1123: yeah, I think you might be right

12:22 the user can always start a new thread if they want it

12:25 glob157: any good "full" application examples, other than ants.clj out there for learning how to build "real" clojure apps ?

12:26 im still getting lost in a maze of maps with hidden key names etc... i think my code organization is missing something

12:27 mattmitchell: duck1123: This is what I came up with, basically TimMc 's idea of using let https://gist.github.com/1262089

12:28 not real elegant, but working for now. I'll try your implementation out next.

12:29 TimMc: I'm not sure why time uses prn instead of println.

12:30 duck1123: mattmitchell: won't that print twice?

12:30 mattmitchell: duck1123: no, it's only printing once

12:31 duck1123: oh, well yes sorry.

12:32 TimMc: glob157: Here's an application I wrote: https://github.com/timmc/CS4300-HW6 -- can't speak for "good", but it is a decent application

12:33 glob157: Sample output: https://github.com/timmc/CS4300-hw6/blob/master/dev/sierpinski%20trace%20pastels%20ambient.png

12:33 duck1123: this is my largest app. https://github.com/duck1123/jiksnu I have a few other libraries on my page

12:33 dnolen: glob157: also Ring source is pretty clean well organized.

12:34 TimMc: dnolen: It can be hard to understand library sources, because you also have to understand the hypothetical clients that use them.

12:34 duck1123: that (should be) what tests are for

12:34 TimMc: mmm, true

12:34 glob157: the ray trace is great , but a little off topic compared with most apps. im thinking of a typical client side app with some application logic, maybe some MVC, etc...

12:35 dnolen: glob157: you might want to check out clooj, people actually use that, it's a lightweight Clojure IDE

12:36 glob157: oh ok

12:36 TimMc: glob157: Like something with widgets in a UI, or a web app?

12:37 Widgets and state: https://github.com/timmc/CS4300-HW3/blob/master/doc/screencap-main.png -- another project of mine, involves dragging and stuff.

12:37 glob157: not worried about the particulars - but I wanted to see an app that had good separation of concerns.... hopefully one that explained the design philosophy as well. most of the examples I find are project euler.

12:37 TimMc: Ah, like a proper sample app.

12:38 Almost like a tutorial.

12:38 glob157: Yeah, like JPetStore. Anyone interested in collaborating on one ? I have a github project called RudolF that was built to exemplify functional programming for new people like me.

12:39 ive built a lot of example apps using heroku, wrapping molecular vialization tools, etc, but i never really got a good feel for how complex data and state is handled in clj

12:41 TimMc: I think I did a pretty good job in the HW3 project. State is managed in refs, and the user data state is fully undoable/redoable.

12:41 duck1123: https://github.com/search?language=Clojure&q=tutorial

12:43 TimMc: I should actually split out cascade.clj to a separate utility.

12:44 glob157: which is hw3

12:44 TimMc: https://github.com/timmc/CS4300-HW3/tree/master/src/timmcHW3

12:45 core.clj declares some refs at the top (I use *earmuffs* to mark them, even though that is usually used for rebindable vars) and the data structures are defined in state.clj

12:46 cascade.clj is a make-like utility for managing state recomputations

12:46 glob157: oh ok. tim thanks. tim if interested in collab on some open source clojure bioinformatics stuff let me know !

12:46 TimMc: That might be cool.

12:46 Do you have a github project (or similar) for it yet?

12:47 glob157: check out https://github.com/jayunit100/RudolF/bioclojure/

12:47 its all prototype code, but works. we want to bring it into a non prototype stage

12:48 TimMc: bad URL?

12:49 -RudolF

12:51 duck1123: ,(= 1/2 0.5)

12:51 clojurebot: false

12:51 duck1123: that's more unfortunate than the 2 vs 2.0 IMO

12:51 glob157: https://github.com/jayunit100/RudolF/tree/master/bioclojure

12:57 semperos: I need to call a static method on a Java class; I'm given the name of that static method as a string/keyword; what's the best way to dynamically call that method? any Clojure-specific way?

12:57 jkkramer: ,(== 1/2 0.5)

12:57 clojurebot: true

12:59 mattmitchell: What's the preferred json output library for clojure?

12:59 technomancy: ~cheshire

12:59 clojurebot: Huh?

12:59 technomancy: ...

12:59 dakrone: ~json

12:59 clojurebot: http://dakrone.github.com/cheshire/

12:59 joegallo: mattmitchell: https://github.com/dakrone/cheshire

12:59 mattmitchell: cool thanks!

13:00 joegallo: semperos: you'll probably just want to use reflection for that

13:00 technomancy: how do you do redirects/aliases with clojurebot?

13:00 dakrone: clojurebot: cheshire is <reply>https://github.com/dakrone/cheshire

13:00 clojurebot: Ik begrijp

13:00 dakrone: ~cheshire

13:00 clojurebot: https://github.com/dakrone/cheshire

13:00 dakrone: like that?

13:01 not sure what you meant

13:01 joegallo: dakrone: now define ~alias to output the example :)

13:01 technomancy: dakrone: I was thinking so it would refer to the same entry in memory, but I guess that's not as important in clojurebot since terms only show one entry at a time

13:02 dakrone: ahh

13:02 semperos: joegallo: yeah, I just got .invoke working, wasn't sure if there was a preferred/better abstraction at the Clojure level

13:02 TimMc: semperos: Maybe RT could help.

13:03 joegallo: http://clojure.github.com/clojure-contrib/#reflect

13:03 there's that

13:03 zerokarmaleft: dakrone: fyi, the stream encoding example in the readme has args out of order

13:04 semperos: TimMc, joegallo thanks

13:04 joegallo: that looks about like what I'm doing, so good to know I was on the right track

13:04 dakrone: zerokarmaleft: you are right! lemme update that

13:04 semperos: using 1.3, so not going to depend on a 1.2 contrib fn, but good to see the implementation

13:04 dakrone: zerokarmaleft: thanks!

13:11 devth: hi. trying to upgrade to 1.3 but i'm getting "Warning: *classpath* not declared dynamic .." and "ClassNotFoundException clojure.lang.ILookupHost java.net.URLClassLoader" when i try to start my repl. what would be a good way to debug? i tried removing deps in my project.clj but makes no difference.

13:12 technomancy: devth: try lein upgrade

13:13 devth: technomancy: upgrading...

13:15 technomancy: upgraded to 1.6.1 but seeing the same issue. deps: https://gist.github.com/1262209

13:15 technomancy: devth: clojure-json is deprecated. but it's more likely lein-nailgun.

13:18 devth: technomancy: hm, still see it after removing both of those

13:18 technomancy: devth: can't repro here; are you sure you're using 1.6?

13:18 devth: technomancy: i'll reinstall. originally installed with homebrew

13:22 tremolo: in Leiningen, what's the preferred way to set up a dependency to another local lein project? is this possible?

13:22 i couldn't find any documentation on this

13:23 technomancy: tremolo: add it to :dependencies and then set up the checkouts/ directory. look for "checkout dependencies" in "lein help readme"

13:23 tremolo: technomancy: awesome, thank you

13:24 technomancy: no problem

13:26 devth: technomancy: classpath error is gone -- now just seeing "ClassNotFoundException clojure.lang.ILookupHost java.net.URLClassLoader$1.run (URLClassLoader.java:202)"

13:26 technomancy: huh; never seen that before

13:26 devth: hrm. strange. i will keep messing with it. thanks!

13:48 faust451: hi guys

13:48 devn: How does Haskell's iteratee relate to clojure's chunked sequences?

13:48 Is there any relationship there?

13:48 faust451: i try using Lucene with Clojure, but fail. please help me

13:50 joegallo: faust451: that's a pretty open-ended question. maybe a little more detail?

13:50 faust451: this code http://friendpaste.com/56X61Tkfi6u1iwDEOvVD7A fail with java.lang.ClassNotFoundException: RAMDirectory.

13:50 dakrone: faust451: recommend this: https://github.com/weavejester/clucy

13:51 faust451: dakrone: thanks

13:51 joegallo: faust451: are you using leiningen? is lucene on your classpath? it seems like you are missing the jars you need

13:51 faust451: joegallo: yes leiningen

13:52 joegallo: and if you `ls lib`, do you see the lucene jars there?

13:52 because it seems like you might be missing some of them

13:52 TimMc: lein classpath

13:55 faust451: joegallo: ls lib/ lucene-core-3.0.3.jar, lucene-queries-3.0.3.jar

13:56 joegallo: http://friendpaste.com/2pKJXrnwhWmVGcDieu2ogP

13:57 TimMc: faust451: That's all that's in lib? Try running lein deps

13:59 faust451: TimMc: it's for ls -l lib/ | grep lucene

13:59 TimMc: k

13:59 technomancy: faust451: I recommend using clucy

13:59 faust451: TimMc: in project file i require only lucene-core and lucene-queries

14:02 joegallo: def index (RAMDirectory.))

14:03 you are missing parens around the RAMDirectory. constructor call

14:03 faust451: technomancy: but what i am doing wrong?

14:03 joegallo: you are doing your syntax wrong

14:03 your dependencies are fine, but because of the way you have your code typed in, clojure is looking for the non-existent class "RAMDirectory." rather than "RAMDirectory", which you have.

14:05 faust451: joegallo: thanks, let me try to fix

14:33 zodiak: is it jst me that is sitting watching the whole node.js community become rabid dogs and thinking, I don't actually want to convert any of them to clojure :)

14:33 Raynes: It's just you.

14:33 zodiak: awesome :D

14:34 Raynes: ;)

14:34 zodiak: all the peeps at work here are trying to jump onto the node.js bandwagon, I keep trying to push clojure+ring

14:35 I don't know how to 'soft sell' clojure+ring more though.

14:36 there is definitely a visceral reaction when it comes up that clojure is a child (somewhat ;) of lisp

14:38 cemerick: zodiak: just bring up that node.js is a child of javascript; on the merits, that should carry the day.

14:38 amalloy: hahahaha

14:39 cemerick: js is a disowned mutant child of scheme though, right?

14:39 technomancy: I've never understood that argument


14:39 is it just shorthand for "it has closures"?

14:39 cemerick: technomancy: which one?

14:39 technomancy: cemerick: "JS is secretly just scheme with bad syntax"

14:40 feels like a non-sequitur

14:40 amalloy: technomancy: allegedly the guy who wrote js was hired with the promise that he could write "scheme for the browser"

14:40 and then was told "oh btw it has to look like java, marketing guys love that shit"

14:40 cemerick: I think it came from Eich having referred to scheme while working on the implementation.

14:40 zodiak: cemerick, sadly, I think that because it's a "language we know" that node.js is "the way to go" .. which is laughable when I bring up js has prototypal inheritance (which is not good imo) and everyone else goes 'huh' in the room

14:41 TimMc: >_<

14:45 PPPaul: does anyone know a good way to flatten a tree into a 1d vector (preserving the paths) :eg [[root child child][root child child]]

14:46 cemerick: zodiak: doesn't sound like people know the language all that much.

14:47 PPPaul: js is a child of lisp too

14:47 my js looks a lot like my clojure code

14:47 Raynes: Probably more parentheses in the JS code.

14:47 PPPaul: maybe

14:52 ibdknox: ,(flatten [[:hey :how [:are :you]] [:doing :today]])

14:52 clojurebot: (:hey :how :are :you :doing ...)

14:52 ibdknox: PPPaul: ^

14:53 PPPaul: but, no

14:53 amalloy: PPPaul: your question is pretty vague, it seems to me

14:53 PPPaul: [hey how are... [hey how you...

14:53 i want to be able to re make the tree

14:54 TimMc: PPPaul: Provide sample input and output.

14:54 bsod1: is there a function in clojure like (some), but returns value of first true item instead of true or nil?

14:54 PPPaul: [:a [:b :c]] [[:a :b][:a :c]]

14:54 TimMc: bsod1: That's what some does.

14:55 bsod1: TimMc: no, some returns true or nil, I want the value of item instead of true

14:55 ibdknox: ,(some (partial > 3) [1 2 1 1 5 4 3 2])

14:55 clojurebot: true

14:55 TimMc: ,(some identity [nil false 5 'bsod1])

14:55 clojurebot: 5

14:55 ibdknox: it depends on the function TimMc

14:55 bsod1: ,(some #(= % 12) [1 3 12])

14:55 clojurebot: true

14:56 bsod1: oh, wait

14:56 TimMc: Ah, you want to run a predicate too.

14:56 bsod1: TimMc: yes

14:56 symbole: Anybody here at JavaOne?

14:56 bsod1: ,(some #(when (= % 12) %) [1 3 12])

14:56 clojurebot: 12

14:57 bsod1: any better ways to do this?

14:57 jkkramer: ,(some #{12} [1 3 12])

14:57 clojurebot: 12

14:57 TimMc: bsod1: That won't work for a predicate that accepts nil or false.

14:58 bsod1: TimMc: I know, I can't find any better solutions

14:58 jkkramer: great

14:58 thanks

14:59 TimMc: ,(some #{nil} [1 nil 5]) :-P

14:59 clojurebot: nil

14:59 amalloy: bsod1: (comp first filter)

15:00 TimMc: nice

15:01 amalloy: personally i wish that's how some behaved, but it's not a huge deal

15:12 apgwoz: has anyone ever use Gson/fromJson with clojure?

15:14 mister_roboto: Is clojure-clr at clojure 1.2 now? 1.3? Can't seem to find any specifics on the github page

15:14 Bronsa: 1.3

15:14 mister_roboto: Cool thx

15:19 TimMc: Oh hey, is that still in development?

15:33 hugod: I wonder if it makes sense for clojure.match to allow matching on arbitrary function literals [#(some-predicate? %)]

15:36 amalloy: hugod: isn't that the "predicate dispatch" dnolen has been saying he plans to add eventually?

15:37 disclaimer: i know little about either match or predicate-dispatch

15:41 hugod: amalloy: I don't think so - I think that is a dispatch mechanism for multimethods, etc

15:43 hiredman: dakrone: have you ever seen errors about a missing class SyncBasicHttpParams when trying to use clj-http?

15:45 ah, ring and clj-http depend on different versions of httpcomponents

15:47 dnolen_: hugod: it also supports that via guards

15:47 s/also/already

15:47 lazybot: <dnolen_> hugod: it already supports that via guards

15:49 srid: what is the primitive for returning a count of true's in a list of true's and false's?

15:49 or should I just use (count (filter ...?

15:49 amalloy: why would there be a primitive for that?

15:50 srid: just wondering if there was (to score in code golf :P )

15:50 amalloy: *chuckle*

15:50 srid: problem 83?

15:50 srid: nope, 83

15:50 nope, 120

15:52 TimMc: $findfn [true false true true false] 3

15:52 lazybot: []

15:52 TimMc: :-)

15:52 amalloy: TimMc: o/

15:54 srid: is there a function to map f1 f2 .. fn on a coll? got it, (map (comp f1 f2) coll)!

15:56 gtrak: map comp looks to be the same as (map f1 (map f2 coll))

15:56 amalloy: it is the same

15:58 duck1123: isn't it closer to (map #(f1 (f2 %)) coll) ? (same effect though)

15:58 gtrak: but the comp is 1 more character

15:58 yea, that's smaller

15:58 hugod: dnolen_: ah, thanks. should have realised that…

15:59 gtrak: actually, mine is fewer chars :-)

16:03 duck1123: wasn't there a contrib library that aliased comp and partial for point-free nuts?

16:04 amalloy: clojure.contrib.haskell?

16:04 clojurebot: clojure-stub is http://github.com/nakkaya/clojure-stub/tree/master

16:04 amalloy: ~rimshot

16:04 clojurebot: Badum, *ching*

16:04 TimMc: ching, really?

16:04 more of a tsh

16:04 srid: (filter #(true? %) ... <- can I obviate the true? here?

16:05 TimMc: identity, sort of

16:05 srid: right

16:05 TimMc: ,(doc true?)

16:05 amalloy: TimMc: take it up with fsbot; i copied his rimshot to clojurebot

16:05 clojurebot: "([x]); Returns true if x is the value true, false otherwise."

16:05 srid: #(* % %) <- can't this be shortened

16:05 TimMc: srid: identity is going to be sloppier

16:05 srid: ?

16:05 it would only accept boolean, so identity is fine.

16:06 gtrak: ,#t

16:06 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: t>

16:07 kzar: Any ideas how I can re-write this blog-snippet enlive snippet? https://github.com/kzar/daveinadub/blob/master/src/daveinadub/views/blog.clj#L10 It looks awful ATM

16:42 technomancy: if you haven't been using M-x clojure-jack-in on account of how much elisp it spews out upon every connect, there's a new swank-clojure that fixes that: lein plugin install swank-clojure 1.3.3

16:46 hugod: is there a predicate to test if a number is boxed or not?

16:47 amalloy: hugod: i don't think that's possible

16:49 duck1123: isn't that a Heisenberg situation? Always true

16:49 hugod: not even in java?

16:49 brehaut: amalloy: really? surely a protocol would make it fairly trivial?

16:49 amalloy: since functions can only take objects, which are necessarily boxed. in 1.3 you can have a function that takes unboxed primitives, but afaik it can't say "i take a single arg which is either Object or long or double"

16:50 brehaut: no way

16:50 napping: maybe something like *warn-on-reflection* could exist

16:50 brehaut: amalloy: but you can make a protocol know about arrays of bytes

16:50 hiredman: ugh

16:50 brehaut: i guess theres a backing class though isn't there

16:51 hiredman: anyone know if clj-http's :form-params actually work?

16:51 amalloy: hugod: you can't do it in java either, i think, but i'm less certain

16:52 it's a weirder question in java, because java has static type information: "Did I declare this variable as an int or an Integer?" is not a useful question to ask

16:52 dakrone: hiredman: have you tried the latest clj-http version? someone sent a pull recently that was merged

16:52 hugod: amalloy: I thought it might be possible with overloading

16:53 amalloy: hugod: maybe. that's certainly the only approach that might work

16:53 brehaut: hugod: in java i think it would; but only because the type system already knows what that the local vars are primitives already

16:53 amalloy: but i don't know the details of how clojure passes numbers to java methods; it might notice that the thing takes a primitive long and unbox it

16:54 brehaut: hugod: i recall method overload selection being a compile time rather than runtime decision

16:54 hiredman: dakrone: I'm on the latest release

16:55 dakrone: cool, how's it not working for you?

16:55 amalloy: brehaut: correct. but since he's calling it from clojure, he'll be using reflection with runtime data

16:56 brehaut: amalloy: at which point, you are using the reflection data anyway, so why go to java?

16:56 hiredman: dakrone: from what I can tell (running it against ring, ring just printing out request map) it looks like it is ignoring :form-params

16:56 amalloy: good point

16:56 dakrone: hiredman: GET or POST?

16:56 hiredman: client/post

16:57 dakrone: can you send me a snippet?

16:58 terom: ,(.isPrimitive (class 3))

16:58 clojurebot: false

16:58 terom: ,(.isPrimitive (Integer/TYPE))

16:58 clojurebot: true

17:04 kzar: ibdknox: You there?

17:06 ibdknox: kzar: hey

17:07 kzar: ibdknox: Is there a way have multiple routes in a defpage? I wanted /blog to set :page to 0 and /blog/archive/:page to set :page to what's given

17:08 ibdknox: take a look at (render)

17:08 with a named route for blog-page, it would look like this:

17:09 (defpage "/blog" (render blog-page {:page 0}))

17:09 kzar: ibdknox: Ah cool I see, cheers

17:10 ibdknox: Oh wait, how do name blog-page? defpage doesn't take a name

17:11 ibdknox: it does

17:11 as of 1.2

17:11 kzar: aha gotya

17:11 ibdknox: (defpage blog-page "/blog/archive/:page" {:keys [page]} ...)

17:11 or rather

17:11 it can :)

17:14 kzar: you can do the same thing without naming it

17:14 (render "/blog/archive/:page" {:page 0})

17:17 kzar: ibdknox: cool OK, yea I got both ways working fine :) cheers

17:19 carllerche: I have a leiningen project that has a ragel -> java step, what would be the easiest way to have leiningen run a couple of ragel commands before javac?

17:34 semperos: I'm not strong on my Java jarring skills, getting following error while trying to uberjar

17:34 java.lang.SecurityException: no manifiest section for signature file entry org/bouncycastle/asn1/ocsp/ResponderID.class

17:34 I see that I can add a :uberjar-exclusions ["signature file here"] in my project.clj as one possible solution

17:35 but I don't entirely understand

17:38 nm, just needed to learn more about jar structure...

17:44 mwillhite: hey all - I'm confused. working with the jets3t lib and I can get a list of all the objects in my bucket, however when I try to apply a prefix (filter) I get an IllegalArgumentException

17:44 it may be a clojure syntax issue, just not sure

17:44 https://gist.github.com/1262913

17:44 any help will be greatly appreciated!

17:46 hiredman: mwillhite: check the javadocs, the method you are trying to call doesn't exist

17:47 mwillhite: I'm looking at the method in the docs…

17:47 and why would it work without the prefix arg?

17:47 wink: listObjects only takes one argument

17:47 what is stammer? your bucket?

17:47 mwillhite: check the next method definition

17:47 yeah its the bucket

17:47 amalloy: mwillhite: listObjects doesn't seem to have a two-arg version

17:47 one, or three

17:47 mwillhite: oh (I know nothing about java)

17:48 so I need to fill in the other arguments?

17:48 semperos: yep

17:48 mwillhite: thanks :)

17:48 semperos: that API offers several different method signatures

17:48 you have to support at least one, giving all arg's for that one

17:48 mwillhite: okay cool

17:48 good to know

17:49 wink: so (.listObjects s3-foo bucket prefix delimiter) basiclaly

17:49 mwillhite: what is that last thing "long maxListingLength"

17:49 what does that mean? its not an arg?

17:49 wink: that's the 4 arg version

17:49 mwillhite: okay

17:50 wink: oh how I love people who use @deprecated without stating what is the best way now

17:50 mwillhite: hehe thanks all, its working now!!

17:53 wink: hm, when "lein deps" fails to find a dependency and tells me to mvn install:install-file - what do I do if I seem to have no maven because I'm on windows and lein magically works anyway?

17:54 hiredman: wink: install maven

17:57 duck1123: or download the project in question and build it, but install maven anyway

17:58 technomancy: could be your :dependencies has a typo or something

17:58 wink: it worked when just copying the jar inside lib/ - but another lein deps kills it

17:58 it's h2 - not in any repo I've seen

17:59 technomancy: probably need to file a bug with h2 then

18:00 in the mean time that's something you still do need maven for

18:00 wink: oh? it sounded like total intended behavior, so I wasn't really bothered

18:00 yeah, on it

18:00 hiredman: h2? the embedded sql? it is in repos

18:00 joegallo: http://mirrors.ibiblio.org/pub/mirrors/maven2/com/h2database/h2/

18:00 technomancy: well if their intention is to not publish an artifact then their intention is wrong

18:01 joegallo: for future reference:

18:01 http://mvnrepository.com/search.html?query=h2

18:01 hiredman: ~google maven h2

18:01 clojurebot: First, out of 22400 results is:

18:01 Maven Repository: com.h2database » h2

18:01 http://mvnrepository.com/artifact/com.h2database/h2

18:01 technomancy: joegallo: nah: http://search.maven.org/#search%7Cga%7C1%7Ch2

18:01 crappier URL, but nicer otherwise

18:02 wink: oh well, if they suggest org.h2 instead of com.h2database - that could be it

18:03 again, you're all really helpful and I'm the idiot. thanks a lot

18:03 joegallo: technomancy: nice, and thanks! (keyword added for search!)

18:04 wink: works :)

18:11 TimMc: OK, I just got a new laptop, and I am picking a hostname. I'm thinking about "thunk". My question: If I go to the Conj, is everyone else going to have the same damn hostname?

18:12 sjl: Anyone know if there's a reason I shouldn't be able to start the Noir server from inside of swank?

18:12 technomancy: TimMc: there's a who occasionally visits this channel who goes by thunk

18:13 wink: TimMc: Did you really thunk hard about that hostname? Was it even a ThunkPadded?

18:13 TimMc: wink: It's a ThinkPad, yes.

18:13 Which is also built pretty sturdily, so it was a shoo-in name.

18:13 wink: a colleague of mine named it lolnovo

18:13 TimMc: haha

18:14 technomancy: niiiice

18:21 cemerick: looking forward to trying out pomegranate

18:21 I've had the idea for something like that for a while

18:21 cemerick: technomancy: I demo'd it live at J1 about an hour ago, so it *seems* to work :-)

18:22 technomancy: gutsy for a brand-new project =)

18:22 cemerick: I'm trying to go big these days.

18:22 or, bigger :-P

18:22 technomancy: my plan was to have the users edit project.clj and have the running instance recalculate it, but of course that only works for additive deltas.

18:23 cemerick: well, pomegranate isn't any smarter

18:23 It's a very long length of rope

18:23 technomancy: yeah, it's just more specific

18:23 but then the responsibility lies with the user to keep the instance in sync with the deps declaration

18:24 cemerick: sure

18:25 I think we're talking about the same thing in any case; the 'recalculate' part is in aether, insofar as existing dependencies are in .m2/repo

18:26 i.e. I don't think it matters if the same jar URL is registered with a classloader twice

18:26 technomancy: right

18:27 cemerick: As I was writing it, I was thinking "jeez, leiningen already has some of these utilities" :-P

18:27 technomancy: I meant "recalculate from project.clj" rather than taking the additional deps as function args"

18:28 cemerick: Have you started with aether in lein yet, or is that still just dangling over your head?

18:28 technomancy: I have a stash for it, but it's mostly cribbed from a gist I got from hugod

18:28 ibdknox: cemerick: technomancy: it'd be nice to have a lib that just generally lets you interact with the classpath

18:28 for example, there are somethings in tools.namespace that I really wished worked in more contexts

18:29 some things*

18:29 cemerick: ibdknox: It's tricky. Once you're talking about the classpath as a mutable thing, you have to ask, "which classpath?"

18:30 hiredman: yeah, there is no classpath

18:30 there are classloaders

18:31 ibdknox: sure, is there no way for us to create an abstraction that would make that an implementation detail?

18:31 cemerick: either no classpath, or 1 + N classpaths, yes.

18:31 ibdknox: these are the things that are currently available to us

18:31 cemerick: ibdknox: pomegranate is 99% of the way there, as long as you only care about clojure

18:32 module systems and app servers suck for these sorts of things

18:33 ibdknox: cemerick: in theory does pomegranate work in a war?

18:33 cemerick: sure

18:33 actually, it will currently attempt to find the "eldest" classloader, which may be above the war's classloader

18:34 That may be a problem. :-P

18:34 ibdknox: haha :)

18:34 cemerick: Maybe I'll look at that in week 2.

18:34 ibdknox: why the caveat "only about Clojure", are things significantly different for loading random java stuff? (I know very little about classloaders and such)

18:36 cemerick: Random Java stuff has static names in it. You need something like JRebel for that.

18:36 or osgi :-P

18:36 ibdknox: ah

18:37 cemerick: vars are the real hero of clojure's dynamicism.

19:15 sjl: ibdknox: Hey, you're the author of Noir, right?

19:15 ibdknox: sjl: yep

19:16 sjl: ibdknox: any idea why I'd be getting this when trying to use 'lein run' in a noir project? http://dpaste.com/627489/

19:16 ibdknox: those are netty errors

19:16 are you using aleph?

19:18 sjl: that's from something external to noir. It doesn't use contrib or netty :)

19:19 sjl: is your project on github? I can take a quick look to see if I can spot anything

19:19 shep-home: So, one of my functions goes off into an infinite loop when I test it. How do I jump in to that running thread with a debugger?

19:19 sjl: ibdknox: nevermind, I think I figured it out... for some reason Puppet doesn't want to install and start Redis until I provision it a second time

19:19 shep-home: I'm running it inside of emacs with clojure-test-mode

19:20 technomancy: shep-home: M-x slime-list-threads maybe

19:25 shep-home: technomancy: that seems to go off into it's own little hole

19:27 M-x slime-interrupt doesn't

19:28 (work that is)

19:30 technomancy: sorry don't know

19:31 shep-home: ANy idea how to get the JVM running so that I can attach with a java debugger?

19:32 I'm currently using clojure-jack-in

19:33 technomancy: maybe the cdt documentation would say

19:35 shep-home: I'll dig into that, thnks

19:38 Is there a way I can change what `lein jack-in` does?

19:39 TheBusby: only if you purchase a lein gold account

19:39 ibdknox: lol

19:42 technomancy: shep-home: you can add additional elisp files to be piggy-packed, though it's not well-documented

19:42 is that what you mean?

19:51 shep-home: technomancy: move like trying to figure if I can add -X... options when it starts Java

19:51 technomancy: sure; that's orthogonal to jack-in

19:51 :jvm-opts in project.clj

19:52 shep-home: thx

19:54 whidden: Hello all, is the function 'some efficient?

19:56 arohner: whidden: it's O(n)

19:59 whidden: arohner: hmm that's what I thought but when i profile my use of some it doesn't look like O(n), more like O(e^n)

20:00 arohner: whidden: what's in your predicate? I'm confident some by itself is O(n)

20:01 whidden: arohner: yeah all things point to my predicate, which is a partial that at its core does a range check.

20:01 amalloy: arohner: prime? :)

20:02 arohner: amalloy: factor-rsa :-)

20:02 whidden: Are there issues with using the clojure.contrib.profile collection of tools?

20:53 paul_: anyone here use clutch?

20:54 brehaut: paul_: just go ahead and ask your question; if someone can help they will answer

20:55 paul_: ok

20:55 i want to change the port for clutch

20:55 i think i need to use "with-bindings"

20:55 i don't know how, though

20:57 brehaut: paul_: its the slightly more awkward version of binding; (with-bindings {#'*foo* :bar} …) rather than (binding [*foo* :bar] …)

20:57 ibdknox: woah what is that nonsense?

20:58 brehaut: ibdknox: i didn't think i was that far off track

20:58 ibdknox: no no

20:58 why doesn't that use a vector?

21:00 brehaut: ibdknox: so that you can build up a map of bindings programattically

21:00 ibdknox: hm

21:00 * TimMc dubiouses

21:02 ibdknox: brehaut: is this the clutch we're talking about? https://github.com/ashafa/clutch

21:03 brehaut: i think so

21:03 ibdknox: I looked through the source

21:03 with-bindings isn't there?

21:03 lol

21:03 brehaut: i think with-db probably uses bindings rather than with-bindings?

21:04 would you look at that it does

21:04 https://github.com/ashafa/clutch/blob/master/src/com/ashafa/clutch.clj#L129-135

21:04 ibdknox: hah

21:05 I thought with-bindings was something specific to clutch. I didn't realize it was a core thing

21:05 brehaut: oh right haha

21:05 ibdknox: I don't think he needs with-bindings.

21:06 brehaut: i dont either

21:06 i think with-db will do it

21:06 ibdknox: paul_: ^

21:06 brehaut: paul_: the db map is i think {:host "hostname" :port int? :name "dbname"}

21:07 paul_: see also set-clutch-defaults! https://github.com/ashafa/clutch/blob/master/src/com/ashafa/clutch.clj#L54-62

21:08 paul_: way back when i last used clutch i found the source to be pretty readable in general. theres very little complicated stuff

21:12 cgray: is there a more idiomatic way of doing (comp not =) ?

21:12 brehaut: (complement =)

21:12 cgray: and is comp idiomatic in general?

21:13 ibdknox: ,(doc not=)

21:13 clojurebot: "([x] [x y] [x y & more]); Same as (not (= obj1 obj2))"

21:13 ibdknox: cgray: yeah, comp is idiomatic

21:13 cgray: ibdknox: thanks

21:14 khaliG: wonder why they didn't just go with the java !=

21:15 ibdknox: ! means side-effects in clojure

21:15 as a matter of convention

21:15 khaliG: as a prefix though?

21:15 brehaut: and not= is the lisp convention isn't it?

21:16 zippy314: Hi, what's the correct way to use regular expressions in clojurescript. i.e. what's the equivalent of (re-find #"^a" some-str)?

21:16 ibdknox: (/=) is lisp I think

21:16 err CL that is

21:16 khaliG: ibdknox, yeah /= in CL

21:17 TimMc: ,(doc re-find)

21:17 clojurebot: "([m] [re s]); Returns the next regex match, if any, of string to pattern, using java.util.regex.Matcher.find(). Uses re-groups to return the groups."

21:17 TimMc: zippy314: I'm not a cljs user -- does it have regex literals yet?

21:17 ibdknox: zippy314: it's the same?

21:17 zippy314: https://github.com/clojure/clojurescript/blob/master/src/cljs/cljs/core.cljs#L2576

21:18 zippy314: no, it's not

21:18 ibdknox: ah

21:18 TimMc: zippy314: So what happens if you do ##(re-find #"^a" "abc") in cljs?

21:18 lazybot: ⇒ "a"

21:18 ibdknox: (re-pattern)

21:20 zippy314: It's weird: https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure says you have to use Javascript regexs (see Other Functions)

21:20 ibdknox: zippy314: I just did it in the repljs

21:21 zippy314: ibdknox: what exactly?

21:21 ibdknox: (re-find #"a" "hhha")

21:21 zippy314: hmmm..

21:22 ibdknox: also fine: (let [x "some string"] (re-find #"a" x))

21:22 zippy314: Is there version thing going on here?

21:23 In my code that totally fails.

21:23 ibdknox: I have the latest

21:23 zippy314: I have (if (re-find #"/^multipart/" "multipart") (js/alert "test")) and I don't get the alert...

21:24 ibdknox: get rid of the /

21:24 zippy314: duh!

21:24 It worked. Thanks!

21:34 paul_: for clutch i tried (db/set-clutch-port! "5985" (db/all-databases)) but it doesn't work

21:34 going to look at the src

21:36 devth: am i correct to assume it's not possible to (:require [com.foo.bar.*]) to require all namespaces starting with `com.foo.bar`?

21:37 paul_: seems to work with set-clutch-defaults!

21:39 ok, got it working... i'm now trying to query a view, but i'm having trouble doing so too... going to look at the source :D

21:46 gfredericks: devth: darn tootin you're correct!

21:50 amalloy: ask lazybot, he knows everything. lazybot, is it possible to (:require [com.foo.bar.*])??

21:50 lazybot: amalloy: Uh, no. Why would you even ask?

21:51 gfredericks: lazybot, is it possible to (:require [clojure.set])??

21:51 lazybot: gfredericks: What are you, crazy? Of course not!

21:51 amalloy: gfredericks: you just have to not ask him any dumb questions. it's all your fault for phrasing it wrong

21:52 gfredericks: lazybot: is it possible for me to ask you a dumb question??

21:52 lazybot: gfredericks: Uh, no. Why would you even ask?

21:54 gfredericks: amalloy: given that he just contradicted you, I have to conclude that you're right.

21:59 ibdknox: lazybot: is gfredericks trying to game the system???

21:59 lazybot: ibdknox: Oh, absolutely.

22:00 ibdknox: lazybot: is that acceptable??

22:00 lazybot: ibdknox: Definitely not.

22:00 brehaut: lazybot: is this a question?????

22:00 ibdknox: lol

22:00 amalloy: brehaut: he probably knows better than to respond to people with five question marks. answering such people only leads to sadness

22:00 ibdknox: > 4 ?'s and he should tell you to go to hell ;)

22:00 hsbot: <hint>:1:6: lexical error in string/character literal at character ' '

22:00 ibdknox: oh no's

22:00 lol

22:00 brehaut: we have a haskell bot?!

22:01 amalloy: brehaut: we have two

22:01 brehaut: fantastic :)

22:01 amalloy: i'm not sure who owns hsbot, but lazybot does haskell too

22:01 brehaut: > print "hello, world!"

22:01 hsbot: No instance for (GHC.Show.Show (GHC.Types.IO ())) arising from a use of `M5580730128600360166.show_M5580730128600360166' Possible fix: add an instance declaration for (GHC.Show.Show (GHC.Types.IO ()))

22:01 amalloy: $heval [1,3...15]

22:01 brehaut: baha fail

22:01 lazybot: ⟹ Not in scope: `...'

22:01 amalloy: $heval [1,3..15]

22:01 lazybot: ⟹ [1,3,5,7,9,11,13,15]

22:02 ibdknox: $heval print "hey"

22:02 lazybot: ⟹ No instance for (GHC.Show.Show (GHC.Types.IO ())) arising from a use of `M1183673886.show_M1183673886' at <interactive>:(2,0)-(4,30)Possible fix: add an instance declaration for (GHC.Show.Show (GHC.Types.IO ()))

22:02 brehaut: clearly they are sanely not operating in the IO monad

22:02 its a pretty good sandbox

22:02 amalloy: hah

22:02 brehaut: > show 1

22:02 hsbot: "1"

22:02 amalloy: > [1, 2..]

22:02 hsbot: [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,...

22:03 brehaut: > 1 + read "1"

22:03 hsbot: 2

22:04 brehaut: > fib where fib = 1:1: zipWith (+) fib $ tail fib

22:04 hsbot: <hint>:1:5: parse error on input `where'

22:04 brehaut: > let fib = 1 : 1 : zipWith (+) fib $ tail fib in fib

22:04 hsbot: Couldn't match expected type `[a0]' with actual type `[b0] -> [c0]'

22:04 brehaut: and this is why i use clojure, not haskell, for my day to day programming

22:04 ibdknox: what I'm learning here is that haskell sucks

22:05 brehaut: ibdknox: i think if i threw some braces at the first one it would be ok

22:05 ibdknox: haha I was just trying to see who would yell at me ;)

22:05 brehaut: or at least present the same type con flit as the second

22:05 ibdknox: I know basically nothing about haskell

22:06 gfredericks: I look away for two seconds and suddenly everybody knows haskell.

22:06 ibdknox: gfredericks: welcome to #haskell, hope you brought your helmet.

22:06 amalloy: i love that it thinks :1:5: parse error on input `where' is a good hint

22:07 ibdknox: lol

22:09 brehaut: ibdknox: i only know enough haskell to get the really cryptic compiler warnings

22:09 mjonsson: > let fib = 1:1:zipWith (+) fib (tail fib) in fib

22:09 hsbot: [1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368,75025,121393,196418,317811,514229,832040,1346269,2178309,3524578,5702887,9227465,14930352,24157817,39088169,63245986,102334155,1...

22:09 ibdknox: brehaut: about enough I'd say

22:10 brehaut: mjonsson: was it the $ that tripped it up?

22:10 mjonsson: brehaut: yep

22:17 gfredericks: it's so weird to look at recursive code and not worry about what the poor jvm is going to think

22:18 > let fib = 1:4:zipWith (+) fib (tail fib) in fib

22:18 hsbot: [1,4,5,9,14,23,37,60,97,157,254,411,665,1076,1741,2817,4558,7375,11933,19308,31241,50549,81790,132339,214129,346468,560597,907065,1467662,2374727,3842389,6217116,10059505,16276621,26336126,42612747,68948873,111561620,180...

22:20 sleepynate: lambdabot in #clojure, this just seems so backward

22:22 brehaut: sleepynate: i think you're thinking of algolbot

22:24 sleepynate: har har

22:51 srid: &(or (and (zero? 1) 'zero) 'nonzero)

22:51 lazybot: ⇒ nonzero

22:51 srid: &(or (and (zero? 0) 'zero) 'nonzero)

22:51 lazybot: ⇒ zero

22:53 brehaut: srid: that looks like a complicated way to write if :P

22:54 amalloy: brehaut: i've written if that way before, in a language that had and/or expressions, and if statements

22:54 brehaut: amalloy: likewise; python frinstance

22:54 srid: its the habbit of doing "expr and 'foo' or 'bar'" in languages like python

22:55 in lisp, an `if` is nothing special.

22:55 * srid needs to unlearn more

22:56 brehaut: srid: I'm also curious why you used quoted symbols rather than keywords (not that its really important here)

22:57 srid: oh right. forgot keywords. scheme-habit

22:57 though i use them pretty often in my html code using hiccup

23:19 miwillhite: good eve; I know they are the same thing but which is more standard? (:name bucket) or (bucket :name)

23:19 assuming bucket is a map of course…

23:20 dnolen: miwillhite: (:foo x) preferred.

23:20 ,(nil :foo)

23:20 clojurebot: #<CompilerException java.lang.IllegalArgumentException: Can't call nil, compiling:(NO_SOURCE_PATH:0)>

23:20 dnolen: ,(:foo nil)

23:20 clojurebot: nil

23:21 miwillhite: cool thanks

23:27 amalloy: miwillhite: http://stackoverflow.com/questions/7034803/idiomatic-clojure-map-lookup-by-keyword/7035984#7035984 gives a little detail on why that is, if you're interested

23:37 khaliG: so i've got a bunch of data files in the form of clojure readable sexps - and i'd like to batch modify the lot. is there an existing tool suitable for this purpose or shall i go ahead and roll my own?

Logging service provided by n01se.net