#clojure log - May 19 2011

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

0:02 amalloy: *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

0:09 wastrel: i'm having fun trying to figure out slimv

0:32 yeah i have no idea how to install or use slimv

0:34 puredanger: In case anyone here has thoughts: http://stackoverflow.com/questions/6053483/how-can-i-proxy-a-java-class-with-overloaded-methods-in-clojure

0:41 rmarianski: puredanger: what happens if you use gen-class and only override the one?

0:42 puredanger: rmarianski: haven't tried gen-class

0:42 rmarianski: I have fulfilled my clojure edge case quota for the data and worked around it with a Java adapter for the moment :)

0:42 s/data/day/

0:42 sexpbot: <puredanger> rmarianski: I have fulfilled my clojure edge case quota for the day and worked around it with a Java adapter for the moment :)

0:43 puredanger: sexpbot: stuff it

0:43 amalloy: puredanger: we can add you to the list of people he won't do sed replacement for

0:43 puredanger: amalloy: it's ok, just tired :)

0:44 rmarianski: :)

0:46 seems like proxy should work though

1:02 seancorfield__: java interop question... i went to a neo4j preso tonight and they seem to define relationships as enums that implement an interface...

1:03 amalloy: seancorfield__: you're SOL there

1:04 brehaut: i was under the impression that enums are just sugar for classes in java?

1:04 amalloy: brehaut: they're special classes

1:06 the compiler knows about them and gives them special properties, which i would demonstrate if i could find any enums baked-in to java

1:09 i 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

1:10 brehaut: weird

1:11 amalloy: brehaut: this allows several nice things, like the compiler can complain if your switch/case statement doesn't cover all the enum constants

1:27 seancorfield__: hmm, i posted a Q about java interop earlier but was having network probs so i don't think it went thru

1:28 i went to a neo4j preso tonight...

1:29 amalloy: seancorfield__: we concluded you're out of luck

1:29 seancorfield__: lol

1:29 so how much of the question did you get?

1:29 amalloy: you mentioned enums

1:29 ie, we only got the first message

1:30 seancorfield__: yeah... so i did (def knows (reify RelationshipType (name [this] "knows")))

1:30 amalloy: here, i'll gist it

1:31 seancorfield__: that worked for use with neo4j but i wondered if there was a nicer way to construct a set of enums in clojure

1:31 amalloy: seancorfield__: https://gist.github.com/980249

1:31 wait, you were able to define an enum from clojure?

1:32 seancorfield__: yup

1:32 amalloy: also, god almighty those other two seancorfield[_] folks make it hard to tab-complete you

1:32 seancorfield__: sorry man

1:32 amalloy: can i see how you defined an enum? i thought clojure didn't do that

1:32 seancorfield__: public enum MyRelationship implements RelationshipType { KNOWS, IS_FRIENDS_WITH };

1:33 (def knows (reify RelationshipType (name [this] "knows")))

1:33 and similarly for is-friends-with

1:33 amalloy: but...(not= knows MyRelationship/KNOWS), right?

1:34 seancorfield__: yeah, but it didn't need to be equivalent - just acceptable to neo4j

1:34 there is no actual java equivalent

1:34 amalloy: huh

1:34 btw that ; after the enum is spurious

1:34 seancorfield__: 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

1:34 amalloy: i don't write java dude :)

1:35 i was just surprised that a java enum could implement an interface that had a public String name(); method

1:35 amalloy: au contraire! i see there some java code you wrote

1:36 seancorfield__: the guy showed an example in java, i just wrote it in clojure instead

1:37 if the java type existed, i would have just imported it :)

1:37 amalloy: seancorfield__: 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"

1:37 so 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

1:38 so 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

1:40 seancorfield__: probably... does java actually define what Enum.name() returns?

1:40 amalloy: yeah, it returns the name exactly as written in the source code

1:41 http://download.oracle.com/javase/6/docs/api/java/lang/Enum.html#name()

1:41 oh, and it's final. so you *can't* define special behavior for MyRelationship.name() if you implement it using an enum

1:48 seancorfield__: so (def knows (reify RelationshipType (name [this] "KNOWS"))) would match public enum MyRels implements RelationshipType { KNOWS } yes?

1:49 if so, that means clojure is really f'ing awesome :) :)

1:54 amalloy: i don't really know what you mean by "match"

1:55 they'll both look the same to someone who treats them as RelationshipType objects

1:55 but someone who expects enums won't like the clojure one

1:55 seancorfield__: i guess i'll have to write some java and do gen-class on the clojure to find out...

1:55 ah, ok

1:56 well, i guess i don't care about that... no one around me is going to be writing java :)

1:56 amalloy: fwiw i'd write a little macro you can use like (create-relationship-types knows is-friends-with)

