#clojure log - Nov 24 2011

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

0:00 callen: spoon16: nope, you're stuck with me.

0:02 spoon16: I have some questions about using lein with ivy… we have a large repo at NFLX that uses IVY and I'd like to figure out what it would look like to make lein work with a repository that has *-ivy.xml files

0:02 I guess I will hit up the mailing list

0:03 callen: spoon16: what's the latency for responses in irc for you usually?

0:04 spoon16: apache ivy?

0:06 spoon16: callen: not sure what you mean… I was just thinking the mailing list for leiningen is probably a more appropriate place

0:07 and yes… apache IVY… we have a maven repository where dependencies are described using IVY.xml files. I notice that lein deps pulls the jars that i have explicitly identified, but it does not pull down the dependencies

0:07 callen: are those ellipses?

0:07 ...

0:07 they have to be.

0:10 spoon16: netflix uses Clojure?

0:41 georgek: ah of course, just needed to require clojure-mode in .emacs before adding the hook

0:42 spoon16: callen: sorry, got a phone call

0:43 callen: I'm not aware of any projects at NFLX that use Clojure in production

0:44 but I work on a project and we'd like to use it for a couple of tools… if things go well we may see about leveraging clojure to develop some of our back end services

0:44 Raynes: That's awesome.

0:44 I'm a huge fan of Netflix.

0:45 spoon16: the technology is good

0:46 Raynes: I think I'm the only person the planet who was okay with a price increase and separation of DVD and streaming services.

0:49 callen: spoon16: so why do you want leiningen?

0:49 Raynes: I'd be a bigger fan and more likely to stay a paying customer if they'd get the bloody linux client done.

0:49 Raynes: Yeah, Silverlight is a bit of a problem.

0:49 callen: Raynes: I was okay with the price increase, I just want a damn client.

0:51 spoon16: linux client is coming… eventually

0:52 I don't think there are enough users to make it a high priority

0:52 not on one of the clients teams though… so who knows what the real reasons are

0:52 callen: because it's fancy

0:53 I supposed i do not really need it

0:53 I just started using it and thought there might be some way to get it to work

0:54 callen: spoon16: you'd be bending over backwards unnecessarily, IMHO

0:54 spoon16: I think you are right

4:32 dmi3y: Hi, guys. I'm solving a problen on 4clojure.com where it's required to implement function to count number of elements in a list w\o using the count fn. Can you give me a hint how can I do that in Clojure cause I'm fairly new to it. Thanks!

4:32 ... please

4:39 Wild_Cat: dmi3y: you probably want to use recursion and/or destructuring.

4:39 dmi3y: got it, thanks

5:40 fridim_: hi :)

5:57 aperiodic: hiredman: you recommend i implement a simple lisp earlier to help me understand evaluation in clojure; do you think i should implement a spec, or try to come up with something simple myself?

5:58 hiredman: i've been exposed to scheme before in a PL class, so I'll give it a shot, but I'll probably screw up at some point :)

6:03 hoeck: apear

6:04 aperiodic: that should be part of the curriculum of any programming course: design and implement a simple lisp interpreter in the language of your choice

6:04 aperiodic: I did this in powerbuilder and it helped me alot to understand lisp better :)

6:05 you will also gain a better understanding of language-of-your-choice

6:05 aperiodic: hoeck: to be fair, my degree was in math, not CS

6:06 hoeck: it was not a top-notch CS curriculum by a long shot!

6:07 hoeck: aperiodic: but you had at least some exposure to scheme!

6:07 aperiodic: this is true

6:07 i remember the introductory class was taught half in haskell

6:07 which i thought was great

6:08 the professor said he wanted to "level the playing field", figuring that most people who had dabbled in programming probably hadn't tried that

6:09 hoeck: mine was half haskell half c, and we had to implement a parser and a simple compiler for a mimal subset of haskell wit c and yacc

6:09 aperiodic: ooh nice

6:10 we did a basic heavily-arithmetic language in scheme

6:10 (in the PL class)

6:11 then tried to add type-inference

6:11 i didn't grok all the theorems for that though!

6:12 hoeck: back then, I didn't understand the concepts very well, and most of the time we where in a hurry to accomplish the next subtask, but in retrospect, that introduced me to FP

6:13 aperiodic: it's really good to get an exposure to that

6:13 i remember i really admired the expresiveness when compared with c

6:14 but c mapped on to my mental model of computation very well

6:14 until i found myself wishing for first-class functions

6:16 msappler: hello guys, i have a question about "compile". I have a settings namespace with a (def jar-file? false) and I always set it to true before compiling manually. How can I automate this? I tried to re-def it and compiling but it did not work

6:16 hoeck: The first time when I played with haskell, I was surprised that there were no segfaults when the code had errors in it (coming from c)

6:17 aperiodic: it took me then another 3 years or so to fully grasp what first class functions are

6:17 aperiodic: i was really blown away by how much work the type system did for me

6:17 msappler: why do you want the jar-file? flag set?

6:18 msappler: i've done a fair amount of java interop and never needed anything like it

6:19 Blkt: good day everyone

