#clojure log - Jun 23 2011

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

0:37 rhdoenges: I am proficient with vim and learning clojure. Is vimclojure/slimv effective or should I just learn emacs?

0:38 Scriptor: rhdoenges: I've heard some complaints about it, and learning the basics of emacs isn't too hard

0:40 rhdoenges: Scriptor: I guess I'll go watch the PeepCode screencast about emacs.

0:42 I might as well learn emacs if I'm going to be learning clojure; I can kill two birds with one stone

0:55 scgilardi: inc

0:55 amac: dec

0:55 amalloy: (juxt inc dec)

0:58 amac: that is very zen.

1:01 rhdoenges: #(dec (inc %))

1:02 amalloy: amac: juxt is always the right answer

1:06 rhdoenges: but what is the question

1:09 amac: juxt is also the question

1:13 rhdoenges: ,(map #(% 1) ((juxt juxt juxt) inc dec))

1:13 clojurebot: ([2 0] [2 0])

1:13 rhdoenges: (juxt juxt juxt)

1:16 Scriptor: ,(doc juxt)

1:16 clojurebot: "([f] [f g] [f g h] [f g h & fs]); Alpha - name subject to change. Takes a set of functions and returns a fn that is the juxtaposition of those fns. The returned fn takes a variable number of args, and returns a vector containing the result of applying each fn to the args (left-to-right). ((juxt a b c) x) => [(a x) (b x) (c x)]"

1:18 rhdoenges: ,(map #(flatten (% 1)) ((juxt juxt juxt) inc dec))

1:18 clojurebot: ((2 0) (2 0))

1:18 rhdoenges: ,(flatten (map #(% 1) ((juxt juxt juxt) inc dec)))

1:18 clojurebot: (2 0 2 0)

1:19 rhdoenges: [I like juxt. I dislike juxt.]

1:34 halfprogrammer: [I Ꞁıʞǝ ɾnxʇ˙ I pıslıʞǝ ɾnxʇ˙]

1:36 rhdoenges: halfprogrammer: shit is deep, man.

1:36 halfprogrammer: rhdoenges: ɥǝ ɥǝ ɥǝ

1:37 rhdoenges: halfprogammer: what are you using to generate that text?

1:37 Scriptor: rhdoenges: it's somewhere online, just google for 'upside down text'

1:37 halfprogrammer: rhdoenges: I am using weechat for irc. There is a 'flip' plugin available for that

1:38 rhdoenges: I shall try to write it in clojure now.

1:59 amalloy: rhdoenges: write it in clojure? isn't it basically: (1) look up unicode for upside-down letters, (2) type in a hashmap literal?

2:14 zakwilson: Your new password is clojureql.core.RTable@bb998e4d <-- I don't think that's quite right.

2:19 hiredman: I bet those password strength widgets would give it a pass

2:34 amalloy: hiredman: two pairs in a row of repeated characters? laughably weak

2:43 rhdoenges: amalloy: I'm learning clojure. it will be good for me

2:44 amalloy: also I'm curious about stdout/stdin

2:44 amalloy: rhdoenges: cool beans. every problem is a good candidate for a learning project

2:46 i love clojure (functional programming in general, i guess?). if my code compiles, nine times out of ten it yields the right answer

3:00 sunnibo: I'm making a twitter client with clojure-twitter. (twitter/favorites) works well, but (twitter/destroy-favorite) does'nt work. it generates a 400 error and tells me that I have to use GET method. it's weird.

3:01 http://dev.twitter.com/doc/post/favorites/destroy/:id says the supported request method is POST and DELETE

7:42 void_: how do I turn {:a 1 :b 2} into (list :a 1 :b 2) ?

7:42 opqdonut: ,(apply concat (seq {:a 1 :b 2}))

7:42 clojurebot: (:a 1 :b 2)

7:43 opqdonut: (the order of the key-value pairs will be undeterministic)

7:43 (unless you use sorted-map)

7:46 void_: doesn't matter, thanks!

8:00 jaju: ,(+ 1 2)

8:00 clojurebot: 3

8:00 jaju: (+ 1 2)

8:00 clojurebot: 3

8:03 solussd: clojure is deterministic!

8:04 (* 1 2)

8:04 clojurebot: 2

8:04 solussd: hm

8:05 jaju: (println "hello")

8:05 opqdonut: ,(println "hello")

8:05 clojurebot: hello

8:05 opqdonut: slightly different

8:06 jaju: oh thanks!

8:06 interesting

8:06 clojurebot accepts function definitions too?

8:06 trying

8:06 (defn mul [x y] (* x y))

8:06 ,(defn mul [x y] (* x y))

8:06 clojurebot: DENIED

8:07 jaju: ,(defn mul [x y] (* x y))

8:07 clojurebot: DENIED

8:07 jaju: oh cool!

8:07 Fossi: nope

8:07 it's sandboxed

8:07 and def is evil ;)

8:07 jaju: my first time here - so, exploring a bit :)

8:07 manutter: I think you can use letfn to make temporary functions though

8:07 Fossi: you can also message it in private

8:07 jaju: cool stuff!

8:07 Fossi: if you wanna toy around a whole lot :)

8:08 manutter: ,(letfn [(plus [a b] (+ a b))] (plus 1 2))

8:08 clojurebot: 3

8:08 manutter: heh :)

8:08 jaju: oh no - just exploring. I'd rather have clojure discussions! :)

8:08 cool - thanks for the tip

8:08 Fossi: there's also sexpbot and another one

8:08 #()

8:08 manutter: The letfn is more useful on 4clojure.org

8:08 Fossi: #(= 1 1 )

8:08 jaju: maybe - when I do not have a clojure repl around, this might be handy!

8:08 Fossi: #(+ 1 1)

8:09 manutter: ##(= 1 1)

8:09 sexpbot: ⟹ true

8:09 Fossi: ah, that was it

8:09 manutter: I've seen some cool bot commands but I don't remember may of them

8:09 jaju: ##(+ 1 1)

8:09 sexpbot: ⟹ 2

8:09 manutter: ~botsnack

8:09 clojurebot: Thanks, but I prefer chocolate

8:09 jaju: nice

8:09 manutter: ~chocolate

8:09 clojurebot: No entiendo

8:10 jaju: haha

8:10 manutter: clojurebot: you lie.

8:10 clojurebot: Gabh mo leithscéal?

8:10 manutter: clojurebot: help

8:10 clojurebot: http://www.khanacademy.org/

8:10 manutter: lol

8:10 jaju: :)

8:10 clojurebot: what's your name?

8:10 clojurebot: amespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it

8:11 manutter: not the answer I was looking for, but a good link nonetheless

8:13 jaju: ~corn

8:13 clojurebot: Huh?

8:13 jaju: ~corn

8:13 clojurebot: excusez-moi

8:13 jaju: ~coffee

8:13 clojurebot: Pardon?

8:14 jaju: (doc +)

8:14 clojurebot: "([] [x] [x y] [x y & more]); Returns the sum of nums. (+) returns 0."

8:14 jaju: (source +)

8:14 ,(source +)

8:14 clojurebot: java.lang.Exception: Unable to resolve symbol: source in this context

9:13 manutter: I shiver a little when I have to document code that uses variables like $magic_function_name

9:16 then again, it IS php...

9:40 kryft: Hmm, what's the difference between PersistentArrayMap and PersistentHashMap? JoC apparently refers to the former as a hash map.

9:44 manutter: I'm getting the impression that PersistentArrayMaps maintain order but can't hold as many values, whereas PersistentHashMap can be bigger but does not maintain order

9:45 That's googling for both terms and skimming a few blogs, so don't quote me

9:46 TobiasRaeder: yeah just based on the names the array map probably holds all data in an array the hash map in a hash based tree/trie

9:46 -> lookups in long/large arrays might get expensive but should keep insertion order

9:46 since the hashmap will distribute the data based on the hashes there is no way to reconstruct the insertion order

9:47 but faster lookup on larger maps

9:47 same here - dont quote me on it ;) just a quick look at the implementation and thinking about the names

9:50 kryft: Sounds logical. I was just confused by JoC page 98: ".. a new hash map can be created idiomatically ..: (into {} [[:a 1] [:b 2]])

9:50 "

9:52 TobiasRaeder: yeah

9:52 {} creates an array map and not a hash-map

9:52 seems like a typoe

9:52 pjstadig: The ordering of keys by PersistentArrayMap is just coincidental, and not a guarantee, the array map is just faster for smaller number of keys, and automatically promotes to a PersistentHashMap at some threshold (8 keys I think)

9:52 TobiasRaeder: mhm

9:52 &(class (hash-map))

9:52 sexpbot: ⟹ clojure.lang.PersistentArrayMap

9:53 TobiasRaeder: thats really interesting

9:53 manutter: &(class {})

9:53 sexpbot: ⟹ clojure.lang.PersistentArrayMap

9:53 kryft: &(class (hash-map :a 1))

