#clojure log - Dec 24 2011

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

0:01 tauntaun: dnolen: Haven't seen you in quite a while. I hope all's well.

0:01 dnolen: tauntaun: bit busy with work. all is well :)

6:29 ben_m: Hi everyone! Are there any libraries other than clj-processing for simple graphics/interaction prototyping? :)

9:38 jli: WAIT

9:39 does being a JavaBean mean being like a map?

9:45 simonadameit: hi

9:45 i'd like to implement some data structure in clojure, and have it work with the clojure collection/ sequence abstractions

9:46 how can I find out about which interfaces I need to implement?

9:46 (besides browsing through the code on github)

9:47 the interfaces dont seem to be part of the documentation on clojure.og

9:47 jli: simonadameit: er, I think that's the way. check out ISeq.java

9:48 simonadameit: jli: oh.. ok.. thanks.. thats too bad. I did not want to get lost in implementation details of clojure… but have something more like an overview of the public interfaces that are ment to be extended

9:48 but I think it will do :)

9:49 jli: simonadameit: I think you'll have to look at a bit of the source if you want to add new data structures, but it's quite small

9:50 ISeq.java is 29 lines

9:52 simonadameit: jli: I know, I have looked at it… I just thought there might be some kind of public interface / documentation .. with a litlle more guidance of what I need to implement :)

9:54 … I thought adding a new data structure might be somewhat "common"

10:29 glide: are swank and slime deprecated in favor of noir?

10:43 cemerick: glide: You're lumping together a REPL protocol, an emacs mode, and a web framework.

10:43 glide: cemerick, yeah, i'm a total newb

10:44 trying to get my dev environment/workflow up, so i can start learning

10:45 there's more than one way to skin this cat

10:45 cemerick: glide: what do you usually use to code?

10:45 If it's emacs, use SLIME. If it's not, use whatever you're used to until you have your sea-legs.

10:46 glide: i.e. http://dev.clojure.org/display/doc/Clojure+Tools

10:47 glide: maybe i should try clooj

10:47 keep it simple for now

10:50 simonadameit: in IPersistentMap, whats the difference between assoc and assocEx ?

10:51 what should assocEx do?

10:57 Dyresen: I have a simple question. I'm learning clojure and one of my favorite ways of learning a language is to make some web apps. Is there a recommended web framework? I have seen compojure and noir. I like django from the python world if that matters in what choice to go with.

10:58 Raynes: Dyresen: Noir is a pretty simple framework. It is well documented too. I'd give it a go.

11:00 Dyresen: Raynes: ok, I'll try that. Thanks.

11:13 is it safe to run noir with clojure 1.3?

11:16 Raynes: Dyresen: Yes.

11:27 technomancy_: ping

11:30 pandeiro: how can i kill/restart a swank repl that is not responding for some reason?

11:30 tolstoy: In slime, ",sayonara" kills it.

11:32 Dyresen: Raynes: thanks

11:32 noir is a bit like sinatra I guess? (apart from the ruby part)

11:32 Raynes: Never used Sinatra.

11:33 tolstoy: Compojure is more like Sinatra. Noir adds a lot of stuff on top of that.

11:34 If you want a straight up web service (no html pages, session management, etc), compojure's hard to beat.

11:35 Dyresen: Ahh oki, Ill go with noir :)

11:37 tmciver: pandeiro: you can also run Alt-x 'slime-interrupt' if it's hung in an infinite loop. That should bring you back to the repl.

11:38 pandeiro: tolstoy: tmciver: thanks, when i bork it again i will try those

11:42 jli: if objects are .equals(), then they should have the same .hashCode(). is the converse not true (hashcode equal implies equals)?

11:44 ah, no, it's not

11:44 tolstoy: Hm. I guess I haven't really thought about it, but I thought .equals was just a method objects (on the JVM) implemented to mean whatever they want (generally in terms of value, not identity).

11:45 s/haven't really thought about it/researched or looked it up/

11:45 jli: actually, duh, of course it's not. collisions and pigeonholes and such.

12:54 dabd: i'm trying to use a function to download content from a url like so https://gist.github.com/1517935

12:54 but the resulting download file has zero length

12:55 is anything wrong with the code?

12:58 tmciver: dabd: no idea, but what http client lib are you using?

12:58 for my own curiosity.

13:01 ahh, looks like http.agent in clojure.contrib

13:01 not familiar with it, sorry.

13:01 Raynes: You don't really need a special library for this.