6:20 msappler: @aperiodic: i have different image loading functions for jar files and "normal"

6:20 aperiodic: msappler: huh, why is that necessary?

6:20 msappler: basically I do a .listFiles File which does not work in a jar file

6:20 aperiodic: okay

6:21 well, i dunno how you can automate that, sorry!

6:21 msappler: ok! ;)

6:21 aperiodic: you might try looking into lein hooks, though (if you use leiningen)

6:24 hoeck: msappler: are those images resources like icons and such?

6:25 msappler: they are animations. in each folder and I just use listFiles and sort them. for example "0.png" "1.png" "2.png"

6:26 which is quite comfortable I dont need to know how many frames there are

7:03 r0man: Hi, what's the preferred way to override the toString method of a

7:03 ClojureScript record? I could use set! to change the toString fn

7:03 of a record after it has been initialized, but wonder if there is

7:03 something more idiomatic?

7:10 lypanov: for users stuck with rails on the front-end: https://github.com/yokolet/clementine (jruby) https://github.com/lypanov/clementine (MRI)

7:10 clojurebot: eg, https://github.com/clojure/tools.logging is the new version of clojure.contrib.logging

8:38 samaaron: /wi ejackson

8:38 wi ejackson

9:16 biallym: theoretically speaking

9:16 how would I reverse a (shutdown -agents)

9:16 how would I reverse a (shutdown-agents)*

9:22 I'll take that as a "not possible"

9:22 nachtalp: biallym: java.util.concurrent.ExecutorService doesn't really seem to have support for that

9:22 biallym: so it should only be used when it is a for sure thing that you are about to exit

9:23 either that or create a way to trick clojure into using a new thread pool?

9:26 nachtalp: biallym: if you need to shutdown and create threadpools maybe it's better to manage them yourself? or maybe use something like medusa? (http://bit.ly/arp1ih)

9:31 biallym: not sure what exactly you're trying to achieve, though :)

9:31 biallym: Just thinking about how to clean up properly

9:33 Because I am writing a program with a lot of inherient state, I have to think about that a lot

9:35 The thing I was really trying to do is know if a library should call shutdown agents if it uses agents, but the answear seems like a resounding no

9:35 (The clojure site makes it sound like that has to be called before exiting can occur correctly)

9:38 nachtalp: biallym: this post has some discussion: http://tech.puredanger.com/2010/06/08/clojure-agent-thread-pools/

9:56 andrewclegg: is there a quick way to make a string out of n repetitions of a char?

9:57 so far I have (apply str (repeat 100 \ ))

9:57 nachtalp: (apply str (take 5 (repeat \C)))

9:58 andrewclegg: is that likely to be more efficient?

10:00 nachtalp: i don't think so

10:04 andrewclegg: mine's less function calls then ;-)

10:05 nachtalp: andrewclegg: agreed :)

10:06 andrewclegg: actually, if you look at the source of repeat it's the same ;)