9:53 sexpbot: ⟹ clojure.lang.PersistentHashMap

9:53 pjstadig: i think the term "hash map" can be applied to both since they both implement the same set of methods

9:53 i wouldn't get hung up on the names

9:54 manutter: &(class {:a 1 :b 2 :c 3 :d 4 :e 5 :f 6 :g 7 :h 8 :i 9})

9:54 sexpbot: ⟹ clojure.lang.PersistentHashMap

9:55 manutter: Yeah, I think "hash map" is a non-implementation-specific term meaning "access values by key"

9:55 pjstadig: ,(class {:a 1 :b 2 :c 3 :d 4 :e 5 :f 6 :g 7 :h 8})

9:55 clojurebot: clojure.lang.PersistentArrayMap

9:55 pjstadig: ,(class {:a 1 :b 2 :c 3 :d 4 :e 5 :f 6 :g 7 :h 8 :i 9})

9:55 clojurebot: clojure.lang.PersistentHashMap

9:55 manutter: PHashMap vs PArrayMap are just implementation details that should be ignored in most cases.

9:56 djpowell: Hmm, is there a bug with aset on 2-d arrays?

9:56 ,(aset (make-array Integer/TYPE 3 3) 0 0 1)

9:56 clojurebot: 1

9:56 djpowell: grr

9:56 #(aset (make-array Integer/TYPE 3 3) 0 0 1)

9:56 manutter: ,(doc make-array)

9:56 clojurebot: "([type len] [type dim & more-dims]); Creates and returns an array of instances of the specified class of the specified dimension(s). Note that a class object is required. Class objects can be obtained by using their imported or fully-qualified name. Class objects for the primitive types can be obtained using, e.g., Integer/TYPE."

9:56 djpowell: what ver is sexpbot, and how do i talk to it?

9:57 manutter: &(doc make-array)

9:57 sexpbot: ⟹ "([type len] [type dim & more-dims]); Creates and returns an array of instances of the specified class of the specified dimension(s). Note that a class object is required. Class objects can be obtained by using their imported or fully-qualified name. Class objects f... http://gist.github.com/1042576

9:57 mrBliss: &(clojure-version)

9:57 sexpbot: ⟹ "1.2.0"

9:57 djpowell: &(aset (make-array Integer/TYPE 3 3) 0 0 1)

9:57 sexpbot: ⟹ 1

9:57 mrBliss: ,(clojure-version)

9:57 clojurebot: "1.2.0"

9:57 djpowell: &(clojure-version)

9:57 sexpbot: ⟹ "1.2.0"

9:57 djpowell: ah

9:57 manutter: (doc aset)

9:57 clojurebot: "([array idx val] [array idx idx2 & idxv]); Sets the value at the index/indices. Works on Java arrays of reference types. Returns val."

9:57 djpowell: ok - it fails in clojure 1.3

9:57 pjstadig: neither of the bots is running 1.2.1...tsk tsk

9:58 manutter: (insert famous obiwan quote here...)

10:01 djpowell: it seems to be a bug anyway, i'll file a report

10:09 ah, it is the new default behaviour of longs that is doing it - the aset value is getting converted to a Long rather than an Integer

10:10 oh, hang on; the aset-int method works. everyone normally seems to suggest avoiding that

10:10 gfrlog: I am getting very strange behavior from "lein uberjar" -- it's throwing a java.util.zip.ZipException for various files in src/resources/public

10:11 doesn't seem to be a particular file, because renaming or deleting the offending file doesn't help

10:11 djpowell: on windows?

10:11 gfrlog: I should say the exception message is "duplicate entry: <filename>"

10:11 I'm on linux

10:12 djpowell: ah k. I seemed to have an issue with odd file permissions recently, but it doesn't sound like that

10:12 gfrlog: guess I should see if "lein jar" fails as well

10:12 djpowell: do you have a file of the same name in src and resources?

10:12 gfrlog: nope

10:12 nothing weird like that

10:13 same exception for "lein jar"

10:14 "lein ring server-headless" succeeds though, and I believe it properly serves the files in src/resources/public

11:01 pyr: clojure 1.3 has a deref with timeout and timeout-val possible,nice!

11:16 technomancy: gfrlog: there's probably a duplicate in your dependencies. maybe uberjar needs debug logging to track that kind of thing down

11:21 fliebel: Life is still a vector.

11:26 chouser: ##(= == =)##

11:26 sexpbot: ⟹ false

11:26 chouser: good, just checking.

11:26 Fossi: #(- _ -)

11:26 ##(- _ -)

11:26 sexpbot: java.lang.Exception: Unable to resolve symbol: _ in this context

11:26 TobiasRaeder: what is the most idiomatic way to convert a string to an int?

11:27 pjstadig: Integer/parseInt

11:27 Fossi: i thought there was a wrapper somewhere

11:27 TobiasRaeder: mhm

11:27 kk

11:27 if i find it ill use it otherwise just write something

11:28 jcromartie: what do y'all think of DDD? http://domaindrivendesign.org/resources/ddd_terms

11:28 seems like a good match

11:28 chouser: parseInt is good. You can use (read), but you may be surprised by the results.

11:28 manutter: a good match for clojure?

11:28 jcromartie: ^^

11:29 jcromartie: yes manutter

11:29 tomoj: the DDD book I have has like three good chapters then a bunch of OOP BS

11:29 jcromartie: hah

11:30 tomoj: guess I ought to slog through it to try to get the point anyway :/

11:34 jcromartie: I think that glossary maps really nicely to lots of clojure concepts

11:34 especially the difference between value and identity

12:14 timvisher: hi all

12:14 arohner: timvisher: hi

12:14 timvisher: is there a function I can easily combine with some that will return the thing matched from a seq?

12:14 hoo boy that was a bad explanation.

12:14 let me gist something

12:15 https://gist.github.com/1042882

12:15 basically, i find myself someing over a seq a lot and then returning the thing that I was searching for by duplicating it

12:15 because the only thing I know to do is to use =

12:16 which is a predicate

12:16 arohner: the return value of some is the thing it matched

12:16 timvisher: i know

12:16 not quite though

12:16 it's the return value of the function that returned non-nil

