#clojure log - Jul 23 2011

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

0:29 semperos: anybody else getting errors like this when trying to compile ClojureScript? https://gist.github.com/1101014

0:36 tufflax: Say I have a vector, and I want to find the index of the first element that satisfies a predicate, like so: (index odd? [2 4 3 6]) => 2. Is there such a fn?

0:44 semperos: tufflax: can you explain why you need the index?

0:44 or what you need it for?

0:46 tufflax: I have a list of maps, and I want to find a map in the list that satisfies the predicate, so that I can make a new list with that map updated, using update-in.

0:46 s/list/vector/

0:46 lazybot: <tufflax> I have a vector of maps, and I want to find a map in the vector that satisfies the predicate, so that I can make a new vector with that map updated, using update-in.

0:48 tufflax: semperos you see? or is there a better way?

0:49 semperos: I don't know how complex your data structures are

0:49 tufflax: Why does is matter?

0:49 semperos: sorry, first sentence of a longer answer :)

0:50 is there any reason you can't do a for comprehension over the vector of maps

0:50 have a conditional (your current predicate) that "finds" what you're looking for in the target map

0:50 make the update to the map right there

0:50 then just do (into []) if you actually need the sequence to be in vector form

0:50 if you have code, happy to take a look

0:51 tufflax: Hmm, I haven't thought about it, maybe... I don't use for often. :p

0:51 ihodes: or take the `first` of a `filter`ed list

0:51 semperos: very rare that you need to make a change to a datastructure in Clojure in two steps like that

0:51 speaking to tufflax

0:52 tufflax: ihodes but then i dont get the index

0:52 semperos: tufflax: code?

0:52 ihodes: tufflax: you actually need the index? you seems to be trying to treat the immutable data structs like mutable structs...

0:53 tufflax: ihodes no i don't want it to be immutable, i just wanna update it and get a new value. :p

0:54 mutable*

0:54 not immutable

0:54 semperos: tufflax: here's an overkill example using the vector of num's you used above

0:54 https://gist.github.com/1101032

0:55 that returns a lazy seq, which you can make into anything you want

0:55 that returns (2 4 "foo" 6)

0:55 no index or second-pass needed to make an update

0:57 tufflax: i see, but using 2 simple functions to do something that can be made with 1 more complicated function/macro is not necessarily bad :p Thanks, I'll get back with what I end up with

0:57 semperos: not sure I understand, but okie dokie :)

0:58 tufflax: when u talked about "second-pass needed" it sounded like you didn't like the idea of using 2 fns for something like that

0:58 whatever :p

0:58 semperos: code sniff

0:59 more than likely not a functional way to handle it, using things like for is idiomatic

0:59 but go for what works for you, Clojure is nothing if not practical

1:00 tufflax: Believe me, I'm all about elegance, just didn't think about for at first :)

1:00 ihodes: (for [x [1 2 3 4 5 6] :when (odd? x)] (DOSTUFF x))

1:00 is the way to go.

1:00 semperos: even nicer, for a simple predicate

1:01 ihodes: for any non-anonymous predicate

1:01 tufflax: But that wouldn't return the whole origial with a few updates

1:01 ihodes: true, sorry tufflax

1:01 tufflax: np ;)

1:01 ihodes: you can map a function that handles the cases over the list, too

1:01 semperos: obviously if you're using for against a seq of maps

1:02 you'll need to return a map inside the for

1:02 tufflax: yeah

1:03 semperos: I agree with ihodes , you can try using map as well, see which fits better

1:05 https://gist.github.com/1101032 with equivalent `map` version

1:05 tufflax: semperos ihodes im making a simple time tracking app, heres the gist of it, but i forgot a paren :p http://pastebin.com/3nhQCDL5

1:06 semperos: tufflax: are you trying to update the atom with that code?

1:06 tufflax: yes

1:06 semperos: you need to use swap! to do that

1:06 tufflax: what about it?

1:07 well... need is a strong word. why do i need to?

1:07 semperos: you can't update Clojure's concurrency data structures without their proper functions

1:07 you've assigned x the value of your data atom at that moment in time

1:07 tufflax: yeah i know i know

1:07 semperos: ok

1:07 tufflax: but im gonna use reset!

1:08 semperos: sorry

1:08 gotcha

1:13 tufflax: https://gist.github.com/1101052

1:15 tufflax: yeah that's nice too. I usually go for 'map' before 'for'.

1:15 semperos: however this doesn't feel quite right, as it seems like when calling reset! you could be overwriting other tasks that started/stopped, so some kind of in-place swap! is probably better

1:15 signing off for tonight, have fun

1:17 tufflax: bye

3:54 chouser: I was under the impression lein would add to my classpath any dirs in my checkouts/ dir. Is this not true?

3:55 hiredman: it assumes checkouts are leins projects, so checkouts/project/src

3:55 * chouser despairs

3:59 chouser: hm, it doesn't seem to be adding anything from checkouts at all. Do I need to include same-named items in my project.clj deps or anything?

4:00 hiredman: possibly, it that is what it was designed for

4:01 * chouser tries something else

4:01 hiredman: you can just but a symbolic link in lib/

4:01 chouser: ooh!

4:01 hiredman: (will get cleared whenever you fetch deps though)

4:02 ^- entirely too excited about that

4:02 chouser: I'm getting desperate

4:03 hiredman: not desperate enough to jar it up and mvn install into ~/.m2?

4:03 chouser: I'm trying to deploy to heroku

4:04 hiredman: :|

4:04 chouser: besides, thinking about make a .jar of clojurescript makes my head hurt

4:04 hiredman: mmm

4:04 yes

4:06 if only the shiny new clojure(script) was easily usable from the old and neglected clojure

4:06 chouser: ok!

4:06 found a horrible hack of a symlink that gets it working

4:18 triyo: Is there a recommendation for how best to incorporate the ClojureScript libs into a new/or existing leiningen-based project?

4:18 chouser: funny, I was just trying to do that.

4:18 I can't imagine what I'm doing would be recommended by anyone.

4:19 triyo: As they say, great minds think a like. ;-)

4:19 *alike

4:20 I gather you are running emacs with swank-clojure?

4:20 chouser: not even a little bit

4:20 fliebel: Doesn't ClojureScript just use maven? :(

4:20 chouser: I tried a git submodule first, but heroku doesn't support that

4:21 so now I've got a subtree merge and a well-placed symlink. I think that'll work.

4:21 hiredman: fliebel: rich actually said something like "I hope maven never gets near clojurescript"

4:21 triyo: nope, no trace of maven in the source

4:21 hiredman: and something about not wanting clojurescript in jars

4:22 no idea what he is thinking

4:22 the most obvious thing (to me) once you have clojurescript is to incorporate it into existing clojure projects, but it just doesn't fit in with the tools

4:22 fliebel: hiredman: That's just silly if you ask me. The compiler still lives in JVM land, deal with it.

4:23 hiredman: it's a silly old world

4:24 fliebel: ... then rewrite the compiler in cljs, then we can start using npm

4:24 triyo: So let me get this straight. No jar exists for the src/ dir of the ClojureScript project?

4:24 hiredman: triyo: that would be too simple

4:24 fliebel: Anyway, how does one contribute to it? No pull request I'm afraid?

4:25 chouser: fliebel: same as clojure. attach a patch to a jira ticket

4:26 fliebel: hm, okay. I'm thinking a zipper for the dom would be a fun exercise to get started.

4:27 Is the XML zipper even supposed to work? Or do we need to port clojure.data.xml first?

4:30 triyo: Anyone else impressed with the ClojureScript twitterbuzz sample?

4:33 The code is far more readable than what you would have to write in JavaScript or even GoogleClosure to achieve the same result.

4:40 Raynes: I find that amusing when they actually put the goog libraries in a jar when they pull them down.