13:02 Here is a little example of downloading a zip file (and unzipping it): https://github.com/Raynes/sherlock/blob/master/src/sherlock/core.clj#L28

13:04 In any case, I'm assuming your ds/ alias is duck-streams? That's ancient, deprecated, and no longer existent. Use clojure.java.io instead. Furthermore, avoid monolithic contrib as well. Prefer the new separated libraries. More info: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go

13:07 dabd: tmciver: http-agent

14:01 mcrittenden: if anyone is around and bored, I'd love a code review on my tiny cli tic tac toe game. it's my first clojure code ever so I'm sure it's terrible. https://github.com/mikecrittenden/clojure-tictactoe/blob/master/tictactoe.clj

14:02 johnstorey: I'm trying to do a slime connect in Emacs 24 pretest on OSX after starting swank with "~/.lein/bin/swank-clojure" on the command line. I consistently get the error "Wrong type argument: bufferp, nil" when typing "M-x slime-connect". Anyone have an idea what to do to correct this off the top of their head?

14:03 tmciver: johnstorey: have you tried starting swank with just 'lein swank'?

14:05 johnstorey: tmciver: A bunch of warnings followed by a stack trace. I'll look into them. The error should pop up there. Thanks for pointing me in the right direction.

14:06 Vinzent: what about using vaadin with clojure? Is it possible to have usual interactive dev workflow?

14:15 mcrittenden, haven't read it well, but looks good

14:16 maybe rename to 'valid-move?'

14:22 mcrittenden: Vinzent yeah, there are a few functions that I need to add ? to the name

14:22 thanks for looking

15:39 Tharem: I've hit a bit of a namespace snag. I've got a protocol defined in one namespace. Now I'm trying to call a function from that protocol in another namespace. What do I add to my in-ns call to get the second namespace to find the protocol?

15:43 simard: is there a function that does that ? (defn rotate [n s] (take (count s) (drop n (cycle s))))

15:45 Tharem: simard: I cant find one, so I guess not

15:52 dnolen: Tharem: normally namespaces are mapped to files. unless you have a good reason you shouldn'tbe using in-ns

15:52 Tharem: Doah that was a typo. I meant what do I have to add to ns to make it work

15:53 Sorry for that, I was testing things on the repl

15:53 dnolen: Tharem: you need to require or use that other namespace

15:55 Tharem: Hmm, in that case I must have an error in the protocol itself or it's implementation... Thanks

16:00 lnostdal_: hm, redefining defrecords doesn't really work all that well at times .. i have to remove type declarations from functions, then add them back again for things to compile proper...

16:00 "java.lang.ClassCastException: SomeType cannot be cast to SomeType" .. crap

16:01 Tharem: I think that's because defrecord already provides a bunch of protocols for you, so trying to redefine the functions associated with them is going to be met with some resistance (hope I've got my termoogy right)

16:02 Oh wait, I was misreading what you said

16:02 I think that's because the functions still see the old definition of the defrecord

16:03 And since that definition is immutable... Well, you can guess it

16:03 lnostdal_: yeah, it actually seems to be some thread related thing ..

16:03 dnolen: lnostdal_: deftype / defrecord redefinition just doesn't work generally, I recompile the whole file usually.

16:03 lnostdal_: some threads see the old definition, some see the new definition .. two different type checks .. etc.

16:03 dnolen: lnostdal_: that said, if you stick w/ protocols, keyword access less of a problem.

16:03 lnostdal_: yeah, i have both the defrecord and the functions that "use it" in the same file .. so i think it's some thread thing or something .. not sure

16:04 djhworld: w

16:04 lnostdal_: hm, ok

16:04 Tharem: Anyway know what the following error means? "No implementation of method: :dimensions of protocol: #'RogueLike.map/MultiDim found for class: RogueLike.map.game-map"

16:05 I have defined dimensions on both the protocol and the deftype that uses the protocol

16:09 dnolen: Tharem: it means that protocol has not been implemented for that type

16:10 Tharem: So, how do I define it?

16:10 dnolen: Tharem: but it may be misleading - you may need to recompile both files

16:11 Tharem: XD I forgot the shortcut for compiling a file in Slime

16:11 dnolen: C-c C-k

16:11 kenth: Hi, how would I destructure a list into a head and rest part?

16:11 Tharem: That did it, thanks

16:12 dnolen: (let [[head & rest] [1 2 3]] {:head head :rest rest})

16:12 ,(let [[head & rest] [1 2 3]] {:head head :rest rest})

16:12 clojurebot: {:head 1, :rest (2 3)}