12:17 so in other words, ,(some #(= 1 %) [1 2 3 4 5])

12:17 ,(some #(= 1 %) [1 2 3 4 5])

12:17 clojurebot: true

12:17 timvisher: whereas

12:17 ,(some identity [nil nil 1])

12:17 clojurebot: 1

12:17 arohner: (some #(if (= "png" %) % nil) extensions)

12:17 mrBliss: ,(or (first (filter #(= 1 %) [1 2 3 4 5])) :else)

12:17 clojurebot: 1

12:18 arohner: oh yeah. I do first filter a lot

12:18 timvisher: arohner: wow, not sure why i didn't think of that

12:18 goes to show how blind you can get when you're stairing at your own code

12:18 thanks for the tips, arohner and mrBliss

12:28 gfrlog: deffing things that depend on IO is really messy I'm finding out :(

12:28 tomoj: isn't #(if (= "png" %) % nil) #{"png"}

12:29 no_mind: any plans for proposing clojure miniconf at linux.conf.au ?

12:29 tomoj: ,(doc some)

12:29 clojurebot: "([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence, otherwise nil: (some #{:fred} coll)"

12:29 arohner: tomoj: doh. yeah, that's better

12:50 redline6561_: Hi. Sorry if this question is dumb but are there plans to extend leiningen to handle a use-case more like cljr? My background is CL and I miss being able to fire up SLIME and have access to all my globally installed libs. :-P

12:53 manutter: redline6561_: Have you looked at jark?

12:53 redline6561_: manutter: Nope. Haven't heard of it.

12:54 davekong: Is using a map or doing the equivalent with a list comprehension more efficient? Is one way considered more idiomatic than the other?

12:54 manutter: ah, you might like it, http://icylisper.in/jark

12:54 technomancy: redline6561_: why not create a project to contain your libs?

12:54 manutter: (I think that's the right url...)

12:54 (yeah, that works)

12:55 redline6561_: technomancy: Mostly to be able to experiment with new libs and try things that I might not necessarily have a specific project in mind for.

12:55 Admittedly, I could have (or leiningen could ship with) a default/experiments project for screwing around.

12:55 It's just extra work vs my old start emacs, M-x slime process...so I was curious. :)

12:56 manutter: Interesting, thanks!

12:56 technomancy: redline6561_: well, the JVM prevents you from adding new deps without restarting anyway

12:56 so it's never going to be like CL

12:56 cemerick: technomancy: maybe have `lein repl` add the most recent versions of all artifacts in ~/.m2 to the classpath if there's no project.clj? :-P

12:56 redline6561_: technomancy: :( Yeah, that's the impression I got.

12:56 technomancy: cemerick: can't tell if you're serious. =)

12:57 redline6561_: cemerick +1000

12:57 cemerick: technomancy: sure, why not? Print a warning, maybe with a link that explains what's going on, and let 'em have at it.

12:57 pjstadig: ugh

12:57 manutter: what if your .m2 contains incompatible libs?

12:58 pjstadig: terrible idea

12:58 technomancy: doesn't perf degrade with a ginormous classpath?

12:58 sot: Hi, Does anyone know in what new module str-join is in?

12:58 cemerick: only when loading resources

12:58 manutter: but while we're on this topic, does lein support like a user.clj global file?

12:58 cemerick: Clearly not intended for "real work" — but it'd be hard to beat for experimentation and newbies.

12:58 technomancy: maybe a separate "mega-repl" task; probably not suitable for the default

12:59 pjstadig: manutter: clojure supports it,if it's on the classpath

12:59 manutter: maybe lein isn't the right place for that, though

12:59 redline6561_: mega-repl sounds acceptable to me.

12:59 technomancy: manutter: there's ~/.lein/init.clj which runs in lein's process

13:00 manutter: yeah, I'm trying to figure out how to have some util routines that are available whenever I fire up a repl

13:00 redline6561_: I like clojure a lot and have been glad to see leiningen gain traction...but the remaining extra functionality found in cljr/jark/cake is functionality I really like.

13:00 Would prefer not to have several build/lib tools.

13:00 Mega-repl is certainly the main thing in my mind. Less concerned with scripting + persistent jvm.

13:00 technomancy: I've yet to see a convincing explanation for how that's different from just creating a throwaway project

13:01 but mega-repl would be easy-peasy to implemnet as a plugin

13:01 cemerick: redline6561_: I think we're going to see continued proliferation of such tools for a while.

13:01 manutter: but if I just do clojure-jack-in then I haven't necessarily launched my repl from lein, so lein isn't the right place for it

13:01 technomancy: manutter: maybe you want user-level plugins?

13:01 redline6561_: That's totally fair, not trying to be pushy. It was just a late evening and I went, "Ugh. Create a pretend project? No." and went to bed.

13:01 manutter: redline6561_: it seems to me that the focus of lein and jark are somewhat different, build tool vs repl tool

13:02 redline6561_: ^^ technomancy. It's certainly a workable solution, if not an ideal one.

13:02 manutter: True. cemerick: Duly noted. Thanks.

13:02 technomancy: redline6561_: I think psychologically it's different. I'm just not sure if technically it is

13:02 redline6561_: UX is all about psychology. :)

13:02 technomancy: maybe if there were just a project auto-generated in ~/.lein/scratch or something

13:02 redline6561_: Technically, yeah, it's pretty much identical.

13:03 manutter: technomancy: if I install a plugin with "lein plugin install", does that make it available to all my projects automatically?

13:03 technomancy: manutter: yeah

13:05 manutter: Ok, so I create a project with lein new, but then I just fire up emacs and do clojure-jack-in, will it stlll be there?

13:05 redline6561_: technomancy: Thanks for leiningen. Excited for search in 1.6. Will be quite nice for a Quicklisp guy like myself. :D

13:05 * technomancy is hoping to release in the next week

13:06 * manutter is looking forward to that

13:06 technomancy: manutter: sure

13:06 arohner: davekong: no, one isn't more idiomatic than the other. it's user preference

13:06 manutter: technomancy: cool! I'd have thought you needed a lein swank or something, but this suits my purposes

13:07 technomancy: jack-in just delegates to swank

13:07 * manutter goes back to his day-job work again

13:07 * redline6561_ too

13:08 mattmitchell: how can i easily convert a hash map into a vector: {:names ["one" "two"] :id 100} would become [:names ["one" "two"] :id 100] ???

13:08 pjstadig: starting a repl is not the same thing as a build tool, and perhaps having a standard CLI for clojure would be a better solution

13:08 mattmitchell: (map vec {}) almost does it, but I want the top level flattened

13:09 gfrlog: mattmitchell: ##(apply concat (seq {:names ["one" "two"] :id 100}))

13:09 sexpbot: ⟹ (:names ["one" "two"] :id 100)

13:09 mattmitchell: gravity: awesome thank you

13:09 gfrlog: I guess pass that to vec if you really do need a vector

13:09 technomancy: pjstadig: a novel idea!

13:09 gfrlog: mattmitchell: no problem :)

13:10 ##(mapcat {:names ["one" "two"] :id 100})

13:10 sexpbot: java.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$map

13:10 gfrlog: ##(mapcat identity {:names ["one" "two"] :id 100})

13:10 sexpbot: ⟹ (:names ["one" "two"] :id 100)

13:10 gfrlog: maybe that's a little simpler

13:12 mattmitchell: gfrlog: cool, yeah i like that

13:14 gfrlog: mattmitchell: note that the order of the pairs is not defined

13:15 mattmitchell: gfrlog: you mean ordering of the keys could possibly change?

13:26 gfrlog: mattmitchell: yes

13:26 ,(map seq [{:foo 1 :bar 2} {:bar 2 :foo 1}])

13:26 clojurebot: (([:foo 1] [:bar 2]) ([:bar 2] [:foo 1]))

13:27 gfrlog: that is apparently a bad example

13:27 probably small maps use arrays

13:27 but I don't think that's something you're supposed to depend on

13:28 mattmitchell: gfrlog: ok, so is it possible a key/value could get messed up in the resulting list?

13:28 gfrlog: mattmitchell: I mean that you should assume {:foo 1 :bar 2} could come out either as [:foo 1 :bar 2] or [:bar 2 :foo 1]

13:28 but NOT anything like [:foo 2 :bar 1] or [1 2 :foo :bar]

13:28 at least not with the code we used above

13:28 mattmitchell: gfrlog: ahh ok yes, that's fine

13:29 thank you for clarifying

13:29 gfrlog: no problem

13:31 technomancy: removing my src/resources directory causes the [uber]jar tasks to succeed -- does that go along with or contradict your "duplicate dependencies" suggestion?

13:32 technomancy: gfrlog: must be a dupe between your project and a dep then

13:32 if the error message doesn't make it clear what file is conflicting, that should be addressed

13:33 gfrlog: technomancy: it does, but each time I delete a file a new file is the culprit. Some of the files have rather unique names too

13:33 technomancy: do you have your own project as a dependency? =)

13:33 gfrlog: I have 4 files in src/resources total, and it blamed all 4 of them as I deleted the others

13:34 technomancy: I hope not :)

13:34 technomancy: the project's not on clojars or anything like that

13:35 technomancy: I guess I'll start hacking away at the project until I get a minimal example of the error

13:37 technomancy: gfrlog: actually uberjar keeps a running set of all files already included and automatically omits dupes

13:37 so somehow your project is working around that

13:37 gfrlog: technomancy: did I mention than "lein jar" fails the same way? so it's not an uberjar thing

13:37 technomancy: oh, I didn't catch that

13:39 gfrlog: technomancy: and "lein ring server" succeeds, and the app correctly serves the static files from src/resources

13:39 I've never had an issue with that, and also never tried building a jar until now

13:52 I bet this is me not using :resources-path correctly

13:52 cuz I have the project down to about nothing and it's still failing

13:52 * gfrlog goes to look up the docs

13:54 cemerick: dnolen: See, it looks like you have quite the cheering section, at the very least. :-)

13:55 dnolen: cemerick: heh

14:01 gfrlog: technomancy: if this isn't a minimal example I don't know what is :) https://github.com/fredericksgary/isuckatlein

14:02 I'm sure it'll end up being some missing key in the project.clj

14:04 dnolen: though it's a bit disappointing that people think types for Clojure are "advanced", "hard". A logic engine gives you most of a type system for "free". The HM type checker for Prolog is 890 LOC. I don't expect a HM type checker on top of core.logic for Clojure to be significantly more than that.

14:05 in Typed Racket it sounds like a lot of the actual complexity comes from integrating untyped code.

14:09 technomancy: gfrlog: mv src/resources .

14:09 it's odd that it would fail that way though

14:10 amalloy: technomancy, gfrlog: foo-whatever.bar is on the classpath twice, with different paths. that sounds to me like a bad plan

14:10 technomancy: I see what's going on; the mechanism for trimming the filename is the same for files in src or in resources

14:10 so it gets confused if there is overlap

14:10 however, there shouldn't bever be overlap

14:11 pyr: hey

14:11 gfrlog: so I'm misunderstanding how to use :resources-path?

14:11 pyr: i'm having a clojure problem that's related to my understanding of java i think

14:11 technomancy: gfrlog: you only set :resources-path if for some reason you don't want to keep your resources in the resources/ dir in the project root

14:12 if resources/ exists, it will use it without any configuration in project.clj

14:12 pyr: i have an exception occurring nested within futures and when I catch it and print the full trace

14:12 gfrlog: technomancy: okay. I guess I don't mind moving it.

14:12 pyr: it seems it doesn't go "deep" enough

14:12 technomancy: gfrlog: in fact, resources is explicitly for things that don't belong in src anyway

14:12 so src/resources is kind of contradictory

14:12 amalloy: pyr: each thread has its own stack

14:13 pyr: http://pastie.org/2112344

14:13 gfrlog: technomancy: how about this: :dev-resources-path "test/resources"

14:13 pyr: amalloy: the pastie is the function I use to catch the trace

14:13 gfrlog: technomancy: i.e., is there a better place for dev-resources?

14:14 technomancy: gfrlog: same thing; just mkdir test-resources

14:14 (will be moved to dev-resources in 2.0)

14:14 gfrlog: technomancy: okay. Cool, thanks.

14:14 amalloy: pyr: you're explicitly catching e and e.getCause

14:14 what about the cause of the cause of e?

14:14 technomancy: no need for all this nesting

14:14 amalloy: and so on down the line

14:15 hiredman: ,(doc root-cause)

14:15 clojurebot: I don't understand.

14:15 hiredman: clojurebot: jerk

14:15 clojurebot: Gabh mo leithscéal?

14:15 hiredman: ,(require 'clojure.stacktrace)

14:15 clojurebot: nil

14:15 hiredman: ,(doc root-cause)

14:15 clojurebot: Excuse me?

14:15 pyr: ah ok

14:15 amalloy: when java prints a stacktrace, it explicitly runs through all the nested .getCause's and prints them all. you only do two

14:15 hiredman: clojurebot: for real?

14:15 clojurebot: Gabh mo leithscéal?

14:16 pyr: ok, alright, I didn't get what getCause was, didn't read thoroughly enough

14:16 so yeah, I should instead loop while getCause returns something

14:16 and print my trace

14:17 pjstadig: or just use clojure.stacktrace/root-cause

14:17 i think hiredman is trying to tell you that root-cause already does the looping for you

14:17 '(doc clojure.stacktrace/root-cause)

14:17 ,(doc clojure.stacktrace/root-cause)

14:18 clojurebot: "([tr]); Returns the last 'cause' Throwable in a chain of Throwables."

14:18 amalloy: pjstadig: but it doesn't

14:18 well. it does. but it only returns the last exception, not all the ones on the way

14:18 pjstadig: sure

14:18 but usually the last one is the interesting one

14:19 pyr: thanks for the clarifications anyhow :)

14:19 i still get lost in java details, my burden for coming from a non jvm background i guess

14:21 * gfrlog can imagine that would be daunting

14:22 pyr: easier than I had feared, thanks to leiningen mostly

14:22 gfrlog: I'm a fan of leiningen

14:33 timvisher: anyone know off the top of their heads how to get clj-time (or joda time) to honor DST?

14:33 choffstein: Hey all. I have developed a jetty app that runs perfectly on my local machine when I run it as a jar, but I would like to deploy it as a war. I've heard this can be done with a few leiningen plugins, but am having some serious trouble figuring out how to package it all up and how to construct my servlet. Anyone here familiar with building and deploying jars that wouldn't mind me asking them a few questions in private?

14:34 (only to not clutter this channel with stupid questions)

14:34 timvisher: i thought it did it automatically but i'm seeing incorrect results that are an hour slow

14:34 choffstein: go for it, bro. i do nothing but ask stupid questions here and i haven't been banned yet!

14:34 'fraid i won't be much use to you, though

14:34 Scriptor: choffstein: don't worrying about cluttering the channel, it's not all that busy

14:34 timvisher: i'm still pre-deployment with my web app

14:35 Scriptor: and other might be interested in the discussion!

14:37 choffstein: Well, I guess the first question would be is: does anyone know of a very, very barebones example of a lein project set up to be deployed as a war using ring?

14:38 Every tutorial online seems to do it a different way

14:38 timvisher: choffstein: what about this? https://github.com/weavejester/compojure-example

14:38 choffstein: The second question would be: I use a "public" directory for my static files (css / javascript) in the root directory of my lein project -- any idea how to get this wrapped in to my war file?

14:39 ibdknox: you just need to put it in a resources folder

14:39 timvisher: in fact, is this what you're looking for? https://github.com/weavejester/lein-ring

14:41 choffstein: ...wow, that was simple

14:41 I need to stop spending 2 hours trying to solve things myself and just come ask you guys

14:41 timvisher: ,drinks

14:41 clojurebot: java.lang.Exception: Unable to resolve symbol: drinks in this context

14:41 timvisher: boo

14:41 used to #emacs

14:41 anyway,

14:41 drinks all around!

14:42 can anyone help with my clj-time question?

14:42 why might it not appear to be honoring DST?

14:48 choffstein: Any idea why ring's warp-file might not be playing nice with the resources folder?

14:48 e.g. saying files not found?

14:50 timvisher: not off hand but you could verify through an http watcher that the paths are actually correct

14:51 I had issues with utf-8 in my app

14:53 unfortunately, i only know ring as it's exposed by compojure

14:53 choffstein: holy shit. it works...

14:53 This isn't supposed to work...

14:55 timvisher: heh

14:55 that could be a good thing

15:03 can anyone help with my clj-time question?

15:03 why might it not appear to be honoring DST?

15:04 amalloy: timvisher: not really enough information there for anyone to help, i think? i don't know anything about clj-time, but if i did i don't think i'd know what, specifically, your problem is

15:05 timvisher: let me explain then

15:05 i'm playing with clj-time at the repl

15:06 I do (now) and it returns, as expected, this instant in GWT

15:06 GMT*

15:06 Somelauw: (- \h \a)

15:06 timvisher: except that instead of 20 being returned for (hour (now))

15:06 I get 19

15:07 Somelauw: = 7 or something in java. But can I get the same result in clojure without translating to int?

15:07 timvisher: as if DST wasn't in effect at the moment

15:07 jcromartie: Somelauw: no

15:07 timvisher: make sense?

15:07 everything I've read about joda time is that it handles DST automagically

15:07 jcromartie: Somelauw: (defn char- [& chars] (apply - (map int chars)))

15:08 and if you want, (defn char- [& chars] (char (apply - (map int chars))))

15:08 to keep it in the char type

15:08 so, (char- \z 1) => \y

15:09 Somelauw: okay, thansk

15:11 ibdknox: timvisher: are you sure you have the locale set correctly?

15:11 timvisher: don't even know enough to tell you

15:12 is there a ! function I have to call in clj-time to set that?

15:13 ibdknox: try this:

15:13 (def time-format (tform/formatter "h:mma" (ctime/default-time-zone)))

15:13 whoops

15:13 you'll need to require:

15:13 [clj-time.core :as ctime]

15:13 [clj-time.format :as tform]

15:14 (tform/unparse time-format (ctime/now))

15:14 see if that gives you the correct time

15:16 timvisher: that indeed seems to do it

15:16 though it only returns it for GMT

15:16 why wouldn't the time-zone-for-offset -5 work, though?

15:16 ibdknox: weird, that returns PST for me

15:16 timvisher: are they returning different things?

15:17 actually

15:17 i'm calling it wrong

15:19 ibdknox: (tform/show-formatters)

15:19 that will show you every format

15:19 one of which is :local-time

15:20 so you could also do this:

15:21 (tform/unparse (:local-time tform/formatters) (ctime/now))

15:21 I believe

15:24 timvisher: that's strange, my show-formatters doesn't include local-time

15:25 so the issue seems to be that the DateTime returned by (time/to-time-zone (time/now) (time/default-time-zone)) is in fact correct

15:25 but the call (time/to-time-zone (time/now) (time/time-zone-for-offset -5)) is off by an hour

15:26 which doesn't make sense to me because they should be returning the same TimeZone

15:27 ibdknox: hm :local-time is in the source

15:27 what version are you using?

15:28 timvisher: it's strange because it in fact works, but it's not listed when I call the show function

15:29 ibdknox: I see, does it get you what you want?

15:29 timvisher: it actually returns 19

15:29 which is very odd

15:29 version is 0.3.0

15:30 https://gist.github.com/1043415

15:34 ibdknox: I'm not sure, using my custom formatter and setting it to the default-time-zone gives me PST as I would expect

15:35 timvisher: what if you call it with (time-zone-for-offset -8) ?

15:35 or whatever the offset is for PST

15:36 ibdknox: it's off by one then

15:36 11:35 instead of 12:35

15:36 timvisher: interesting

15:36 maybe i'm misunderstanding the semantics of that call

15:37 ibdknox: well given that DST is a national thing

15:37 not a time-zone thing

15:37 that's what I would expect

15:37 other countries will be in that time zone, so it's giving me the mathematically correct time

15:37 choffstein: Anyone have any experience deploying war files to amazon's elastic beanstalk?

15:37 timvisher: but why then would the default-time-zone return something different than the your time-zone calculated via an offset

15:38 ibdknox: it's the locale

15:38 timvisher: choffstein: have you seen https://github.com/weavejester/lein-beanstalk

15:38 choffstein: jesus, weavejester just has everything

15:38 ibdknox: #<CachedDateTimeZone America/Los_Angeles>

15:38 is what (ctime/default-time-zone)

15:38 timvisher: the man is prolific

15:39 ibdknox: returns

15:39 timvisher: ah

15:39 so they're returning different types

15:39 that's interesting

15:39 ibdknox: yep

15:40 timvisher: so what do you think the usefulness of time-zone-for-offset would be then?

15:40 given that you would have to manually keep track of DST.

15:40 i can't think of any reasonable uses for it off the top of my head

15:40 ibdknox: No one else has DST ;)