4:44 triyo: I'm just gonna copy the src/ and lib/ to my project until there is a better solution for ClojureScript dep.

4:48 zakwilson: It seems strange that the core Clojure developers are putting a bunch of work in to this JS port when Clojure 1.3 still isn't done.

4:48 I don't mean that as a complaint; I really have no idea what the thinking behind that is, and it may indeed be very sound. It just seems a little odd.

4:48 Raynes: The work itself probably has something to do with why this release cycle has taken longer than the others.

4:49 Likewise. I think ClojureScript is awesome.

4:49 It couldn't have come at a better time for me.

4:50 zakwilson: I have yet to try it, but most of my front-end stuff is pretty light on JS.

4:50 Raynes: I'm into it for non-web reasons.

4:50 More CLI-related reasons.

4:51 hiredman: well, relevance is a webshop, I believe

4:51 Raynes: Nodejs.

4:51 zakwilson: Oh... so running compiled apps on V8 instead of the JVM for faster startup?

4:52 Raynes: Yes.

4:53 hiredman: I've been fiddling with cocoa+webkit+javascript which clojurescript might in

4:53 fit in

4:53 zakwilson: I don't have that as a problem yet, but clojurescript could be a way.

4:53 Right now, I want to to a self-join in clojureql and suspect I might have to hack clojureql itself to make it happen.

4:54 hiredman: I still can't believe you are still using that

4:55 zakwilson: It's really nice except for the lack of self-joins.

4:56 How do you interface your Clojure app with your rdbms? (code snippet requested)

4:57 hiredman: clojurebot uses a old version of clojureql from at least a year ago, but it just works so I am not really motivated to rip it out (but I plan to)

4:58 zakwilson: Why do you plan to get rid of it?

5:00 hiredman: because it's and ancient version, the code that uses it is ugly, and I am more likely to use clojure.whatever.jdbc

5:00 (and I think Lau is a tool)

5:01 zakwilson: How would you generate SQL from your Clojure code?

5:01 hiredman: just strings

5:01 zakwilson: Yech.

5:02 hiredman: *shrug* all in one place in the data storage layer

5:02 zakwilson: I don't even hate SQL that much (It's kinda ugly, but I've seen worse things), but I really hate having another language in my code as strings.

5:02 hiredman: I've sort of thought about using an index instead of a db (lucene)

5:03 but clojurebot is hardly taxing on anything

5:03 zakwilson: That might be appropriate for the application in question. I've never used lucene.

5:08 amalloy: hiredman: mongodb? has been pretty natural and simple for all my uses, though i don't know what clojurebot's usage pattern is like

5:09 hiredman: derby is nice, no external dependency

5:09 I don't really want to install anything

5:10 ejackson: i'll join the chorusline and say how much I've enjoyed Redis :)

5:11 ibdknox: Redis has served me well too

5:14 zakwilson: I'd really like to use a graph database as a general purpose database for a website. Neo4j, the most obvious implementation has a few drawbacks though, like bad performance with date comparisons.

5:15 And you can't easily swap out one graph database for another, even if another appeared that was better suited to the task.

5:16 This is really making me want to write a graph DB that's awesome as a general-purpose backend, but I wouldn't even know where to start.

5:16 Oh, and I'm lazy.

5:31 amalloy: zakwilson: jiraph?

5:32 zakwilson: amalloy: how production-ready is that?

5:32 amalloy: zakwilson: geni has been using it for some time

5:33 zakwilson: If I wanted a general comparison between it and Neo4j, is there a place I could find one?

5:33 amalloy: you could ask ninjudd, probably. i imagine he looked at neo before writing jiraph

5:35 zakwilson: I actually saw jiraph earlier and thought it looked like an example of something I'd read to see how a simple graph DB is implemented. My impression was it was just a toy, but I have little to back up that impression.

5:43 Raynes: zakwilson, amalloy: The reason we have Jiraph is because Geni needed the revision stuff in Jiraph but Neo4j doesn't have it.

5:43 zakwilson: It is absolutely production reader.

5:43 ready, even.

5:43 amalloy: oh yeah, revisions. that's some cool stuff

6:25 ivan: which OS X file manager is Hickey using in his ClojureScript presentation?

6:33 ejackson: forklift

6:36 ivan: ejackson: thanks

7:48 Cozey: Hello. What SQL db access method do You use? ClojureQL, contrib.sql, other?

8:38 phenom_: hey folks, any idea on how clojure is doing witht he jdk7 dev preview?

9:17 gfrlog: Cozey: I use both of those

9:18 romanroe: hi

9:19 How can I instantiate a Java class, passing the args as a list? E.g. like (apply str [1 2 3])

9:26 gfrlog: romanroe: is it a fixed length?

9:26 romanroe: yes

9:26 gfrlog: well the quick and dirty way would be to do it manually: (let [[a b c] foo-args] (new Foo a b c))

9:27 I don't think it could get much better than that. Maybe a macro could give you something more flexible...

9:28 romanroe: ah, well, its fixed length, but not known when I write the code

9:28 Scriptor: right, I don't think apply works with java methods/constructors

9:28 gfrlog: romanroe: but you know that there will be a constructor matching the args?

9:28 \

9:28 romanroe: I am currently working on a macro without success :-/

9:28 gfrlog,, yes

