#clojure logs

2011-05-19

00:02amalloy*chuckle* thanks, google. you were wrong in guessing that i meant to search for "mongo ninja" instead of "mongo nin", but you improved my day
00:09wastreli'm having fun trying to figure out slimv
00:32wastrelyeah i have no idea how to install or use slimv
00:34puredangerIn case anyone here has thoughts: http://stackoverflow.com/questions/6053483/how-can-i-proxy-a-java-class-with-overloaded-methods-in-clojure
00:41rmarianskipuredanger: what happens if you use gen-class and only override the one?
00:42puredangerrmarianski: haven't tried gen-class
00:42puredangerrmarianski: I have fulfilled my clojure edge case quota for the data and worked around it with a Java adapter for the moment :)
00:42puredangers/data/day/
00:42sexpbot<puredanger> rmarianski: I have fulfilled my clojure edge case quota for the day and worked around it with a Java adapter for the moment :)
00:43puredangersexpbot: stuff it
00:43amalloypuredanger: we can add you to the list of people he won't do sed replacement for
00:43puredangeramalloy: it's ok, just tired :)
00:44rmarianski:)
00:46rmarianskiseems like proxy should work though
01:02seancorfield__java interop question... i went to a neo4j preso tonight and they seem to define relationships as enums that implement an interface...
01:03amalloyseancorfield__: you're SOL there
01:04brehauti was under the impression that enums are just sugar for classes in java?
01:04amalloybrehaut: they're special classes
01:06amalloythe compiler knows about them and gives them special properties, which i would demonstrate if i could find any enums baked-in to java
01:09amalloyi can't seem to do that, but here: http://download.oracle.com/javase/1,5.0/docs/api/java/lang/Class.html#isEnum%28%29
01:10brehautweird
01:11amalloybrehaut: this allows several nice things, like the compiler can complain if your switch/case statement doesn't cover all the enum constants
01:27seancorfield__hmm, i posted a Q about java interop earlier but was having network probs so i don't think it went thru
01:28seancorfield__i went to a neo4j preso tonight...
01:29amalloyseancorfield__: we concluded you're out of luck
01:29seancorfield__lol
01:29seancorfield__so how much of the question did you get?
01:29amalloyyou mentioned enums
01:29amalloyie, we only got the first message
01:30seancorfield__yeah... so i did (def knows (reify RelationshipType (name [this] "knows")))
01:30amalloyhere, i'll gist it
01:31seancorfield__that worked for use with neo4j but i wondered if there was a nicer way to construct a set of enums in clojure
01:31amalloyseancorfield__: https://gist.github.com/980249
01:31amalloywait, you were able to define an enum from clojure?
01:32seancorfield__yup
01:32amalloyalso, god almighty those other two seancorfield[_] folks make it hard to tab-complete you
01:32seancorfield__sorry man
01:32amalloycan i see how you defined an enum? i thought clojure didn't do that
01:32seancorfield__public enum MyRelationship implements RelationshipType { KNOWS, IS_FRIENDS_WITH };
01:33seancorfield__(def knows (reify RelationshipType (name [this] "knows")))
01:33seancorfield__and similarly for is-friends-with
01:33amalloybut...(not= knows MyRelationship/KNOWS), right?
01:34seancorfield__yeah, but it didn't need to be equivalent - just acceptable to neo4j
01:34seancorfield__there is no actual java equivalent
01:34amalloyhuh
01:34amalloybtw that ; after the enum is spurious
01:34seancorfield__i mean, i needed a clojure version of the java code - but there's no actual java code like that... it was a port to clojure
01:34seancorfield__amalloy: i don't write java dude :)
01:35seancorfield__i was just surprised that a java enum could implement an interface that had a public String name(); method
01:35amalloyau contraire! i see there some java code you wrote
01:36seancorfield__the guy showed an example in java, i just wrote it in clojure instead
01:37seancorfield__if the java type existed, i would have just imported it :)
01:37amalloyseancorfield__: it can implement name(), but there's no way to distinguish between "gimme the enum's name" and "gimme the name defined by this interface"
01:37amalloyso if you wanted to define some special behavior for name(), you would have to alter the behavior of someone who wants the names of your enum constants
01:38amalloyso i suspect the core requirement is that the thing implement name(), and someone is being clever and using the built-in Enum.name() to avoid writing any code
01:40seancorfield__probably... does java actually define what Enum.name() returns?
01:40amalloyyeah, it returns the name exactly as written in the source code
01:41amalloyhttp://download.oracle.com/javase/6/docs/api/java/lang/Enum.html#name()
01:41amalloyoh, and it's final. so you *can't* define special behavior for MyRelationship.name() if you implement it using an enum
01:48seancorfield__so (def knows (reify RelationshipType (name [this] "KNOWS"))) would match public enum MyRels implements RelationshipType { KNOWS } yes?
01:49seancorfield__if so, that means clojure is really f'ing awesome :) :)
01:54amalloyi don't really know what you mean by "match"
01:55amalloythey'll both look the same to someone who treats them as RelationshipType objects
01:55amalloybut someone who expects enums won't like the clojure one
01:55seancorfield__i guess i'll have to write some java and do gen-class on the clojure to find out...
01:55seancorfield__ah, ok
01:56seancorfield__well, i guess i don't care about that... no one around me is going to be writing java :)
01:56amalloyfwiw i'd write a little macro you can use like (create-relationship-types knows is-friends-with)
01:57Lajla,(print "I Worship His Shadow")
01:57clojurebotLajla: I don't understand.
01:58Lajla=(
01:58amalloy(defmacro create-relationship-types [& types] (cons `do (for [type types] `(def ~type (reify RelationshipType (~'name [~'this] ~(str type)))))))))))))))) ; not sure how many of those you need, at this point
02:00seancorfield__yeah amalloy i was starting to lean that way... i need to go see what various neo4j clj libs exist and what they do i guess
02:00seancorfield__i wouldn't want to reinvent the wheel :)
02:01amalloyseancorfield__: have you looked at jiraph, the clojure graphdb?
02:04seancorfield__nope... how stable / scalable is it? neo4j seems rock solid :)
02:04amalloyno idea really
02:05amalloyask ninjudd
02:05amalloysoon it's going to be my job to work on it though, so you can bet it'll fall apart all the time
02:10seancorfield__http://wiki.neo4j.org/content/Clojure
02:12seancorfield__emil eifrem from neo4j was the speaker - he said there were about four clojure bindings out there but their site only lists that one
02:12seancorfield__but i'll look at jiraph as well :)
02:13mec,(let [[first & [second] & rest :as s] [1 2 3]] [first second rest s]) ;is there a clearer way to destructure this?
02:13clojurebot[1 2 (2 3) [1 2 3]]
02:17amalloy&(let [[first second & rest :as s] [1 2 3]] [first second rest s])?
02:17sexpbot⟹ [1 2 (3) [1 2 3]]
02:17amalloyoh. yours isn't even valid because it has multiple &s?
02:18mec,(let [[first & [second :as rest] :as s] [1 2 3]] [first second rest s]) ;is there a clearer way to destructure this?
02:18clojurebot[1 2 (2 3) [1 2 3]]
02:18mecmultiple & seems to work, multiple :as doesnt tho
02:20amalloy$source destructure
02:20sexpbotdestructure is http://is.gd/tqzQbj
02:22amalloymec: if multiple &s work, it's at best a coincidence. having & appear twice in the same sub-section of a destructuring pattern is wrong
02:23amalloyyour :as/:as behavior is what i would use
02:23meci prefer that more too
02:39markomanso im struggling with translations again. I have this example: {:lang "en", :data [:ul {:id "menus"} ([:li {:id "menu0"} "menu 0"] [:li {:id "menu1"} "menu 1"] [:li {:id "menu2"} "menu 2"])]} and result should be something like: {:en {:menus.menu0 "menu 0" :menus.menu1 "menu 1" :menus.menu2 "menu 2"}}
02:39markomanany ideas how this could be achieved, im using hiccup forms there...
02:41amalloyyour code will look less awful if you use :ul#menus instead of :ul {:id "menus"}
02:41markomanhiccup has (html ...) macro, maybe if I copy it to (transl ...) and modify...
02:42amalloybecause any human being trying to parse that without whitespace will go certifiably insane
02:44markomanbut problem is, how I do this then: (for [r (range 0 3)] [:li#(str "menu" r) (str "menu " r)])
02:45markomanbecause a lot of content has similar logic
02:45amalloywrite a function for it. don't do everything with the bare bones provided by hiccup
02:46amalloy(defn labeled-with-content [type content] whatever, repeating content twice)
02:47markomani dont understand that...
02:49amalloythen you call it as (labeled-with-content :li (str "menu" r))
02:49amalloyand it returns [:li#menu1 menu1], or the equivalent with {:id} stuff if you rpefer
02:49amalloyjust don't write it all by hand every time
02:52markomanok, i think i got it. but its a side road for translation problem. I have ids, or in some cases classes and in some neither one... I think final translation data could be also:
02:55markoman{:en {:menus.li "menu 0" :menus.li "menu 1" :menus.li "menu 2"}} or something like that
02:56markomanif li ids are not specified...
03:29markomanI often counter this same problem when working with sets. first I have original-set,, but then eventually I need to filter it with include-only. and after some time its common I need to filter set with exclude also.
03:30markomanso I end up wondering what is the best practice for this situation, when you may need to provide all three sets, original, include and exclude sets
03:32markomansimilar problem comes with for example user roles, you want to allow and disallow some roles
03:34markomananyone familiar with this pattern or is it just me and my programming routines that brings this up so often
05:09daturahi
05:09mkleenmoin ;-)
06:29ilyak,:s
06:29clojurebot:s
06:34opqdonut_,:I
06:34clojurebot:I
06:58ilyakAre there any interesting XML Clojure apis?
06:59ilyakSomething event-based for reading large files.
07:09manutterilyak: this might be of interest -- http://groups.google.com/group/clojure/browse_thread/thread/ce8131bd1ae59bfc
07:27ilyakmanutter: It looks like in-memory parser
07:27ilyaki.e. it will make a structure from the xml stream
07:28ilyakIsn't good when xml stream won't fix into memory
07:28manutterI think it is, but it seems to be implementing a sax interface, which is an event-based parser
07:28manutterI don't know of a pre-build clojure lib for this, but if you have to roll your own...
07:29ilyakIt seems to be using sax - they all do
07:29ilyakThe problem with "naive" sax or stax is that it's very stateful
07:30manutterhmm, that's true but I don't see how to implement an event-based, stateless parser
07:30manutterNever thought of it before, actually
07:34ilyakWell, you can obviously transform [events] to [deserialized-structures]
07:35manutterEven with nested structures? How do you keep track of nesting levels without state?
07:36manutter(I'm still learning functional/lisp-ish coding style, by the way -- PHP coder by day, clojure wannabe by night)
07:43raekilyak: the source for the clojure.xml namespace is using a sax parser with thread local bindings of vars
07:43raekilyak: thread local vars can be mutated with set! and this is a typical usecase for them
08:01ilyakraek: It also makes the whole tree
08:01ilyakAs far as I understand
08:03manutterIt sounds like a pretty cool project, though
08:03manutterI might try and put together a lib to do event-based XML parsing of arbitrarily-long xml files
08:07dnolenfliebel: turns out your program and the tabling issue are not really related. your program does need tabling, there are no cycles in your graph.
08:09dnolenfliebel: does not need tabling, I mean. You're right about a tabled goal always returning the same answer after being run once, different issue tho.
08:11fliebeldnolen: You mean it doesn't oscillate? Because it *can* create cycles in its path. So the not-membero *is* the right way to go?
08:12dnolenfliebel: I guess in your versions cycles arise from 'connected'
08:12ilyakmanutter: Actually it might be pretty cool to more or less port e.g. arrows from haskell
08:13dnolenfliebel: also your notmembero seems odd to me, why not, https://gist.github.com/980610
08:13manutterilyak: sounds fun, but I don't think I'm up to it -- I know just enough Haskell to walk in the front door and fall down the stairs :)
08:13fliebelwell, yea. (btw, why the dot, and not a question mark?)
08:14dnolenfliebel: ?
08:14fliebeldnolen: So, should I use conda or condu in connected?
08:15fliebeldnolen: [a . b] vs [a ? b] I know scheme does pairs, but ? is more like destructuring
08:15dnolenfliebel: does the Prolog version use cut? Do you have a link to the original Prolog?
08:15dnolenfliebel: [a ? b] does mean anything core.logic. I use the dot to show that you might not be destructuring a proper seq.
08:16fliebeldnolen: http://www.csupomona.edu/~jrfisher/www/prolog_tutorial/2_15.html
08:16dnolennot really destructuring here anyhow, more like pattern-matching via unification.
08:17dnolenfliebel: that's a cut free program as far I can tell. You should be able to implement that as is in core.logic w/o tabling.
08:18fliebeldnolen: Right, so… I did, and it ran in endless loops.
08:18fliebelwell, I think I did.
08:19dnolenfliebel: your notmembero is not right.
08:19dnolenfliebel: it calls membero instead of itself, and there's no terminal case.
08:19fliebelhahaha! really?
08:20fliebeloh, well, I copied yours now. Let's see what happens
08:30fliebeldnolen: :( When I add the not-membero it runs forever without producing *any* result. Something must be wrong…
08:31dnolenfliebel: what's your run statement look like?
08:31fliebel(run 1 [q] (patho 1 5 q))
08:32fliebel(run 1 [q] (patho 1 2 q)) works, since it just does (connected 1 2)
08:33dnolenfliebel: here's a correct translation of the Prolog, works fine, https://gist.github.com/980642
08:34dnolenfliebel: still glad we tried tabling yesterday, who knows when I would have discovered that issue otherwise.
08:35fliebel:)
08:35fliebelSo what was wrong with it, just my not-membero?
08:37dnolenfliebel: patho needed to call reverso
08:38dnolenpatho also needed the (exist [q] ...), travelo needed to use that as it's output not res
08:39fliebeldnolen: Well, only if I cared about the order of the output, right? I just settled with reverse output untill I fixed the reverse function.
08:40dnolenfliebel: ah yes that's true, then the problem was not-membero.
08:42fliebeldnolen: Okay. Good to know it works. Meanwhile, I wrote something based on your readme patho, which does not use these weird accumulators and reverseo. Only, it fails when I add the not-membero: http://paste.pocoo.org/show/391784/
08:45abhinavmehtahey guys....anybody would like to share some good pointers to start looking and learning clojure...I'm a newbie to it. :)
08:46fliebelAh, I already know what's wrong
08:46fliebelpath is not the whole thing in my case.
08:46manutterabhinavmehta: have you found clojuredocs.org yet?
08:47abhinavmehtamanutter: hmm....
08:47manutterIt's a reference, not a tutorial, but it's useful
08:47abhinavmehtamanutter: but before I end-up reading at many places....I thought to ask with some experienced guys.. :)
08:48abhinavmehtamanutter: hmm....i know.
08:48manutterIf you don't mind paying for a book, _Clojure In Action_ is pretty good
08:48manutterhttp://www.manning.com/rathore/
08:48abhinavmehtamanutter: np about paying....ahaa, will look for this book. Thanks manutter
08:48wastrelhi
09:08dnolenfliebel: you have a working version and non-working version, you'll need to compare and contrast ;) gotta run.
09:08fliebeldnolen: I did, threw away mine.
09:08fliebeldnolen: contrast: mine hasn;t an acumulator to not-membero agains
09:08fliebeloh, to late
09:19mattmitchelli'm doing a sql query using group_concat. The value for that field coming back to clojure land is a byte array. I'm using a combination of slurp and read-string to extract the string. My question is, how can I reconstruct a byte array representing a string so I can test my function that parses the data from sql?
09:31wastreli got the android clojure repl it's fun
09:53manuttermattmitchell: are you asking how to generate a byte array from a string, for testing?
09:53mattmitchellmanutter: yes exactly
09:55bultersanybody knows how i start multiple java process' in the same jvm?
09:56danlarkinthe jvm is one process
09:56danlarkinyou can run multiple threads in a single jvm, however
09:56bultersok, let me rephrase. multiple threads
09:56bultersthat what you said ;-)
09:56manutter,(.getBytes "This is a string")
09:56clojurebot#<byte[] [B@1f2c3f4>
09:56danlarkinbulters: http://download.oracle.com/javase/6/docs/api/java/lang/Thread.html
09:57manuttermattmitchell, I think just (.getBytes "some string") is all you need.
09:57mattmitchellmanutter: do'h! that's it. thank you.
09:58bultersdanlarkin: 'problem' is as follows: I have a server process (stanford maximum entity pos-tagger) running in the jvm listening on port 12345.
09:58bultersdanlarkin: but I want to start another 'server' on port 12346, preferable in the same jvm process
09:59danlarkinsure. your program will spawn threads for each, then
10:00bultersSo I'll have to built a 'wrapping' server process which starts both in a thread... was hoping I could somehow 'add' the new thread to the running process
10:00bultersthanks
10:02raekmattmitchell: don't forget the encoding parameter to .getBytes. ##(seq (.getBytes "åäö" "UTF-8"))
10:03sexpbot⟹ (-61 -91 -61 -92 -61 -74)
10:03mattmitchellraek: great. good tip thanks.
10:03raek,(seq (.getBytes "åäö" "ISO-8859-1"))
10:03clojurebot(-27 -28 -10)
10:04raekmattmitchell: also, why do you get string data as an array?
10:04b6nk6n(contains? '(\h \o \t) \o)
10:04b6nk6nwhy is this false?
10:05raekmattmitchell: later when you compare the arrays, you need to use something like http://download.oracle.com/javase/6/docs/api/java/util/Arrays.html#equals(char[],%20char[])
10:05raek...or (= (seq array-1) (seq array-2))
10:06raeksince = on arrays check identity and not value
10:06mattmitchellraek: well, the value coming from a sql statement exec contains this byte array from using group_concat and using a "," separator
10:06raekb6nk6n: "contains?" actually means "has-key?" and is only used for maps and sets
10:07raek,(contains? (set "hot") \o)
10:07clojurebottrue
10:07mattmitchellraek: so i have a little function that splits if for me, but it first needs to call slurp
10:07raekmattmitchell: but why do you store strings as byte arrays?
10:08mattmitchellraek: it's actually the result i'm getting back from the sql library
10:08raekwhich library is this, btw?
10:08b6nk6nraek: ah ok thanks, what would be the equivalent to lists and vecs, some?
10:08mattmitchellraek: i'm not sure why that is
10:08raekI would expect it to return a string
10:09mattmitchellraek: totally, me too
10:09raekb6nk6n: yes, some. it does a linear search thtough the sequence
10:09mattmitchell,(clojure.contrib.string/split #"," (slurp (.getBytes "test,test")))
10:09clojurebot("test" "test")
10:09raeksets are better if you check for membership multiple times
10:09mattmitchellraek: that's what i'm doing to handle it
10:10raekmattmitchell: String has a constructor for byte-arrays
10:10raek,(String. (into-array Byte/TYPE [-61 -91 -61 -92 -61 -74]) "UTF-8")
10:10clojurebotjava.lang.IllegalArgumentException: argument type mismatch
10:11b6nk6nok thanks I find ,(doc contains?) a bit misleading then.
10:11mattmitchellraek: oh nice. that simplifies it a bit
10:11raek,(String. (into-array Byte/TYPE (map byte [-61 -91 -61 -92 -61 -74])) "UTF-8")
10:11clojurebot"åäö"
10:12raekmattmitchell: but the real problem you should solve is why you get arrays from the sql lib
10:12mattmitchellraek: right. maybe there's an option in the connection config or something. i'll dig around a bit.
10:12raekwhich lib is it?
10:13raekmattmitchell: and also, what type does the column have in the db?
10:14mattmitchellraek: well this is coming from 2 different fields, here is the relevant bit:
10:14mattmitchellraek: group_concat(DISTINCT concat(p.id, "::", p.code) ORDER BY p.id) as partner_codes
10:14mattmitchellraek: so that partner_codes value comes out as a byte array
10:16raekmattmitchell: what clojure sql library is this, and what types do the p.id and p.code have?
10:17mattmitchellraek: [mysql/mysql-connector-java "5.1.6"] and [clojure.contrib.sql :as sql]
10:17mattmitchellraek: id is int, code is varchar
10:18raekmattmitchell: maybe you could try converting the int to a varchar in some way
10:18raekmattmitchell: what happens if you concat two varchar columns?
10:18mattmitchellraek: i'll try that
10:19raekif you still get a byte array then, I suggest you report this as a bug
10:19raekfrom the mysql docs: "The result type is TEXT or BLOB unless group_concat_max_len is less than or equal to 512, in which case the result type is VARCHAR or VARBINARY."
10:19raeklooks like you get a blob or a varbinary
10:23raekmattmitchell: you could also try concat(cast(p.id, varchar(50)), "::", p.code)
10:24raekor maybe concat(convert(varchar(50), p.id), "::", p.code)
10:25mattmitchellraek: ahh cool. let me try that.
10:37jose__Hello!
10:38wastrelhi
10:43wastrelso do people use the GUI or just cli for emacs
10:44wastrelsince i'm getting started with it
10:44wastreli geneally prefer cli but if GUI is How Things Are Done i'll work with it
10:44Fossiyou mean like xemacs or console?
10:44TimMcwastrel: They're pretty much the same.
10:45Fossiyeah
10:45TimMcwastrel: But if you're just getting started, use the GUI by all means.
10:45wastrelI dunno i just installed emacs typed "emacs" and got a giant window filling up my screen.
10:45wastrelinstead of a tidy little app in my terminal
10:45Fossitype emacs -nw then ;)
10:45Fossiif you care
10:45wastrelgenerally i care because i hate the mouse :]
10:46Fossiwell, it's not in the way either way
10:46TimMc$google emacs n00b start
10:46sexpbotFirst out of 4200 results is: Emacs quick start: One n00b to another. | Brain on Fire
10:46Fossiyou dan't have to use it with a window either
10:46sexpbothttp://www.brainonfire.net/blog/emacs-n00b-start/
10:46TimMc^ I wrote this to help other beginners.
10:48wastrelok thanks
10:48TimMcIt's not a tutorial -- the goal is to cover basics that many tutorials forget to mention at the beginning. :-)
10:49wastrelif i do all this, i'll get a repl with brace matching and pretty printing and syntax hilighting?
10:49TimMcNah, for that you'll ened to customize your .emacs config file.
10:50TimMcLet me paste mine so you can grab interesting bits.
10:50wastrelby do all this i mean, setup & learn emacs, get the clojure stuff setup and slime or swank or silly or whatever
10:51raekwastrel: check out http://technomancy.us/149
10:52raekthe emacs + clojure setup is now a whole lot simpler
10:52raekdnolen: cool!
10:53TimMcwastrel: https://gist.github.com/980934 -- there are some nice bits in here
11:00mattmitchellraek: ok using mysql cast(col as char) does the trick!
11:04dnolenthis is kind of an awesome read, http://www.cotilliongroup.com/arts/DCG.html, Definite Clause Grammars - Not Just For Parsing Anymore.
11:08wastrelthis channel involves a lot of reading
11:09dnolenwastrel: and thinking too.
11:09wastrelit's a problem
11:10wastreloh instapaper they must have an android app by now
11:10dnolenwastrel: it's fun!
11:14dnolenDCGs seem kinda monadic, makes me curious about the relationship between DCGs and parser combinators, this paper seems to shed some light, http://gpd.sip.ucm.es/rafa/papers/flops99.pdf
11:16dnolenraek: the DCG - Not Just For Parsing anymore points out the relationship between DCGS and types.
11:17raekwow. I'm really excited that we have the tools for this in Clojure now
11:18wastrelheh i haven't used instapaper since 2009
11:18raekdnolen: in the end, isn't DCGs just a notation that expands into ordinary relations?
11:18dnolenraek: yup, I need to dig in some more, but I'm definitely very interested in macro support so that people can easily port existing Prolog literature.
11:23dnolenraek: ah looks you need to thread difference lists, http://www.amzi.com/manuals/amzi/pro/ref_dcg.htm
11:27rlbSo <, >, etc. don't work for Comparables (i.e. Date)?
11:29dakronerlb: clojure.contrib.generic.comparison let's you define your own multimethod for < & >, so you can do one for [Date Date] pretty easily
11:32rlbdakrone: thanks -- though for now I think I'll just use (pos? (compare x y)) in the filter.
11:33ahmed1hi
11:33ahmed1www.pakk.tk
11:36fliebeldnolen: what does mplus do?
11:42fliebeldnolen: I was wondering if I could do something like conde, but with a seq and without the macro. As a solution to the anonymous rel.
11:42dnolenfliebel: interleaves streams of results.
11:43dnolenfliebel: it's possible but you'll want to look at how I did it with defrel & facts in the prelude.
11:44fliebeldnolen: Looking at it now, but there are so many layer of macro on top of it.
11:44mattmitchellwhat's the nicest way to convert a hash-map to a vector?
11:47fliebeldnolen: what is the index atom for?
11:47rlbmattmitchell: (vec map)?
11:48rlb##(vec {:a 1 :b 2})
11:48sexpbot⟹ [[:a 1] [:b 2]]
11:48rlb##(vec #{:a 1 :b 2})
11:48sexpbot⟹ [1 2 :a :b]
11:48dnolenfliebel: indexed facts
11:48mattmitchellrlb: ok is there a nice way to have the hash-map flatten?
11:48dnolenfliebel: by default index the first element of the fact tuple, this makes queries way faster.
11:49dnolenfliebel: later I'll add knobs so you can index any element of the tuple.
11:49dnolenfliebel: w/o indexing you have to do what conde does which is consider all alternative even those that don't apply.
11:50dnolenfliebel: the trick here is we see a ground lvar, we can used the indexed facts.
11:50fliebeloh.
11:50dnolenfliebel: standard Prolog optimization.
11:51fliebelokay, so basically, what I want is to provide answers with whatever you do to that set to get the indexed one.
11:52rlbmattmitchell: iirc yes, and someone even mentioned it to me the other day -- trying to remember...
11:53rlbahh "<dnolen> ,(apply concat {:a 'b :c 'd})"
11:53rlb##(apply concat {:a 'b :c 'd})
11:53sexpbot⟹ (:a b :c d)
12:01fliebeldnolen: What about this? (defn rel [names values] (fn [a] (answers a values (index values) names)))
12:06technomancyredinger: ping
12:24fliebeldnolen: What about this? (defn rel [names values] (fn [a] (answers a values (index values) names)))
12:25fliebeluser=> (run* [q] (rel [1 q] [[1 2] [3 4]]))
12:25fliebel(2)
12:28dnolenfliebel: put together a patch and the related test and I'll think about it. to be honest tho, now that you know how it works, I would prefer a patch that adds extend-rel.
12:28dnolenfliebel: (extend-rel rel-name facts)
12:30dnolenfliebel: even better, the fact that I use vector is broken, allows for duplicates, really a collection of facts should be a set.
12:30fliebeldnolen: What would that do? Just basically (doseq [f facts] (fact rel-name f))?
12:31dnolenfliebel: no it would be simpler, it would reduce the new set of facts onto the old one and recompute the indexed set.
12:31fliebeldnolen: You're not allowed to take patches form me, as I haven no CA. I should resend it, I know.
12:31dnolenfliebel: get on it man!
12:31lpt1!history
12:31lpt1!logs
12:31fliebel~logs
12:31clojurebotlogs is http://clojure-log.n01se.net/
12:31lpt1tx
12:32fliebeldnolen: Okay, I'll see what I can do.
12:50dnolentype inference for the simply typed lambda calc in 6 lines of Prolog, http://muaddibspace.blogspot.com/2008/01/type-inference-for-simply-typed-lambda.html, Kiselyov mentions the problems in Haskell Cafe, but core.logic has occur-check *and* disequality constraints.
13:17`fogus-away(inc dnolen)
13:17sexpbot⟹ 2
13:19fliebelIs there a way to kill a single statement instead of the whole vm? Like in Python.
13:20fliebel(in lein)
13:20amalloyfliebel: i don't think clojure's repl exposes that
13:20fliebel:(
13:20amalloyto get it, you'd have to start every expression on a new thread
13:22dnolenfliebel: you don't use Emacs do you?
13:22hiredmanswank-clojure can do it, calls Thread.interrupt on the repl thread which throws an exception
13:22fliebelno
13:24TimMcamalloy: Perhaps there is a signal that can be sent to the REPL process?
13:24chouserclojure.repl/set-break-handler!
13:27TimMcchouser: Since when?
13:27fliebelCan;t find it...
13:28amalloyi try to say at least one grotesquely-wrong thing to start my morning
13:28TimMcfliebel: I don't think it's in 1.2.
13:29fliebelTimMc: http://clojure.github.com/clojure/branch-master/clojure.repl-api.html
13:29TimMcfliebel: https://github.com/clojure/clojure/blob/master/src/clj/clojure/repl.clj#L276
13:30chouserif it's not in clojure.repl for you, look in clojure.contrib.repl-utils
13:30chouserit's pretty old, in clojure-years
13:31fliebel:)
13:33dnolenchouser: a tried and true weapon against the unruly infinite lazy-seq
13:34chouserheh
13:42mattmitchellhmm, how to remove one key/val pair from a hash, based on the key's name?
13:43ataggartdissoc
13:43mattmitchellataggart: ahh right
14:47blackcoffeeriderhello fellas
14:49blackcoffeerideranyone ever came across #<CompilerException java.lang.ClassCastException (NO_SOURCE_FILE:0)> when using lazy-xml/pull-seq with a pull parser?
14:51blackcoffeeridersame file with clojure.contrib.lazy-xml/has-pull defined to false gives expected result
14:51blackcoffeeriderswitched back on again causes a classcast exception
14:53blackcoffeeridertried kxml2-2.3.0 and xpp3-1.1.4c <= class cast exception ... tried xmlpull_1_1_3_4c from http://www.xmlpull.org/v1/download <= not recognized?
14:56blackcoffeerider@chouser: by the way - is there a final solution in contrib 1.3 for the quoting issue in lazy-xml? unfortunately i need " and ' to be quoted as entities which lazy-xml doesnt do in 1.2 "stock" version
14:57chouserbleh, sounds like a mess
14:57chouserI actually plan to give lazy-xml a good going-over, probably starting next week
14:58blackcoffeeriderchouser: if you want to i can hand you over the changes i did to emit which does the trick for me... but its not nice
14:59chouseremit in lazy-xml uses javax.xml transformer -- you're saying that still doesn't do " and ' correctly?
15:02blackcoffeeriderchouser - not for me... sorry
15:02blackcoffeeriderchouser - using stock 1.2-core and 1.2-contrib from the downloadpage
15:04blackcoffeeriderchouser: http://pastebin.com/XKztv87B
15:07blackcoffeeriderchouser: sorry ignore lines 1-10... i actually havn't figured out the real issue with it - but the workaround is to disable outputescape - (line 61, 62) and
15:08blackcoffeeriderto reescape it ourselves - 11. , 19.
15:08chouseryikes. ok.
15:09blackcoffeeriderchouser: ugly as hell... i know - but i need to have a proper round-trip with a verry fuzzy application which won't accept unescaped " and '...
15:10blackcoffeeriderany hints with my pull issue on the reader side?
15:12chouserblackcoffeerider: sorry I haven't looked at it in a while. Is it trying perhaps to use a different version of the pull parser?
15:12chouserI think I remember noticing that the pull parser API isn't as stable as SAX.
15:14blackcoffeeriderchouser: which parser & version had you used that was working?
15:15chouserI think it was XPP2 at this link: http://www.extreme.indiana.edu/xgws/xsoap/xpp/
15:16blackcoffeeriderchouser: thanks - ill give it a try!
15:31blackcoffeeriderchouser: xpp2 doesnt semm to implement xmlpull.org - so i tried the oldest version of xpp3 i could find... no luck either
15:31blackcoffeeriderchouser: will look at your source and see what exactly happens...
15:32chouserthis was written before I was aware of any kind of story for external dependencies.
15:33chouserand this week I'm still grading homework
15:33chouserbut *next* week, ah next week I will have time... :-)
15:38Rayneschouser: We all have time next week, right? Right?
15:39chousernot as lyrical as "tomorrow", but it seems more realistic.
15:39chouser"next week, oh next week, I luv ya, oh next week"
15:48Raynes$max
15:48sexpbotThe most users ever in #clojure is 317
17:08no_mindI have to define a multimethod based on a map key. The map is :form-param from ring so all keys are strings instead of keywords. How do I define a multimethod in such case ?
17:13scgilardiwhat difficulty do you anticipate?
17:44gigamonkeyAnyone know how many folks attended the first ClojureConj?
17:44technomancygigamonkey: just a smidge under 200 IIRC
17:46gigamonkeyThanks.
17:46gigamonkeyIf anyone has a citable source for that number, that'd be cool too.
17:46gigamonkey(I'm writing the intro to Michael Fogus's interview with Rich Hickey that's going up on Code Quarterly soon.)
17:47ataggartI think Alan Dipert was in charge of the conj, he might know
17:47ataggartor stu
17:47technomancyredinger maybe?
17:47ataggartya, pretty much anyone at relevance
17:49gigamonkeyIs there a particular mailing list, google group, or something that is the center of "the Clojure community"?
17:50hiredmanpprint would be really nice if it didn't deref vars
17:50technomancygigamonkey: yeah: http://groups.google.com/group/clojure
17:57blackcoffeerider@chouser: problem solved... xmlpullparser wants a reader as source- cant handle a java.io.File as opposed to standard parse...
18:10amalloyyeah, the google group and #clojure. if you want a mailing list, that's the one
19:22symboleI'm trying to launch SLIME using clojure-jack-in, but I get an error "Symbol's function definition is void: locate-dominating-file". Is this defined in another package I need?
19:25technomancysymbole: looks like it's not compatible with Emacs 22; can you upgrade?
19:25technomancy23 has been around for many years now
19:27duck1123I'm still forced to use 21 on some of the machines at work
19:27duck1123it drives me nuts
19:28symboleShouldn't be a problem. I'll try emacs23 on another machine.
19:28technomancycripes; 21? that's like IE6-era.
19:29symboletechnomancy: The instructions on your site says to install swank-clojure 1.3.1, but the tutorial video uses 1.4.SNAPSHOT. Which one is required?
19:30duck1123technomancy: that's exactly my point
19:31technomancysymbole: either will work. 1.3.1 is all you need.
19:32technomancy1.4.0-SNAPSHOT has nice new debugging features but isn't a stable release
19:44symboletechnomancy: After "Starting swank server...", there's the following error "error in process filter: progn: Symbol's value as variable is void: user=>". This is on emacs23.2.1.
19:46technomancysymbole: do you have another swank version in lib or lib/dev?
19:46technomancyor ~/.lein/plugins for that matter?
19:47symbolein ~/.lein.plugins I have 1.3.0, 1.3.1, and 1.4.0-SNAPSHOT.
19:48technomancysymbole: try clearing that out to just 1.3.1
19:49symboleI hastily only left 1.4-SNAPSHOT, and it worked.
19:49technomancycool
19:50symboleThis is very cool. Thanks.
19:51technomancystill a few rough edges it looks like
20:01zippy314Hi folks, newbie compojure question: I'm getting "java.io.FileNotFoundException: Could not locate ring/adapter/jetty__init.class or ring/adapter/jetty.clj on classpath" when trying to lein run a very simple compojure app. I've added [compojure "0.6.3"] to my lein project.clj, done a lien deps which copies 11 files to lib, and added (:use compojure.core, ring.adapter.jetty) (:require [compojure.route :as route])) to my ns cal
20:02dnolenzippy314: is there a ring jar in your lib folder?
20:02amalloyzippy314: jetty is not related to compojure afaik. you need ring, which will pull in jetty
20:03zippy314There's a "ring-core-0.3.8.jar" file.
20:03zippy314that's not enough?
20:04amalloyzippy314: it's probably not in ring-core, but in something like ring-jetty
20:04amalloyi have as a dependency [ring "0.3.7"]
20:05zippy314amalloy: I'll try that. Thanks
20:05amalloyand that causes me to get, among other things, ring-jetty-adapter.jar
21:19zippy314Hi folks, another newbie compojure question: here's a simple app that doesn't want to print the form data from a POST. What am I missing? https://gist.github.com/982163
21:19zippy314in that example, data comes back empty. Why?
21:25tomojzippy314: what's the content-type of the request?
21:25tomojapplication/x-www-form-urlencoded right?
21:26zippy314just sending a simple curl like this: curl localhost:8080 -d some-data
21:26zippy314so not sure.
21:26tomojdo you have nc handy?
21:26zippy314How would I find that out?
21:26zippy314it seems to be on my machine, but I haven't used it.
21:27tomoj`nc -l 8081 > req.log`, then make the form hit 8081
21:27amalloyi'm pretty sure the {blah :params} thing is way old syntax
21:27tomojof course maybe your request is perfectly fine and it's some compojure problem..
21:27amalloyjust do (defroutes (POST "/" [data] (call-function data)))
21:27amalloyand it will intercept the :data element from the form
21:28tomojwat
21:28tomojbased on application/x-www-urlencoded content type I guess?
21:28amalloya snippet from 4clojure source: (POST "/problem/edit" [id] (edit-problem (Integer. id)))
21:29tomojdoes it auto-figure-out json post bodies now too? :D
21:29zippy314I've tried that. It doesn't work.
21:30tomojI'd try stepping through the middleware in the repl with a grabbed request object
21:31zippy314amalloy: I've updated the gist https://gist.github.com/982163 to reflect the syntax you suggest, but the code still doesn't add the data from the form into the output.
21:32zippy314am I setting up the middleware correctly?
21:32tomojis there a magic 'request' binding inside defroutes or are you not supposed to be able to get the request?
21:32tomojzippy314: compojure.handler/site adds a bunch of middleware for you
21:33amalloyzippy314: are you sure your server has the new def'd routes? starting a jetty server and then changing its routes in the code doesn't affect the running server
21:33tomojwon't it if you use (run-jetty #'main-routes ...) ?
21:35amalloyprovided that you actually recompile the code, i think so. just editing the source won't do it unless you use wrap-reload
21:35zippy314tomoj: this is my first hour on compojure, so I'm no totally clear on all the things you are saying.
21:36zippy314I'm running this stuff with lein run, so I assume it recompiles.
21:37zippy314amalloy: I kill the process each time I make a change and re do 'lein run;
21:37tomojouch
21:40wastrelapropos of the thread on the mailing list about newbie setup
21:41wastrelspeaking as a newbie it is quite a process
22:26tomojhttp://www.learningclojure.com/2010/09/clojure-faster-than-machine-code.html so if you do this, you will probably run out of permgen?
23:19zippy314In compojure I see mentions on the web of "serve-file" for sending back files. But that seems to be broken now. What's the new way of doing that?
23:28dnolenwastrel: what's the specific problem you encountered? which setup were you trying to follow through on?
23:30wastreldnolen: well i did get the basic repl and such working fine, with jline and later with rlwrap
23:31wastrelbut i want a fancy repl with syntax hilighting and indenting and brace matching
23:31wastrelso that's what i've been having trouble with.
23:31dnolenwastrel: what kind of REPL experience are you coming from?
23:31wastreldabbling with drscheme
23:32dnolenwastrel: comparing command line experience to a full blow GUI environment seems ... unfair. But yeah, DrRacket is good. what other REPLs have you used?
23:32wastrelno serious work in any lisps but i'm a longtime vim user working with bash, perl and other languages and am addicted to colors and other such luxuries
23:33dnolenwastrel: why not VimClojure or slimv then?
23:33wastrelcouldn't get either working
23:33dnolenwastrel: and you weren't able to ping the maintainers?
23:34wastrelwell i did get the vimclojure working for syntax hilighting but indenting wasn't
23:34wastrelanyway i'm not complaining just observing :]
23:35wastrelthen i decided the grass was greener over on the emacs side so i tried setting it up to no noticable success
23:36wastrelas to the maintainers I didn't, no. i was still browsing around
23:36clojurebotblip.tv is http://clojure.blip.tv/
23:36dnolenwastrel: Emacs is great, but it's admittedly formidable - even with technomancy's heroic efforts. I certainly would never recommend it as a introductory enviroment.
23:36wastreli just wanted a fancy repl
23:37wastrel"just" :]
23:37dnolenwastrel: are you on OS X? Linux?
23:37wastrelbut the thread on the mailing list is right it's a lot of hoop jumping
23:37wastrellinux yes
23:37dnolenwastrel: do you use Ruby?
23:37wastreli've written a ruby hello world but no, not really
23:38dnolenwastrel: if you have ruby installed, I would do "sudo gem install cake"
23:38dnolenwastrel: cake has the best REPL that's not tied to anything else, as long as your ok w/ the ruby dep.
23:39wastrelok i'll check it out
23:42dnolenwastrel: I think the multiplatform "it just works" is just beyond the scope of what the core Clojure team has the resources/expertise to support. It's tough to manage expectations though when people are coming from langs w/ order of magnitude more users.
23:42wastreldnolen: so are you saying i wouldn't get colors, indenting & brace matching with emacs even if i did get it all setup ?
23:43dnolenwastrel: no you would get all those things. But you'd have to learn Emacs. No small hurdle.
23:44wastrelin a repl or would it be writing a file in emacs and then running the file?
23:44amalloywastrel: you can get it in the repl. i haven't bothered
23:45dnolenwastrel: Emacs has sophisticated Lisp support in general, Lisp programming is natural in Emacs once you learn the chorded commands.
23:45wastrelthe cake repl is nice but not bling bling :]
23:45dnolenwastrel: true, but you can get far w/ cake repl plus plain text editor.
23:45amalloydnolen: i realized today i've been searching all my life for emacs. i disable the Back button on my mouse then install mouse gestures, so that i can click right-left to get a chorded back button
23:48dnolenwastrel: I actually make a point in all my tutorials to show how to use cake and lein w/ a plain text editor. People have responded very positively to that. Newbie desires are very different from those people that have experience.
23:56zakwilsonI'm strongly considering doing a customer project in Clojure. Project is essentially airbnb.com for a different market. JVM is not a requirement. Talk me out of it?
23:56dnolenzakwilson: talk you out of it ?!
23:57zakwilsonYes, I'm hoping that if anyone has had a bad experience using Clojure in a serious production environment, they'll say so now. I'm hoping nobody has, of course.