15:41 timvisher: actually, London is in DST at the moment

15:41 gfrlog: why wouldn't you arbitrarily change your clocks?

15:41 timvisher: there are a number of locations that do this awful thing to us

15:41 :)

15:41 ibdknox: lol

15:41 gfrlog: we're demonstrating that the time is whatever we say it is

15:41 ibdknox: it's better to stick to a standard, I think

15:41 gfrlog: if we can't do that it's a slippery slope

15:42 ibdknox: but I'm sure there's a magical way to get all of the DST's to work out

15:42 you'll likely need to look more into Joda to figure that out

15:44 VT_entity: hey, all. Anyone have any experience with "seque"

15:44 choffstein: okay ... very specific question. When using "lein ring war", I keep getting a "ZipException: duplicate entry" error with my servlet.clj file. Anyone know why that may be happening? Is it a name clash?

15:44 "lein war" works fine...

15:44 gfrlog: that's weird...

15:45 VT_entity: I'm trying to peek and pop off of a seque, but I think I'm doing it wrong, and the documentation is really slim.

15:45 davekong: I spent some time trying to figure out how to quickly load a 120MB binary file (unsigned ints) into an array of longs and eventually came up with code that works but it still pretty slow (90s on my machine). I am wondering if there is an obvious way to speed this up by a factor of ten or so. http://www.pastie.org/2112719