10:09 Saturnation: ,(#(+ (* %1 2) (if (= %2 "0") 0 1)) 0 "0")

10:09 clojurebot: 0

10:09 Saturnation: ,(reduce #(+ (* %1 2) (if (= %2 "0") 0 1)) 0 "0")

10:09 clojurebot: 1

10:09 Saturnation: that confuses me :(

10:10 what am I missing?

10:10 * Saturnation expected both to return 0

10:10 * gfredericks stares hard

10:10 Saturnation: using it to convert binary string "10110" to int

10:11 I'd expect to replace the final string argument in the reduce with a binary string and get the int back

10:11 gfredericks: you can't use the built-in for that?

10:11 ,(Integer/parseInt "10110" 2)

10:11 clojurebot: 22

10:11 * Saturnation is doing 4Clojure problems at the moment :)

10:11 gfredericks: oh

10:11 _fine_ :P

10:11 * gfredericks stares again

10:11 Saturnation: probably would work better :)

10:12 just really want to grok reduce better, regardless

10:12 gfredericks: ah ha

10:12 the last arg to reduce is supposed to be a list

10:12 ,(reduce #(+ (* %1 2) (if (= %2 "0") 0 1)) 0 ["0"])

10:12 clojurebot: 0

10:12 gfredericks: so the "list" you were passing in was ##(seq "0")

10:12 lazybot: ⇒ (\0)

10:12 Saturnation: ah, thought a string was a list

10:12 gfredericks: it is

10:13 Saturnation: huh?

10:13 gfredericks: so alternatively we could have:

10:13 ,(reduce #(+ (* %1 2) (if (= %2 \0) 0 1)) 0 "0")

10:13 clojurebot: 0

10:13 gfredericks: a string is a list of characters, not a list of length-1 strings

10:13 "0" is different from \0

10:13 Saturnation: AH

10:13 got it, thanks

10:13 :)

10:13 gfredericks: now I've done my thanksgiving good deed

10:14 biallym: nachtalp: Thanks, I guess I'll file agents as not fully developed yet

10:14 Saturnation: so (= "0" \0) -> false

10:14 gfredericks: ,(= "0" \0)

10:14 clojurebot: false

10:14 Saturnation: :)

10:14 thanks again

10:14 gfredericks: yep

10:14 good luck

10:14 * gfredericks wanders off

10:14 Saturnation: getting there

10:16 nachtalp: biallym: what brings you to that conclusion?

10:17 biallym: Because there isn't fully fleshed out support for them in libraries, long running applications, or development enviroments

10:18 They seem fun to play with, and useful for small apps, but don't have the level of support I would expect, to be able to use them in anything like those ^

10:19 nachtalp: biallym: i don't see why the couldn't be used in the scenarios mentioned above...

10:19 they, even

10:21 biallym: Libraries: including the library stops the program from closing without boiler plate and starts up a bunch of thread pools without user knowledge. Additionally there is no way for the library to treat it's agents differently

10:26 And for the other two, it means there is a one-time-only, restart required to fix, language feature. Which means to get agents back I have to loose all of my state

10:27 nachtalp: biallym: i still don't understand why you want to shutdown the thread pools in order to "clean up" ... the state associated with the agents is independent from the thread pools afaik

10:28 biallym: Because you have to call it to cleanly exit a program >.>

10:28 like if you don't call it the program will just hang on the terminal

10:28 which is really annoying for the user (programmer) of a library

10:29 Also, while I don't know the stability of java threads/thread pools, if they somehow did crash, there is no way to recover the language feature

10:31 And I am not talking about getting the agent state, if there is an agent I need to manipulate to get a crashed program without a working agent threadpool back into a running state without loosing any other accumulated state, I am screwed

10:32 say if I had a long running calculation, it crashes into a repl, how do I use agents if the thread pool has crashed? How can I restore the program to a running state again?

10:33 Yes I could save it to disk and reload it, if that is even easily feasible with clojure, but I would prefer language features which are more robust

10:33 nachtalp: biallym: if those are your requirements, agents might not be what you're looking for (i may be wrong, however)

10:35 biallym: Well they would be an elegant way to handel certain parts of an application, but they don't seem robust enough for my paranoia >.>

10:39 especially because those are control and command parts, which I would prefer worked on a consistent basis :p

10:40 nachtalp: biallym: sure, if you don't trust the built-in threadpools in java to be robust...

10:40 biallym: Haha, I don't trust java, I come from lisp land, not java land

10:41 I really miss condtions and resets too >.> (http://www.gigamonkeys.com/book/beyond-exception-handling-conditions-and-restarts.html)

10:44 However the speed is competitive (enough) with common lisp for what I am doing, clojure has much better concurrency support, and I'm getting time on a cluster so *shrug*

10:46 andrewclegg: biallym: java's thread pools are very well tested by now

10:48 biallym: I am sure they are... I just don't feel secure using them in a long running program all. And not at all for any library.

10:48 is all*

10:50 I probably will end up using them, I just think it's stupid the way they are set up now >.>

10:52 Especially for libraries... >.>

11:53 Guest91650: hello - can someone help me with understanding somtehing about symbols and functions?

11:53 if have the following source

11:53 (defn hello [x y] (str "hi " x " and " (apply y)))(defn robert [] (str "Rrrrobert "))

11:54 and when using (map hello '(1) '(robert))

11:54 i don't get the expected "hi 1 and Rrrrobert" but an exception.

11:55 Vinzent: Guest91650, why (apply y)? just (y)

11:57 Guest91650: this is a simplification of a real situation which shows me i don't know how to invoke the function associated as a symbol (you see already i tried with apply)

11:57 just (y) gives me the errpr #<IllegalArgumentException java.lang.IllegalArgumentException: Wrong number of args (0) passed to: Symbol>

11:58 and with apply i get the exception #<IllegalArgumentException java.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$apply>

11:58 Vinzent: Guest91650, show the whole code, please, looks like you have ('f) or ((symbol "f"))

11:59 Guest91650: this is the whole code

11:59 just the 2 lines

11:59 (defn hello [x y] (str "hi " x " and " (apply y)))

11:59 and

11:59 (defn robert [] (str "Rrrrobert "))

11:59 and this is the call from the repl

11:59 (map hello '(1) '(robert))

12:00 Vinzent: oh, right - you should use [robert]

12:00 because ' prevents evaluation of robert, so it's a symbol, not a function, so it tries to call ('robert)

12:00 Guest91650: => (map hello '(1) [robert])

12:00 kephale: ,(let [hello (fn [x y] (str "hi " x " and " (y))) robert (fn [] (str "blah"))] (map hello [1] [robert]))

12:00 Guest91650: #<IllegalArgumentException java.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$apply>

12:00 clojurebot: ("hi 1 and blah")

12:01 Vinzent: Guest91650, as i sayed abive, (y), not (apply y)

12:06 Guest91650: Thank you a lot Vinzent and kephale! now it works. but then i miss something - if i understand you correctly - using [robert] make robert to get evaluated to the function itself which is then correctly called by map. so far - so good. then - using '(robert) prevents the evaluation of robert to the function denoted by that symbol. also ok. but that means that i can't use function names in...

12:06 ...lists to be invoked later. or there is a possibility to find the function of a symbol which i don't know (except the now shown explicit putting it in an array for example)

12:07 p.s. called by (y) and not by map - sorry.

12:07 to clarify - i look for something like symbol-function of common lisp.

12:08 kephale: Guest91650: you also could have used (list robert)

12:09 Guest91650: that was it... forgot about ' being a shortcut to (list...)....

12:09 Thanky you again, kephale!

12:11 Vinzent: actually, ' is shortcut for (quote ...)

12:11 biallym: ,(let [foo (fn [] ())] (macroexpand-1 '('foo)))

12:11 clojurebot: ((quote foo))

12:12 biallym: Also notice the difference:

12:12 Guest91650: yes, you are right

12:12 biallym: ,(let [foo (fn [] ())] (macroexpand-1 `('foo)))

12:12 clojurebot: ((quote sandbox/foo))

12:12 biallym: Not sure if that is relvent to what you were talking about but it might be

12:12 (the second one, not the first one)

12:15 Guest91650: biallym - ty, kephale and vinzent helped already a lot to reboot my head from lisp-2 hapbits :)

12:15 and sometimes to not see such things...

12:16 biallym: Yea clojure has a lot of subtle differences from other lisps

12:16 most of them good

12:16 i find it very rare that you ever need a quote, for example

12:16 (unless you are dealing with macros that is)

12:18 Guest91650: well - even without macros - each case where part of your program is represented as data - there could be a lot of quoting

12:18 biallym: Like I was saying, I find that very rare, because of a lot of clojures default behavior (I also come from lisp land, I found that about 60% of my quotes were unnessecary in clojure)

12:20 Guest91650: probably - i'm not yet that experienced in clojure.

12:25 while porting something from cl to clojure - sometimes i stumble upon things and don't get through until someone points to the right direction - which often seems so obvious - but only after someone else shows it... :)

12:58 krunaldo: I'm having some issues with clojure 1.3, well I can't start it. 1.2.1 works fine! It says colud not find main class, java version "1.6.0_23"(openjdk)

12:58 any clue?

13:00 just tried it with jre1.6.0_29 did not work either.

13:01 Vinzent: are trying to start swank or what?

13:01 *are you

13:02 krunaldo: clojure -cp $jar clojure.main

13:03 hahah, nvm I'm really stupid

13:03 my -cp pointed to the zip file

13:03 I'll just go into my corner of shame and shoot myself :)

13:12 Vinzent: krunaldo, hah :) but, seriously, why don't you use leiningen?

13:16 krunaldo: Vinzent: Getting to that, I just want to trial out some code. I'll get to the tool chain later on :)

13:17 hhutch: i'm having problems with clojurescript interop: http://paste.lisp.org/display/126064

13:17 anybody have a suggestion?

13:19 Vinzent: krunaldo, ok, but It's just so much easier to do this with leiningen (no classpath issues etc, just start lein repl and code!)

13:21 hhutch, I haven't tried clojurescript, but don't you think it should be (apply (. shortcut-handler registerShortcut) ...)?

13:26 hhutch: Vinzent: no, i need to pass a list of arguments to registerShortcut (a mothod of shortcut-handler) ...

13:27 just like (apply str ["a" "b" "c"]) is (str "a" "b" "c")

13:27 Vinzent: (. shortcut-handler registerShortcut) returns that method (which actually is a function)

13:30 hhutch: Vinzent: I'm pretty sure apply doesn't work that way in java interop anyway, that's why you use doto, or am i wrong?

13:33 Vinzent: hhutch, in java (.method class) just calls the method, because in java you can't take it and treat as a function; but it's possible in javascript, so (.method class) returns the function, and to call it you have to use ((.meth class) arg1 arg2) or (. class (method arg1 arg2))

13:36 hhutch: Vinzent: that's all correct, but (. class method) will return a function you can run apply against?

13:36 Vinzent: hhutch, in clojurescript - yes, that's what I'm talking about

13:36 hhutch: (. shortcut-handler (registerShortcut "S" "s"))

13:36 (apply (. shortcut-handler registerShortcut) ["S" "s"])

13:37 are not equivalent though when I tested it

13:39 Vinzent: is it throws an exception or something? I don't have working clojurescript setup right now, so I can't test it, sorry...

13:40 hhutch: Vinzent: no problem. it compiles, but the JS throws an exception

13:40 i'm moving on, i'll figure it out later

14:06 pyr: ahhh, the dreaded Don't know how to create ISeq from: clojure.lang.Symbol

14:44 Vinzent: hhutch, hey, I've set up cljs and played a little with it, looks like function returned by (.method target) syntax can't be used as a normal clojure function, see: http://pastebin.com/rxdqGqED

14:45 licenser: Vinzent: (. target (method))

14:46 Vinzent: licenser, no, we need (apply (.method target) [args])

14:46 is it possible?

14:47 also see this thread: http://tinyurl.com/cukhlgc

14:47 licenser: google wants me to log in the bugger

14:47 so you want to use apply with it?

14:48 Vinzent: yeah, I want treat function returned by (.m t) as a clojure function

14:52 Interesting that after some calls to (f "a") I've defined g as (.toString sb), and (g) returned "undefinedaaaaaaaa", so it looks like when I invoke (f "a") method of some other object is called

14:52 licenser: Vinzent: I have no clue, I ran in the problem myself but I actually wanted what (. target (method)) does

14:55 Vinzent: ok, then i'd better ask about it on the group

15:07 dmi3y: Hi, guys. Can you help me to find error in this function. It gives me timeout error. - http://pastebin.com/a0zSdnSV

15:11 brehaut: dmi3y: mixing rest and next like that seems awkward

15:13 dmi3y: firstly, i wouldnt use loop recur to count a seq (ignoring count for now)

15:14 dmi3y: its an obvious case for a reduce #(reduce (fn [a _] (inc a)) 0 %) for instance

15:16 dmi3y: heres a cleaned up version of your code (fn [coll] (loop [c 0 s coll] (if (seq s) (recur (inc c) (rest s)) c)))

15:18 dmi3y: thank you very much, I'll ponder that one

15:18 brehaut: dmi3y: if i didnt have a head ache id step through the code and give you a real answer

15:19 dmi3y: that was more than helpful, I appreciate your help

15:20 still not clear, why was it stupid to mix next/rest that way?

15:20 brehaut: im not sure id say stupid, but you are doing the same thing twice in slightly different ways

15:21 'the same thing' bar the laziness change

15:21 a slight tweak to the recur version: (fn [coll] (loop [c 0 s (seq coll)] (if s (recur (inc c) (next s)) c)))

15:24 dmi3y: thank, it's clear now

15:24 brehaut: cool

15:26 obligatory point free nonsense: (comp (partial apply +) (partial map (constantly 1)))

15:26 fridim_: clojurebot, def sin

15:31 Raynes: brehaut: I can't wait for your brush to be in marginalia.

15:31 I'm so sick of inconsistent symbol highlights.

15:32 brehaut: Raynes: me too :D

15:33 Raynes: the old brush did no structural analysis, just basic tokenization, so it had to use a table of know core names for guessing the highlighting

15:34 Raynes: brehaut: It didn't even highlight 'defn' consistently.

15:34 brehaut: oh dear

15:46 triyo: Anyone had an opportunity to scale the jetty server via Ring library for some heavy hits?

15:46 brehaut: triyo: err

15:47 what counts as heavy?

15:47 triyo: err? (error)

15:47 brehaut: sorry, just your question is quite broad

15:47 ive had no trouble surviving HN on my blog with ring + jetty (and an nginx gateway)

15:49 triyo: member:brehaut: We have growing number of consumers utilizing SmartMeter data from our data acquisition system.

15:49 These are period reads via REST services

15:49 *periodic

15:50 we looking at about 5m reads a day

15:51 Pretty short lived http requests though.

15:51 small playloads

15:52 brehaut: thats more information. unfortunately it means im not really qualified to answer

15:54 triyo: there is no conversation state at all though so I don't foresee any major problem in horizontally scale jetty servers.

15:57 meaning we don't have to worry about thing such as HTTP sessions, etc.

15:58 Anyways I'll report back, success or fail.

16:45 mmarczyk: Raynes: ping?

17:03 Raynes: mmarczyk: Pong.

17:06 patrkris_: Raynes: a cake question: would you happen to know why I don't see the ng (nailgun) task, even though I have vimclojure/server as a dep-dependency?

17:06 Raynes: No idea.

17:06 Never used vimclojure or ng.

17:07 patrkris_: ok… the task is part of cake, and if-ns is used to see if the vimclojure namespace is available

17:07 oh well, I'll keep trying

17:07 mmarczyk: Raynes: hi

17:07 Raynes: Hi.

17:08 mmarczyk: would you have a moment to try and run Marginalia's test suite?

17:08 just want to check if I'm by any chance going crazy

17:08 Raynes: Sure.

17:08 mmarczyk: thanks

17:08 Raynes: mmarczyk: Master?

17:08 mmarczyk: yup

17:08 no changes, btw

17:08 I think an existing commit breaks tests, but.....

17:09 Raynes: mmarczyk: Fails because contrib isn't around.

17:09 mmarczyk: oh?

17:09 no mention of first_page.clj or the like?

17:09 Raynes: Can't find java-utils

17:09 Nope.

17:10 mmarczyk: hm.

17:12 weird, works for me with a fresh checkout; or rather, doesn't work, but complains at a later stage

17:13 Raynes: mmarczyk: After I fix the contrib dependency, I get an error about first_part.clj

17:13 mmarczyk: ok, good :-)

17:13 Raynes: Not good that you have contrib on your classpath though.

17:14 mmarczyk: I don't

17:14 ...I think?

17:14 Raynes: You must.

17:14 mmarczyk: certainly not in lib or lib/dev

17:14 also, where's the dependency?

17:14 Raynes: Look at helpers.clj

17:14 In the test dir.

17:15 mmarczyk: whoa.

17:16 and yet `lein classpath` contains no mention of contrib

17:16 Raynes: evil

17:16 mmarczyk: surely lein doesn't add contrib in when running tests?

17:16 Raynes: echo $CLASSPATH

17:16 amalloy: mmarczyk: echo $CLASSPATH

17:16 Raynes: amalloy: o/

17:17 mmarczyk: amalloy: not set at my box

17:17 amalloy: and probably also $JAVA_OPTS

17:17 mmarczyk: ...on...

17:17 amalloy: or whatever it is

17:17 mmarczyk: likewise

17:17 Raynes: What version of Leiningen?

17:17 mmarczyk: 1.6.2

17:18 Raynes: I suggest you see a doctor.

17:18 mmarczyk: hm, actually a checkout of 1.x

17:18 :-)

17:18 Raynes: Because something about you is sick.

17:18 mmarczyk: seems likely

17:18 see -- that's why I asked you to run the tests, can't trust myself any more :-P

17:18 Raynes: :p

17:18 Anyways, tests don't pass regardless, so you're good.

17:19 mmarczyk: whew ;-P

17:19 at any rate, first_rate.clj is a problem IMO because of a recent commit which drops try / catch around a require

17:19 so, armed with the knowledge that it does not only break for me, I shall go forward and revert and maybe submit an issue to complain :-P

17:20 Raynes: :p

17:20 * Raynes goes back to wasting the day playing Aquaria.

17:21 mmarczyk: :-)

17:23 ok, pushed the fix to #45 and the revert... now to dive inside lein

19:09 seancorfield: gee, web application development / deployment is so drop dead easy with Clojure on Heroku!

19:33 romanandreg: hello… can someone give me a had with core.logic library?

19:33 amalloy: ~anyone

19:33 clojurebot: Just a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."

19:34 romanandreg: whenever I'm trying to use the defrel macro, I'm getting the following error:

19:34 "CompilerException java.lang.RuntimeException: Unable to resolve symbol: to-stream in this context"

19:35 for some reason, the maco expands to a method being used called "to-stream" that doesn't seem to be defined :-/

19:40 amalloy: well, ambrosebs might know. i certainly don't

19:41 ambrosebs: using 0.6.5?

19:43 romanandreg: throw up a gist of your code?

19:43 and core.logic version

19:44 romanandreg: ambrosebs: https://gist.github.com/1392568

19:45 core.logic v0.6.5

19:46 ambrosebs: to fix use (:use [clojure.core.logic])

19:46 quick fix at least

19:46 romanandreg: uhmm

19:46 amalloy: oh ouch. non-fully-qualified macroexpansions?

19:47 ambrosebs: i'll have a look at the source

19:47 romanandreg: ambrosebs: heap that do the trick

19:47 yeap that did the trick*

19:48 ambrosebs: yep it's a bug

19:48 cheers for that

19:48 romanandreg: probably is already fixed in 0.6.6 :-)

19:49 ambrosebs: nope, submitting a patch now :)

21:22 romanandreg: ambrosebs: still there? :-o

21:23 ambrosebs: yep

21:23 romanandreg: I'm getting a strange behaviour on core.logic functions when calling doc to them

21:24 is this normal?

21:24 ambrosebs: which?

21:24 amalloy: hah. i think a "strange behavior" is not normal by definition. the problem is you definition of strange may be wrong

21:25 romanandreg: http://pastie.org/2917274

21:25 amalloy: by strange behaviour I mean, not showing the documentation

21:25 ambrosebs: however when calling source on them over the repl, it works as expected

21:26 and it seems they have a doctstring, on there definition, so that adds a point to the fact that doc is behaving strangely in this case

21:26 s/there/their/

21:26 ambrosebs: right

21:27 well defrel doesn't have a docstring in 0.6.5

21:27 but the rest do

21:27 (I just patched defrel)

21:27 I don't know why there no docstring printed :(

21:28 romanandreg: ambrosebs: at least we know there is a problem :-)

21:29 ambrosebs: can I ask you some questions about usage?

21:29 of core.logic?

21:29 ambrosebs: shoot

21:29 ,(-> doc meta)

21:29 clojurebot: #<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.repl/doc, compiling:(NO_SOURCE_PATH:0)>

21:29 ambrosebs: ,(-> + meta)

21:29 clojurebot: nil

21:30 ambrosebs: ,(-> #'+ meta)

21:30 clojurebot: {:ns #<Namespace clojure.core>, :name +, :file "clojure/core.clj", :line 919, :arglists ([] [x] [x y] [x y & more]), ...}

21:30 amalloy: ambrosebs: all the ~' in RelHelper makes me seasick, and i think all it does is break things. eg, ~'IRel is less correct than IRel would have been

21:30 romanandreg: ambrosebs: let me update the gists

21:30 ambrosebs: romanandreg: try and eval (-> #'fresh meta)

21:31 romanandreg: ambrosebs: http://pastie.org/2917274

21:32 ambrosebs: romanandreg: David wrote it, I've mentioned it in the ticket: http://dev.clojure.org/jira/browse/LOGIC-22

21:32 lots of weird hacks

21:32 romanandreg: ambrosebs: good to know ticket is there :-)

21:33 ambrosebs: romanandreg: weird, seems there's no :doc

21:35 who thinks it's a good idea to print a warning if a string literal is found after the argslist in a defn or defmacro?

21:35 amalloy: ew

21:35 ambrosebs: as in, it was probably supposed to be doc metadata, but it has to go before the args

21:35 romanandreg: ambrosebs: https://gist.github.com/1392568

21:35 amalloy: (defn get-db-host [context] "localhost")

21:35 romanandreg: ambrosebs: check the comments bellow

21:36 ambrosebs: clearly that's the edge case

21:36 amalloy: but i think i agree if more expressions follow

21:36 since evaluating a string literal for side effects is pretty bizarre

21:36 ambrosebs: it's a very common error

21:36 even clojure.core has suffered from it

21:37 amalloy: ambrosebs: i think this problem probably wouldn't even exist if clojure didn't give you an implicit (do) around function bodies

21:37 romanandreg: oh what is wrong is the order of the docstring and args

21:37 ambrosebs: romanandreg: good point!

21:37 romanandreg: ambrosebs: hehehe just stating the obvious :-p you figured that out

21:38 ambrosebs: no, I didn't think of it that way

21:39 amalloy: wait, this conversation is getting fuzzy. is someone proposing (defn foo [x] "docstring" (...))?

21:39 ambrosebs: right

21:39 but I was proposing printing a warning

21:39 amalloy: no good, because of multiple arities

21:39 never mind, i'm talking at cross-purposes here

21:40 romanandreg: ambrosebs: +1 on the warning, you can shoot yourself in the foot easily without it

21:41 ambrosebs: romanandreg: I do it all the time

21:42 romanandreg: ambrosebs: about the gist I sent you, in the comments at the end, I'm trying to infer the parent in a run* call, it works when not using the father function, but it does when doing the function body directly on the run* code

21:42 I'm obviously missing something there...

21:43 ambrosebs: function body needs to be in an "clojure.core.logic/all" form

21:43 syntactically like "do"

21:43 or wrap it in an empty fresh, same thing

21:44 romanandreg: ambrosebs: uhmm

21:44 ambrosebs: (defn father [f c] (all (parent f c) (man f)))

21:44 romanandreg: in the second option, I don't see how that might work

21:44 with a fresh in the father function only I mean

21:45 ambrosebs: (defn father [f c] (fresh [] (parent f c) (man f)))

21:45 probably works :P

21:46 romanandreg: oh… you just define a fresh with an empty vector, interesting

21:46 ambrosebs: what is the purpose of fresh exactly, I'm using it just because it makes it work

21:46 :-)

21:46 ambrosebs: use "all"

21:47 (defn father [f c] (all (parent f c) (man f)))

21:47 romanandreg: ambrosebs: ok

21:47 ambrosebs: but fresh introduces "fresh" logical variables

21:47 think of fresh like this

21:47 (fresh [x y z] (== x y))

21:47 is like

21:47 (let [x (lvar) y (lvar) z (lvar)] (all (== x y)))

21:48 but don't talk about lvar ;)

21:49 romanandreg: ambrosebs: lol, there is a lot of things that are hard to digest here, but I can make it through as long as I'm not to pesky about my understandings of how everything works… I'm not even familiar with prolog, I re-discovered that after Richies talk "Simple made easy"

21:50 ambrosebs: I can go all day, ask away :)

21:50 romanandreg: ambrosebs: thanks… this is the third time I get to this channel I find awesome people like yourself, this community is amazing

21:50 ambrosebs: my Clojure Conj talk will probably come out in the next few weeks, look out for it

21:51 :D +!

21:51 +1

21:51 I go through how to think of core.logic's execution

21:51 it's a simple concept, but very smart implementation

21:52 romanandreg: ambrosebs: by smart you suggest more complicated for it's own sake? :-)

21:52 too complicated*

21:52 ambrosebs: hmm :)

21:53 I'll say that it is utter genius and only a handful of people understand it intimately

21:53 no including me

21:53 *not

21:53 as in I don't know what's going on :D

21:53 but the original implementation is like a couple of hundred lines long

21:54 romanandreg: ambrosebs: well I tried to read it, and I felt a bit dumb, this is way over my clojure foo

21:54 ambrosebs: The Reasoned Schemer's implementation of minikanren in scheme is easier to grap (ha!)

21:54 *grasp

21:54 romanandreg: ambrosebs: I don't mind feeling dumb though, I'm used to that, luckily I'm stubborn

21:55 ambrosebs: romanandreg: that sounds too familiar.. :)

21:55 romanandreg: ambrosebs: no experience with schemer either (yet)… I got to this Clojure wagon through Haskell :-p

21:56 scheme*

21:56 ambrosebs: scheme's pretty easy after Clojure

22:00 romanandreg: ambrosebs: going back to the gist I sent you and the example that is on it, how do we avoid having adam listed twice on the run* ?

22:01 ambrosebs: what does (match q f) do?

22:02 romanandreg: ambrosebs: hehehe… well I don't know exactly, but what I believe, it matches the q with the entries that match the criteria of father

22:02 there is only one, but is repeated twice… once per child I guess

22:02 ambrosebs: or, where does it come from?

22:03 romanandreg: ambrosebs: I think I don't quite get the "where does it come from?" question :-/

22:03 ambrosebs: I don't recognize "match", what namespace is it in?

22:04 romanandreg: oh

22:04 (use '[clojure.core.logic :rename {== match}])

22:04 ambrosebs: romanandreg: BTW if you're just hacking with core.logic, use this ns declaration: https://github.com/frenchy64/Logic-Starter/blob/master/src/logic_introduction/facts.clj#L1

22:05 == is pronounced unify

22:05 romanandreg: ambrosebs: hehe good to know

22:05 ambrosebs: going to rename it like that then

22:06 ambrosebs: could you update the gist with your changes?

22:06 easier if I see the whole story

22:07 romanandreg: sure… well I'm testing on repl so I'm going to comment how I'm importing everything on it through comments

22:10 ambrosebs: https://gist.github.com/1392568

22:14 ambrosebs: don't import unify

22:14 it's just much easier to use the namespace decl I suggested

22:15 unify is not the same as ==

22:15 but == is *pronounced* "unify" :P

22:16 alexbaranosky: does anyone know if cake is going to continue to be supported after the merger with Leiningen? Mostly I am trying to weasel out of having to update the cake midje pluging

22:29 brweber2: ambrosebs: Maybe IRC is better than twitter for this :)

22:29 ambrosebs: brweber2: LOL

22:29 god twitter is hopeless with replies

22:29 brweber2: ambrosebs: Sure is. Anyway, (source identity) in 1.3.0 confirms that it was fixed.

22:31 ambrosebs: ,(source identity)

22:31 clojurebot: Source not found

22:31 ambrosebs: :)

22:32 brweber2: did you see the minikanren demo at the conj?

22:32 brweber2: ambrosebs: No, stupidly I skipped it. 100% kicking myself for that....

22:32 Hmmm, does clojurebot allow contrib libraries to be loaded?

22:33 amalloy: brweber2: if they happen to be on his classpath, sure. but i doubt if many are, especially since he's running on 1.3

22:34 brweber2: amalloy: Well, 1.3.0 is what I'd like to see in this case, but just thinking out loud :)

22:35 ambrosebs: ,(use 'clojure.core.logic)

22:35 clojurebot: #<RuntimeException java.lang.RuntimeException: java.io.FileNotFoundException: Could not locate clojure/core/logic__init.class or clojure/core/logic.clj on classpath: >

22:36 ambrosebs: brweber2: it was recorded, never fear

22:37 brweber2: ,*clojure-version*

22:37 clojurebot: {:major 1, :minor 3, :incremental 0, :qualifier nil}

22:37 brweber2: ,(doc source)

22:37 clojurebot: "([n]); Prints the source code for the given symbol, if it can find it. This requires that the symbol resolve to a Var defined in a namespace for which the .clj is in the classpath. Example: (source filter)"

22:37 brweber2: ,(source identity)

22:37 clojurebot: Source not found

22:39 brweber2: ,(source println)

22:39 clojurebot: Source not found

22:41 brweber2: Hmm, source sure seems like it would be a useful function to have in clojurebot… I wonder if it was removed for sandbox reasons?

22:42 wiseen: is there a prettier way to write : (let [top (atom nil)] (swap! queue (fn [queue] (reset! top (first queue)) (pop queue)))) - assuming queue is a atom containing a collection value

22:43 ideally I would return two values from (swap!) but that can't be done afaik

22:43 ambrosebs: ,(use 'clojure.repl)

22:43 clojurebot: nil

22:43 ambrosebs: ,(source println)

22:43 clojurebot: Source not found

22:43 ambrosebs: source

22:44 ,source

22:44 clojurebot: #<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.repl/source, compiling:(NO_SOURCE_PATH:0)>

22:45 amalloy: wiseen: i don't think your version is just un-pretty, it's actively not-working

22:46 in case of contention

22:46 wiseen: amalloy, how so ?

22:47 amalloy: wiseen: i guess it depends what you're doing with top. you're trying to deref it after the swap happens?

22:48 wiseen: amalloy, yes

22:48 that would happen at the end of let so it just returns top value

22:48 (let [top (atom nil)] ... @top)

22:48 amalloy: in that case, you might "miss" the value top was set to by thread 1, if thread 2 changes it between the reset! and your deref

22:49 wiseen: ah but top is thread local

22:49 it's a local scope variable

22:50 amalloy: oh, i see

22:50 well, then this will work but is gross

22:50 the easiest solution is to use a ref

22:51 which lets you (dosync (alter x f) (return whatever you want))

22:52 it's possible with an atom, if you choose to define the atom's value as a pair of [data, return-value]. your swap! reads data and writes both; when it's done you look at the return-value

22:53 wiseen: amalloy, your're right - nice !

22:54 amalloy: i've done that a few times in pointless pursuit of atoms, but a ref is less hacky

22:54 wiseen: still would be nice to have some (magic-return-type foo) that you can return from swap! and first value be applied to the atom rest returned from swap!, I don't think this behavior is an edge case I think it's often that you need to modify atom value and return some other data (like pop an element :))

Logging service provided by n01se.net