1:57 Lajla: ,(print "I Worship His Shadow")

1:57 clojurebot: Lajla: I don't understand.

1:58 Lajla: =(

1:58 amalloy: (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

2:00 seancorfield__: 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

2:00 i wouldn't want to reinvent the wheel :)

2:01 amalloy: seancorfield__: have you looked at jiraph, the clojure graphdb?

2:04 seancorfield__: nope... how stable / scalable is it? neo4j seems rock solid :)

2:04 amalloy: no idea really

2:05 ask ninjudd

2:05 soon it's going to be my job to work on it though, so you can bet it'll fall apart all the time

2:10 seancorfield__: http://wiki.neo4j.org/content/Clojure

2:12 emil eifrem from neo4j was the speaker - he said there were about four clojure bindings out there but their site only lists that one

2:12 but i'll look at jiraph as well :)

2:13 mec: ,(let [[first & [second] & rest :as s] [1 2 3]] [first second rest s]) ;is there a clearer way to destructure this?

2:13 clojurebot: [1 2 (2 3) [1 2 3]]

2:17 amalloy: &(let [[first second & rest :as s] [1 2 3]] [first second rest s])?

2:17 sexpbot: ⟹ [1 2 (3) [1 2 3]]

2:17 amalloy: oh. yours isn't even valid because it has multiple &s?

2:18 mec: ,(let [[first & [second :as rest] :as s] [1 2 3]] [first second rest s]) ;is there a clearer way to destructure this?

2:18 clojurebot: [1 2 (2 3) [1 2 3]]

2:18 mec: multiple & seems to work, multiple :as doesnt tho

2:20 amalloy: $source destructure

2:20 sexpbot: destructure is http://is.gd/tqzQbj

2:22 amalloy: mec: if multiple &s work, it's at best a coincidence. having & appear twice in the same sub-section of a destructuring pattern is wrong

2:23 your :as/:as behavior is what i would use

2:23 mec: i prefer that more too

2:39 markoman: so 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"}}

2:39 any ideas how this could be achieved, im using hiccup forms there...

2:41 amalloy: your code will look less awful if you use :ul#menus instead of :ul {:id "menus"}

2:41 markoman: hiccup has (html ...) macro, maybe if I copy it to (transl ...) and modify...

2:42 amalloy: because any human being trying to parse that without whitespace will go certifiably insane

2:44 markoman: but problem is, how I do this then: (for [r (range 0 3)] [:li#(str "menu" r) (str "menu " r)])

2:45 because a lot of content has similar logic

2:45 amalloy: write a function for it. don't do everything with the bare bones provided by hiccup

2:46 (defn labeled-with-content [type content] whatever, repeating content twice)

2:47 markoman: i dont understand that...

2:49 amalloy: then you call it as (labeled-with-content :li (str "menu" r))

2:49 and it returns [:li#menu1 menu1], or the equivalent with {:id} stuff if you rpefer

2:49 just don't write it all by hand every time

2:52 markoman: ok, 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:

2:55 {:en {:menus.li "menu 0" :menus.li "menu 1" :menus.li "menu 2"}} or something like that

2:56 if li ids are not specified...

3:29 I 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.

3:30 so 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

3:32 similar problem comes with for example user roles, you want to allow and disallow some roles

3:34 anyone familiar with this pattern or is it just me and my programming routines that brings this up so often

5:09 datura: hi

5:09 mkleen: moin ;-)

6:29 ilyak: ,:s

6:29 clojurebot: :s

6:34 opqdonut_: ,:I

6:34 clojurebot: :I

6:58 ilyak: Are there any interesting XML Clojure apis?

6:59 Something event-based for reading large files.

7:09 manutter: ilyak: this might be of interest -- http://groups.google.com/group/clojure/browse_thread/thread/ce8131bd1ae59bfc

7:27 ilyak: manutter: It looks like in-memory parser

7:27 i.e. it will make a structure from the xml stream

7:28 Isn't good when xml stream won't fix into memory

7:28 manutter: I think it is, but it seems to be implementing a sax interface, which is an event-based parser

7:28 I don't know of a pre-build clojure lib for this, but if you have to roll your own...

7:29 ilyak: It seems to be using sax - they all do

7:29 The problem with "naive" sax or stax is that it's very stateful

7:30 manutter: hmm, that's true but I don't see how to implement an event-based, stateless parser

7:30 Never thought of it before, actually

7:34 ilyak: Well, you can obviously transform [events] to [deserialized-structures]

7:35 manutter: Even with nested structures? How do you keep track of nesting levels without state?

7:36 (I'm still learning functional/lisp-ish coding style, by the way -- PHP coder by day, clojure wannabe by night)

7:43 raek: ilyak: the source for the clojure.xml namespace is using a sax parser with thread local bindings of vars

7:43 ilyak: thread local vars can be mutated with set! and this is a typical usecase for them

8:01 ilyak: raek: It also makes the whole tree

8:01 As far as I understand

8:03 manutter: It sounds like a pretty cool project, though

8:03 I might try and put together a lib to do event-based XML parsing of arbitrarily-long xml files

8:07 dnolen: fliebel: turns out your program and the tabling issue are not really related. your program does need tabling, there are no cycles in your graph.

8:09 fliebel: 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.

8:11 fliebel: dnolen: You mean it doesn't oscillate? Because it *can* create cycles in its path. So the not-membero *is* the right way to go?

8:12 dnolen: fliebel: I guess in your versions cycles arise from 'connected'

8:12 ilyak: manutter: Actually it might be pretty cool to more or less port e.g. arrows from haskell

8:13 dnolen: fliebel: also your notmembero seems odd to me, why not, https://gist.github.com/980610

8:13 manutter: ilyak: 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 :)

8:13 fliebel: well, yea. (btw, why the dot, and not a question mark?)

8:14 dnolen: fliebel: ?

8:14 fliebel: dnolen: So, should I use conda or condu in connected?

8:15 dnolen: [a . b] vs [a ? b] I know scheme does pairs, but ? is more like destructuring

8:15 dnolen: fliebel: does the Prolog version use cut? Do you have a link to the original Prolog?

8:15 fliebel: [a ? b] does mean anything core.logic. I use the dot to show that you might not be destructuring a proper seq.

8:16 fliebel: dnolen: http://www.csupomona.edu/~jrfisher/www/prolog_tutorial/2_15.html

8:16 dnolen: not really destructuring here anyhow, more like pattern-matching via unification.

8:17 fliebel: 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.

8:18 fliebel: dnolen: Right, so… I did, and it ran in endless loops.

8:18 well, I think I did.

8:19 dnolen: fliebel: your notmembero is not right.

8:19 fliebel: it calls membero instead of itself, and there's no terminal case.

8:19 fliebel: hahaha! really?

8:20 oh, well, I copied yours now. Let's see what happens

8:30 dnolen: :( When I add the not-membero it runs forever without producing *any* result. Something must be wrong…

8:31 dnolen: fliebel: what's your run statement look like?

8:31 fliebel: (run 1 [q] (patho 1 5 q))

8:32 (run 1 [q] (patho 1 2 q)) works, since it just does (connected 1 2)

8:33 dnolen: fliebel: here's a correct translation of the Prolog, works fine, https://gist.github.com/980642

8:34 fliebel: still glad we tried tabling yesterday, who knows when I would have discovered that issue otherwise.

8:35 fliebel: :)

8:35 So what was wrong with it, just my not-membero?

8:37 dnolen: fliebel: patho needed to call reverso

8:38 patho also needed the (exist [q] ...), travelo needed to use that as it's output not res

8:39 fliebel: dnolen: Well, only if I cared about the order of the output, right? I just settled with reverse output untill I fixed the reverse function.

8:40 dnolen: fliebel: ah yes that's true, then the problem was not-membero.

8:42 fliebel: dnolen: 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/

8:45 abhinavmehta: hey guys....anybody would like to share some good pointers to start looking and learning clojure...I'm a newbie to it. :)

8:46 fliebel: Ah, I already know what's wrong

8:46 path is not the whole thing in my case.

8:46 manutter: abhinavmehta: have you found clojuredocs.org yet?

8:47 abhinavmehta: manutter: hmm....

8:47 manutter: It's a reference, not a tutorial, but it's useful

8:47 abhinavmehta: manutter: but before I end-up reading at many places....I thought to ask with some experienced guys.. :)

8:48 manutter: hmm....i know.

8:48 manutter: If you don't mind paying for a book, _Clojure In Action_ is pretty good

8:48 http://www.manning.com/rathore/

8:48 abhinavmehta: manutter: np about paying....ahaa, will look for this book. Thanks manutter

8:48 wastrel: hi

9:08 dnolen: fliebel: you have a working version and non-working version, you'll need to compare and contrast ;) gotta run.

9:08 fliebel: dnolen: I did, threw away mine.

9:08 dnolen: contrast: mine hasn;t an acumulator to not-membero agains

9:08 oh, to late

9:19 mattmitchell: i'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?

9:31 wastrel: i got the android clojure repl it's fun

9:53 manutter: mattmitchell: are you asking how to generate a byte array from a string, for testing?

9:53 mattmitchell: manutter: yes exactly

9:55 bulters: anybody knows how i start multiple java process' in the same jvm?

9:56 danlarkin: the jvm is one process

9:56 you can run multiple threads in a single jvm, however

9:56 bulters: ok, let me rephrase. multiple threads

9:56 that what you said ;-)

9:56 manutter: ,(.getBytes "This is a string")

9:56 clojurebot: #<byte[] [B@1f2c3f4>

9:56 danlarkin: bulters: http://download.oracle.com/javase/6/docs/api/java/lang/Thread.html

9:57 manutter: mattmitchell, I think just (.getBytes "some string") is all you need.

9:57 mattmitchell: manutter: do'h! that's it. thank you.

9:58 bulters: danlarkin: 'problem' is as follows: I have a server process (stanford maximum entity pos-tagger) running in the jvm listening on port 12345.

9:58 danlarkin: but I want to start another 'server' on port 12346, preferable in the same jvm process

9:59 danlarkin: sure. your program will spawn threads for each, then

10:00 bulters: So 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:00 thanks

10:02 raek: mattmitchell: don't forget the encoding parameter to .getBytes. ##(seq (.getBytes "åäö" "UTF-8"))

10:03 sexpbot: ⟹ (-61 -91 -61 -92 -61 -74)

10:03 mattmitchell: raek: great. good tip thanks.

10:03 raek: ,(seq (.getBytes "åäö" "ISO-8859-1"))

10:03 clojurebot: (-27 -28 -10)

10:04 raek: mattmitchell: also, why do you get string data as an array?

10:04 b6nk6n: (contains? '(\h \o \t) \o)

10:04 why is this false?

10:05 raek: mattmitchell: 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:05 ...or (= (seq array-1) (seq array-2))

10:06 since = on arrays check identity and not value

10:06 mattmitchell: raek: well, the value coming from a sql statement exec contains this byte array from using group_concat and using a "," separator

10:06 raek: b6nk6n: "contains?" actually means "has-key?" and is only used for maps and sets

10:07 ,(contains? (set "hot") \o)

10:07 clojurebot: true

10:07 mattmitchell: raek: so i have a little function that splits if for me, but it first needs to call slurp

10:07 raek: mattmitchell: but why do you store strings as byte arrays?

10:08 mattmitchell: raek: it's actually the result i'm getting back from the sql library

10:08 raek: which library is this, btw?

10:08 b6nk6n: raek: ah ok thanks, what would be the equivalent to lists and vecs, some?

10:08 mattmitchell: raek: i'm not sure why that is

10:08 raek: I would expect it to return a string

10:09 mattmitchell: raek: totally, me too

10:09 raek: b6nk6n: yes, some. it does a linear search thtough the sequence

10:09 mattmitchell: ,(clojure.contrib.string/split #"," (slurp (.getBytes "test,test")))

10:09 clojurebot: ("test" "test")

10:09 raek: sets are better if you check for membership multiple times

10:09 mattmitchell: raek: that's what i'm doing to handle it

10:10 raek: mattmitchell: String has a constructor for byte-arrays

10:10 ,(String. (into-array Byte/TYPE [-61 -91 -61 -92 -61 -74]) "UTF-8")

10:10 clojurebot: java.lang.IllegalArgumentException: argument type mismatch

10:11 b6nk6n: ok thanks I find ,(doc contains?) a bit misleading then.

10:11 mattmitchell: raek: oh nice. that simplifies it a bit

10:11 raek: ,(String. (into-array Byte/TYPE (map byte [-61 -91 -61 -92 -61 -74])) "UTF-8")

10:11 clojurebot: "åäö"

10:12 raek: mattmitchell: but the real problem you should solve is why you get arrays from the sql lib

10:12 mattmitchell: raek: right. maybe there's an option in the connection config or something. i'll dig around a bit.

10:12 raek: which lib is it?

10:13 mattmitchell: and also, what type does the column have in the db?

10:14 mattmitchell: raek: well this is coming from 2 different fields, here is the relevant bit:

10:14 raek: group_concat(DISTINCT concat(p.id, "::", p.code) ORDER BY p.id) as partner_codes

10:14 raek: so that partner_codes value comes out as a byte array

10:16 raek: mattmitchell: what clojure sql library is this, and what types do the p.id and p.code have?

10:17 mattmitchell: raek: [mysql/mysql-connector-java "5.1.6"] and [clojure.contrib.sql :as sql]

10:17 raek: id is int, code is varchar

10:18 raek: mattmitchell: maybe you could try converting the int to a varchar in some way

10:18 mattmitchell: what happens if you concat two varchar columns?

10:18 mattmitchell: raek: i'll try that

10:19 raek: if you still get a byte array then, I suggest you report this as a bug

10:19 from 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:19 looks like you get a blob or a varbinary

10:23 mattmitchell: you could also try concat(cast(p.id, varchar(50)), "::", p.code)

10:24 or maybe concat(convert(varchar(50), p.id), "::", p.code)

10:25 mattmitchell: raek: ahh cool. let me try that.

10:37 jose__: Hello!

10:38 wastrel: hi

10:43 so do people use the GUI or just cli for emacs

10:44 since i'm getting started with it

10:44 i geneally prefer cli but if GUI is How Things Are Done i'll work with it

10:44 Fossi: you mean like xemacs or console?

10:44 TimMc: wastrel: They're pretty much the same.

10:45 Fossi: yeah

10:45 TimMc: wastrel: But if you're just getting started, use the GUI by all means.

10:45 wastrel: I dunno i just installed emacs typed "emacs" and got a giant window filling up my screen.

10:45 instead of a tidy little app in my terminal

10:45 Fossi: type emacs -nw then ;)

10:45 if you care

10:45 wastrel: generally i care because i hate the mouse :]

10:46 Fossi: well, it's not in the way either way

10:46 TimMc: $google emacs n00b start

10:46 sexpbot: First out of 4200 results is: Emacs quick start: One n00b to another. | Brain on Fire

10:46 Fossi: you dan't have to use it with a window either

10:46 sexpbot: http://www.brainonfire.net/blog/emacs-n00b-start/

10:46 TimMc: ^ I wrote this to help other beginners.

10:48 wastrel: ok thanks

10:48 TimMc: It's not a tutorial -- the goal is to cover basics that many tutorials forget to mention at the beginning. :-)

10:49 wastrel: if i do all this, i'll get a repl with brace matching and pretty printing and syntax hilighting?

10:49 TimMc: Nah, for that you'll ened to customize your .emacs config file.

10:50 Let me paste mine so you can grab interesting bits.

10:50 wastrel: by do all this i mean, setup & learn emacs, get the clojure stuff setup and slime or swank or silly or whatever

10:51 raek: wastrel: check out http://technomancy.us/149

10:52 the emacs + clojure setup is now a whole lot simpler

10:52 * dnolen is contemplating explicit Definite Clause Grammar support in core.logic

10:52 raek: dnolen: cool!

10:53 TimMc: wastrel: https://gist.github.com/980934 -- there are some nice bits in here

11:00 mattmitchell: raek: ok using mysql cast(col as char) does the trick!

11:04 dnolen: this is kind of an awesome read, http://www.cotilliongroup.com/arts/DCG.html, Definite Clause Grammars - Not Just For Parsing Anymore.

11:08 wastrel: this channel involves a lot of reading

11:08 * raek adds it to his Instapaper

11:09 dnolen: wastrel: and thinking too.

11:09 wastrel: it's a problem

11:10 oh instapaper they must have an android app by now

11:10 dnolen: wastrel: it's fun!

11:14 DCGs 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:15 * raek o O ( I wonder if DCGs could be used to implement type inference in a toy language )

11:16 dnolen: raek: the DCG - Not Just For Parsing anymore points out the relationship between DCGS and types.

11:17 raek: wow. I'm really excited that we have the tools for this in Clojure now

11:18 wastrel: heh i haven't used instapaper since 2009

11:18 raek: dnolen: in the end, isn't DCGs just a notation that expands into ordinary relations?

11:18 dnolen: raek: 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:23 raek: ah looks you need to thread difference lists, http://www.amzi.com/manuals/amzi/pro/ref_dcg.htm

11:27 rlb: So <, >, etc. don't work for Comparables (i.e. Date)?

11:29 dakrone: rlb: clojure.contrib.generic.comparison let's you define your own multimethod for < & >, so you can do one for [Date Date] pretty easily

11:32 rlb: dakrone: thanks -- though for now I think I'll just use (pos? (compare x y)) in the filter.

11:33 ahmed1: hi

11:33 www.pakk.tk

11:36 fliebel: dnolen: what does mplus do?

11:42 dnolen: 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:42 dnolen: fliebel: interleaves streams of results.

11:43 fliebel: it's possible but you'll want to look at how I did it with defrel & facts in the prelude.

11:44 fliebel: dnolen: Looking at it now, but there are so many layer of macro on top of it.

11:44 mattmitchell: what's the nicest way to convert a hash-map to a vector?

11:47 fliebel: dnolen: what is the index atom for?

11:47 rlb: mattmitchell: (vec map)?

11:48 ##(vec {:a 1 :b 2})

11:48 sexpbot: ⟹ [[:a 1] [:b 2]]

11:48 rlb: ##(vec #{:a 1 :b 2})

11:48 sexpbot: ⟹ [1 2 :a :b]

11:48 dnolen: fliebel: indexed facts

11:48 mattmitchell: rlb: ok is there a nice way to have the hash-map flatten?

11:48 dnolen: fliebel: by default index the first element of the fact tuple, this makes queries way faster.

11:49 fliebel: later I'll add knobs so you can index any element of the tuple.

11:49 fliebel: w/o indexing you have to do what conde does which is consider all alternative even those that don't apply.

11:50 fliebel: the trick here is we see a ground lvar, we can used the indexed facts.

11:50 fliebel: oh.

11:50 dnolen: fliebel: standard Prolog optimization.

11:51 fliebel: okay, so basically, what I want is to provide answers with whatever you do to that set to get the indexed one.

11:52 rlb: mattmitchell: iirc yes, and someone even mentioned it to me the other day -- trying to remember...

11:53 ahh "<dnolen> ,(apply concat {:a 'b :c 'd})"

11:53 ##(apply concat {:a 'b :c 'd})

11:53 sexpbot: ⟹ (:a b :c d)

12:01 fliebel: dnolen: What about this? (defn rel [names values] (fn [a] (answers a values (index values) names)))

12:06 technomancy: redinger: ping

12:24 fliebel: dnolen: What about this? (defn rel [names values] (fn [a] (answers a values (index values) names)))

12:25 user=> (run* [q] (rel [1 q] [[1 2] [3 4]]))

12:25 (2)

12:28 dnolen: fliebel: 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:28 fliebel: (extend-rel rel-name facts)

12:30 fliebel: even better, the fact that I use vector is broken, allows for duplicates, really a collection of facts should be a set.

12:30 fliebel: dnolen: What would that do? Just basically (doseq [f facts] (fact rel-name f))?

12:31 dnolen: fliebel: no it would be simpler, it would reduce the new set of facts onto the old one and recompute the indexed set.

12:31 fliebel: dnolen: You're not allowed to take patches form me, as I haven no CA. I should resend it, I know.

12:31 dnolen: fliebel: get on it man!

12:31 lpt1: !history

12:31 !logs

12:31 fliebel: ~logs

12:31 clojurebot: logs is http://clojure-log.n01se.net/

12:31 lpt1: tx

12:32 fliebel: dnolen: Okay, I'll see what I can do.

12:50 dnolen: type 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:17 sexpbot: ⟹ 2

13:19 fliebel: Is there a way to kill a single statement instead of the whole vm? Like in Python.

13:20 (in lein)

13:20 amalloy: fliebel: i don't think clojure's repl exposes that

13:20 fliebel: :(

13:20 amalloy: to get it, you'd have to start every expression on a new thread

13:22 dnolen: fliebel: you don't use Emacs do you?

13:22 hiredman: swank-clojure can do it, calls Thread.interrupt on the repl thread which throws an exception

13:22 fliebel: no

13:24 TimMc: amalloy: Perhaps there is a signal that can be sent to the REPL process?

13:24 chouser: clojure.repl/set-break-handler!

13:27 TimMc: chouser: Since when?

13:27 fliebel: Can;t find it...

13:28 amalloy: i try to say at least one grotesquely-wrong thing to start my morning

13:28 TimMc: fliebel: I don't think it's in 1.2.

13:29 fliebel: TimMc: http://clojure.github.com/clojure/branch-master/clojure.repl-api.html

13:29 TimMc: fliebel: https://github.com/clojure/clojure/blob/master/src/clj/clojure/repl.clj#L276

13:30 chouser: if it's not in clojure.repl for you, look in clojure.contrib.repl-utils

13:30 it's pretty old, in clojure-years

13:31 fliebel: :)

13:33 dnolen: chouser: a tried and true weapon against the unruly infinite lazy-seq

13:34 chouser: heh

13:42 mattmitchell: hmm, how to remove one key/val pair from a hash, based on the key's name?

13:43 ataggart: dissoc

13:43 mattmitchell: ataggart: ahh right

14:47 blackcoffeerider: hello fellas

14:49 anyone ever came across #<CompilerException java.lang.ClassCastException (NO_SOURCE_FILE:0)> when using lazy-xml/pull-seq with a pull parser?

14:51 same file with clojure.contrib.lazy-xml/has-pull defined to false gives expected result

14:51 switched back on again causes a classcast exception

14:53 tried 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:56 @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:57 chouser: bleh, sounds like a mess

14:57 I actually plan to give lazy-xml a good going-over, probably starting next week

14:58 blackcoffeerider: chouser: 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:59 chouser: emit in lazy-xml uses javax.xml transformer -- you're saying that still doesn't do " and ' correctly?

15:02 blackcoffeerider: chouser - not for me... sorry

15:02 chouser - using stock 1.2-core and 1.2-contrib from the downloadpage

15:04 chouser: http://pastebin.com/XKztv87B

15:07 chouser: 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:08 to reescape it ourselves - 11. , 19.

15:08 chouser: yikes. ok.

15:09 blackcoffeerider: chouser: 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:10 any hints with my pull issue on the reader side?

15:12 chouser: blackcoffeerider: sorry I haven't looked at it in a while. Is it trying perhaps to use a different version of the pull parser?

15:12 I think I remember noticing that the pull parser API isn't as stable as SAX.

15:14 blackcoffeerider: chouser: which parser & version had you used that was working?

15:15 chouser: I think it was XPP2 at this link: http://www.extreme.indiana.edu/xgws/xsoap/xpp/

15:16 blackcoffeerider: chouser: thanks - ill give it a try!

15:31 chouser: xpp2 doesnt semm to implement xmlpull.org - so i tried the oldest version of xpp3 i could find... no luck either

15:31 chouser: will look at your source and see what exactly happens...

15:32 chouser: this was written before I was aware of any kind of story for external dependencies.

15:33 and this week I'm still grading homework

15:33 but *next* week, ah next week I will have time... :-)