15:45 timvisher: gfrlog: i'm already convinced that you should store only UTC times

15:45 gfrlog: choffstein: do you have a resources directory?

15:45 timvisher: i'm now concerned with display

15:45 gfrlog: timvisher: amen

15:45 timvisher: that's where i started running into the issue we've been discussing

15:45 choffstein: gfrlog: yep

15:46 gfrlog: choffstein: it's just "/resources"?

15:46 not anywhere weird?

15:46 choffstein: gfrlog: Exact error: "Exception in thread "main" java.util.zip.ZipException: duplicate entry: /WEB-INF/classes/portal/servlet.clj (NO_SOURCE_FILE:0)"

15:46 davekong: to-byte-array from contrib.io is very fast, but it is unclear to me how to write a to-long-array equivalent

15:46 timvisher: it looks like the way to set it up will be to store the long "America/New_York" time-zone in the customer account rather than the offset, which is what i was hoping for

15:46 choffstein: yep, nothing weird. "lein ring server" works fine.

15:47 gfrlog: choffstein: Okay. I had a strangely similar problem earlier today that technomancy helped me figure out. Sounds like it's probably unrelated though.

15:48 choffstein: ah, gotcha. thanks for trying anyway :)

15:49 timvisher: choffstein: i'm sure you've checked that you don't actually have 2 servlet.clj files?

15:52 choffstein: as far as I can tell, I don't :)

15:52 timvisher: just making sure

15:52 how familiar are you with jarring from the commandline?

15:52 could you try to do it outside of lein?

15:52 and see if you still get the same problem

15:53 choffstein: not hugely familiar. i've always been a c++ / ruby guy

15:53 timvisher: or maybe see if any of the various and sundry IDEs out there support a lein project and try exporting?

15:54 hmm

15:54 fraid I'm entirely out of my depth at this point

15:54 i only ever built wars 'by hand' using the ant task

15:54 and i believe lein is backed by maven

15:54 hope someone can help

15:54 amalloy: timvisher: lein is backed by maven *and* ant

15:54 choffstein: it's alright. i'll figure it out

15:55 * timvisher falls over in shock :)

15:55 amalloy: maven for dependency resolution, ant for building, iiuc

15:57 choffstein: hmmm ... looks like "lein ring uberjar" is expecting everything to be in WEB-INF/ ... that could be a problem

15:57 timvisher: ah good ol `wtf`

15:57 shame it doesn't work well with M-|

15:58 choffstein: hmmm ... or maybe not. gotta dig deeper into the source.

15:58 "use the source, choffstein..."

16:06 hmm ... just changing my servlet.clj to another file name and changing all my servlet references to that new name in the project and web.xml files made it work. That is very ... very odd.

16:09 timvisher: choffstein: just had a though

16:09 thought*

16:10 it's possible that ring uberjar is generating a servlet.clj file for you

16:10 auto'magically' as it were

16:10 and then yours is conflicting

16:10 are you sure there isn't an alternative to get things into the servlet.clj file?

16:11 choffstein: yeah, that is what I am guessing (hence why I tried changing it) -- but i'm not seeing that in the source

16:11 timvisher: maybe passing a map in project.clj or something?

16:11 choffstein: well, it works fine now. I just had to rename and remap. it's just strange that it seemed to be a restricted name -- but i'm not seeing that in the lein-ring source code

16:12 timvisher: you could always ask weavejester on github

16:13 he's ordinarily quite responsive in my experience

16:13 in fact, i just realized i've been assuming he's a guy this whole time

16:13 hmm

16:14 * gfrlog tries to figure out a way to parse "timvisher" such that it sounds feminine

16:14 amalloy: timvis, her

16:14 * gfrlog applauds

16:15 timvisher: :)

16:15 choffstein: on the internet, we're all just dudes pretending to be women

16:16 timvisher: ah the days of aol chat rooms, they were different times

16:16 better yet, compuserve chat rooms

16:16 but then again, here i am in irc

16:16 wondering whether weavejester is a guy or a girl

16:16 i hate clearcase

16:16 ...

16:16 Somelauw: timvishster

16:18 gfrlog: timvi-she-r

16:19 I think I got lucky. I had no idea before making the comment that his named had both "she" and "her" as substrings.

16:19 aw crap I just assumed timvisher was a dude

16:20 timvisher: gfrlog: there you go assuming!

16:20 you know when you assume you make an ass out of all of us.

16:20 * timvisher nods his head wisely

16:20 gfrlog: no that's what happens when you assallus

16:24 OscarZ: hi.. what's the relation between Clojure and Scala ? Both seem to be FP languages on top of JVM.. are there some specific issues with Scala where Clojure wanted to go other way?

16:25 I'm just trying to get an overview of the FP languages that are available..

16:26 technomancy: OscarZ: the syntaxes and type systems are the most obvious differences. also scala is hybrid OO/FP while Clojure is "just" FP.

16:27 Somelauw: They are both functional but differ a lot I think.

16:27 __name__: Clojure is lispy, Scala is not at all.

16:28 timvisher: OscarZ: I'd recommend googling. Reams have been written on this subject

16:28 i think __name__ has the most fundamental difference though

16:29 gfrlog: (inc __name__)

16:29 sexpbot: ⟹ 1

16:29 __name__: Yay, I am 1 now.

16:29 Somelauw: I think clojure is easy to compile but might not always work the first time. Scala is really hard to compile, but often works the first time.

16:29 * gfrlog thinks maybe it ought to be inc!

16:29 gfrlog: Somelauw: that sounds like static vs. dynamic

16:29 * __name__ concurs

16:29 technomancy: gfrlog: (swap! ~name inc)

16:30 OscarZ: Ok.. I'm a Java programmer trying to learn some FP.. I've been looking at Haskell a bit before

16:30 gfrlog: (swap! technomancy inc)

16:30 technomancy: what I meant is I agree :)

16:30 technomancy: though I've always been partial to dinc

16:30 gfrlog: d for what?

16:30 technomancy: double

16:30 gfrlog: phonetics?

16:30 technomancy: (def dinc (comp inc inc))

16:31 gfrlog: ah ha

16:31 timvisher: OscarZ: fwiw, i chose Clojure over Scala in your situation because I knew Clojure would push me pretty strongly towards FP where Scala seemed much more like Groovy with FP tacked on

16:31 technomancy: very extreme situations may call for oinc

16:31 __name__: oinc?

16:31 gfrlog: (apply comp (take 8 (repeat inc)))

16:31 timvisher: it's not impossible or even terribly difficult to write non-functional code in Clojure, but the whole language pushes you that way

16:31 whereas Scala is far more agnostic

16:31 hiredman: e.g. if you have an off by one error and are missing a long

16:31 technomancy: gfrlog: exactly

16:32 timvisher: it seems like the 'best' Scala programmers write mostly FP, but it takes awhile to get there

16:32 technomancy: clojurebot: oinc is octo-inc: (apply comp (take 8 (repeat inc)))

16:32 clojurebot: Ik begrijp

16:32 amalloy: Somelauw: heathen. clojure code works the first time, almost always. it's so functional that you don't have to be careful with bookkeeping

16:32 OscarZ: timvisher: Ok I see, I'd really like to learn the FP way of thinking and I guess its better to go with more "pure" FP .. that's why I looked at Haskell first

