#clojure logs

2011-07-23

00:29semperosanybody else getting errors like this when trying to compile ClojureScript? https://gist.github.com/1101014
00:36tufflaxSay 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?
00:44semperostufflax: can you explain why you need the index?
00:44semperosor what you need it for?
00:46tufflaxI 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.
00:46tufflaxs/list/vector/
00:46lazybot<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.
00:48tufflaxsemperos you see? or is there a better way?
00:49semperosI don't know how complex your data structures are
00:49tufflaxWhy does is matter?
00:49semperossorry, first sentence of a longer answer :)
00:50semperosis there any reason you can't do a for comprehension over the vector of maps
00:50semperoshave a conditional (your current predicate) that "finds" what you're looking for in the target map
00:50semperosmake the update to the map right there
00:50semperosthen just do (into []) if you actually need the sequence to be in vector form
00:50semperosif you have code, happy to take a look
00:51tufflaxHmm, I haven't thought about it, maybe... I don't use for often. :p
00:51ihodesor take the `first` of a `filter`ed list
00:51semperosvery rare that you need to make a change to a datastructure in Clojure in two steps like that
00:51semperosspeaking to tufflax
00:52tufflaxihodes but then i dont get the index
00:52semperostufflax: code?
00:52ihodestufflax: you actually need the index? you seems to be trying to treat the immutable data structs like mutable structs...
00:53tufflaxihodes no i don't want it to be immutable, i just wanna update it and get a new value. :p
00:54tufflaxmutable*
00:54tufflaxnot immutable
00:54semperostufflax: here's an overkill example using the vector of num's you used above
00:54semperoshttps://gist.github.com/1101032
00:55semperosthat returns a lazy seq, which you can make into anything you want
00:55semperosthat returns (2 4 "foo" 6)
00:55semperosno index or second-pass needed to make an update
00:57tufflaxi 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
00:57semperosnot sure I understand, but okie dokie :)
00:58tufflaxwhen u talked about "second-pass needed" it sounded like you didn't like the idea of using 2 fns for something like that
00:58tufflaxwhatever :p
00:58semperoscode sniff
00:59semperosmore than likely not a functional way to handle it, using things like for is idiomatic
00:59semperosbut go for what works for you, Clojure is nothing if not practical
01:00tufflaxBelieve me, I'm all about elegance, just didn't think about for at first :)
01:00ihodes(for [x [1 2 3 4 5 6] :when (odd? x)] (DOSTUFF x))
01:00ihodesis the way to go.
01:00semperoseven nicer, for a simple predicate
01:01ihodesfor any non-anonymous predicate
01:01tufflaxBut that wouldn't return the whole origial with a few updates
01:01ihodestrue, sorry tufflax
01:01tufflaxnp ;)
01:01ihodesyou can map a function that handles the cases over the list, too
01:01semperosobviously if you're using for against a seq of maps
01:02semperosyou'll need to return a map inside the for
01:02tufflaxyeah
01:03semperosI agree with ihodes , you can try using map as well, see which fits better
01:05semperoshttps://gist.github.com/1101032 with equivalent `map` version
01:05tufflaxsemperos ihodes im making a simple time tracking app, heres the gist of it, but i forgot a paren :p http://pastebin.com/3nhQCDL5
01:06semperostufflax: are you trying to update the atom with that code?
01:06tufflaxyes
01:06semperosyou need to use swap! to do that
01:06tufflaxwhat about it?
01:07tufflaxwell... need is a strong word. why do i need to?
01:07semperosyou can't update Clojure's concurrency data structures without their proper functions
01:07semperosyou've assigned x the value of your data atom at that moment in time
01:07tufflaxyeah i know i know
01:07semperosok
01:07tufflaxbut im gonna use reset!
01:08semperossorry
01:08semperosgotcha
01:13semperostufflax: https://gist.github.com/1101052
01:15tufflaxyeah that's nice too. I usually go for 'map' before 'for'.
01:15semperoshowever 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
01:15semperossigning off for tonight, have fun
01:17tufflaxbye
03:54chouserI was under the impression lein would add to my classpath any dirs in my checkouts/ dir. Is this not true?
03:55hiredmanit assumes checkouts are leins projects, so checkouts/project/src
03:59chouserhm, 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?
04:00hiredmanpossibly, it that is what it was designed for
04:01hiredmanyou can just but a symbolic link in lib/
04:01chouserooh!
04:01hiredman(will get cleared whenever you fetch deps though)
04:02hiredman^- entirely too excited about that
04:02chouserI'm getting desperate
04:03hiredmannot desperate enough to jar it up and mvn install into ~/.m2?
04:03chouserI'm trying to deploy to heroku
04:04hiredman:|
04:04chouserbesides, thinking about make a .jar of clojurescript makes my head hurt
04:04hiredmanmmm
04:04hiredmanyes
04:06hiredmanif only the shiny new clojure(script) was easily usable from the old and neglected clojure
04:06chouserok!
04:06chouserfound a horrible hack of a symlink that gets it working
04:18triyoIs there a recommendation for how best to incorporate the ClojureScript libs into a new/or existing leiningen-based project?
04:18chouserfunny, I was just trying to do that.
04:18chouserI can't imagine what I'm doing would be recommended by anyone.
04:19triyoAs they say, great minds think a like. ;-)
04:19triyo*alike
04:20triyoI gather you are running emacs with swank-clojure?
04:20chousernot even a little bit
04:20fliebelDoesn't ClojureScript just use maven? :(
04:20chouserI tried a git submodule first, but heroku doesn't support that
04:21chouserso now I've got a subtree merge and a well-placed symlink. I think that'll work.
04:21hiredmanfliebel: rich actually said something like "I hope maven never gets near clojurescript"
04:21triyonope, no trace of maven in the source
04:21hiredmanand something about not wanting clojurescript in jars
04:22hiredmanno idea what he is thinking
04:22hiredmanthe 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
04:22fliebelhiredman: That's just silly if you ask me. The compiler still lives in JVM land, deal with it.
04:23hiredmanit's a silly old world
04:24fliebel... then rewrite the compiler in cljs, then we can start using npm
04:24triyoSo let me get this straight. No jar exists for the src/ dir of the ClojureScript project?
04:24hiredmantriyo: that would be too simple
04:24fliebelAnyway, how does one contribute to it? No pull request I'm afraid?
04:25chouserfliebel: same as clojure. attach a patch to a jira ticket
04:26fliebelhm, okay. I'm thinking a zipper for the dom would be a fun exercise to get started.
04:27fliebelIs the XML zipper even supposed to work? Or do we need to port clojure.data.xml first?
04:30triyoAnyone else impressed with the ClojureScript twitterbuzz sample?
04:33triyoThe code is far more readable than what you would have to write in JavaScript or even GoogleClosure to achieve the same result.
04:40RaynesI find that amusing when they actually put the goog libraries in a jar when they pull them down.
04:44triyoI'm just gonna copy the src/ and lib/ to my project until there is a better solution for ClojureScript dep.
04:48zakwilsonIt 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.
04:48zakwilsonI 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.
04:48RaynesThe work itself probably has something to do with why this release cycle has taken longer than the others.
04:49RaynesLikewise. I think ClojureScript is awesome.
04:49RaynesIt couldn't have come at a better time for me.
04:50zakwilsonI have yet to try it, but most of my front-end stuff is pretty light on JS.
04:50RaynesI'm into it for non-web reasons.
04:50RaynesMore CLI-related reasons.
04:51hiredmanwell, relevance is a webshop, I believe
04:51RaynesNodejs.
04:51zakwilsonOh... so running compiled apps on V8 instead of the JVM for faster startup?
04:52RaynesYes.
04:53hiredmanI've been fiddling with cocoa+webkit+javascript which clojurescript might in
04:53hiredmanfit in
04:53zakwilsonI don't have that as a problem yet, but clojurescript could be a way.
04:53zakwilsonRight now, I want to to a self-join in clojureql and suspect I might have to hack clojureql itself to make it happen.
04:54hiredmanI still can't believe you are still using that
04:55zakwilsonIt's really nice except for the lack of self-joins.
04:56zakwilsonHow do you interface your Clojure app with your rdbms? (code snippet requested)
04:57hiredmanclojurebot 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)
04:58zakwilsonWhy do you plan to get rid of it?
05:00hiredmanbecause it's and ancient version, the code that uses it is ugly, and I am more likely to use clojure.whatever.jdbc
05:00hiredman(and I think Lau is a tool)
05:01zakwilsonHow would you generate SQL from your Clojure code?
05:01hiredmanjust strings
05:01zakwilsonYech.
05:02hiredman*shrug* all in one place in the data storage layer
05:02zakwilsonI 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.
05:02hiredmanI've sort of thought about using an index instead of a db (lucene)
05:03hiredmanbut clojurebot is hardly taxing on anything
05:03zakwilsonThat might be appropriate for the application in question. I've never used lucene.
05:08amalloyhiredman: mongodb? has been pretty natural and simple for all my uses, though i don't know what clojurebot's usage pattern is like
05:09hiredmanderby is nice, no external dependency
05:09hiredmanI don't really want to install anything
05:10ejacksoni'll join the chorusline and say how much I've enjoyed Redis :)
05:11ibdknoxRedis has served me well too
05:14zakwilsonI'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.
05:15zakwilsonAnd you can't easily swap out one graph database for another, even if another appeared that was better suited to the task.
05:16zakwilsonThis 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.
05:16zakwilsonOh, and I'm lazy.
05:31amalloyzakwilson: jiraph?
05:32zakwilsonamalloy: how production-ready is that?
05:32amalloyzakwilson: geni has been using it for some time
05:33zakwilsonIf I wanted a general comparison between it and Neo4j, is there a place I could find one?
05:33amalloyyou could ask ninjudd, probably. i imagine he looked at neo before writing jiraph
05:35zakwilsonI 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.
05:43Rayneszakwilson, amalloy: The reason we have Jiraph is because Geni needed the revision stuff in Jiraph but Neo4j doesn't have it.
05:43Rayneszakwilson: It is absolutely production reader.
05:43Raynesready, even.
05:43amalloyoh yeah, revisions. that's some cool stuff
06:25ivanwhich OS X file manager is Hickey using in his ClojureScript presentation?
06:33ejacksonforklift
06:36ivanejackson: thanks
07:48CozeyHello. What SQL db access method do You use? ClojureQL, contrib.sql, other?
08:38phenom_hey folks, any idea on how clojure is doing witht he jdk7 dev preview?
09:17gfrlogCozey: I use both of those
09:18romanroehi
09:19romanroeHow can I instantiate a Java class, passing the args as a list? E.g. like (apply str [1 2 3])
09:26gfrlogromanroe: is it a fixed length?
09:26romanroeyes
09:26gfrlogwell the quick and dirty way would be to do it manually: (let [[a b c] foo-args] (new Foo a b c))
09:27gfrlogI don't think it could get much better than that. Maybe a macro could give you something more flexible...
09:28romanroeah, well, its fixed length, but not known when I write the code
09:28Scriptorright, I don't think apply works with java methods/constructors
09:28gfrlogromanroe: but you know that there will be a constructor matching the args?
09:28gfrlog\
09:28romanroeI am currently working on a macro without success :-/
09:28romanroegfrlog,, yes
09:29gfrlogromanroe: (defmacro construct [class args] `(new ~class ~@args))?
09:29gfrlogthat probably doesn't work actually
09:29romanroegfrlog, tried that, didnt work
09:29gfrlogsince the args wouldn't be a list literal
09:29gfrlogis there an upper bound on the list size? :)
09:29romanroeexactly
09:29romanroeye
09:30romanroeyes
09:30gfrlogactuaally I feel like this could be done better with the macro
09:30gfrlogif you could get args evaluated then that would work...
09:31gfrlogand I think a macro can do that but I forget how
09:31romanroegfrlog, when you remember, tell me :-)
09:32gfrlogromanroe: of course
09:32romanroegfrlog, what about (eval args)?
09:33gfrlogromanroe: I'd wager at least five dollars that wouldn't work
09:33romanroelet me try that...
09:33gfrlogalso every time you use eval somebody in #clojure yells at you
09:34jjidodon't think you can use macros for Java constructs
09:34gfrlogjjido: I think that's too vague to be true
09:34Bronsayou could use the #= reader macro
09:34romanroedont know #=, will check
09:35romanroebtw, it seems to work with eval
09:35gfrlogwhat's the macro look like?
09:36Vinzentwhat does #= do?
09:36romanroegfrlog, just a sec
09:36gfrlogVinzent: makes the reader evaluate a form
09:36romanroegfrlog, https://gist.github.com/1101437
09:37Vinzentdidn't know that
09:37gfrlogVinzent: I didn't either for a long while
09:37gfrlogVinzent: and I've never used it
09:37gfrlogVinzent: the primary use case I've heard of is for printing obscure objects in a reader-compatible way
09:38Bronsawith print-dup?
09:38gfrlogyeah that kind of thing
09:38gfrlogso a (sorted-set 1 2) would print as #=(sorted-set 1 2) instead of #{1 2}
09:38Bronsai think you could use it also to force evaluation of some args to a macro
09:39gfrlogBronsa: how so?
09:40Bronsai mean (macro #=(this will be evaluated) (this wont be evaluated))
09:40Vinzentinteresting (but don't think I'll ever need it)
09:40gfrlogBronsa: it wouldn't let you do anything at runtime
09:40romanroegfrlog, (defrecord Foo a b c)
09:40gfrlogso if romanroe has a list that he constructed at runtime, I don't see how that could help him
09:41romanroegfrlog, (new-apply Foo my-list) given (def my-list [1 2 3])
09:41Bronsaoh right
09:41gfrlogromanroe: in particular I'd like something with two different constructors...
09:42gfrlogromanroe: but I probably owe you $5
09:42romanroegfrlog, he, donate them to clojure :-)
09:44gfrlogI'm watching rhickey's recent talk, and coincidentally he just mentioned that eval is something you don't really use in production :)
09:44gfrlogI'm sure there's got to be a better way...
09:47Bronsabut
09:47romanroegfrlog, yep and I just noticed that it doesnt work with locals, only with top-level vars
09:47romanroegfrlog, which makes sense
09:48gfrlogromanroe: yeah, that's actually what I was expecting when I said it wouldn't work. I guess I didn't test it well enough.
09:50romanroegfrlog, lets donate $2.5 each
09:51gfrlogto minimize transaction costs we could flip a coin and the loser donates $5
09:52romanroegfrlog, ok, just did not, you lost... sorry
09:53romanroeerr, did *it*
09:53gfrlogromanroe: no we have to do it trustlessly
09:53romanroegfrlog, to keep it simple, I guess I fall back to reflection for now. clazz.newInstance etc.
09:54gfrlogromanroe: write a function that enumerates all possible arg-lengths
10:00gfrlogdistributed-coin-flip-utility:
10:00gfrlogX=$(uuidgen); echo $X; echo "tails $X" | sha256sum
10:01gfrlogI suppose printing in the opposite order would be more natural
10:02gfrlogthis one's better; X=$(uuidgen); echo "tails $X" | sha256sum; echo "tails $X"
10:14Cozeygfrlog: regarding sql db's - do you guys use anything else - orm'ish etc?
10:18hedelehello 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:18hedeletranslate 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:19hedelesorry for the wall of text
10:21hedeleas 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:21hedelesolving project euler problems is only fun to a limited degree :/
10:23hedele(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:26hedelemaybe 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:27dnolen_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:30hedelednolen_: 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:31hedeleyou 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:32hedeleI'm looking for something which is not developer oriented and I can use, examine its code and improve further
10:33hedeleit 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:33dnolen_hedele: most of the libraries are end user focused so I'm not sure what you mean by that.
10:34hedelednolen_: oh, I meant non programmers (even non tech savvy) by that.
10:34dnolen_hedele: you mean like applications.
10:34hedelefor example if I was learning common lisp I cound just dive in something like stumpwm (a window manager for X)
10:35hedeleyeah, sorry for the confusion
10:35Vinzentthere is a clooj - simple clojure-written ide
10:36Vinzentah, non-programmers
10:36Vinzenthedele, do you want desktop or web app?
10:37hedeleVinzent: 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:39hedelemy 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:40Vinzenthedele, i just don't think that java platform is something very suitable for desktop apps. hm, let me think
10:40jsnikerisHi 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:41Vinzenthedele, by the way, about emacs, you can implement emacs-like editor in clojure (but it's for programmers again)
10:42Vinzentjsnikeris, probably not (I've never seen such destructing)
10:43jsnikerisVinzent: OK, thanks.
10:44hedeleVinzent: 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:45hedeleyup, 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:46hedeleI also*
10:48Vinzenthedele, 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:49Vinzenthedele, I think auto-indentaion, syntax highlighing and integration with lein would be already very usefull for beginner clojurians
10:50hedeleit 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:50hedelebtw there is also qt jambi
10:53hedelemaybe 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:58Vinzentas a faithful Gnome user I feel a vague discomfort when I see the word "qt' :)
10:59raekjsnikeris: you can destructure the result from calling rseq on the vector
10:59raek,(let [[x y z] (rseq [:a :b :c :d :e])] [x y z])
10:59clojurebot[:e :d :c]
10:59Vinzenthedele, it's a good idea, but you also need something not very large, right?..
11:00jsnikeris,(doc rseq)
11:00clojurebot"([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:01jsnikerisraek: ah, clever. thanks!
11:01hedeleVinzent: 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:02raekjust in case you din't know: you *can* use "native" look and feel for swing apps
11:02hedeleon the other hand kde look and feel of gtk is not as good (qt one is almost pixel perfect)
11:03Vinzenthedele, 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:03raek(I'm not saying swing is the best gui framework out there)
11:04Vinzentraek, usually it looks not very "native", misc details is different, like fonts, margins, etc
11:04hedeleraek: 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:04hedeleit looks alien but at least it is good and fast
11:05hedeleVinzent: you are right btw, such a project would be too big for me atm
11:05Vinzent+1 for nimbus (also "alloy" or smth like is not bad)
11:07raekyeah, the font rendereing is important
11:08meegeealso it doesn't use system menubar color and stuff
11:08Vinzenthedele, 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:09raekreally? I might take my utterance back.
11:09Vinzentmaybe it's possible to improve this somehow and build something like "utils for beginner writers" (just an idea)
11:09gfrlogCozey: most of what I've done has been a solo effort. I haven't used any additional ORM; just maps.
11:12meegeeraek: 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:13meegeeVinzent: My initial idea was finding an application to use and contribute to but I might just do something like that, thanks
11:16meegee(I'm hedele btw, forgot my long running irc instance on usealice.org and logged in using erc ignoring my unstable connection)
11:17Vinzentmeegee, I believe he will open source it so you'll be able to join the project soon :)
11:17meegeeoh sweet
11:21Vinzentalso, it'd be really cool if someone developed simple cross-platform convenient note editor.
11:23meegeeI believe it is something you just open up an app, a website or Mx-org-mode, write your note down and close quickly
11:24meegeethere are already many people that did it way better than clojure can handle :)
12:17kryftHmm, 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:18kryftOr a pmap in clojure or something. :)
12:37corbbetwith 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:38corbbetso im not able to run clojurescript from within the clojure repl with swank (although it works fine in the terminal)
12:53tomojcorbbet: huh, me too
12:54tomojI didn't expect it
12:54corbbettomoj: seems to be a swank issue
12:54tomojI thought it used to work if you went to the jvm in the terminal and typed stuff in
12:54corbbetyeah that works fine
12:54tomojI mean, the one `lein swank` is running in
12:54corbbetoh hmm
12:55tomojbut it doesn't for me now
12:55tomojare you using clojure-jack-in or something?
12:55corbbettomoj: nope, just lein swank
12:55tomojoh, right
12:55corbbetusing swank 1.3.1, ill upgrading to the snapshot
12:55corbbetill try upgrading*
12:57corbbethmm 1.4.0 has the same issue it seems
12:58tomojwhat does clojurescript call (read) for?
12:58corbbetfor its repl loop
12:59tomojoh.. I wouldn't expect a custom repl to work inside of slime-repl
13:02kephaletomoj: clojurescript repl works inside slime-repl
13:02corbbetkephale: what version of swank are you using?
13:02corbbetkephale: even a simple (read) fails for me
14:59jsnikerisHi 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:59jsnikerisideas?
14:59danlarkinworking as intended
14:59jsnikerisdanlarkin: what am I doing wrong?
15:00danlarkinnothing
15:00danlarkinyou're just misunderstanding what you see
15:00danlarkincheckouts/ doesn't "replace" your regular deps
15:01danlarkinit will just come first on the classpath
15:04jsnikerisdanlarkin: 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:05jsnikerisand then after that, changes will be picked up automatically
15:05danlarkinno, that should not be necessary
15:06danlarkinfair warning: I haven't actually ever used checkout deps, but I think I understand how it works
15:27fliebel_testlazybot: ping!
15:27fliebel_test&(+ 1 1)
15:27lazybot⇒ 2
15:27gfrlogfliebel_test: ##(println "pong")
15:27lazybot⇒ pong nil
15:29fliebel_testCan you believe it? IRC from iChat!
15:42jsnikerisNow 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:48arohnerjsnikeris: make sure the class is in the jar?
15:49jsnikerisarohner: browsing the jar I see: net/cgrand/enlive_html.clj
15:49jsnikerisarohner: my error is: java.lang.ClassNotFoundException: net.cgrand.enlive-html
15:49arohnerjsnikeris: class? how are you trying to load that?
15:50arohneri.e. what clojure command are you using?
15:50jsnikerisarohner: I'm just trying to run a simple test: lein test. Let me see if I can get a REPL up
15:51arohnerright, but what clojure command are you using to load enlive?
15:52jsnikeris(require '[net.cgrand.enlive-html :as e]) works fine
15:53jsnikeris(ns ... (:require [net.cgrand.enlive-html :as e]))
15:55arohnerjsnikeris: 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:55arohnerlein test loads eveything in test/, maybe an unexpected file is being loaded
15:56jsnikerisarohner: ahh I was closing the ns declaration before the (:require [net.cgrand.enlive-html :as e])
15:57jsnikeris,(:require [clojure.core :as e])
15:57clojurebotjava.lang.ClassNotFoundException: clojure.core
15:58jsnikeris,(:require [clojure.test :as e])
15:58clojurebotjava.lang.ClassNotFoundException: clojure.test
15:59jsnikeris,clojure.test
15:59clojurebotjava.lang.ClassNotFoundException: clojure.test
16:00jsnikerisarohner: ClassNotFoundException had me barking up the wrong tree. Thanks for the help
16:00arohnernp
18:09qbgIs there a map-contains relation in core.unify?
18:09qbgI mean core.logic
18:11neesonHey 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:12dsantiagoneeson, the best option right now is probably ritz, github.com/pallet/ritz .
18:12neesonChecking it now now...
18:13neesonout now, rather :)
18:14dsantiagoIt still has some problems.
18:14technomancythere's also CDT
18:14dsantiagoClojure's locals clearing will pretty much remove most of the useful information in the stack frames when you try to set breakpoints.
18:15neesonI 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:16neesonI remember that things that you really need (like line numbers in error reports) simply didn't work from the REPL
18:16dsantiagoYeah, it's still spotty.
18:17neesonI'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:17mdeboardI think I'm going to try to rewrite some js I wrote for work in cljs
18:17technomancywell, 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:17mdeboardwish me luck
18:17qbgLine numbers should work (though macros may disturb it a bit)
18:19neesonLooking at CDT now - interesting. technomancy: can you say how solid it is in practice?
18:21technomancyneeson: I haven't used it myself. the only debugging tool I use is swank break
18:21technomancyclojurebot: swank.core/break?
18:21clojurebotswank is try the readme. seriously.
18:21mdeboardlol
18:22technomancyclose, but not quite
18:22technomancyclojurebot: 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:22clojurebotIn Ordnung
18:22technomancyI've never found myself needing to step through code, so cdt seems like overkill.
18:23neesonRight, 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:23neesonIs swank stable?
18:24dsantiagoRitz 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:25technomancythe only problem I've run into with swank is related to emacs24
18:26neesonGotcha
18:26dsantiagoNeither will get around the locals clearing problems, as far as I know.
18:26technomancyneeson: 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:26technomancyhence clojurebot's advice above
18:27neesonRight
18:28neesonWell 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:29technomancyneeson: what's the website, if you don't mind my asking?
18:29technomancyI don't remember any production use of clojure announced before the start of 09
18:29neesonIt's down now, but it was Urbantastic.com. It got about 100 uniques a day at its peak
18:30neesonI used Clojure and CouchDB, both of which were pre-1.0
18:31technomancycool
18:32neesonYeah, I've got issues with using cool tech before it's stable :) Since then I've been using nodejs, but I miss lisp.
18:33technomancywere you trying to be stealthy about the fact that you used clojure?
18:35neesonNot 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:36technomancyok, so it was announced in 09
18:37technomancyluc prefontaine's project was announced in january of 09
18:38technomancyI think I actually remember reading this post =)
18:39neesonThat's crazy :) I remember it got onto the second page of Reddit and the front of Hacker News
18:41technomancythis was just a couple months before I got a job using Clojure
18:41neesonI'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:42neesonWell done on the Clojure job - I wouldn't have guessed that there'd have been any back then :)
18:42technomancyneeson: well, I think this may have been the first =)
18:42neesonNice :)
18:43neesonAnyway, I've got to jet, but it was nice talking with you technomancy :)
18:43technomancycheers
18:43technomancyhope you get things figured out
18:43neesonThanks again
19:00dnolen_qbg: no containso in core.logic, I don't see how Clojure maps can be dealt with in a relational manner.
19:00devnhey everyone
19:01dnolen_core.logic does support map unification, but logic vars are only allowed in the values, not in the keys.
19:04qbgdnolen_: A map is a function relation
19:07mdeboardI'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:07qbgmdeboard: Destructuring
19:07mdeboardthanks
19:09amalloymdeboard: syntax for it is ##(let [[x y & more] [1 2 3 4 5]] (list x y more))
19:09lazybot⇒ (1 2 (3 4 5))
19:10mdeboardBut I can use any collection that has a rest method right
19:10mdeboarddoesn't have to be a vector in other words
19:11qbg##(let [[x y & more] '(1 2 3 4 5)] (list x y more))
19:11lazybot⇒ (1 2 (3 4 5))
19:11amalloythat's true for the thing on the right, not the one on the left
19:13mdeboardcoo
19:14amalloyand even then not strictly true
19:14amalloysince maps and sets can't be destructured into vectors without first taking a seq view of them
19:15mdeboardhm
19:16mdeboard##(let [(x, y & more) {:foo 1 :bar 2 :baz 3}] (list y))
19:16lazybotjava.lang.Exception: Unsupported binding form: (x y & more)
19:16mdeboardoop
19:17mdeboard##(let [[x, y & more] {:foo 1 :bar 2 :baz 3}] (list y))
19:17lazybotjava.lang.UnsupportedOperationException: nth not supported on this type: PersistentArrayMap
19:17qbgdnolen_: Any tips on how to implement a (mathematical) function (relation) in core.logic?
19:19amalloybut mdeboard, ##(let [[x, y & more] (seq {:foo 1 :bar 2 :baz 3})] (list y)) will work fine
19:19lazybot⇒ ([:bar 2])
19:22mdeboardgfrlog: ew
19:22mdeboardgfrlog: I don't want it trying to guess my intentinos.
19:22mdeboardintentions
19:22amalloy(inc mdeboard)
19:22lazybot⟹ 1
19:22gfrlogmdeboard: what? it's no different than any other function that seqs things
19:22gfrlogit's not a guess, I just happened to use the word "try"
19:23mdeboardgfrlog: What if it does that and works, but the result isn't actually what I wanted to do?
19:23gfrlogmdeboard: what if ##(first #{3 4}) isn't what I wanted it to do?
19:23lazybot⇒ 3
19:24mdeboardwhat.
19:24gfrloga set isn't sequential but (first) is happy to call seq on it
19:25mdeboardI guess I don't see the equivalency, but admittedly I'm not thinking real hard on it.
19:26gfrlogI'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:28dnolen_qbg: like arithmetic?
19:28qbgdnolen_: No
19:29dnolen_qbg: what kind of mathematical relation then?
19:29mdeboardgfrlog: 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:30mdeboardThat turned convoluted after the first quote
19:31mdeboardgfrlog: Is clojure actually calling (first (seq #{1 2 3}) when you type (first #{1 2 3}) ?
19:31amalloymdeboard: i think the whole statement was a mess anyway
19:31mdeboardamalloy: :|
19:31gfrlogmdeboard: I assume so
19:31amalloymdeboard: no, it's not. first is implemented in terms of seq
19:31mdeboardgfrlog: I doubt it
19:32amalloyfirst could be (but isn't) implemented as (.first (seq x))
19:32dnolen_,(source first)
19:32gfrlog^ that's essentially what I was thinking
19:32clojurebotjava.lang.Exception: Unable to resolve symbol: source in this context
19:32gfrlogdnolen_: it just delegates to clojure.lang.RT
19:32amalloygfrlog: which actually does the seq(x).first() call, i think
19:33amalloyyou could make nth do that, but getting it to behave nicely in a destructuring context is actually not easy
19:33amalloyif you always call seq on everything, you lose fast-random-access on objects that supported it
19:33gfrlogamalloy: is nth the difference between types that will destructure and won't?
19:33dnolen_qbg: can you explain what you want to do?
19:33amalloyyes
19:34gfrlog(sequential-destructure of course)
19:34qbgdnolen_: Basically containso
19:34amalloynth and nthnext; i'm not sure how nthnext is implemented
19:34qbg(defn geto [k v m] (membero [k v] m)) allows for k to be mapped to v and v'.
19:34dnolen_,(seq {1 2 3 4})
19:34clojurebot([1 2] [3 4])
19:34qbgBut containso would not
19:35gfrlogamalloy: so what happens with (let [[a b & cs] (vec (range 200000))] cs)?
19:35dnolen_qbg: a proper containso is possible if you call seq on the map first.
19:35qbgI would want (run* [q] (containso :a 1 q) (containso :a 2 q)) to return an empty sequence
19:35amalloygfrlog: i think it uses nthnext three times, but try it and see
19:36amalloy&(destructure '[[x y & more] foo])
19:36lazybot⇒ [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:36gfrlogamalloy: returns a clojure.lang.PersistentVector$ChunkedSeq
19:36gfrlogdoes such a seq have fast nth?
19:36dnolen_qbg: it would since :a is not a sequence.
19:37amalloyi don't think so
19:37amalloybut the vec you started with did
19:37dnolen_qbg: a more efficient solution might be possible once I get CLP(X) into core.logic.
19:37qbgdnolen_: containso here is key-value-map
19:37gfrlogamalloy: okay, so the criticism about losing fast-nth is not a reason to not call seq for destructuring
19:37gfrlogamalloy: I wasn't sure if you meant it that way or not
19:37amalloyyou're misunderstanding
19:37amalloyit is a reason for that
19:38dnolen_qbg: ? what are the arguments to containso ?
19:38gfrlogamalloy: okay. what am I missing?
19:38amalloyyou make the destructuring *itself* slower, by calling seq on it before you call nth on it
19:38qbgdnolen_: First a key, then a value, and then a map
19:38amalloyrather than losing fast-access to the thing you get after destructuring
19:39gfrlogamalloy: I guess I don't see why you need to call nth on something when destructuring
19:39amalloyit puzzles me sometimes too. that's how the current impl works though
19:39qbgdnolen_: (containso k v m) -> (== (get m k) v) essentially
19:40gfrlogamalloy: okay. so this isn't a principled argument, just about the implications given the current implementation?
19:40amalloyit seems like it could be implemented all in terms of seq
19:40dnolen_qbg: have you looked at the logic starter by ambrose?
19:41qbgdnolen_: You mean https://github.com/frenchy64/Logic-Starter/wiki
19:41qbgIf so, yes
19:42amalloygfrlog: i think so. it would be an interesting exercise to rewrite destructure with just seq
19:43gfrlogamalloy: for lists, I would think nth would be _less_ performant
19:43amalloybut destructure is an incredibly dense/convoluted thing
19:43amalloygfrlog: for sure
19:44gfrlognot that it makes much difference for nearly any common case.
19:45amalloygfrlog: 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:45gfrlogamalloy: but then I'd have to sign that CA that's been on my desk for the last week
19:45triyoI'm trying ClojureScript with (goog.net.XhrIo/send url callback)
19:46amalloyi think it would be a better implementation, and as a side effect (har har) would solve the problem you've been having
19:46gfrlogamalloy: changing the behavior wouldn't be acceptable though would it?
19:47gfrlogI guess I assumed it is the way it is because somebody disagrees with me :)
19:47triyoThen 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:47triyoThis seems very wrong..
19:47triyoIs the a js to clj process that I'm missing
19:49triyowell 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:50triyoMY return type is html
19:50triyoI've seen Json examples that work.
19:52amalloygfrlog: 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:53gfrlogamalloy: oh right
19:56amalloygfrlog: not that that approach wouldn't be fun... https://github.com/clojure/clojure/pull/6
20:02gfrlogamalloy: that commit has a very high changes-to-effort ratio
20:02gfrlogalso a high ratio of git-storage-space-to-complexity-of-change
20:09mdeboardgfrlog: I'm glad we can agree that I am correct.
20:09mdeboardgfrlog: (kidding)
20:10mdeboardIs cljs packaged up and onto maven or what have you so I can add it to my project.clj deps?
20:10amalloygfrlog: https://github.com/MrMEEE/bumblebee/commit/a047be8 has a pretty high changes:effort too
20:10ibdknoxmdeboard: my understanding is that it is intentionally not packaged right now
20:11mdeboardibdknox: I see, thanks
20:12ibdknoxis anyone else finding the Google Closure APIs extremely painful?
20:13mdeboardibdknox: 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:13mdeboardmentioned during the cljs announcement
20:14ibdknoxmdeboard: haha
20:14ibdknoxwell, they could definitely fill a book
20:14ibdknoxdoing anything in it seems to take an order of magnitude more code than in most other JS libs out there
20:22mdeboardIs it even possible then at this point to access the cljs namespaces from within emacs then?
20:22mdeboardclojure-jack-in swank errors out
20:26ibdknoxmdeboard: rich was using emacs in the demo wasn't he?
20:26mdeboardOh yeah
20:26mdeboardwith some trouble :P
20:26ibdknoxso far I've only gotten things to work when I'm in the root dir
20:28Scriptor`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:32dnolen_qbg: fascinating, trickier than I thought, https://gist.github.com/1102041
20:36dnolen_qbg: real puzzle, glad you brought it up.
20:37mdeboardIs there a way to add a subdir to the classpath?
20:37mdeboardis classpath just an env var?
20:37mdeboardjava magic imo
20:38qbg##(doc add-classpath)
20:38lazybot⇒ "([url]); DEPRECATED Adds the url (String or URL object) to the classpath per URLClassLoader.addURL"
20:38mdeboarddeprecated in favor of?
20:38amalloymdeboard: deprecated in favor of not doing it; it doesn't work reliably
20:39qbgmdeboard: Do you not know the subdir when you launch the jvm?
20:39amalloyyou have to set up the classpath when you start the jvm
20:40dnolen_qbg: particularly cool because it's relational so we don't need to define dissoco or containso
20:40mdeboardWel, I'm talking in relation to lein of course, so is further classpath specs something I can put in project.clj?
20:40qbgdnolan_: Cool. What does 'nm' stand for?
20:40dnolen_qbg: new map
20:40qbgSweet.
20:40amalloymdeboard: what do you want to add? more source files, more libraries, or what?
20:41XPheriorIs 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:41amalloy&(nth [1 2] 5 10)
20:41lazybot⇒ 10
20:42XPheriorWhat's with the last two parameters? I can understand the 5, by why is 10 tacked on?
20:42amalloy&(doc nth)
20:42lazybot⇒ "([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:42XPheriorOh wait, I get it.
20:42XPheriorWow that was silly. Thanks man.
20:43zmarilPardon me, why is it that "some" and "every?" have varying amounts of question marks?
20:43dnolen_qbg: https://gist.github.com/1102041, this is why I love relational programming
20:43zmarilWhy not "some?" and "every?" or "some" and "every"?
20:43dnolen_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:45hiredmanzmaril: every? returns a boolean, some returns the first result of the function you pass it or nil
20:47zmarilhiredman: 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:47qbgdnolen_: Hmm... (run* [q] (assoco [[:a 1]] :a 2 q))
20:48dnolen_qbg: ()
20:48qbgIt would be cool if it was ([[:a 2]])
20:50qbgThen containso would be (defn containso [m k v] (assoco m k v m))
20:51dnolen_qbg: you making me write code that's blowing my mind :) https://gist.github.com/1102041
20:54dnolen_assoc, dissoc, contains, get all in one relation
20:56qbgToo bad (run 1 [q] (containso q :a 1) (containso q :a 2)) doesn't seem to terminate.
20:57dnolen_qbg: yr definition of containso is wrong
20:57qbgHow should it be defined then?
20:59dnolen_qbg: https://gist.github.com/1102041
21:03qbgdnolen_: Doesn't that definition of containso say that [k v] is contained in every map?
21:04dnolen_qbg: you have to think relationally, if q is not ground ... yes
21:06dnolen_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:06qbgBut (run* [q] (containso [[:a 1]] :a 2)) will return (_.0) with that definition
21:07dnolen_qbg: q isn't involved, it never gets bound to anything, thus (_.0)
21:08qbgShouldn't the return value be () as :a does not map to 2 in [[:a 1]]?
21:08dnolen_no, containso just checks for the existence of a key, not the value.
21:09dnolen_qbg: what you want is findo, not containso
21:09qbgOkay, that make much more sense.
21:10qbgThen why isn't containso just [m k], instead of [m k v]?
21:10mdeboardWhat do all of you do with Clojure? amalloy excepted somewhat
21:10mdeboardIn terms of types of projects
21:10mdeboardamalloy: Well, I have a good example of what you do already
21:11dnolen_qbg: sorry I was just riffing of what you wanted initially
21:11qbgI guess I didn't understand what I was asking for then :)
21:12mdeboardamalloy: Mostly i'm looking for things that aren't web-centric
21:12ambrosebsdnolen: neat!
21:12qbgdnolen_: Any chance this makes it into core.logic?
21:13amalloymdeboard: there's lazybot too
21:13dnolen_qbg: I need to play around with this some more, I think there are some edge cases still.
21:13dnolen_qbg: but yes, it seems useful.
21:13mdeboardamalloy: Yeah I github stalked you already
21:14qbgdnolen_: (run 1 [q] (assoco q :a 1 q) (assoco q :a 2 q)) not halting might be one
21:15dnolen_qbg: can't fix that. q is not ground, and assoco definition will search indefinitely for a solution.
21:17dnolen_qbg: that problem is easily avoided by using a fresh variables for the output in both goals..
21:18dnolen_(run 1 [q0] (exist [q1 q2] (assoco q1 :a q2) (assoco q2 :a 2 q0)))
21:20ambrosebsdnolen_: can we assoc clojure maps?
21:20dnolen_ambrosebs: not without calling seq on them first no.
21:21octei'm using destructuring to assign the items from a seq to variables (let [[foo bar baz] blargh])
21:21octewhat's the best way to modify some of those variables
21:21octefor 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:21qbgdnolen_: Assuming it was :a 1 above, then that won't return ()
21:23dnolen_qbg: why should it? you wanted assoco to replace.
21:25amalloyocte: 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:26qbgJust pointing out that your code isn't equivalent to mine
21:26dnolen_qbg: it's not clear to me what you're trying to express.
21:26amalloyyou could write (let [[foo bar baz] (map #(% %2) [identity inc identity] [1 2 3])])
21:27qbg(run 1 [q] (assoco q :a 1 q) (assoco q :a 2 q)) is a contradiction
21:27octeactually i did
21:27amalloybut that's really worse than just pulling the things out and working with them one at a time
21:27octe(let [[foo bar baz] some-seq foo (Integer/parseInt)])
21:27octe(let [[foo bar baz] some-seq foo (Integer/parseInt foo)])
21:28amalloyright
21:30qbgdnolen_: (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:31dnolen_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:31dnolen_qbg: the second will always fail, causing your program to backtrack looking for another solution.
21:31dnolen_s/second/second goal
21:31lazybot<dnolen_> qbg: the second goal will always fail, causing your program to backtrack looking for another solution.
21:31dnolen_forever
21:33dnolen_qbg: defna commits to a particularly branch of the search, if that fails it won't try again.
21:33dnolen_qbg: this is not relational, you can no longer infer input values from the output value.
21:35dnolen_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:36dnolen_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:36dnolen_s/that/the
21:36lazybot<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:36dnolen_erg, heh
21:37qbgI just have a feeling this is because we are emulating a map with a seq of k/v pairs
21:38ambrosebsqbg: do you completely understand the difference between conde and conda?
21:38dnolen_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:38qbgVery interesting stuff this is...
21:39qbgIn 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:48dnolen_qbg: well gosh darn, I figured it out I think.
21:48dnolen_qbg: https://gist.github.com/1102041
21:49dnolen_qbg: basically enforcing that q cannot equal itself if it's changing
21:50ambrosebsthat's awesome
21:50qbgIt passes that test case at least!
21:51qbgThis. Is. Awesom.
21:51qbg*Awesome.
21:51mdeboardOk, 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:52qbgmdeboard: How are you running the project?
21:52seancorfield:require mdeboard
21:52seancorfield(ns foo.core (:require [clj-http.client :as client]))
21:52dnolen_qbg: another correction, https://gist.github.com/1102041
21:53seancorfieldi assume your project namespace would be foo.core (for project foo), not just foo
21:53dnolen_qbg: I'm done, great fun, let me know if you fun into things that don't work w/ that.
21:53dnolen_s/fun/run
21:53lazybot<dnolen_> qbg: I'm done, great run, let me know if you run into things that don't work w/ that.
21:53dnolen_are
21:53devnhello all
21:53dnolen_arg :)
21:53mdeboardqbg: Using clojure-jack-in
21:54mdeboardseancorfield: Made no difference fwiw but thanks
21:54mdeboardseancorfield: made it easier to diagnose when I'm using correct syntax :)
21:54seancorfieldglad it helped a tiny bit :)
21:54seancorfieldi gather you're using emacs/swank or something?
21:54mdeboardyep
21:55seancorfieldthen i probably can't help... not an emacs user...
21:55mdeboardwell, even in the repl.
21:55seancorfieldbut i bet there's plenty of emacs users here who can...
21:55mdeboardlein repl
21:55amalloymdeboard: you added the : *and* dropped the ' and it complained?
21:56hiredmanmdeboard: (ns foo (:require ...)) vs (ns foo (require ...))
21:56seancorfieldhmm, did it put it in lib/ when you ran lein deps ?
21:56seancorfieldif not, perhaps the problem is in project.clj?
21:56mdeboardamalloy: No, didn't drop the ', was following instrs from the clj-http readme :\
21:56mdeboarddropping it did the trick
21:56mdeboardthanks
21:56seancorfieldwhee!
21:56amalloylink to the readme?
21:56mdeboardhttps://github.com/mmcgrana/clj-http
21:57seancorfieldah, that (require) syntax is for the REPL, not for a (ns) decl
21:57amalloyclojurebot: require?
21:57clojurebotNo entiendo
21:57amalloymutter
21:57mdeboardlol
21:57amalloymdeboard: short version: require/use/etc are functions, which need their arguments quoted
21:57mdeboardoh I get it.
21:57amalloy(ns...) is a macro that doesn't need quoting, and uses :require instead of of require
21:58mdeboardbut ns accepts mapped kwargs
21:58mdeboardor just kwargs, rather.
21:58mdeboardGotcha
21:58mdeboardThat connects the dots better.
21:59mdeboardlol
22:06antares_hey guys
22:07antares_I am trying to define a protocol and getting exceptions
22:07antares_and examples in The Joy of Clojure seem to be different from the source in Clojure master :/
22:07antares_did defprotocol change for 1.3?
22:08qbgantares_: Source and exception?
22:08antares_qbg: https://gist.github.com/1724d20f73e650ff9937
22:09antares_qbg: the order of protocol name & extended type seems to be different between master (protocols.clj) and The Joy of Clojure
22:09antares_or I am just missing something :)
22:09antares_oops
22:10antares_sorry, in this example protocol name is incorrect (uses leporidae.core) but I tried a million of other ways, including just Closeable :)
22:10antares_I've updated the gist
22:10qbgI think you want extend-protocol instead of extend-type
22:10clojurebotexcusez-moi
22:10antares_qbg: bummer
22:10antares_qbg: let me try
22:13antares_qbg: that helps. Now one more question. My protocol has the `close' function. How do I use it in my random namespace?
22:13mdeboardI hate Clojure for giving me a reason to join ##java :(
22:14antares_http://clojuredocs.org/clojure_core/clojure.core/extend-protocol doesn't demonstrate how to use the protocol we just defined :(
22:14clojurebothttp://clojure-log.n01se.net/date/2009-10-13.html#12:02
22:14qbgantares_: Use how?
22:14antares_qbg: my goal is to be able to call (close c) where c is an instance of several Java classes
22:15antares_qbg: or am I abusing protocols then?
22:15qbgJava does have java.io.Closeable
22:16antares_qbg: ok. But those classes do not implement it.
22:17amalloyantares_: that sounds more or less like what protocols are for
22:18qbgIf you rename extend-type to extend-protocol (and optionally merge them together), it should work
22:19antares_qbg: ok, let me dabble with this a little more. I already switched to extend-protocol, that helped. Thank you.
22:41hiredmanstandby for upgrade to clojurebot 0.3.0 "Development Has Stalled"
23:04mdeboardIs tehre a "private method" convention in clojure?
23:05qbgmdeboard: defn- ?
23:06hiredmanif 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:06hiredman(defn- is a shortcut for the above)
23:06mdeboardAh, I see
23:06mdeboardThanks both of you
23:10amalloyhiredman: that's not really true, though, right? :private just means "don't put this in my list of ns-publics"
23:13hiredmanpossibly
23:15hiredmanlooks it actually does both in different code paths *sigh*
23:15hiredmanlooks like
23:15amalloyhaha
23:15amalloyhiredman: then why does #'private-var work fine?
23:16amalloyer, #'some-ns/private-var
23:16hiredmanthevarexpr codepath doesn't check .isPublic
23:17hiredmannot both as in (and … …) both as in (or … …) depending on what you are doing with the var
23:22amalloyah
23:32mdeboardIs there an idiomatic way of converting a :keyword to a string and strip the leading colon? Besides (string/replace s match replace)
23:33hiredman ,(name :foo)
23:33hiredman,(name :foo)
23:33clojurebot"foo"
23:33mdeboardah, awesome
23:33mdeboardthanks
23:36hiredman ,(name :foo)
23:36clojurebot"foo"
23:36hiredman^- that'll be in 0.4.0
23:37mdeboardWhat will be
23:37mdeboardoh, ignoring leading whitespace
23:37mdeboard?
23:37hiredmanright
23:38mdeboardAnd 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:38mdeboard(key {:foo "bar"})
23:38mdeboard,(key {:foo "bar"})
23:38clojurebotjava.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.util.Map$Entry
23:38hiredman,(doc key)
23:38clojurebot"([e]); Returns the key of the map entry."
23:38qbg,(key (first {:foo 5}))
23:38clojurebot:foo
23:38mdeboardYeah
23:38hiredman{} is map, not a map entry
23:38mdeboard(first {:foo 5})
23:38hiredman~google java MapEntry
23:38clojurebotFirst, out of 29000 results is:
23:38clojurebotMap.Entry (Java 2 Platform SE v1.4.2)
23:38clojurebothttp://download.oracle.com/javase/1.4.2/docs/api/java/util/Map.Entry.html
23:39mdeboard,(first {:foo 5})
23:39clojurebot[:foo 5]
23:39mdeboardoh
23:39mdeboard:|
23:39hiredman^- looks like a vector, and is, but is also a MapEntry
23:40mdeboardI suppose I expected (key) to work on a length 1 map
23:42mdeboard,(val (first {:foo 5}))
23:42clojurebot5
23:43mdeboard,(let [x {:foo 5}] (for [i x] (str (key i) "=" (val i))))
23:43clojurebot(":foo=5")
23:43mdeboardhm