9:29 gfrlog: romanroe: (defmacro construct [class args] `(new ~class ~@args))?

9:29 that probably doesn't work actually

9:29 romanroe: gfrlog, tried that, didnt work

9:29 gfrlog: since the args wouldn't be a list literal

9:29 is there an upper bound on the list size? :)

9:29 romanroe: exactly

9:29 ye

9:30 yes

9:30 gfrlog: actuaally I feel like this could be done better with the macro

9:30 if you could get args evaluated then that would work...

9:31 and I think a macro can do that but I forget how

9:31 romanroe: gfrlog, when you remember, tell me :-)

9:32 gfrlog: romanroe: of course

9:32 romanroe: gfrlog, what about (eval args)?

9:33 gfrlog: romanroe: I'd wager at least five dollars that wouldn't work

9:33 romanroe: let me try that...

9:33 gfrlog: also every time you use eval somebody in #clojure yells at you

9:34 jjido: don't think you can use macros for Java constructs

9:34 gfrlog: jjido: I think that's too vague to be true

9:34 Bronsa: you could use the #= reader macro

9:34 romanroe: dont know #=, will check

9:35 btw, it seems to work with eval

9:35 gfrlog: what's the macro look like?

9:36 Vinzent: what does #= do?

9:36 romanroe: gfrlog, just a sec

9:36 gfrlog: Vinzent: makes the reader evaluate a form

9:36 romanroe: gfrlog, https://gist.github.com/1101437

9:37 Vinzent: didn't know that

9:37 gfrlog: Vinzent: I didn't either for a long while

9:37 Vinzent: and I've never used it

9:37 Vinzent: the primary use case I've heard of is for printing obscure objects in a reader-compatible way

9:38 Bronsa: with print-dup?

9:38 gfrlog: yeah that kind of thing

9:38 so a (sorted-set 1 2) would print as #=(sorted-set 1 2) instead of #{1 2}

9:38 Bronsa: i think you could use it also to force evaluation of some args to a macro

9:39 gfrlog: Bronsa: how so?

9:39 * gfrlog has new-apply in his repl and can't think of any java objects to try it out with

9:40 Bronsa: i mean (macro #=(this will be evaluated) (this wont be evaluated))

9:40 Vinzent: interesting (but don't think I'll ever need it)

9:40 gfrlog: Bronsa: it wouldn't let you do anything at runtime

9:40 romanroe: gfrlog, (defrecord Foo a b c)

9:40 gfrlog: so if romanroe has a list that he constructed at runtime, I don't see how that could help him

9:41 romanroe: gfrlog, (new-apply Foo my-list) given (def my-list [1 2 3])

9:41 Bronsa: oh right

9:41 gfrlog: romanroe: in particular I'd like something with two different constructors...

9:42 romanroe: but I probably owe you $5

9:42 romanroe: gfrlog, he, donate them to clojure :-)

9:44 gfrlog: I'm watching rhickey's recent talk, and coincidentally he just mentioned that eval is something you don't really use in production :)

9:44 I'm sure there's got to be a better way...

9:47 Bronsa: but

9:47 romanroe: gfrlog, yep and I just noticed that it doesnt work with locals, only with top-level vars

9:47 gfrlog, which makes sense

9:48 gfrlog: romanroe: yeah, that's actually what I was expecting when I said it wouldn't work. I guess I didn't test it well enough.

9:48 * gfrlog undonates his $5

9:50 romanroe: gfrlog, lets donate $2.5 each

9:51 gfrlog: to minimize transaction costs we could flip a coin and the loser donates $5

9:52 romanroe: gfrlog, ok, just did not, you lost... sorry

9:53 err, did *it*

9:53 gfrlog: romanroe: no we have to do it trustlessly

9:53 romanroe: gfrlog, to keep it simple, I guess I fall back to reflection for now. clazz.newInstance etc.

9:54 gfrlog: romanroe: write a function that enumerates all possible arg-lengths

10:00 distributed-coin-flip-utility:

10:00 X=$(uuidgen); echo $X; echo "tails $X" | sha256sum

10:01 I suppose printing in the opposite order would be more natural

10:02 this one's better; X=$(uuidgen); echo "tails $X" | sha256sum; echo "tails $X"

10:14 Cozey: gfrlog: regarding sql db's - do you guys use anything else - orm'ish etc?

10:18 hedele: hello guys. I'm a new clojure programmer and need help finding open source projects to contribute to/learn from. I've googled a lot but most people suggest that clojure is in need of good libs and one should contribute to them. The thing is I don't consider myself adept for library development (apart from game related stuff I plan to do later on). I'm not a great programmer, even tho I've been programming since for ever I can't

10:18 translate most of what I do to clojure although I really want to use it. I mostly do game related stuff and one off scripts. I do not have (yet) an idea for a service etc. which I can develop its backend in clojure. What I am asking is that is there any end user apps you know that is written in clojure? Anything will do, from an IM client to note taking app

10:19 sorry for the wall of text

10:21 as I don't have any project ideas I want to do, any library I think clojure lacks and I need or an application that I use which I want to develop further it is hard for me to get motivated and experiment with the language

10:21 solving project euler problems is only fun to a limited degree :/

10:23 (you may ask that what am I doing with a language I have no use for. true but I really like it and hope to use it heavily later on, but when the time comes I want to be good at it)

10:26 maybe the problem is clojure developers are generally very intelligent and not interested in trivial apps (which clojure may not be suitable for) that I'm looking for

10:27 dnolen_: hedele: if you're into games Penumbra is fun, Clojure OpenGL wrapper. clj-processing as well. ClojureScript makes the one off script story more feasible (but there's a lot of work to done on it before it day to day usable)

10:30 hedele: dnolen_: oh I'm knee deep in ugly languages for my game development and want to get away from it a little, not that I don't find clojure suitable for it

10:31 you know, if you are learning languages like c and python it is pretty easy to do that. just open pidgin, your favorite torrent client etc and just dive in

10:32 I'm looking for something which is not developer oriented and I can use, examine its code and improve further

10:33 it feels weird to ask "is there anything written in x language that I can use as an end user" but I think I'm doing that :)

10:33 dnolen_: hedele: most of the libraries are end user focused so I'm not sure what you mean by that.

10:34 hedele: dnolen_: oh, I meant non programmers (even non tech savvy) by that.

10:34 dnolen_: hedele: you mean like applications.

10:34 hedele: for example if I was learning common lisp I cound just dive in something like stumpwm (a window manager for X)

10:35 yeah, sorry for the confusion

10:35 Vinzent: there is a clooj - simple clojure-written ide

10:36 ah, non-programmers

10:36 hedele, do you want desktop or web app?

10:37 hedele: Vinzent: I would prefer a desktop one but either is fine if you think web apps as a app with a local browser interface instead of a web service

10:39 my brain is hard-wired to emacs, I'll check clooj out but I wouldn't want to develop something I would never use and mess with other developers good intentions :)

10:40 Vinzent: hedele, i just don't think that java platform is something very suitable for desktop apps. hm, let me think

10:40 jsnikeris: Hi all. Is there a way to destructure a vector such that the last few elements are bound? Something like: (let [[& more x y z] [0 1 2 3 4 5]] [x y z]) -> [3 4 5]

10:41 Vinzent: hedele, by the way, about emacs, you can implement emacs-like editor in clojure (but it's for programmers again)

10:42 jsnikeris, probably not (I've never seen such destructing)

10:43 jsnikeris: Vinzent: OK, thanks.

10:44 hedele: Vinzent: I disagree. I've played with java for a few months before diving in to clojure and most of my prejudgements disappeared. Apart from the startup time there are bunch of useful open source everyday apps. But sadly I believe one continue to hate a crude swing interface and java app until he develops one himself :)

10:45 yup, I'm also don't know much so I don't think I can rewrite any subset of emacs that would prove useful for anyone

10:46 I also*

10:48 Vinzent: hedele, true :) but we must not forget that there is also SWT (but, anyway, I believe if someone see java in the dependencies of some app, he goes and googles for java-free analogue)

10:49 hedele, I think auto-indentaion, syntax highlighing and integration with lein would be already very usefull for beginner clojurians

10:50 hedele: it is a sad fact tho, I was one of those people until a few months even though I had java installed. People still think slow apps with ugly gray interface when they think of java :(

10:50 btw there is also qt jambi

10:53 maybe I should force myself to have an idea for a web service to run on heroku. I don't think that would work out well tho. or I can duplicate an established service to make a version of it aimed at my non english speaking home country and acquire lawsuits :)

10:58 Vinzent: as a faithful Gnome user I feel a vague discomfort when I see the word "qt' :)

10:59 raek: jsnikeris: you can destructure the result from calling rseq on the vector

10:59 ,(let [[x y z] (rseq [:a :b :c :d :e])] [x y z])

10:59 clojurebot: [:e :d :c]

10:59 Vinzent: hedele, it's a good idea, but you also need something not very large, right?..

11:00 jsnikeris: ,(doc rseq)

11:00 clojurebot: "([rev]); Returns, in constant time, a seq of the items in rev (which can be a vector or sorted-map), in reverse order. If rev is empty returns nil"

11:01 jsnikeris: raek: ah, clever. thanks!

11:01 hedele: Vinzent: I believe you shoudln't tho. It is a breeze to develop with qt framework compared to GTK, it is not a big dependency if you don't use KDE libs and has a great engine that uses gtk widgets to draw (I believe it is the default everywhere except KDE)

11:02 raek: just in case you din't know: you *can* use "native" look and feel for swing apps

11:02 hedele: on the other hand kde look and feel of gtk is not as good (qt one is almost pixel perfect)

11:03 Vinzent: hedele, well, but do we really need it, when there is swt? or qt gives some additional benefits compared to swt (not just native LaF)?

11:03 raek: (I'm not saying swing is the best gui framework out there)

11:04 Vinzent: raek, usually it looks not very "native", misc details is different, like fonts, margins, etc

11:04 hedele: raek: I find it way slower for some reason and it doesn't integrate well (I believe doesn't use gtk font rendering for instance, and somehow look out of place) so I usually switch it to nimbus

11:04 it looks alien but at least it is good and fast

11:05 Vinzent: you are right btw, such a project would be too big for me atm

11:05 Vinzent: +1 for nimbus (also "alloy" or smth like is not bad)

11:07 raek: yeah, the font rendereing is important

11:08 meegee: also it doesn't use system menubar color and stuff

11:08 Vinzent: hedele, hm, one my friend told me about little app for beginner writers: it highlights the same words, so writer can see if he's uses one too much

11:09 raek: really? I might take my utterance back.

11:09 Vinzent: maybe it's possible to improve this somehow and build something like "utils for beginner writers" (just an idea)

11:09 gfrlog: Cozey: most of what I've done has been a solo effort. I haven't used any additional ORM; just maps.

11:12 meegee: raek: I think so. I can't test it right know because I've changed the default laf to nimbus system wide but I remember loathing its appearance and unresponsiveness even tho I mostly use gtk apps

11:13 Vinzent: My initial idea was finding an application to use and contribute to but I might just do something like that, thanks

11:16 (I'm hedele btw, forgot my long running irc instance on usealice.org and logged in using erc ignoring my unstable connection)

11:17 Vinzent: meegee, I believe he will open source it so you'll be able to join the project soon :)

11:17 meegee: oh sweet

11:21 Vinzent: also, it'd be really cool if someone developed simple cross-platform convenient note editor.

11:23 meegee: I believe it is something you just open up an app, a website or Mx-org-mode, write your note down and close quickly

11:24 there are already many people that did it way better than clojure can handle :)

12:17 kryft: Hmm, do you happen to know how useful hyper-threading is if you're running several (> n_cores) independent processes, such as several instances of the same algorithm with different data or parameter values?

12:18 Or a pmap in clojure or something. :)

12:37 corbbet: with emacs+slime+swank, a call to (read) will give an EOF while reading runtime exception. is that expected or am i doing something wrong?

12:38 so im not able to run clojurescript from within the clojure repl with swank (although it works fine in the terminal)

12:53 tomoj: corbbet: huh, me too

12:54 I didn't expect it

12:54 corbbet: tomoj: seems to be a swank issue

12:54 tomoj: I thought it used to work if you went to the jvm in the terminal and typed stuff in

12:54 corbbet: yeah that works fine

12:54 tomoj: I mean, the one `lein swank` is running in

12:54 corbbet: oh hmm

12:55 tomoj: but it doesn't for me now

12:55 are you using clojure-jack-in or something?

12:55 corbbet: tomoj: nope, just lein swank

12:55 tomoj: oh, right

12:55 corbbet: using swank 1.3.1, ill upgrading to the snapshot

12:55 ill try upgrading*

12:57 hmm 1.4.0 has the same issue it seems

12:58 tomoj: what does clojurescript call (read) for?

12:58 corbbet: for its repl loop

12:59 tomoj: oh.. I wouldn't expect a custom repl to work inside of slime-repl

13:02 kephale: tomoj: clojurescript repl works inside slime-repl

13:02 corbbet: kephale: what version of swank are you using?

13:02 kephale: even a simple (read) fails for me

14:59 jsnikeris: Hi all. I'm having some trouble using the checkout dependencies feature of leiningen. I have a directory named "checkouts" in the same directory as my project.clj. In this directory, I have a symlink to another project root. When I run "lein deps" it tries to download the symlinked project from clojars. I'm expecting it to build/install the symlinked project, and grab the resulting jar instead of looking for the jar on clojars. Any

14:59 ideas?

14:59 danlarkin: working as intended

14:59 jsnikeris: danlarkin: what am I doing wrong?

15:00 danlarkin: nothing

15:00 you're just misunderstanding what you see

15:00 checkouts/ doesn't "replace" your regular deps

15:01 it will just come first on the classpath

15:04 jsnikeris: danlarkin: hmm. OK. So I need to do a manual build/install of the JAR first, so that I don't get these dependency errors

15:05 and then after that, changes will be picked up automatically

15:05 danlarkin: no, that should not be necessary

15:06 fair warning: I haven't actually ever used checkout deps, but I think I understand how it works

15:27 fliebel_test: lazybot: ping!

15:27 &(+ 1 1)

15:27 lazybot: ⇒ 2

15:27 gfrlog: fliebel_test: ##(println "pong")

15:27 lazybot: ⇒ pong nil

15:29 fliebel_test: Can you believe it? IRC from iChat!

15:42 jsnikeris: Now I'm really confused. I removed the checkouts/ directory, 'lein install'ed the dependency. 'lein deps' pulls the dependency into my lib directory. Browsing through the jar, everything looks good. However, a 'lein test' is giving me a ClassNotFoundException for the dependency.

15:48 arohner: jsnikeris: make sure the class is in the jar?

15:49 jsnikeris: arohner: browsing the jar I see: net/cgrand/enlive_html.clj

15:49 arohner: my error is: java.lang.ClassNotFoundException: net.cgrand.enlive-html

15:49 arohner: jsnikeris: class? how are you trying to load that?

15:50 i.e. what clojure command are you using?

15:50 jsnikeris: arohner: I'm just trying to run a simple test: lein test. Let me see if I can get a REPL up

15:51 arohner: right, but what clojure command are you using to load enlive?

15:52 jsnikeris: (require '[net.cgrand.enlive-html :as e]) works fine

15:53 (ns ... (:require [net.cgrand.enlive-html :as e]))

15:55 arohner: jsnikeris: make sure lein test isn't loading any files you don't expect. or, make sure the exception is in the file you expect to test

15:55 lein test loads eveything in test/, maybe an unexpected file is being loaded

15:56 jsnikeris: arohner: ahh I was closing the ns declaration before the (:require [net.cgrand.enlive-html :as e])

15:57 ,(:require [clojure.core :as e])

15:57 clojurebot: java.lang.ClassNotFoundException: clojure.core

15:58 jsnikeris: ,(:require [clojure.test :as e])

15:58 clojurebot: java.lang.ClassNotFoundException: clojure.test

15:59 jsnikeris: ,clojure.test

15:59 clojurebot: java.lang.ClassNotFoundException: clojure.test

16:00 jsnikeris: arohner: ClassNotFoundException had me barking up the wrong tree. Thanks for the help

16:00 arohner: np

18:09 qbg: Is there a map-contains relation in core.unify?

18:09 I mean core.logic

18:11 neeson: Hey everyone, I've got a random question. I launched a website way back in the old days (2008) using Clojure. My impression from back then was that the syntax was wonderful, but debugging was frustrating (I wasn't using swank, just the REPL). Has much changed since then (0.9 version)?

18:12 dsantiago: neeson, the best option right now is probably ritz, github.com/pallet/ritz .

18:12 neeson: Checking it now now...

18:13 out now, rather :)

18:14 dsantiago: It still has some problems.

18:14 technomancy: there's also CDT

18:14 dsantiago: Clojure's locals clearing will pretty much remove most of the useful information in the stack frames when you try to set breakpoints.

18:15 neeson: I think maybe the biggest issue was that I'm a Vim guy, and so I was going against the grain w/ regards to tools

18:16 I remember that things that you really need (like line numbers in error reports) simply didn't work from the REPL

18:16 dsantiago: Yeah, it's still spotty.

18:17 neeson: I'm wondering if I should give it another go, but first learn enough emacs to get by. Seems like an awefully big learning curve though

18:17 mdeboard: I think I'm going to try to rewrite some js I wrote for work in cljs

18:17 technomancy: well, it's more like defns entered from the repl don't have line numbers. calling functions defined in a file from a repl is fine

18:17 mdeboard: wish me luck

18:17 * mdeboard throws a smoke grenade

18:17 qbg: Line numbers should work (though macros may disturb it a bit)

18:19 neeson: Looking at CDT now - interesting. technomancy: can you say how solid it is in practice?

18:21 technomancy: neeson: I haven't used it myself. the only debugging tool I use is swank break

18:21 clojurebot: swank.core/break?

18:21 clojurebot: swank is try the readme. seriously.

18:21 mdeboard: lol

18:22 technomancy: close, but not quite

18:22 clojurebot: swank.core/break is simple debugging breakpoints with swank-clojure: http://hugoduncan.org/post/2010/swank_clojure_gets_a_break_with_the_local_environment.xhtml

18:22 clojurebot: In Ordnung

18:22 technomancy: I've never found myself needing to step through code, so cdt seems like overkill.

18:23 neeson: Right, I'm not a big tool guy. Mostly I just use line numbers and print statements. This didn't work very well back in the day

18:23 Is swank stable?

18:24 dsantiago: Ritz is what resulted when hugo duncan kept working on that stuff. It'll let you set a breakpoint right from slime, without needing to modify the code.

18:25 technomancy: the only problem I've run into with swank is related to emacs24

18:26 neeson: Gotcha

18:26 dsantiago: Neither will get around the locals clearing problems, as far as I know.

18:26 technomancy: neeson: the main problem others run into is they're reading bad documentation, so be sure to just follow what's in the readme on github.

18:26 hence clojurebot's advice above

18:27 neeson: Right

18:28 Well thank you everyone. It's great to be able to just get the gestalt - sounds like things have moved forward a bit, I'll have another look at using Clojure

18:29 technomancy: neeson: what's the website, if you don't mind my asking?

18:29 I don't remember any production use of clojure announced before the start of 09

18:29 neeson: It's down now, but it was Urbantastic.com. It got about 100 uniques a day at its peak

18:30 I used Clojure and CouchDB, both of which were pre-1.0

18:31 technomancy: cool

18:32 neeson: Yeah, I've got issues with using cool tech before it's stable :) Since then I've been using nodejs, but I miss lisp.

18:33 technomancy: were you trying to be stealthy about the fact that you used clojure?

18:35 neeson: Not particularly, just wasn't very loud about it. Here's a blog post from way back about the tech behind the site: http://bit.ly/ot3McE

18:36 technomancy: ok, so it was announced in 09

18:37 luc prefontaine's project was announced in january of 09

18:38 I think I actually remember reading this post =)

18:39 neeson: That's crazy :) I remember it got onto the second page of Reddit and the front of Hacker News

18:41 technomancy: this was just a couple months before I got a job using Clojure

18:41 neeson: I've since decided that I like Postgres more than NoSQL, and that creating the HTML on the client side wasn't a big enough win to be worth working against the grain of how the internet is set up

18:42 Well done on the Clojure job - I wouldn't have guessed that there'd have been any back then :)

18:42 technomancy: neeson: well, I think this may have been the first =)

18:42 neeson: Nice :)

18:43 Anyway, I've got to jet, but it was nice talking with you technomancy :)

18:43 technomancy: cheers

18:43 hope you get things figured out

18:43 neeson: Thanks again

19:00 dnolen_: qbg: no containso in core.logic, I don't see how Clojure maps can be dealt with in a relational manner.

19:00 devn: hey everyone

19:01 dnolen_: core.logic does support map unification, but logic vars are only allowed in the values, not in the keys.

19:04 qbg: dnolen_: A map is a function relation

19:07 mdeboard: I'm having a brainfart. What's the practice in Clojure I'm thinking of. Deconstruction? Destructuring? De... something. e.g. (let [(x, y & more) '(1 2 3 4 5)] ... )

19:07 qbg: mdeboard: Destructuring

19:07 mdeboard: thanks

19:09 amalloy: mdeboard: syntax for it is ##(let [[x y & more] [1 2 3 4 5]] (list x y more))

19:09 lazybot: ⇒ (1 2 (3 4 5))

19:10 mdeboard: But I can use any collection that has a rest method right

19:10 doesn't have to be a vector in other words

19:11 qbg: ##(let [[x y & more] '(1 2 3 4 5)] (list x y more))

19:11 lazybot: ⇒ (1 2 (3 4 5))

19:11 amalloy: that's true for the thing on the right, not the one on the left

19:13 mdeboard: coo

19:14 amalloy: and even then not strictly true

19:14 since maps and sets can't be destructured into vectors without first taking a seq view of them

19:15 mdeboard: hm

19:16 ##(let [(x, y & more) {:foo 1 :bar 2 :baz 3}] (list y))

19:16 lazybot: java.lang.Exception: Unsupported binding form: (x y & more)

19:16 mdeboard: oop

19:17 ##(let [[x, y & more] {:foo 1 :bar 2 :baz 3}] (list y))

19:17 lazybot: java.lang.UnsupportedOperationException: nth not supported on this type: PersistentArrayMap

19:17 qbg: dnolen_: Any tips on how to implement a (mathematical) function (relation) in core.logic?

19:19 amalloy: but mdeboard, ##(let [[x, y & more] (seq {:foo 1 :bar 2 :baz 3})] (list y)) will work fine

19:19 lazybot: ⇒ ([:bar 2])

19:20 * gfrlog wishes it would try calling seq before failing outright

19:22 mdeboard: gfrlog: ew

19:22 gfrlog: I don't want it trying to guess my intentinos.

19:22 intentions

19:22 amalloy: (inc mdeboard)

19:22 lazybot: ⟹ 1

19:22 gfrlog: mdeboard: what? it's no different than any other function that seqs things

19:22 it's not a guess, I just happened to use the word "try"

19:23 mdeboard: gfrlog: What if it does that and works, but the result isn't actually what I wanted to do?

19:23 gfrlog: mdeboard: what if ##(first #{3 4}) isn't what I wanted it to do?

19:23 lazybot: ⇒ 3

19:24 mdeboard: what.

19:24 gfrlog: a set isn't sequential but (first) is happy to call seq on it

19:25 mdeboard: I guess I don't see the equivalency, but admittedly I'm not thinking real hard on it.

19:26 gfrlog: I'm having a hard time countering your previous statement; it seems like you could use it to argue against any kind of flexibility in a language

19:28 dnolen_: qbg: like arithmetic?

19:28 qbg: dnolen_: No

19:29 dnolen_: qbg: what kind of mathematical relation then?

19:29 mdeboard: gfrlog: To me, there's a difference between making the design decision to say, "On the following types, allow (first) and (rest) calls. On the rest, disallow it." and short-cutting that (first)-able property of a class by having the language guess that since I called first, I *MUST* know that the object (or whatever) doesn't have that method, but go ahead and mutate the object and call it anyway

19:30 That turned convoluted after the first quote

19:31 gfrlog: Is clojure actually calling (first (seq #{1 2 3}) when you type (first #{1 2 3}) ?

19:31 amalloy: mdeboard: i think the whole statement was a mess anyway

19:31 mdeboard: amalloy: :|

19:31 gfrlog: mdeboard: I assume so

19:31 amalloy: mdeboard: no, it's not. first is implemented in terms of seq

19:31 mdeboard: gfrlog: I doubt it

19:32 amalloy: first could be (but isn't) implemented as (.first (seq x))

19:32 dnolen_: ,(source first)

19:32 gfrlog: ^ that's essentially what I was thinking

19:32 clojurebot: java.lang.Exception: Unable to resolve symbol: source in this context

19:32 gfrlog: dnolen_: it just delegates to clojure.lang.RT

19:32 amalloy: gfrlog: which actually does the seq(x).first() call, i think

19:33 you could make nth do that, but getting it to behave nicely in a destructuring context is actually not easy

19:33 if you always call seq on everything, you lose fast-random-access on objects that supported it

19:33 gfrlog: amalloy: is nth the difference between types that will destructure and won't?

19:33 dnolen_: qbg: can you explain what you want to do?

19:33 amalloy: yes

19:34 gfrlog: (sequential-destructure of course)

19:34 qbg: dnolen_: Basically containso

19:34 amalloy: nth and nthnext; i'm not sure how nthnext is implemented

19:34 qbg: (defn geto [k v m] (membero [k v] m)) allows for k to be mapped to v and v'.

19:34 dnolen_: ,(seq {1 2 3 4})

19:34 clojurebot: ([1 2] [3 4])

19:34 qbg: But containso would not

19:35 gfrlog: amalloy: so what happens with (let [[a b & cs] (vec (range 200000))] cs)?

19:35 dnolen_: qbg: a proper containso is possible if you call seq on the map first.

19:35 qbg: I would want (run* [q] (containso :a 1 q) (containso :a 2 q)) to return an empty sequence

19:35 amalloy: gfrlog: i think it uses nthnext three times, but try it and see

19:36 &(destructure '[[x y & more] foo])

19:36 lazybot: ⇒ [vec__9907 foo x (clojure.core/nth vec__9907 0 nil) y (clojure.core/nth vec__9907 1 nil) more (clojure.core/nthnext vec__9907 2)]

19:36 gfrlog: amalloy: returns a clojure.lang.PersistentVector$ChunkedSeq

19:36 does such a seq have fast nth?

19:36 dnolen_: qbg: it would since :a is not a sequence.

19:37 amalloy: i don't think so

19:37 but the vec you started with did

19:37 dnolen_: qbg: a more efficient solution might be possible once I get CLP(X) into core.logic.

19:37 qbg: dnolen_: containso here is key-value-map

19:37 gfrlog: amalloy: okay, so the criticism about losing fast-nth is not a reason to not call seq for destructuring

19:37 amalloy: I wasn't sure if you meant it that way or not

19:37 amalloy: you're misunderstanding

19:37 it is a reason for that

19:38 dnolen_: qbg: ? what are the arguments to containso ?

19:38 gfrlog: amalloy: okay. what am I missing?

19:38 amalloy: you make the destructuring *itself* slower, by calling seq on it before you call nth on it

19:38 qbg: dnolen_: First a key, then a value, and then a map

19:38 amalloy: rather than losing fast-access to the thing you get after destructuring

19:39 gfrlog: amalloy: I guess I don't see why you need to call nth on something when destructuring

19:39 amalloy: it puzzles me sometimes too. that's how the current impl works though

19:39 qbg: dnolen_: (containso k v m) -> (== (get m k) v) essentially

19:40 gfrlog: amalloy: okay. so this isn't a principled argument, just about the implications given the current implementation?

19:40 amalloy: it seems like it could be implemented all in terms of seq

19:40 dnolen_: qbg: have you looked at the logic starter by ambrose?

19:41 qbg: dnolen_: You mean https://github.com/frenchy64/Logic-Starter/wiki

19:41 If so, yes

19:42 amalloy: gfrlog: i think so. it would be an interesting exercise to rewrite destructure with just seq

19:43 gfrlog: amalloy: for lists, I would think nth would be _less_ performant

19:43 amalloy: but destructure is an incredibly dense/convoluted thing

19:43 gfrlog: for sure

19:44 gfrlog: not that it makes much difference for nearly any common case.

19:45 amalloy: gfrlog: try asking on clj-dev if there's a technical reason to prefer nth over first/next, and work up a patch if not

19:45 gfrlog: amalloy: but then I'd have to sign that CA that's been on my desk for the last week

19:45 triyo: I'm trying ClojureScript with (goog.net.XhrIo/send url callback)

19:46 amalloy: i think it would be a better implementation, and as a side effect (har har) would solve the problem you've been having

19:46 gfrlog: amalloy: changing the behavior wouldn't be acceptable though would it?

19:47 I guess I assumed it is the way it is because somebody disagrees with me :)

19:47 triyo: Then I call (.getResponse (.target %)) . This returns a ... function (){try{return this.a&&this.a.response}catch(a){return E(this.e,"Can not get response: "+a.message),i}}

19:47 This seems very wrong..

19:47 Is the a js to clj process that I'm missing

19:49 well actually it doesn't seem wrong. It just seem that I have to have the returned function evaluated via the browser. However, it still seems a bit hackish.

19:50 MY return type is html

19:50 I've seen Json examples that work.

19:52 amalloy: gfrlog: that's why i said "ask on clj-dev", not "fork clojure, change everything to the way you want it, and go pout in the corner"

19:53 gfrlog: amalloy: oh right

19:56 amalloy: gfrlog: not that that approach wouldn't be fun... https://github.com/clojure/clojure/pull/6

20:02 gfrlog: amalloy: that commit has a very high changes-to-effort ratio

20:02 also a high ratio of git-storage-space-to-complexity-of-change

20:09 mdeboard: gfrlog: I'm glad we can agree that I am correct.

20:09 gfrlog: (kidding)

20:10 Is cljs packaged up and onto maven or what have you so I can add it to my project.clj deps?

20:10 amalloy: gfrlog: https://github.com/MrMEEE/bumblebee/commit/a047be8 has a pretty high changes:effort too

20:10 ibdknox: mdeboard: my understanding is that it is intentionally not packaged right now

20:11 mdeboard: ibdknox: I see, thanks

20:12 ibdknox: is anyone else finding the Google Closure APIs extremely painful?

20:13 mdeboard: ibdknox: I've not touched them, but Rich mentioned the Oreilly closure book several times, so i'm assuming he either gets a kickback or it's actually required reading to understand them in a reasonable timeframe

20:13 mentioned during the cljs announcement

20:14 ibdknox: mdeboard: haha

20:14 well, they could definitely fill a book

20:14 doing anything in it seems to take an order of magnitude more code than in most other JS libs out there

20:22 mdeboard: Is it even possible then at this point to access the cljs namespaces from within emacs then?

20:22 clojure-jack-in swank errors out

20:26 ibdknox: mdeboard: rich was using emacs in the demo wasn't he?

20:26 mdeboard: Oh yeah

20:26 with some trouble :P

20:26 ibdknox: so far I've only gotten things to work when I'm in the root dir

20:28 Scriptor`: I'm convinced there's some ghost version of clojure-swank haunting my machine, pretty sure I cleaned it up and still can't do clojure-jack-in

20:32 dnolen_: qbg: fascinating, trickier than I thought, https://gist.github.com/1102041

20:36 qbg: real puzzle, glad you brought it up.

20:37 mdeboard: Is there a way to add a subdir to the classpath?

20:37 is classpath just an env var?

20:37 java magic imo

20:38 qbg: ##(doc add-classpath)

20:38 lazybot: ⇒ "([url]); DEPRECATED Adds the url (String or URL object) to the classpath per URLClassLoader.addURL"

20:38 mdeboard: deprecated in favor of?

20:38 amalloy: mdeboard: deprecated in favor of not doing it; it doesn't work reliably

20:39 qbg: mdeboard: Do you not know the subdir when you launch the jvm?

20:39 amalloy: you have to set up the classpath when you start the jvm

20:40 dnolen_: qbg: particularly cool because it's relational so we don't need to define dissoco or containso

20:40 mdeboard: Wel, I'm talking in relation to lein of course, so is further classpath specs something I can put in project.clj?

20:40 qbg: dnolan_: Cool. What does 'nm' stand for?

20:40 dnolen_: qbg: new map

20:40 qbg: Sweet.

20:40 amalloy: mdeboard: what do you want to add? more source files, more libraries, or what?

20:41 XPherior: Is it possible to use the nth function in such as way that if the parameter is out of bounds, it returns nil, as opposed to throwing an exception.

20:41 amalloy: &(nth [1 2] 5 10)

20:41 lazybot: ⇒ 10

20:42 XPherior: What's with the last two parameters? I can understand the 5, by why is 10 tacked on?

20:42 amalloy: &(doc nth)

20:42 lazybot: ⇒ "([coll index] [coll index not-found]); Returns the value at the index. get returns nil if index out of bounds, nth throws an exception unless not-found is supplied. nth also works for strings, Java arrays, regex Matchers and Lists, and, in O(n) time, for sequences."

20:42 XPherior: Oh wait, I get it.

20:42 Wow that was silly. Thanks man.

20:43 zmaril: Pardon me, why is it that "some" and "every?" have varying amounts of question marks?

20:43 dnolen_: qbg: https://gist.github.com/1102041, this is why I love relational programming

20:43 zmaril: Why not "some?" and "every?" or "some" and "every"?

20:43 dnolen_: qbg: look at the second example, we can go from a map, and infer that it must be the empty map or one that already contains the key-value pair.

20:45 hiredman: zmaril: every? returns a boolean, some returns the first result of the function you pass it or nil

20:47 zmaril: hiredman: Thank you. Just realized Programming Clojure has that same explanation right after the two functions are introduced. Not the sharpest fry in the drawer.

20:47 qbg: dnolen_: Hmm... (run* [q] (assoco [[:a 1]] :a 2 q))

20:48 dnolen_: qbg: ()

20:48 qbg: It would be cool if it was ([[:a 2]])

20:50 Then containso would be (defn containso [m k v] (assoco m k v m))

20:51 dnolen_: qbg: you making me write code that's blowing my mind :) https://gist.github.com/1102041

20:54 assoc, dissoc, contains, get all in one relation

20:56 qbg: Too bad (run 1 [q] (containso q :a 1) (containso q :a 2)) doesn't seem to terminate.

20:57 dnolen_: qbg: yr definition of containso is wrong

20:57 qbg: How should it be defined then?

20:59 dnolen_: qbg: https://gist.github.com/1102041

21:03 qbg: dnolen_: Doesn't that definition of containso say that [k v] is contained in every map?

21:04 dnolen_: qbg: you have to think relationally, if q is not ground ... yes

21:06 qbg: I mean m, you're passing q which is not ground, which gets bound to m, then containso produces the infinite list of maps with [k v]

21:06 qbg: But (run* [q] (containso [[:a 1]] :a 2)) will return (_.0) with that definition

21:07 dnolen_: qbg: q isn't involved, it never gets bound to anything, thus (_.0)

21:08 qbg: Shouldn't the return value be () as :a does not map to 2 in [[:a 1]]?

21:08 dnolen_: no, containso just checks for the existence of a key, not the value.

21:09 qbg: what you want is findo, not containso

21:09 qbg: Okay, that make much more sense.

21:10 Then why isn't containso just [m k], instead of [m k v]?

21:10 mdeboard: What do all of you do with Clojure? amalloy excepted somewhat

21:10 * amalloy is the boring one, i guess

21:10 mdeboard: In terms of types of projects

21:10 amalloy: Well, I have a good example of what you do already

21:11 dnolen_: qbg: sorry I was just riffing of what you wanted initially

21:11 qbg: I guess I didn't understand what I was asking for then :)

21:12 mdeboard: amalloy: Mostly i'm looking for things that aren't web-centric

21:12 ambrosebs: dnolen: neat!

21:12 qbg: dnolen_: Any chance this makes it into core.logic?

21:13 amalloy: mdeboard: there's lazybot too

21:13 dnolen_: qbg: I need to play around with this some more, I think there are some edge cases still.

21:13 qbg: but yes, it seems useful.

21:13 mdeboard: amalloy: Yeah I github stalked you already

21:14 qbg: dnolen_: (run 1 [q] (assoco q :a 1 q) (assoco q :a 2 q)) not halting might be one

21:15 dnolen_: qbg: can't fix that. q is not ground, and assoco definition will search indefinitely for a solution.

21:17 qbg: that problem is easily avoided by using a fresh variables for the output in both goals..

21:18 (run 1 [q0] (exist [q1 q2] (assoco q1 :a q2) (assoco q2 :a 2 q0)))

21:20 ambrosebs: dnolen_: can we assoc clojure maps?

21:20 dnolen_: ambrosebs: not without calling seq on them first no.

21:21 octe: i'm using destructuring to assign the items from a seq to variables (let [[foo bar baz] blargh])

21:21 what's the best way to modify some of those variables

21:21 for example, the list only contains a string but i know some of them are integers so i'd want to call Integer/parseInt on them

21:21 qbg: dnolen_: Assuming it was :a 1 above, then that won't return ()

21:23 dnolen_: qbg: why should it? you wanted assoco to replace.

21:25 amalloy: octe: if you want to treat some elements of a list specially, you lose a lot of the convenience functions, which are for treating them uniformly

21:26 qbg: Just pointing out that your code isn't equivalent to mine

21:26 dnolen_: qbg: it's not clear to me what you're trying to express.

21:26 amalloy: you could write (let [[foo bar baz] (map #(% %2) [identity inc identity] [1 2 3])])

21:27 qbg: (run 1 [q] (assoco q :a 1 q) (assoco q :a 2 q)) is a contradiction

21:27 octe: actually i did

21:27 amalloy: but that's really worse than just pulling the things out and working with them one at a time

21:27 octe: (let [[foo bar baz] some-seq foo (Integer/parseInt)])

21:27 (let [[foo bar baz] some-seq foo (Integer/parseInt foo)])

21:28 amalloy: right

21:30 qbg: dnolen_: (run 1 [q] (assoco q :a 1 q) (assoco q :a 2 q)) terminates if I defined assoco with defna; don't know what that breaks though

21:31 dnolen_: qbg: perhaps this is where logic programming and logic don't really follow. (assoco q :a 1 q) produces an infinite list of solutions where q contains [:a 1]

21:31 qbg: the second will always fail, causing your program to backtrack looking for another solution.

21:31 s/second/second goal

21:31 lazybot: <dnolen_> qbg: the second goal will always fail, causing your program to backtrack looking for another solution.

21:31 dnolen_: forever

21:33 qbg: defna commits to a particularly branch of the search, if that fails it won't try again.

21:33 qbg: this is not relational, you can no longer infer input values from the output value.

21:35 qbg: basically your program is a obvious contradication, you want the map that will remain the same after assoc :a 1 and assoc :a 2, no such map exists, but I'm not sure core.logic can point out that fact for you.

21:36 qbg: I could of course be quite wrong about that, I'm new to relational programming myself, a good stackoverflow question since this would plague that Prolog implementation as well.

21:36 s/that/the

21:36 lazybot: <dnolen_> qbg: I could of course be quite wrong about the, I'm new to relational programming myself, a good stackoverflow question since this would plague the Prolog implementation as well.

21:36 dnolen_: erg, heh

21:37 qbg: I just have a feeling this is because we are emulating a map with a seq of k/v pairs

21:38 ambrosebs: qbg: do you completely understand the difference between conde and conda?

21:38 dnolen_: qbg: with core.logic's current implementation I'm not sure how this could expressed in any other way. CLP(X) might help here, but I'm just guessing.

21:38 qbg: Very interesting stuff this is...

21:39 In theory, from (findo m :a 1) you derive that {:a 1} is a subset of m, and from (findo m :a 2) you derive that {:a 2} is a subset of m, and then you can derive that there exists no such m.

21:48 dnolen_: qbg: well gosh darn, I figured it out I think.

21:48 * qbg is on the edge of his seat

21:48 dnolen_: qbg: https://gist.github.com/1102041

21:49 qbg: basically enforcing that q cannot equal itself if it's changing

21:50 ambrosebs: that's awesome

21:50 qbg: It passes that test case at least!

21:51 This. Is. Awesom.

21:51 *Awesome.

21:51 mdeboard: Ok, what the heck am I doing wrong? I Just started a new project to play with clj-http. I added it to project.clj. I ran lein deps. I started writing the script with (ns foo (require '[clj-http.client :as client])) and again get this error that it can't find clj-http.clj on classpath.

21:52 qbg: mdeboard: How are you running the project?

21:52 seancorfield: :require mdeboard

21:52 (ns foo.core (:require [clj-http.client :as client]))

21:52 dnolen_: qbg: another correction, https://gist.github.com/1102041

21:53 seancorfield: i assume your project namespace would be foo.core (for project foo), not just foo

21:53 dnolen_: qbg: I'm done, great fun, let me know if you fun into things that don't work w/ that.

21:53 s/fun/run

21:53 lazybot: <dnolen_> qbg: I'm done, great run, let me know if you run into things that don't work w/ that.

21:53 dnolen_: are

21:53 devn: hello all

21:53 dnolen_: arg :)

21:53 mdeboard: qbg: Using clojure-jack-in

21:54 seancorfield: Made no difference fwiw but thanks

21:54 seancorfield: made it easier to diagnose when I'm using correct syntax :)

21:54 seancorfield: glad it helped a tiny bit :)

21:54 i gather you're using emacs/swank or something?

21:54 mdeboard: yep

21:55 * seancorfield is not sure what clojure-jack-in is :)

21:55 seancorfield: then i probably can't help... not an emacs user...

21:55 mdeboard: well, even in the repl.

21:55 seancorfield: but i bet there's plenty of emacs users here who can...

21:55 mdeboard: lein repl

21:55 amalloy: mdeboard: you added the : *and* dropped the ' and it complained?

21:56 hiredman: mdeboard: (ns foo (:require ...)) vs (ns foo (require ...))

21:56 seancorfield: hmm, did it put it in lib/ when you ran lein deps ?

21:56 if not, perhaps the problem is in project.clj?

21:56 mdeboard: amalloy: No, didn't drop the ', was following instrs from the clj-http readme :\

21:56 dropping it did the trick

21:56 thanks

21:56 seancorfield: whee!

21:56 amalloy: link to the readme?

21:56 mdeboard: https://github.com/mmcgrana/clj-http

21:57 seancorfield: ah, that (require) syntax is for the REPL, not for a (ns) decl

21:57 amalloy: clojurebot: require?

21:57 clojurebot: No entiendo

21:57 amalloy: mutter

21:57 mdeboard: lol

21:57 amalloy: mdeboard: short version: require/use/etc are functions, which need their arguments quoted

21:57 mdeboard: oh I get it.

21:57 amalloy: (ns...) is a macro that doesn't need quoting, and uses :require instead of of require

21:58 mdeboard: but ns accepts mapped kwargs

21:58 or just kwargs, rather.

21:58 Gotcha

21:58 That connects the dots better.

21:59 * amalloy got an A in dot-drawing in kindergarten

21:59 mdeboard: lol

22:06 antares_: hey guys

22:07 I am trying to define a protocol and getting exceptions

22:07 and examples in The Joy of Clojure seem to be different from the source in Clojure master :/

22:07 did defprotocol change for 1.3?

22:08 qbg: antares_: Source and exception?

22:08 antares_: qbg: https://gist.github.com/1724d20f73e650ff9937

22:09 qbg: the order of protocol name & extended type seems to be different between master (protocols.clj) and The Joy of Clojure

22:09 or I am just missing something :)

22:09 oops

22:10 sorry, in this example protocol name is incorrect (uses leporidae.core) but I tried a million of other ways, including just Closeable :)

22:10 I've updated the gist

22:10 qbg: I think you want extend-protocol instead of extend-type

22:10 clojurebot: excusez-moi

22:10 antares_: qbg: bummer

22:10 qbg: let me try

22:13 qbg: that helps. Now one more question. My protocol has the `close' function. How do I use it in my random namespace?

22:13 mdeboard: I hate Clojure for giving me a reason to join ##java :(

22:14 antares_: http://clojuredocs.org/clojure_core/clojure.core/extend-protocol doesn't demonstrate how to use the protocol we just defined :(

22:14 clojurebot: http://clojure-log.n01se.net/date/2009-10-13.html#12:02

22:14 qbg: antares_: Use how?

22:14 antares_: qbg: my goal is to be able to call (close c) where c is an instance of several Java classes

22:15 qbg: or am I abusing protocols then?

22:15 qbg: Java does have java.io.Closeable

22:16 antares_: qbg: ok. But those classes do not implement it.

22:17 amalloy: antares_: that sounds more or less like what protocols are for

22:18 qbg: If you rename extend-type to extend-protocol (and optionally merge them together), it should work

22:19 antares_: qbg: ok, let me dabble with this a little more. I already switched to extend-protocol, that helped. Thank you.

22:41 hiredman: standby for upgrade to clojurebot 0.3.0 "Development Has Stalled"

23:04 mdeboard: Is tehre a "private method" convention in clojure?

23:05 qbg: mdeboard: defn- ?

23:06 hiredman: if you add :private true to the metadata on a var the compiler will throw an exception if the var is accessed from a different namespace

23:06 (defn- is a shortcut for the above)

23:06 mdeboard: Ah, I see

23:06 Thanks both of you

23:10 amalloy: hiredman: that's not really true, though, right? :private just means "don't put this in my list of ns-publics"

23:13 hiredman: possibly

23:15 looks it actually does both in different code paths *sigh*

23:15 looks like

23:15 amalloy: haha

23:15 hiredman: then why does #'private-var work fine?

23:16 er, #'some-ns/private-var

23:16 hiredman: thevarexpr codepath doesn't check .isPublic

23:17 not both as in (and … …) both as in (or … …) depending on what you are doing with the var

23:22 amalloy: ah

23:32 mdeboard: Is there an idiomatic way of converting a :keyword to a string and strip the leading colon? Besides (string/replace s match replace)

23:33 hiredman: ,(name :foo)

23:33 ,(name :foo)

23:33 clojurebot: "foo"

23:33 mdeboard: ah, awesome

23:33 thanks

23:36 hiredman: ,(name :foo)

23:36 clojurebot: "foo"

23:36 hiredman: ^- that'll be in 0.4.0

23:37 mdeboard: What will be

23:37 oh, ignoring leading whitespace

23:37 ?

23:37 hiredman: right

23:38 mdeboard: And sorry for this again but what's the proper usage of (key) ? It's really hard to google, and the docs are not that ... specific I guess.

23:38 (key {:foo "bar"})

23:38 ,(key {:foo "bar"})

23:38 clojurebot: java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.util.Map$Entry

23:38 hiredman: ,(doc key)

23:38 clojurebot: "([e]); Returns the key of the map entry."

23:38 qbg: ,(key (first {:foo 5}))

23:38 clojurebot: :foo

23:38 mdeboard: Yeah

23:38 hiredman: {} is map, not a map entry

23:38 mdeboard: (first {:foo 5})

23:38 hiredman: ~google java MapEntry

23:38 clojurebot: First, out of 29000 results is:

23:38 Map.Entry (Java 2 Platform SE v1.4.2)

23:38 http://download.oracle.com/javase/1.4.2/docs/api/java/util/Map.Entry.html

23:39 mdeboard: ,(first {:foo 5})

23:39 clojurebot: [:foo 5]

23:39 mdeboard: oh

23:39 :|

23:39 hiredman: ^- looks like a vector, and is, but is also a MapEntry

23:40 mdeboard: I suppose I expected (key) to work on a length 1 map

23:42 ,(val (first {:foo 5}))

23:42 clojurebot: 5

23:43 mdeboard: ,(let [x {:foo 5}] (for [i x] (str (key i) "=" (val i))))

23:43 clojurebot: (":foo=5")

23:43 mdeboard: hm

Logging service provided by n01se.net