16:32 gfrlog: timvisher: I've heard some java programmers describe doing similiar things in java

16:32 just with less closures I guess

16:32 timvisher: gfrlog: true

16:32 OscarZ: but find it too big leap to actually start using Haskell in some real work where the existing code base is in Java

16:32 timvisher: I've heard that if you really want to push/punish yourself, you go Haskell

16:33 But it's also been a life long dream of mine to learn lisp so

16:33 ..

16:33 ah

16:33 gfrlog: clojurebot: oinc?

16:33 clojurebot: oinc is octo-inc: (apply comp (take 8 (repeat inc)))

16:33 * gfrlog w00ts

16:33 timvisher: well yeah, if you need to integrate on the JVM you basically should choose between Scala and Clojure

16:33 amalloy: anyone have a link to fogus's 140-character obfuscated-oinc tweet?

16:34 OscarZ: But I understand Haskell is really elegant language in terms of being "pure FP", so I guess thats a good place to learn at least some basic concepts

16:34 timvisher: yeah

16:34 I liked Channel9s Intro to FP by Meijer

16:34 gfrlog: OscarZ: as somebody with almost no experince in haskell, I agree

16:34 timvisher: ,google Channel9 Intro to Functional Programming Meijer

16:34 clojurebot: java.lang.Exception: Unable to resolve symbol: google in this context

16:34 timvisher: ,,google Channel9 Intro to Functional Programming Meijer

16:34 clojurebot: java.lang.Exception: Unable to resolve symbol: google in this context

16:34 timvisher: bah

16:34 amalloy: (defn oinc "fourteen" [n] (reduce + n (map #(%) (repeat (.length ((keyword (apply str (map char [100 111 99]))) (meta (var oinc)))) #(*)))))

16:34 timvisher: how do I do that

16:34 gfrlog: use $google with sexpbot

16:34 amalloy: $google hello

16:34 sexpbot: First out of 118000000 results is: Hello

16:34 http://www.hellomagazine.com/

16:34 gfrlog: maybe ~google works for clojurebot

16:34 timvisher: $google Channel9 Intro to Functional Programming Meijer

16:34 sexpbot: First out of 978 results is: Erik Meijer's MSDN Channel 9 lecture series on functional ...

16:34 http://lambda-the-ultimate.org/node/3642

16:35 amalloy: gfrlog: yes, i think so

16:35 gfrlog: ~google sexpbot

16:35 clojurebot: First, out of 149 results is:

16:35 Introduction to sexpbot » Bathroom Reading Material

16:35 http://blog.raynes.me/?p=82

16:35 timvisher: looks about right

16:35 OscarZ: thanks, I'll have a look on that video

16:37 timvisher: but honestly, I learned more about FP by watching through the Clojure blip.tv channel and reading through The Joy of Clojure than anywhere else, probably

16:37 at least to start off with

16:37 not to mention getting ad-hoc code reviews here in this fine channel

16:37 ^_^

16:37 * gfrlog learned about FP by learning erlang

16:37 OscarZ: ok :)

16:40 choffstein: anyone have any experience using lein-beanstalk?

16:41 * timvisher begins to thump chest madly and howl because he unlocked the magic of clj-time.format/with-zone

16:41 timvisher: god i am a nerd...

16:41 __name__: gfrlog: That must have been hard.

16:42 gfrlog: __name__: I was just thinking how weird that was in hindsight. Learning about the actor stuff at the same time.

16:42 __name__: Erlang is painful I guess.

16:42 Its syntax is just, well.

16:42 nishant: can anyone here help me with clj-http?

16:42 gfrlog: it definitely is. I found it fun in that kind of painful way that writing assembly code is also fun.

16:42 __name__: I find C fun in that way.

16:43 gfrlog: yeah. I still think it is a strange mix of high-level and low-level

16:43 kind of exotic I guess

16:43 amalloy: ~anyone

16:43 clojurebot: Please do not ask if anyone uses, knows, is good with, can help you with <some program or library>. Instead, ask your real question and someone will answer if they can help.

16:43 drewr: b

16:44 gfrlog: drewr: c

16:45 drewr: sry little slip of the finger there

16:46 gfrlog: :)

16:50 amac: Clojurebot seems cranky

16:50 ~botsnack

16:50 clojurebot: Thanks! Can I have chocolate next time

16:52 amalloy: that's new

16:55 gfrlog: clojurebot: botsnack?

16:55 clojurebot: Thanks! Can I have chocolate next time

16:55 gfrlog: it was a question.

17:01 ibdknox: does anyone know of an alternative to clojure.contrib.find-namespaces? I'm trying to remove my dependency on contrib in Noir

17:03 nm, tools.namespace appears to be the replacement

17:09 Raynes: ibdknox: Where are you using it in noir?

17:10 ibdknox: to load a dir's worth of views

17:10 as opposed to individually requiring them

17:10 noir.server/load-views

17:18 Raynes: thoughts?

17:21 Raynes: ibdknox: I was just wondering how you were using it. I thought I was going to need it for something myself recently, but found all-ns. Looks like you actually need it though.

17:22 ibdknox: Raynes: ah, yes. I think in this case it's the way to go.

17:23 bdesham: off-topic, but does anyone know of a C++ equivalent of marginalia?

17:24 ibdknox: bdesham: not off the top of my head, but it's based on Docco, so searching for a C++ docco might get you somewhere

17:24 bdesham: ibdknox: great, thanks

17:25 stuartsierra: noweb is a language-agnostic version of Knuth's original literate programming thing.

17:26 bdesham: stuartsierra: will look into that too, thanks

17:33 sot: Hi. Is using future the same as creating a thread in java? I have a few background processes that I need to spawn, and am using future, but am seeing some erratic behaviour.

17:35 stuartsierra: Futures use the same thread pool as send-off.

17:37 So each future gets its own thread, but the thread pool is allow to cache and reuse the thread after the future completes.

17:37 gotta go

17:38 sot: I'm using zeromq and have a number of event loops that listen and send on sockets, and wondering if using future to start these loops is correct.

17:47 hugod: anyone know if something like contrib.condition will be in 1.3?

17:48 technomancy: hugod: it won't be in 1.3, but http://github.com/scgilardi/slingshot is the successor of c.c.condition and is awesome.

17:49 hugod: technomancy: thanks, missed that

17:49 technomancy: hugod: it hasn't been widely publicized

17:55 bsteuber: where can I put init stuff for the user-namespace like (use 'clojure.repl) with leiningen/swank setup?

17:55 technomancy: put :repl-init foo.repl in project.clj where foo.repl is the namespace

17:56 bsteuber: yeah but I have like 10 projects

17:56 and would prefer a global solution

17:57 technomancy: hm... you could do it with a hook in ~/.lein/init.clj, but I guess that should be standardized. open an issue?

17:57 bsteuber: I expected .clojure/user.clj or swank-clojure-init-files to work, but neither did with this setup

17:57 ok I'll do that :)

17:58 hiredman: you can create a project where you keep your stuff

17:58 and add it as a checkout to all your other projects

17:59 bsteuber: checkouts are nice in general, just stumpled across them

17:59 technomancy: could you elaborate on the exact hook I'd need?

18:01 technomancy: bsteuber: off the top of my head: (add-hook #'leiningen.compile/get-readable-form (fn [orig j project form init] (orig j project form `(do ~init (load-file "/home/me/.lein/user.clj")))))

18:02 basically expanding the init arg to every eval-in-project invocation

18:02 bsteuber: great, I'll try that (and still file a ticket) :)

18:16 choffstein: anyone here have any experience distributing clojure web projects as .war files?

18:18 bsteuber: choffstein: got it working once or twice - what's your problem?

18:19 hiredman: choffstein: lein ring is nice

18:20 choffstein: "lein ring server" seems to work fine, but when I create a .war using "lein ring uberwar" and upload it to amazon's aws beanstalk, it doesn't seem to work at all. I was wondering if there is a good way to locally test the war file created by lein ring without having to install apache and tomcat.

18:21 bsteuber: I think I used jetty for that

18:21 hiredman: choffstein: you've seen lein-beanstalk?

18:22 choffstein: yeah -- lein-beanstalk doesn't seem to work for me

18:23 ah, I'll try jetty

18:23 bsteuber: technomancy: great, just added needed use/require clauses and it works!

18:24 so thanks a lot

18:27 timvisher: choffstein: installing tomcat or jetty and running a war file is dead simple

18:27 it might be worthwhile deploying it locally first just to test it.

18:27 choffstein: I'm about to try jetty

18:27 timvisher: nice

18:29 technomancy: bsteuber: if you want it nicer in leiningen 1.6, you could submit a patch =)

18:30 bsteuber: ok I'll try :)

18:30 technomancy: maybe a leiningen.core/add-init macro that could swap a form into an atom that leiningen.compile/get-readable-form could use?

18:31 bsteuber: why not just support .lein/user.clj?

18:31 and do what you did with your hook when it exists

18:32 that's what I'd do without knowing better :)

18:32 technomancy: yeah, no reason to have an atom really. just be sure to honor leiningen.util.paths/leiningen-home instead of hard-coding ~/.lein

18:33 bsteuber: good

18:40 sjl: So for my first non-toy project in Clojure I'm working on a simple Minecraft bot. If anyone has a few minutes to look at my code so far and tell me how to clean it up and make it more idiomatic, I'd love it.

18:40 https://bitbucket.org/sjl/clojurecraft/src/c6c71945637c/src/clojurecraft/core.clj

18:40 There's a lot of repetition that I think could probably be removed.

18:41 the-kenny: First thought on write-packet: use case, this does a constant-time lookup

18:42 Or implement this with multimethods, this would make it extensible (probably unnecessary)

18:43 Also, you can pass assoc more than one key value pair: (assoc m :foo 42 :bar 23) will assoc :foo and :bar

18:43 sjl: the-kenny: wow, I completely missed case. Thanks!

18:43 Yeah, I knew that, but now that you mention it I can clean up those ugly assoc chains with it too

18:43 the-kenny: Oh, and when you just want to populate a map (like in all the read-stuff), just use the map-syntax

18:44 {:foo 23, :bar 42} (the , is optional)

18:44 This removes the need for most assoc and ->

18:45 sjl: the-kenny: well, about that, is it guaranteed to parse the vals in the order I list them?

18:45 the-kenny: Oh, I haven't thought of that. Not sure.

18:45 sjl: the-kenny: the -read-whatever's need to be executed sequentially because the bytes are sent in a specific order

18:45 the-kenny: I understand

18:45 sjl: That's why I did the -> thing, I wasn't sure and just wanted to get a player on the screen, hah

18:46 the-kenny: same deal with the multiple-arg assocs

18:46 the-kenny: I'm pretty sure the order of multi-arg assocs is guaranteed

18:47 sjl: hmm

18:47 the-kenny: If order is important and if you don't want the whole assoc stuff to be gone, you could also do something like (zipmap [(-read-int stream) ...] [:eid ...])

18:48 bsteuber: or write it like (into {} [[:first (do-somehting)] [:second ...

18:48 sjl: mm, I think I'd rather keep the pairs together for readability

18:48 the-kenny: bsteuber's suggestion is more readable :)

18:49 sjl: but is the evaluation order of the vector of pairs guaranteed?

18:49 (same question as the eval-order of map literals, really)

18:49 bsteuber: yes for vectors it is

18:49 but I'd still just use one big assoc :)

18:51 sjl: ok, according to http://clojure.org/evaluation it looks like function arguments are guaranteed to be eval'ed left to right

18:51 so one big assoc should work

18:52 choffstein: egads. I thought this would be easy. jetty doesn't seem to like my war file. can't find "web-app" description ... and yet, there it is in WEB-INF/web.xml...

18:52 sjl: it still feels... dangerous, though.

18:53 amalloy: sjl: it's guaranteed. doesn't get any safer than that :P

18:53 the-kenny: sjl: You can always take a look at the implementation of assoc :)

18:53 sjl: Heh, I'm not worried about now -- I'm worried about a few months from now when the implementation of assoc changes :)

18:54 rkbuchmann: That would mean that evaluation in general would change

18:54 and that is very unlikely

18:55 amalloy: sjl: can you point me at a place where you're worried about order of evaluation? there's a lot of code there and i don't want to scan through all of it

18:56 oh, read-packet-login

18:56 the-kenny: every read/write operation :)

18:56 sjl: amalloy: Yeah, any of the read-packet-whatever ops

18:57 rkbuchmann: Yeah, seems like a pretty significant change, so I guess it's safe to assume it won't happen any time soon.

18:59 choffstein: okay, can anyone with some jetty experience give me a bit of help? I am having some trouble figuring out if there is something wrong with my .war, or if there is something wrong with my jetty setup...

18:59 bsteuber: I'm sure order of function evaluation is guaranteed in the "spec"

19:00 amalloy: sjl: fwiw, the current compiler does eval map literals in order

19:00 i don't know whether it's guaranteed

19:00 sjl: amalloy: Hmm, I think I'll stick with assoc. Not much more verbose, and the wiki says it's safe.

19:00 bsteuber: ah right that should be okay too :)