15:38 Raynes: chouser: We all have time next week, right? Right?

15:39 chouser: not as lyrical as "tomorrow", but it seems more realistic.

15:39 "next week, oh next week, I luv ya, oh next week"

15:48 Raynes: $max

15:48 sexpbot: The most users ever in #clojure is 317

17:08 no_mind: I 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:13 scgilardi: what difficulty do you anticipate?

17:44 gigamonkey: Anyone know how many folks attended the first ClojureConj?

17:44 technomancy: gigamonkey: just a smidge under 200 IIRC

17:46 gigamonkey: Thanks.

17:46 If anyone has a citable source for that number, that'd be cool too.

17:46 (I'm writing the intro to Michael Fogus's interview with Rich Hickey that's going up on Code Quarterly soon.)

17:47 ataggart: I think Alan Dipert was in charge of the conj, he might know

17:47 or stu

17:47 technomancy: redinger maybe?

17:47 ataggart: ya, pretty much anyone at relevance

17:49 gigamonkey: Is there a particular mailing list, google group, or something that is the center of "the Clojure community"?

17:50 hiredman: pprint would be really nice if it didn't deref vars

17:50 technomancy: gigamonkey: yeah: http://groups.google.com/group/clojure

17:57 blackcoffeerider: @chouser: problem solved... xmlpullparser wants a reader as source- cant handle a java.io.File as opposed to standard parse...

18:10 amalloy: yeah, the google group and #clojure. if you want a mailing list, that's the one

19:22 symbole: I'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:25 technomancy: symbole: looks like it's not compatible with Emacs 22; can you upgrade?

19:25 23 has been around for many years now

19:27 duck1123: I'm still forced to use 21 on some of the machines at work

19:27 it drives me nuts

19:28 symbole: Shouldn't be a problem. I'll try emacs23 on another machine.

19:28 technomancy: cripes; 21? that's like IE6-era.

19:29 symbole: technomancy: 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:30 duck1123: technomancy: that's exactly my point

19:31 technomancy: symbole: either will work. 1.3.1 is all you need.

19:32 1.4.0-SNAPSHOT has nice new debugging features but isn't a stable release

19:44 symbole: technomancy: 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:46 technomancy: symbole: do you have another swank version in lib or lib/dev?

19:46 or ~/.lein/plugins for that matter?

19:47 symbole: in ~/.lein.plugins I have 1.3.0, 1.3.1, and 1.4.0-SNAPSHOT.

19:48 technomancy: symbole: try clearing that out to just 1.3.1

19:48 * technomancy makes a mental note to bug trptcolin about that

19:49 symbole: I hastily only left 1.4-SNAPSHOT, and it worked.

19:49 technomancy: cool

19:50 symbole: This is very cool. Thanks.

19:51 technomancy: still a few rough edges it looks like

20:01 zippy314: Hi 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:02 dnolen: zippy314: is there a ring jar in your lib folder?

20:02 amalloy: zippy314: jetty is not related to compojure afaik. you need ring, which will pull in jetty

20:03 zippy314: There's a "ring-core-0.3.8.jar" file.

20:03 that's not enough?

20:04 amalloy: zippy314: it's probably not in ring-core, but in something like ring-jetty

20:04 i have as a dependency [ring "0.3.7"]

20:05 zippy314: amalloy: I'll try that. Thanks

20:05 amalloy: and that causes me to get, among other things, ring-jetty-adapter.jar

21:19 zippy314: Hi 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:19 in that example, data comes back empty. Why?

21:25 tomoj: zippy314: what's the content-type of the request?

21:25 application/x-www-form-urlencoded right?

21:26 zippy314: just sending a simple curl like this: curl localhost:8080 -d some-data

21:26 so not sure.

21:26 tomoj: do you have nc handy?

21:26 zippy314: How would I find that out?

21:26 it seems to be on my machine, but I haven't used it.

21:27 tomoj: `nc -l 8081 > req.log`, then make the form hit 8081

21:27 amalloy: i'm pretty sure the {blah :params} thing is way old syntax

21:27 tomoj: of course maybe your request is perfectly fine and it's some compojure problem..

21:27 amalloy: just do (defroutes (POST "/" [data] (call-function data)))

21:27 and it will intercept the :data element from the form

21:28 tomoj: wat

21:28 based on application/x-www-urlencoded content type I guess?

21:28 amalloy: a snippet from 4clojure source: (POST "/problem/edit" [id] (edit-problem (Integer. id)))

21:29 tomoj: does it auto-figure-out json post bodies now too? :D

21:29 zippy314: I've tried that. It doesn't work.

21:30 tomoj: I'd try stepping through the middleware in the repl with a grabbed request object

21:31 zippy314: amalloy: 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:32 am I setting up the middleware correctly?

21:32 tomoj: is there a magic 'request' binding inside defroutes or are you not supposed to be able to get the request?

21:32 zippy314: compojure.handler/site adds a bunch of middleware for you

21:33 amalloy: zippy314: 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:33 tomoj: won't it if you use (run-jetty #'main-routes ...) ?