16:12 kenth: oh I meant a (list [1 2 3]) type of list

16:13 dnolen: kenth: it's the same

16:13 ,(let [[head & rest] '(1 2 3)] {:head head :rest rest})

16:13 clojurebot: {:head 1, :rest (2 3)}

16:13 Tharem: dbnolen: Yep it works now

16:14 dnolen: Tharem: cool

16:15 kenth: ,(let [[head & rest] (list [1 2 3])] {:head head :rest rest})

16:15 clojurebot: {:head [1 2 3], :rest nil}

16:16 dnolen: kenth: that's a list that includes a vector as the only element

16:16 kenth: oh ok I see what I did, thanks

16:16 dnolen: ,(list 1 2 3)

16:16 clojurebot: (1 2 3)

16:16 dnolen: ,(let [[head & rest] (list 1 2 3)] {:head head :rest rest})

16:16 clojurebot: {:head 1, :rest (2 3)}

16:38 hiredman: amalloy: I don't think clojure's proxies use jvm proxy classes

16:39 amalloy: no? they just override every method and point them all at some internal fn-map, with default impl being "call super.foo()"?

16:39 i tried to look at the source but it was pretty complicated

16:41 hiredman: yes, generate-proxy is large

16:41 ~ping

16:41 clojurebot: Huh?

16:42 hiredman: clojurebot: uh, really?

16:42 clojurebot: Pardon?

16:47 hiredman: ~ping

16:47 clojurebot: PONG!

18:30 bobhope: hello clojurians

18:30 Bronsa: o/

18:30 bobhope: I'd like to write something open source in clojure

18:30 but I'm not sure what would be beneficial

18:35 dnolen: bobhope: you could also contribute to one of the existing open source contrib projects.

18:36 bobhope: hey dnolen, we were talking a few days ago at the meetup

18:36 (context)

18:36 dnolen: bobhope: oh yeah! hullo :)

18:36 bobhope: i don't think i have a solid enough understanding of core.logic to work on the ckanren stuff

18:37 but I am interested in parallelizing core.logic

18:37 dnolen: bobhope: haha, wasn't suggesting that you go down that rabbit hole :)

18:37 bobhope: that would be awesome - a very challenging problem I think.

18:37 bobhope: can I ask you a bunch of questions about how it works?

18:37 I just read the reasoned schemer's chapter on how it works today

18:38 dnolen: bobhope: sure

18:38 bobhope: ok, so if I just got the unifier to parallelize, would that wokr?

18:38 dnolen: bobhope: TRS (the reasoned schemer) only really describes the substitution/unification part in detail

18:38 bobhope: or do the disunification constraints combine in funky ways

18:38 alexbaranosky: bobhope, Midje can always use assistance :)

18:38 dnolen: it glosses over the goal part which is tricky to understand

18:39 bobhope: parellel unification isn't that beneficial

18:39 bobhope: why not?

18:39 dnolen: what we want is running goals in parallel

18:39 bobhope: ah

18:39 how do you run goals now?

18:40 I've got the source open

18:40 dnolen: it's a monadic design, we thread the substituion through functions (goals)

18:41 bobhope: so, where might the parallelism be available...

18:42 dnolen: bobhope: you have fresh - which does conjuncition, and conde which does disjunction

18:42 conde would be a sensible target for parellelism

18:42 bobhope: are those the only 2 points that several goals feed into one goal?

18:42 dnolen: since branches don't affect each other

18:44 bobhope: the issue is not simple. you don't want to just want run all conde branches in parallel

18:44 it'll be hopelessly slower than serial execution

18:44 so we need some kind of analysis - perhaps a user annotation as well?

18:45 bobhope: so, based on my limited understanding and trying to map this to things I already know about, this is what I'm thinking:

18:45 dnolen: bobhope: in anycase I'd read William Byrd's dissertation if you want to investigate this stuff.

18:45 bobhope: the logic program is like TQBF

18:46 which is a pspace-complete problem that essentially creates a tree of conjunctions and disjunctions of clauses

18:47 why do you think that a naive parallization of conde & fresh would be slower?

18:47 dnolen: bobhope: it's already been tried, by the miniKanren researchers.

18:47 bobhope: and it's slower than serial execution?

18:48 dnolen: bobhope: much slower

18:48 bobhope: Ciao Prolog folks have been working on this problem for a while as well.

18:50 bobhope: which isn't to say there isn't a simple solution that works well here - I haven't thought about it much.