19:00 just after the map is constructed the order can change

19:01 amalloy: yes

19:02 choffstein: damn you jetty. you should not be this hard to figure out. what the crap.

19:03 bsteuber: probably it's just some simple thing you need to do different

19:04 did you check your web.xml for syntax errors?

19:08 choffstein: yep. Nothing that i can see.

19:08 I tried turning the warnings off in jetty, but get a whole new slew of problems

19:08 "sealing violation"

19:09 bsteuber: might help to start from some example project on github

19:09 choffstein: seems I am hunting an endangered species...

19:09 bsteuber: which of course I can't find right now :)

19:09 amalloy: (inc choffstein)

19:09 sexpbot: ⟹ 1

19:09 choffstein: eh?

19:10 bsteuber: (inc choffstein)

19:10 sexpbot: ⟹ 2

19:10 bsteuber: ok this is for polls

19:10 thought some nice way to insult people via sexpbot

19:11 at least "you're a null" is insulting in German

19:12 amalloy: choffstein: seal-hunting made me laugh. so you get a sexpbot karma credit

19:12 choffstein: ah, gotcha

19:12 bsteuber: (dec choffstein)

19:12 sexpbot: You want me to leave karma the same? Fine, I will.

19:12 amalloy: !

19:12 bsteuber: lol?

19:12 amalloy: that sounds broked

19:13 rbuchmann: (doc inc)

19:13 clojurebot: "([x]); Returns a number one greater than num."

19:13 rbuchmann: bah

19:13 amalloy: $karma choffstein

19:15 i'm probably the one who broke that, but it's not clear to me how

19:15 (dec Raynes)

19:15 sexpbot: ⟹ 4

19:15 amalloy: interesting. dec works

19:15 Raynes: (inc amalloy)

19:15 sexpbot: ⟹ 10

19:15 amalloy: funny funny. cause i'm the one who should be getting dec'd for breaking shit :P

19:16 rbuchmann: (inc amalloy)

19:16 sexpbot: ⟹ 11

19:18 choffstein: war files are confusing

19:18 rbuchmann: war is hell my friend... :)

19:18 choffstein: it seems war files + static resources (not served) + ring = no no

19:19 I am trying to use files that don't get served, but rather get read by my webserver. I am finding out that such a situation doesn't really work so well...

19:19 rbuchmann: hm, but surely that must be a pretty common scenario...?

19:19 iwillig: hi guys, is there a way i can look up a function in a namespace by a string, i am thinking of something like python's getattr

19:19 choffstein: one would think

19:20 this is getting rather frustrating. why does it work in "lein ring server" but not as a war under jetty. What in the world am I doing wrong...

19:20 Raynes: iwillig: look at resolve and ns-resolve. Might be what you're after. I don't use Python though, so don't hold me to it. ;)

19:21 hiredman: strip your project down to a single handler function and if that works slowly build it back up and see where it breaks

19:23 choffstein: hiredman: yeah ... that sounds horrible.

19:23 hiredman: but unfortunately is looking like the way I will have to go...

19:24 hiredman: choffstein: look, if you know how to read stack traces and are familiar with the jvm you most likely won't have to, but if you aren't what other option is there?

19:24 choffstein: ...I can read stack traces, thanks. these aren't stack trace issues.

19:25 This is trying to figure out why jetty isn't liking my war file

19:25 hiredman: *shrug* I don't know what more you want, you just complain about jetty over and over

19:26 no pastebins with errors, no explantions of this or that, just "I have this project, it doesn't work" for the last few hours

19:27 Raynes: Man, there are better ways to go about requesting more information.

19:27 hiredman: people *compulsively* click on urls, so it is very easy to get people to look at errors, logs, etc

19:27 choffstein: hiredman: fair enough. I'd love to give a pastebin with an error and a stack-trace, but there isn't one.

19:27 hiredman: then how do you know it isn't working?

19:27 choffstein: hiredman: the stacktrace is in jetty and only goes down into the configuration levels of jetty (e.g. the XML parser)

19:28 hiredman: choffstein: that is a stacktrace

19:28 choffstein: hiredman: so the only relevant part is the top level exception, which I have already asked about

19:28 Basically, I'm not an idiot. If I had more information to give, trust me, I would.

19:28 hiredman: well then, strip it down and rebuild it then

19:28 no, you have tons of information

19:29 you have namespace names, you have files, you have bytecode you have xml

19:29 you have *everything*

19:29 choffstein: hiredman: And sometimes, I can't give everything because they are proprietary projects. But the issues I am running into are generic enough and are about setting up your application to be appropriately distributed as a war file, which I am unfamiliar with.

19:30 Raynes: choffstein: gist that stacktrace.