21:35 amalloy: provided that you actually recompile the code, i think so. just editing the source won't do it unless you use wrap-reload

21:35 zippy314: tomoj: this is my first hour on compojure, so I'm no totally clear on all the things you are saying.

21:36 I'm running this stuff with lein run, so I assume it recompiles.

21:37 amalloy: I kill the process each time I make a change and re do 'lein run;

21:37 tomoj: ouch

21:40 wastrel: apropos of the thread on the mailing list about newbie setup

21:41 speaking as a newbie it is quite a process

22:26 tomoj: http://www.learningclojure.com/2010/09/clojure-faster-than-machine-code.html so if you do this, you will probably run out of permgen?

23:19 zippy314: In 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:28 dnolen: wastrel: what's the specific problem you encountered? which setup were you trying to follow through on?

23:30 wastrel: dnolen: well i did get the basic repl and such working fine, with jline and later with rlwrap

23:31 but i want a fancy repl with syntax hilighting and indenting and brace matching

23:31 so that's what i've been having trouble with.

23:31 dnolen: wastrel: what kind of REPL experience are you coming from?

23:31 wastrel: dabbling with drscheme

23:32 dnolen: wastrel: comparing command line experience to a full blow GUI environment seems ... unfair. But yeah, DrRacket is good. what other REPLs have you used?

