#clojure logs

2011-12-24

00:01tauntaundnolen: Haven't seen you in quite a while. I hope all's well.
00:01dnolentauntaun: bit busy with work. all is well :)
06:29ben_mHi everyone! Are there any libraries other than clj-processing for simple graphics/interaction prototyping? :)
09:38jliWAIT
09:39jlidoes being a JavaBean mean being like a map?
09:45simonadameithi
09:45simonadameiti'd like to implement some data structure in clojure, and have it work with the clojure collection/ sequence abstractions
09:46simonadameithow can I find out about which interfaces I need to implement?
09:46simonadameit(besides browsing through the code on github)
09:47simonadameitthe interfaces dont seem to be part of the documentation on clojure.og
09:47jlisimonadameit: er, I think that's the way. check out ISeq.java
09:48simonadameitjli: 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
09:48simonadameitbut I think it will do :)
09:49jlisimonadameit: 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
09:50jliISeq.java is 29 lines
09:52simonadameitjli: 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 :)
09:54simonadameit… I thought adding a new data structure might be somewhat "common"
10:29glideare swank and slime deprecated in favor of noir?
10:43cemerickglide: You're lumping together a REPL protocol, an emacs mode, and a web framework.
10:43glidecemerick, yeah, i'm a total newb
10:44glidetrying to get my dev environment/workflow up, so i can start learning
10:45glidethere's more than one way to skin this cat
10:45cemerickglide: what do you usually use to code?
10:45cemerickIf it's emacs, use SLIME. If it's not, use whatever you're used to until you have your sea-legs.
10:46cemerickglide: i.e. http://dev.clojure.org/display/doc/Clojure+Tools
10:47glidemaybe i should try clooj
10:47glidekeep it simple for now
10:50simonadameitin IPersistentMap, whats the difference between assoc and assocEx ?
10:51simonadameitwhat should assocEx do?
10:57DyresenI 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:58RaynesDyresen: Noir is a pretty simple framework. It is well documented too. I'd give it a go.
11:00DyresenRaynes: ok, I'll try that. Thanks.
11:13Dyresenis it safe to run noir with clojure 1.3?
11:16RaynesDyresen: Yes.
11:27Raynestechnomancy_: ping
11:30pandeirohow can i kill/restart a swank repl that is not responding for some reason?
11:30tolstoyIn slime, ",sayonara" kills it.
11:32DyresenRaynes: thanks
11:32Dyresennoir is a bit like sinatra I guess? (apart from the ruby part)
11:32RaynesNever used Sinatra.
11:33tolstoyCompojure is more like Sinatra. Noir adds a lot of stuff on top of that.
11:34tolstoyIf you want a straight up web service (no html pages, session management, etc), compojure's hard to beat.
11:35DyresenAhh oki, Ill go with noir :)
11:37tmciverpandeiro: 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:38pandeirotolstoy: tmciver: thanks, when i bork it again i will try those
11:42jliif objects are .equals(), then they should have the same .hashCode(). is the converse not true (hashcode equal implies equals)?
11:44jliah, no, it's not
11:44tolstoyHm. 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:45tolstoys/haven't really thought about it/researched or looked it up/
11:45jliactually, duh, of course it's not. collisions and pigeonholes and such.
12:54dabdi'm trying to use a function to download content from a url like so https://gist.github.com/1517935
12:54dabdbut the resulting download file has zero length
12:55dabdis anything wrong with the code?
12:58tmciverdabd: no idea, but what http client lib are you using?
12:58tmciverfor my own curiosity.
13:01tmciverahh, looks like http.agent in clojure.contrib
13:01tmcivernot familiar with it, sorry.
13:01RaynesYou don't really need a special library for this.
13:02RaynesHere 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:04RaynesIn 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:07dabdtmciver: http-agent
14:01mcrittendenif 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:02johnstoreyI'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:03tmciverjohnstorey: have you tried starting swank with just 'lein swank'?
14:05johnstoreytmciver: 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:06Vinzentwhat about using vaadin with clojure? Is it possible to have usual interactive dev workflow?
14:15Vinzentmcrittenden, haven't read it well, but looks good
14:16Vinzentmaybe rename to 'valid-move?'
14:22mcrittendenVinzent yeah, there are a few functions that I need to add ? to the name
14:22mcrittendenthanks for looking
15:39TharemI'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:43simardis there a function that does that ? (defn rotate [n s] (take (count s) (drop n (cycle s))))
15:45Tharemsimard: I cant find one, so I guess not
15:52dnolenTharem: normally namespaces are mapped to files. unless you have a good reason you shouldn'tbe using in-ns
15:52TharemDoah that was a typo. I meant what do I have to add to ns to make it work
15:53TharemSorry for that, I was testing things on the repl
15:53dnolenTharem: you need to require or use that other namespace
15:55TharemHmm, in that case I must have an error in the protocol itself or it's implementation... Thanks
16:00lnostdal_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:00lnostdal_"java.lang.ClassCastException: SomeType cannot be cast to SomeType" .. crap
16:01TharemI 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:02TharemOh wait, I was misreading what you said
16:02TharemI think that's because the functions still see the old definition of the defrecord
16:03TharemAnd since that definition is immutable... Well, you can guess it
16:03lnostdal_yeah, it actually seems to be some thread related thing ..
16:03dnolenlnostdal_: deftype / defrecord redefinition just doesn't work generally, I recompile the whole file usually.
16:03lnostdal_some threads see the old definition, some see the new definition .. two different type checks .. etc.
16:03dnolenlnostdal_: that said, if you stick w/ protocols, keyword access less of a problem.
16:03lnostdal_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:04djhworldw
16:04lnostdal_hm, ok
16:04TharemAnyway know what the following error means? "No implementation of method: :dimensions of protocol: #'RogueLike.map/MultiDim found for class: RogueLike.map.game-map"
16:05TharemI have defined dimensions on both the protocol and the deftype that uses the protocol
16:09dnolenTharem: it means that protocol has not been implemented for that type
16:10TharemSo, how do I define it?
16:10dnolenTharem: but it may be misleading - you may need to recompile both files
16:11TharemXD I forgot the shortcut for compiling a file in Slime
16:11dnolenC-c C-k
16:11kenthHi, how would I destructure a list into a head and rest part?
16:11TharemThat did it, thanks
16:12dnolen(let [[head & rest] [1 2 3]] {:head head :rest rest})
16:12dnolen,(let [[head & rest] [1 2 3]] {:head head :rest rest})
16:12clojurebot{:head 1, :rest (2 3)}
16:12kenthoh I meant a (list [1 2 3]) type of list
16:13dnolenkenth: it's the same
16:13dnolen,(let [[head & rest] '(1 2 3)] {:head head :rest rest})
16:13clojurebot{:head 1, :rest (2 3)}
16:13Tharemdbnolen: Yep it works now
16:14dnolenTharem: cool
16:15kenth,(let [[head & rest] (list [1 2 3])] {:head head :rest rest})
16:15clojurebot{:head [1 2 3], :rest nil}
16:16dnolenkenth: that's a list that includes a vector as the only element
16:16kenthoh ok I see what I did, thanks
16:16dnolen,(list 1 2 3)
16:16clojurebot(1 2 3)
16:16dnolen,(let [[head & rest] (list 1 2 3)] {:head head :rest rest})
16:16clojurebot{:head 1, :rest (2 3)}
16:38hiredmanamalloy: I don't think clojure's proxies use jvm proxy classes
16:39amalloyno? they just override every method and point them all at some internal fn-map, with default impl being "call super.foo()"?
16:39amalloyi tried to look at the source but it was pretty complicated
16:41hiredmanyes, generate-proxy is large
16:41hiredman~ping
16:41clojurebotHuh?
16:42hiredmanclojurebot: uh, really?
16:42clojurebotPardon?
16:47hiredman~ping
16:47clojurebotPONG!
18:30bobhopehello clojurians
18:30Bronsao/
18:30bobhopeI'd like to write something open source in clojure
18:30bobhopebut I'm not sure what would be beneficial
18:35dnolenbobhope: you could also contribute to one of the existing open source contrib projects.
18:36bobhopehey dnolen, we were talking a few days ago at the meetup
18:36bobhope(context)
18:36dnolenbobhope: oh yeah! hullo :)
18:36bobhopei don't think i have a solid enough understanding of core.logic to work on the ckanren stuff
18:37bobhopebut I am interested in parallelizing core.logic
18:37dnolenbobhope: haha, wasn't suggesting that you go down that rabbit hole :)
18:37dnolenbobhope: that would be awesome - a very challenging problem I think.
18:37bobhopecan I ask you a bunch of questions about how it works?
18:37bobhopeI just read the reasoned schemer's chapter on how it works today
18:38dnolenbobhope: sure
18:38bobhopeok, so if I just got the unifier to parallelize, would that wokr?
18:38dnolenbobhope: TRS (the reasoned schemer) only really describes the substitution/unification part in detail
18:38bobhopeor do the disunification constraints combine in funky ways
18:38alexbaranoskybobhope, Midje can always use assistance :)
18:38dnolenit glosses over the goal part which is tricky to understand
18:39dnolenbobhope: parellel unification isn't that beneficial
18:39bobhopewhy not?
18:39dnolenwhat we want is running goals in parallel
18:39bobhopeah
18:39bobhopehow do you run goals now?
18:40bobhopeI've got the source open
18:40dnolenit's a monadic design, we thread the substituion through functions (goals)
18:41bobhopeso, where might the parallelism be available...
18:42dnolenbobhope: you have fresh - which does conjuncition, and conde which does disjunction
18:42dnolenconde would be a sensible target for parellelism
18:42bobhopeare those the only 2 points that several goals feed into one goal?
18:42dnolensince branches don't affect each other
18:44dnolenbobhope: the issue is not simple. you don't want to just want run all conde branches in parallel
18:44dnolenit'll be hopelessly slower than serial execution
18:44dnolenso we need some kind of analysis - perhaps a user annotation as well?
18:45bobhopeso, based on my limited understanding and trying to map this to things I already know about, this is what I'm thinking:
18:45dnolenbobhope: in anycase I'd read William Byrd's dissertation if you want to investigate this stuff.
18:45bobhopethe logic program is like TQBF
18:46bobhopewhich is a pspace-complete problem that essentially creates a tree of conjunctions and disjunctions of clauses
18:47bobhopewhy do you think that a naive parallization of conde & fresh would be slower?
18:47dnolenbobhope: it's already been tried, by the miniKanren researchers.
18:47bobhopeand it's slower than serial execution?
18:48dnolenbobhope: much slower
18:48dnolenbobhope: Ciao Prolog folks have been working on this problem for a while as well.
18:50dnolenbobhope: which isn't to say there isn't a simple solution that works well here - I haven't thought about it much.
18:50bobhopei think that agents might be a suitable candidate for this, and clojure is also a huge win
18:50bobhopehere's why I think that basic parallelization could work for core.logic:
18:51bobhopealthough it's embaressingly parallel, byrd says in his thesis that the communication overhead is painful
18:52bobhopebut 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:53bobhopeso essentially it should have the perf. characteristics of running on a single core from a memory access latency perspective
18:53bobhope2) 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:54bobhopeI'm not sure if agents use work stealing or something dumber, though
18:54dnolenbobhope: I don't think agents use work stealing - but I definitely thought that JDK fork/join could be leveraged here.
18:57bobhopednolen, that looks right
18:57dnolenbobhope: 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:57dnolena parellel core.logic would rock
18:58bobhopeca=contributor's agreement?
18:58dnolenbobhope: yes
18:59bobhopewhat is that?
18:59dnolensomething you need to submit before you can contribute to Clojure projects.
19:12technomancy_clojurebot: twenty-seven b stroke six
19:12clojurebotCool story bro.
19:18replacabobhope, 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:19bobhopewhere is fjvtree located?
19:20bobhopeI hadn't looked too closely at the java7 fork join framework, but that's exactly the solution to this kind of parallelism
19:20bobhopereplaca, dnolen: do you know where fjvtree is implemented?
19:21replacabobhope: I don't know what liebke did with it
19:21replacayou could look on his github and see if he's got it up there
19:21bobhopei see, i think it's on a branch of clojure called "par"
19:21bobhopei just found some thread with that
19:23replacabobhope: I'm not sure if that's good or obsolete
19:24replacain any case, I feel like David hasn't really brought that work to its conclusion, but gotten distracted by other things
19:27dnolenreplaca: or just waiting for other folks to lend a helping hand :)
19:29bobhopednolen, if i work on core.logic without the CA, is that okay?
19:29bobhopeor does that cause issues
19:29bobhopeassuming that i'd get a CA at some point in the fuuter
19:29replacadnolen: yeah, likely
19:30dnolenbobhope: feel free to work on your own fork, but won't be able to merge in anything until Clojure/core get your CA.
19:30dnolenreplaca: heh, I've been surprised by the various little fixes I've gotten to core.match and core.logic already.
19:32dnolenreplaca: recently cgrand contributed a pretty amazing core.logic branch, so it's all just a matter of time sometimes.
19:32replacadnolen: and generating excitement about what you're doing
19:33dnolenreplaca: true, that's key.
19:33replacaI'm surprised more folks haven't been interested in making fork/join a huge win
19:33replacaI know Rich is interested in seeing that happen
19:34dnolenreplaca: I agree. fork/join is untapped.
19:34bobhopecould it be that it's really annoying to install?
19:34dnolenbobhope: it's in JDK 7
19:34bobhopebut jdk7 isn't in any repos on the systems I use, afaict
19:35replacabobhope: yeah, that might be part of it
19:35replacait seems like it would fit enough with the big data story that people would want it
19:37bobhopedo you know an easy way to get clojure on jdk7 on mac or ubuntu 11.04?
19:37bobhopeI'd like to experiment with fork/join parallelizing core.logic
19:38dnolenbobhope: Oracle has a developer preview for os x jdk 7 now, simple install
19:38dnolenhttp://jdk7.java.net/macportpreview/
19:39bobhopewill clojure automatically use that after I install it?
19:39bobhopednolen, or do i need to configure lein correctly
19:41bobhopealso, 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:43replacabobhope: all the clojure.core libs build with Maven
19:43dnolenbobhope: no you need to set the JDK via Java Preferences utility app
19:43dnolenbobhope: everything else after that is automatic
19:44bobhopethat's super easy
19:44dnolenbobhope: you can give this code a spin when you get it setup, http://dosync.posterous.com/clojure-openjdk-7-and-forkjoin
19:44bobhopeI've never used maven--what do I need to know to finish getting running?
19:45dnolenbobhope: you don't need to mess w/ maven, just use lein
19:45jackhammer2022has anybody gone through the book Seven Languages in Seven Weeks ? any reviews for Clojure chapter ?
19:46bobhopednolen, 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:46jackhammer2022i have a fair deal of knowledge of Racket and I am gonna begin learning Clojure with that book :)
19:48dnolenbobhope: it should yes
19:48dnolenjackhammer2022: probably better to get one of the dedicated books on Clojure
19:49bobhopednolen, 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:50jackhammer2022dnolen: umm ok..just had this book for the holidays..
19:51jackhammer2022*got'
19:52dnolenjackhammer2022: it'll probably cover some essentials, but if you're coming from Racket, you know quite a bit about the Lisp thing :)
19:53jackhammer2022dnolen: yes I do.. :)
19:53dnolenbobhope: oh right, just make a project.clj and set the src directory to src/main
19:55dnolenbobhope: https://gist.github.com/1518582
19:55dnolenk gotta run
19:58bobhopeIs there a way to use lein and specify "latest"?
19:59bobhopeOr how can I discover the latest version of a random contrib library?
19:59ibdknoxif it's an actual contrib, looking on github is probably the easiest
20:01sandy1986Hi ;) How to take advantage of "http://dakrone.github.com/cheshire/" >> parsed-seq ?
20:01sandy1986Heard that lazyness is good if it is possible ;)
20:03replacabobhope: it's not a great answer, but there is a reliable way for contribs
20:05replacabobhope: go to the canonical github repo, e.g., https://github.com/clojure/core.logic and look at the branches pulldown
20:06replacaWhere is says "Current branch" and has the pull down, that is
20:07replacathen select the "Tags" tab on that menu
20:07replacaand you'll see a set of tags that are called <proj>-<vers>, e.g., core.logic-0.6.7
20:08replacathese are the releases that have been pushed through the build system to central and can be accessed via Maven and leiningen
20:08replacapresumable the biggest number is the newest
20:30chewbrancaanyone ever encounted this error before? clojure.lang.Numbers.isPos(I)Z for a java.lang.NoSuchMethodError
20:31chewbrancathe 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:31amalloyAOTed against the wrong version of clojure, probably
20:33chewbrancainteresting, so I see clutch depends on clojure 1.2 base, but has multi-deps support for 1.3
20:35chewbrancathe 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:39amalloychewbranca: a real stacktrace would make it possible to at least guess at what code is mis-compiled/linked
20:39amalloyor i guess it's probably an error during compilation/linking, so probably not
20:41chewbrancahttp://paste.lisp.org/display/126675
20:41chewbrancanaw its happening when I try and save a document with clutch
20:42chewbrancawell yeah I see what you mean, the actual issue is probably happening during compile time
20:43chewbrancathe only thing relevant I've changed since this worked was adding: https://github.com/chewbranca/url-normalizer
20:44chewbrancabah.. sorry need to afk for a bit, will be back
20:50amalloychewbranca: if you have a dependency using contrib.io, 1.3 ain't gonna work well
20:54amalloyto see which dependency is pulling in contrib, you can try: $ lein pom && mvn dependency:tree
21:36chewbrancaamalloy: 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:38mcbride25I'm trying to write a config file for my app in clojure
21:38mcbride25but when I do (load-string "config-file.txt")
21:39mcbride25clojure complains that it cant find certain symbols in my config file
21:39mcbride25theyre macros I defined in my namespace
21:39mcbride25however, running the same function via the repl works fine
21:39mcbride25does anyone know why?
21:47ldhi'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:48ibdknoxldh: just return vectos
21:48ibdknoxvectors*
21:49ldhibdknox: sounds good; i didn't know if there was a strict need to return entries
21:49ibdknoxnope :)