19:30 choffstein: Raynes: the jetty one?

19:30 bsteuber: if need the help so badly, put a minimal non-working setup on github

19:30 Raynes: Sure. Whatever stacktrace you're getting.

19:30 bsteuber: there's you missing somewhere

19:30 hiredman: ^-

19:30 bsteuber: "a you"

19:30 whatever :)

19:30 Raynes: He seems fairly certain that your stacktrace is the key to infinity and beyond, so gist it and we can see.

19:31 choffstein: https://gist.github.com/1043893

19:31 Raynes: Before this channel turns into ##c

19:33 choffstein: Furthermore, that is an excellent idea. If you can get a minimal example of what isn't working for people here to see, it'll be easier to debug the problem.

19:34 choffstein: Raynes: I'm doing it as we speak. Hopefully I'll have a barebones up in a few minutes.

19:34 hiredman: choffstein: what version of jetty?

19:34 Raynes: Cool. :)

19:34 choffstein: 5.1.10

19:34 hiredman: very old

19:34 choffstein: installed it from macports.

19:34 hiredman: ugh

19:34 never install jars via system package managers

19:35 choffstein: didn't know it was going to come as a jar.

19:35 didn't know anything about jetty until a couple hours ago

19:35 hiredman: http://blogs.webtide.com/janb/entry/jetty_runner jetty-runner is what you want

19:35 get the latest version, you'll be fine

19:36 choffstein: alright, thanks.

19:36 bsteuber: install all java libraries with leiningen

19:37 jarvana.com is great for finding the maven names

19:37 hiredman: I guess you could jetty-runner via lein, but I would just download the jar as needed

19:37 * Raynes cringes at the poor use of the word 'install'.

19:37 hiredman: java -jar jetty-runner.jar some.war

19:38 bsteuber: sorry, raynes :)

19:38 Raynes: <3

19:38 bsteuber: you mean for confusion with lein install?

19:39 Raynes: Maven blows away any common understanding of what 'install' means to people. jars are copied around and such.

19:40 It's just confusing is all.

19:40 bsteuber: :)

19:43 good night everyone

19:44 or day or whatever :)

19:44 amalloy: ~ugt

19:44 clojurebot: ugt is Universal Greeting Time: http://www.total-knowledge.com/~ilya/mips/ugt.html

19:45 bsteuber: haha, thanks, I'll keep that in mind :)

19:47 pdk: holy shit

19:47 joy of clojure in mobi/epub

19:47 Raynes: Calm down.

19:47 pdk: but god descended man

19:48 technomancy: pdk: that was like two thousand years ago

19:49 choffstein: Ah, fuck. Okay ... so jetty-runner makes my war file run perfectly.

19:49 pdk: i think jesus only had lisp 1.5 then though

19:49 hiredman: technomancy: so not available in epub?

19:49 choffstein: that's ... awesome and horrible at the same time

19:49 Thanks for thinking of the version issue hiredman

19:49 hiredman: choffstein: right the xml lein ring

19:49 generates was too new

19:52 choffstein: ahhh, that makes sense

19:52 hmm. now all of a sudden I have to wonder why my war isn't working with the amazon beanstalk :D but that is a whole new can of worms....

20:30 Anyone try using lein-beanstalk yet?

22:27 justinko: what's the best way to install aquamacs on os x?

22:30 dnolen: justinko: I recommend Cocoa Emacs 23 unless you really, really, realy don't want to learn standard Emacs bindings.

22:32 justinko: dnolen: aquamacs seems so popular, even Hickey uses it

22:34 dnolen: okay I see your point http://stackoverflow.com/questions/1096009/carbon-vs-aqua-vs-cocoa-emacs-builds

22:36 dnolen: justinko: acquamacs is fine, but I've run into weird edge cases here and there which made me abandon it.

22:38 Scriptor: any word on what the theme for clojure/conj would be?

22:39 cemerick: I didn't think there was to be a theme.

22:40 Scriptor: it mentions on the website how they want to "weave a common theme", apparently there was one last year?

22:42 justinko: dnolen: this how you installed cocoa emacs? http://emacsformacosx.com/

22:42 dnolen: justinko: yes

23:07 jamiltron: What is the easiest way to read a single character from the console? I have tried monadic-io-streams' read-char but that seems to always give me back an instance of the function no matter how I use it.

23:18 technomancy: handy little VM setup courtesy of justinlilly: https://github.com/Seajure/emacs-clojure-vagrant

23:18 just in case M-x clojure-jack-in isn't easy enough...

23:19 justinko: technomancy: I'm about to buy your peepcode screencast

23:20 quick question: you guys map control to caps-lock?

23:20 like VIM users do?

23:20 technomancy: justinko: absolutely

23:21 Scriptor: I mapped escape to caps lock :)

23:21 justinko: Scriptor: so then you use control...?

23:22 dnolen: justinko: I got sick of Emacs pinky, control barely helps. Control -> Command, Meta -> Option

23:22 justinko: my pinky would break off

23:22 dnolen: thumbs are your strongest fingers spare your pinkies.

23:22 justinko: yeah command is fine

23:23 option is as bad as pinky though...

23:23 Scriptor: justinko: one advantage of windows on a macbook, left thumb always on the command button

23:23 eh, I just move my thumb a bit

23:23 gko: Is/will there be a unified Clojure/Common Lisp SLIME version?

23:24 dnolen: justinko, Many interesting Meta commands involve chords, no need for pinky on option.

23:24 justinko: if the left thumb get's tired of command, you can use the other! (on mac)

23:24 dnolen: yeah u use the ring finger for option, right?

23:25 technomancy: gko: there could be in the future if 0) the slime devs are open to it and 1) someone from Clojure land cares enough to coordinate with them.

23:25 but 1) is probably not going to be me

23:25 justinko: dnolen: ring finger isn't bad

23:25 dnolen: justinko: depends really. I have a Kinesis, so I think my chording patterns are influenced by that.

23:26 islon: why I cannot do this? (apply and [true true false])

23:26 dnolen: justinko: with Kinesis it's trivial to use both thumbs and a finger on another key at the same time which is hard on standard keyboards.

23:29 justinko: dnolen: damn you going to make me buy a kinesis? :)

23:29 dnolen: justinko: heh, no. I really only use that at work.

23:30 it's just influenced my typing to be more thumb-centric and less obsessed about moving off home keys.

23:32 symbole: islon: I believe it's because and is a macro? I'm probably wrong.

23:32 dnolen: islon: symbole: yup, and is a macro.

23:33 ,(macroexpand '(and true false false))

23:33 clojurebot: (let* [and__3468__auto__ true] (if and__3468__auto__ (clojure.core/and false false) and__3468__auto__))

23:36 justinko: dnolen: wait a minute, you maintain textmate-clojure, yet you use emacs?

23:37 islon: yeah i know

23:38 dnolen: justinko: barely maintain. I was hoping more people would step up to help me since it's so simplistic (thanks to cake). Oh well, the TextMate people seem to use and like it well enough.

23:38 islon: but i want to apply and to a seq

23:39 dnolen: ,(every? [true false false])

23:39 clojurebot: java.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$every-QMARK-

23:39 cemerick: islon: use (every? boolean [true true false …])

23:39 dnolen: ,(every? identity [true false false])

23:39 clojurebot: false

23:40 dnolen: ,(every? identity [true true true])

23:40 clojurebot: true

23:41 gko: technomancy: OK... but how do devs using both CL and Clojure manage this? My solution is to define a function slime, which will ask me if I want to use CVS (for CL) or ELPA (for Clojure) version and load the appropriate version... But then, I can't use the other version without side effects (after reloading) in the same Emacs session...

23:41 islon: cemerick: thanks!

23:42 cemerick: islon: dnolen's is semantically the same, FWIW

23:42 dnolen: gko: I think the CL / Clojure crossover is small, thus the state of things.

23:42 islon: ok

23:43 dnolen: personally I just use LispWorks Personal Edition if I'm messin' w/ CL. Nicer than Slime anyhow and you still get all the Emacs commands.

23:47 gko: dnolen: I use SLIME with LW Pro with slime-connect, because I can't have the listener and editor in the same window.

23:50 dnolen: gko: I see. Yeah that stinks. The more CL people use Clojure, hopefully the more the SLIME folks care to keep things compatible. I remember I tried in the early Clojure days at running both, but it was painful and I gave up.

23:51 symbole: Wasn't somebody working on an editor for Clojure?

23:51 dnolen: symbole: I think there's been a couple of attempts but nothing with legs.

23:52 symbole: Must be a diffucult project, considering that it has to be quite extensible.

23:52 * dnolen never thought he'd actually have to use trampoline ...

23:56 cemerick: symbole: as in, a reimagination of emacs but using Clojure instead of elisp?

23:57 dnolen: symbole: I think a full fledged extensible editor would be too ambitious. Something lightweight, like text editor + REPL would be welcome for newcomers. DrRacket's editor is a good reference point.

Logging service provided by n01se.net