18:50 bobhope: i think that agents might be a suitable candidate for this, and clojure is also a huge win

18:50 here's why I think that basic parallelization could work for core.logic:

18:51 although it's embaressingly parallel, byrd says in his thesis that the communication overhead is painful

18:52 but clojure has 2 ways that it ameliorates this: 1) immutable datastructures leave shared data in a sharable cachable state, so that there should be minimal cache line bouncing

18:53 so essentially it should have the perf. characteristics of running on a single core from a memory access latency perspective

18:53 2) a decent work-stealing task model further offsets the cost of parallelization, since it should do better and better the smaller and more numerous the tasks you run

18:54 I'm not sure if agents use work stealing or something dumber, though

18:54 dnolen: bobhope: I don't think agents use work stealing - but I definitely thought that JDK fork/join could be leveraged here.

18:57 bobhope: dnolen, that looks right

18:57 dnolen: bobhope: I definitely think *something* could work - if you think you've got a good strategy create a core.logic branch and try things out (assuming you've sent in your CA and all that)

18:57 a parellel core.logic would rock

18:58 bobhope: ca=contributor's agreement?

18:58 dnolen: bobhope: yes

18:59 bobhope: what is that?

18:59 dnolen: something you need to submit before you can contribute to Clojure projects.

19:12 technomancy_: clojurebot: twenty-seven b stroke six

19:12 clojurebot: Cool story bro.

19:18 replaca: bobhope, dnolen: see liebke's preso from last year's conj for info on how work stealing and fork/join can be used in Clojure

19:19 bobhope: where is fjvtree located?

19:20 I hadn't looked too closely at the java7 fork join framework, but that's exactly the solution to this kind of parallelism

19:20 replaca, dnolen: do you know where fjvtree is implemented?

19:21 replaca: bobhope: I don't know what liebke did with it

19:21 you could look on his github and see if he's got it up there

19:21 bobhope: i see, i think it's on a branch of clojure called "par"

19:21 i just found some thread with that

19:23 replaca: bobhope: I'm not sure if that's good or obsolete

19:24 in any case, I feel like David hasn't really brought that work to its conclusion, but gotten distracted by other things

19:27 dnolen: replaca: or just waiting for other folks to lend a helping hand :)

19:29 bobhope: dnolen, if i work on core.logic without the CA, is that okay?

19:29 or does that cause issues

19:29 assuming that i'd get a CA at some point in the fuuter

19:29 replaca: dnolen: yeah, likely

19:30 dnolen: bobhope: feel free to work on your own fork, but won't be able to merge in anything until Clojure/core get your CA.

19:30 replaca: heh, I've been surprised by the various little fixes I've gotten to core.match and core.logic already.

19:32 replaca: recently cgrand contributed a pretty amazing core.logic branch, so it's all just a matter of time sometimes.

19:32 replaca: dnolen: and generating excitement about what you're doing

19:33 dnolen: replaca: true, that's key.

19:33 replaca: I'm surprised more folks haven't been interested in making fork/join a huge win

19:33 I know Rich is interested in seeing that happen

19:34 dnolen: replaca: I agree. fork/join is untapped.

19:34 bobhope: could it be that it's really annoying to install?

19:34 dnolen: bobhope: it's in JDK 7

19:34 bobhope: but jdk7 isn't in any repos on the systems I use, afaict

19:35 replaca: bobhope: yeah, that might be part of it

19:35 it seems like it would fit enough with the big data story that people would want it

19:37 bobhope: do you know an easy way to get clojure on jdk7 on mac or ubuntu 11.04?

19:37 I'd like to experiment with fork/join parallelizing core.logic

19:38 dnolen: bobhope: Oracle has a developer preview for os x jdk 7 now, simple install

19:38 http://jdk7.java.net/macportpreview/

19:39 bobhope: will clojure automatically use that after I install it?

19:39 dnolen, or do i need to configure lein correctly

19:41 also, is there a project.clj for core.logic, or a different build/test/repl tool, or should I just make my own as needed?

19:43 replaca: bobhope: all the clojure.core libs build with Maven

19:43 dnolen: bobhope: no you need to set the JDK via Java Preferences utility app

19:43 bobhope: everything else after that is automatic

19:44 bobhope: that's super easy

19:44 dnolen: bobhope: you can give this code a spin when you get it setup, http://dosync.posterous.com/clojure-openjdk-7-and-forkjoin

19:44 bobhope: I've never used maven--what do I need to know to finish getting running?

19:45 dnolen: bobhope: you don't need to mess w/ maven, just use lein