23:32 wastrel: no 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:33 dnolen: wastrel: why not VimClojure or slimv then?

23:33 wastrel: couldn't get either working

23:33 dnolen: wastrel: and you weren't able to ping the maintainers?

23:34 wastrel: well i did get the vimclojure working for syntax hilighting but indenting wasn't

23:34 anyway i'm not complaining just observing :]

23:35 then i decided the grass was greener over on the emacs side so i tried setting it up to no noticable success

23:36 as to the maintainers I didn't, no. i was still browsing around

23:36 clojurebot: blip.tv is http://clojure.blip.tv/

23:36 dnolen: wastrel: 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:36 wastrel: i just wanted a fancy repl

23:37 "just" :]

23:37 dnolen: wastrel: are you on OS X? Linux?

23:37 wastrel: but the thread on the mailing list is right it's a lot of hoop jumping

23:37 linux yes

23:37 dnolen: wastrel: do you use Ruby?

23:37 wastrel: i've written a ruby hello world but no, not really

23:38 dnolen: wastrel: if you have ruby installed, I would do "sudo gem install cake"

23:38 wastrel: cake has the best REPL that's not tied to anything else, as long as your ok w/ the ruby dep.

23:39 wastrel: ok i'll check it out

23:42 dnolen: wastrel: 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:42 wastrel: dnolen: so are you saying i wouldn't get colors, indenting & brace matching with emacs even if i did get it all setup ?

23:43 dnolen: wastrel: no you would get all those things. But you'd have to learn Emacs. No small hurdle.

23:44 wastrel: in a repl or would it be writing a file in emacs and then running the file?

23:44 amalloy: wastrel: you can get it in the repl. i haven't bothered

23:45 dnolen: wastrel: Emacs has sophisticated Lisp support in general, Lisp programming is natural in Emacs once you learn the chorded commands.

23:45 wastrel: the cake repl is nice but not bling bling :]

23:45 dnolen: wastrel: true, but you can get far w/ cake repl plus plain text editor.

23:45 amalloy: dnolen: 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:48 dnolen: wastrel: 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:56 zakwilson: I'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:56 dnolen: zakwilson: talk you out of it ?!

23:57 zakwilson: Yes, 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.

Logging service provided by n01se.net