19:45 jackhammer2022: has anybody gone through the book Seven Languages in Seven Weeks ? any reviews for Clojure chapter ?

19:46 bobhope: dnolen, if I do lein repl in the root of the core.logic repo, will that automatically make it possible for me to (use 'core.logic)?

19:46 jackhammer2022: i have a fair deal of knowledge of Racket and I am gonna begin learning Clojure with that book :)

19:48 dnolen: bobhope: it should yes

19:48 jackhammer2022: probably better to get one of the dedicated books on Clojure

19:49 bobhope: dnolen, I ran "lein repl" in the root of the repository from github, but (use 'clojure.core.logic) and (use 'core.logic) failed. I'm still hazy on how clojure and lein resolve paths

19:50 jackhammer2022: dnolen: umm ok..just had this book for the holidays..

19:51 *got'

19:52 dnolen: jackhammer2022: it'll probably cover some essentials, but if you're coming from Racket, you know quite a bit about the Lisp thing :)

19:53 jackhammer2022: dnolen: yes I do.. :)

19:53 dnolen: bobhope: oh right, just make a project.clj and set the src directory to src/main

19:55 bobhope: https://gist.github.com/1518582

19:55 k gotta run

19:58 bobhope: Is there a way to use lein and specify "latest"?

19:59 Or how can I discover the latest version of a random contrib library?

19:59 ibdknox: if it's an actual contrib, looking on github is probably the easiest

20:01 sandy1986: Hi ;) How to take advantage of "http://dakrone.github.com/cheshire/" >> parsed-seq ?

20:01 Heard that lazyness is good if it is possible ;)

20:03 replaca: bobhope: it's not a great answer, but there is a reliable way for contribs

20:05 bobhope: go to the canonical github repo, e.g., https://github.com/clojure/core.logic and look at the branches pulldown

20:06 Where is says "Current branch" and has the pull down, that is

20:07 then select the "Tags" tab on that menu

20:07 and you'll see a set of tags that are called <proj>-<vers>, e.g., core.logic-0.6.7

20:08 these are the releases that have been pushed through the build system to central and can be accessed via Maven and leiningen

20:08 presumable the biggest number is the newest

20:30 chewbranca: anyone ever encounted this error before? clojure.lang.Numbers.isPos(I)Z for a java.lang.NoSuchMethodError

20:31 the only other place I've been able to find that error is: https://groups.google.com/forum/#!topic/clojure/IP6ALoHKv5Q and just like that guy, the error is occurring in clutch and randomly showed up

20:31 amalloy: AOTed against the wrong version of clojure, probably

20:33 chewbranca: interesting, so I see clutch depends on clojure 1.2 base, but has multi-deps support for 1.3

20:35 the weird thing is that this project started as a clojure 1.3 project using clutch and I've used it for some time and the issue randomly showed up today

20:39 amalloy: chewbranca: a real stacktrace would make it possible to at least guess at what code is mis-compiled/linked

20:39 or i guess it's probably an error during compilation/linking, so probably not

20:41 chewbranca: http://paste.lisp.org/display/126675

20:41 naw its happening when I try and save a document with clutch

20:42 well yeah I see what you mean, the actual issue is probably happening during compile time

20:43 the only thing relevant I've changed since this worked was adding: https://github.com/chewbranca/url-normalizer

20:44 bah.. sorry need to afk for a bit, will be back

20:50 amalloy: chewbranca: if you have a dependency using contrib.io, 1.3 ain't gonna work well

20:54 to see which dependency is pulling in contrib, you can try: $ lein pom && mvn dependency:tree

21:36 chewbranca: amalloy: ahhh nice thanks, I see clojure 1.2 is getting downloaded, but doesn't show up in pom.xml. I'll run with this in a bit and see if I can track down the issue, thanks!

21:38 mcbride25: I'm trying to write a config file for my app in clojure

21:38 but when I do (load-string "config-file.txt")

21:39 clojure complains that it cant find certain symbols in my config file

21:39 theyre macros I defined in my namespace

21:39 however, running the same function via the repl works fine

21:39 does anyone know why?

21:47 ldh: i'm running the map function over a map, so it calls my provided function with each entry. most entries i simply return, but in some cases i'd like to return different ones. how can i create them?

21:48 ibdknox: ldh: just return vectos

21:48 vectors*

21:49 ldh: ibdknox: sounds good; i didn't know if there was a strict need to return entries

21:49 ibdknox: nope :)

Logging service provided by n01se.net