#clojure logs

2011-11-24

00:00callenspoon16: nope, you're stuck with me.
00:02spoon16I 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
00:02spoon16I guess I will hit up the mailing list
00:03callenspoon16: what's the latency for responses in irc for you usually?
00:04callenspoon16: apache ivy?
00:06spoon16callen: not sure what you mean… I was just thinking the mailing list for leiningen is probably a more appropriate place
00:07spoon16and 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
00:07callenare those ellipses?
00:07callen...
00:07callenthey have to be.
00:10callenspoon16: netflix uses Clojure?
00:41georgekah of course, just needed to require clojure-mode in .emacs before adding the hook
00:42spoon16callen: sorry, got a phone call
00:43spoon16callen: I'm not aware of any projects at NFLX that use Clojure in production
00:44spoon16but 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
00:44RaynesThat's awesome.
00:44RaynesI'm a huge fan of Netflix.
00:45spoon16the technology is good
00:46RaynesI think I'm the only person the planet who was okay with a price increase and separation of DVD and streaming services.
00:49callenspoon16: so why do you want leiningen?
00:49callenRaynes: I'd be a bigger fan and more likely to stay a paying customer if they'd get the bloody linux client done.
00:49RaynesYeah, Silverlight is a bit of a problem.
00:49callenRaynes: I was okay with the price increase, I just want a damn client.
00:51spoon16linux client is coming… eventually
00:52spoon16I don't think there are enough users to make it a high priority
00:52spoon16not on one of the clients teams though… so who knows what the real reasons are
00:52spoon16callen: because it's fancy
00:53spoon16I supposed i do not really need it
00:53spoon16I just started using it and thought there might be some way to get it to work
00:54callenspoon16: you'd be bending over backwards unnecessarily, IMHO
00:54spoon16I think you are right
04:32dmi3yHi, 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!
04:32dmi3y... please
04:39Wild_Catdmi3y: you probably want to use recursion and/or destructuring.
04:39dmi3ygot it, thanks
05:40fridim_hi :)
05:57aperiodichiredman: 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?
05:58aperiodichiredman: 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 :)
06:03hoeckapear
06:04hoeckaperiodic: that should be part of the curriculum of any programming course: design and implement a simple lisp interpreter in the language of your choice
06:04hoeckaperiodic: I did this in powerbuilder and it helped me alot to understand lisp better :)
06:05hoeckyou will also gain a better understanding of language-of-your-choice
06:05aperiodichoeck: to be fair, my degree was in math, not CS
06:06aperiodichoeck: it was not a top-notch CS curriculum by a long shot!
06:07hoeckaperiodic: but you had at least some exposure to scheme!
06:07aperiodicthis is true
06:07aperiodici remember the introductory class was taught half in haskell
06:07aperiodicwhich i thought was great
06:08aperiodicthe professor said he wanted to "level the playing field", figuring that most people who had dabbled in programming probably hadn't tried that
06:09hoeckmine 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
06:09aperiodicooh nice
06:10aperiodicwe did a basic heavily-arithmetic language in scheme
06:10aperiodic(in the PL class)
06:11aperiodicthen tried to add type-inference
06:11aperiodici didn't grok all the theorems for that though!
06:12hoeckback 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
06:13aperiodicit's really good to get an exposure to that
06:13aperiodici remember i really admired the expresiveness when compared with c
06:14aperiodicbut c mapped on to my mental model of computation very well
06:14aperiodicuntil i found myself wishing for first-class functions
06:16msapplerhello 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
06:16hoeckThe 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)
06:17hoeckaperiodic: it took me then another 3 years or so to fully grasp what first class functions are
06:17aperiodici was really blown away by how much work the type system did for me
06:17aperiodicmsappler: why do you want the jar-file? flag set?
06:18aperiodicmsappler: i've done a fair amount of java interop and never needed anything like it
06:19Blktgood day everyone
06:20msappler@aperiodic: i have different image loading functions for jar files and "normal"
06:20aperiodicmsappler: huh, why is that necessary?
06:20msapplerbasically I do a .listFiles File which does not work in a jar file
06:20aperiodicokay
06:21aperiodicwell, i dunno how you can automate that, sorry!
06:21msapplerok! ;)
06:21aperiodicyou might try looking into lein hooks, though (if you use leiningen)
06:24hoeckmsappler: are those images resources like icons and such?
06:25msapplerthey are animations. in each folder and I just use listFiles and sort them. for example "0.png" "1.png" "2.png"
06:26msapplerwhich is quite comfortable I dont need to know how many frames there are
07:03r0manHi, what's the preferred way to override the toString method of a
07:03r0manClojureScript record? I could use set! to change the toString fn
07:03r0manof a record after it has been initialized, but wonder if there is
07:03r0mansomething more idiomatic?
07:10lypanovfor users stuck with rails on the front-end: https://github.com/yokolet/clementine (jruby) https://github.com/lypanov/clementine (MRI)
07:10clojureboteg, https://github.com/clojure/tools.logging is the new version of clojure.contrib.logging
08:38samaaron /wi ejackson
08:38samaaronwi ejackson
09:16biallymtheoretically speaking
09:16biallymhow would I reverse a (shutdown -agents)
09:16biallymhow would I reverse a (shutdown-agents)*
09:22biallymI'll take that as a "not possible"
09:22nachtalpbiallym: java.util.concurrent.ExecutorService doesn't really seem to have support for that
09:22biallymso it should only be used when it is a for sure thing that you are about to exit
09:23biallymeither that or create a way to trick clojure into using a new thread pool?
09:26nachtalpbiallym: 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)
09:31nachtalpbiallym: not sure what exactly you're trying to achieve, though :)
09:31biallymJust thinking about how to clean up properly
09:33biallymBecause I am writing a program with a lot of inherient state, I have to think about that a lot
09:35biallymThe 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
09:35biallym(The clojure site makes it sound like that has to be called before exiting can occur correctly)
09:38nachtalpbiallym: this post has some discussion: http://tech.puredanger.com/2010/06/08/clojure-agent-thread-pools/
09:56andrewcleggis there a quick way to make a string out of n repetitions of a char?
09:57andrewcleggso far I have (apply str (repeat 100 \ ))
09:57nachtalp(apply str (take 5 (repeat \C)))
09:58andrewcleggis that likely to be more efficient?
10:00nachtalpi don't think so
10:04andrewcleggmine's less function calls then ;-)
10:05nachtalpandrewclegg: agreed :)
10:06nachtalpandrewclegg: actually, if you look at the source of repeat it's the same ;)
10:09Saturnation,(#(+ (* %1 2) (if (= %2 "0") 0 1)) 0 "0")
10:09clojurebot0
10:09Saturnation,(reduce #(+ (* %1 2) (if (= %2 "0") 0 1)) 0 "0")
10:09clojurebot1
10:09Saturnationthat confuses me :(
10:10Saturnationwhat am I missing?
10:10Saturnationusing it to convert binary string "10110" to int
10:11SaturnationI'd expect to replace the final string argument in the reduce with a binary string and get the int back
10:11gfredericksyou can't use the built-in for that?
10:11gfredericks,(Integer/parseInt "10110" 2)
10:11clojurebot22
10:11gfredericksoh
10:11gfredericks_fine_ :P
10:11Saturnationprobably would work better :)
10:12Saturnationjust really want to grok reduce better, regardless
10:12gfredericksah ha
10:12gfredericksthe last arg to reduce is supposed to be a list
10:12gfredericks,(reduce #(+ (* %1 2) (if (= %2 "0") 0 1)) 0 ["0"])
10:12clojurebot0
10:12gfredericksso the "list" you were passing in was ##(seq "0")
10:12lazybot⇒ (\0)
10:12Saturnationah, thought a string was a list
10:12gfredericksit is
10:13Saturnationhuh?
10:13gfredericksso alternatively we could have:
10:13gfredericks,(reduce #(+ (* %1 2) (if (= %2 \0) 0 1)) 0 "0")
10:13clojurebot0
10:13gfredericksa string is a list of characters, not a list of length-1 strings
10:13gfredericks"0" is different from \0
10:13SaturnationAH
10:13Saturnationgot it, thanks
10:13Saturnation:)
10:13gfredericksnow I've done my thanksgiving good deed
10:14biallymnachtalp: Thanks, I guess I'll file agents as not fully developed yet
10:14Saturnationso (= "0" \0) -> false
10:14gfredericks,(= "0" \0)
10:14clojurebotfalse
10:14Saturnation:)
10:14Saturnationthanks again
10:14gfredericksyep
10:14gfredericksgood luck
10:14Saturnationgetting there
10:16nachtalpbiallym: what brings you to that conclusion?
10:17biallymBecause there isn't fully fleshed out support for them in libraries, long running applications, or development enviroments
10:18biallymThey 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:19nachtalpbiallym: i don't see why the couldn't be used in the scenarios mentioned above...
10:19nachtalpthey, even
10:21biallymLibraries: 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:26biallymAnd 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:27nachtalpbiallym: 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:28biallymBecause you have to call it to cleanly exit a program >.>
10:28biallymlike if you don't call it the program will just hang on the terminal
10:28biallymwhich is really annoying for the user (programmer) of a library
10:29biallymAlso, 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:31biallymAnd 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:32biallymsay 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:33biallymYes 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:33nachtalpbiallym: if those are your requirements, agents might not be what you're looking for (i may be wrong, however)
10:35biallymWell they would be an elegant way to handel certain parts of an application, but they don't seem robust enough for my paranoia >.>
10:39biallymespecially because those are control and command parts, which I would prefer worked on a consistent basis :p
10:40nachtalpbiallym: sure, if you don't trust the built-in threadpools in java to be robust...
10:40biallymHaha, I don't trust java, I come from lisp land, not java land
10:41biallymI really miss condtions and resets too >.> (http://www.gigamonkeys.com/book/beyond-exception-handling-conditions-and-restarts.html)
10:44biallymHowever 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:46andrewcleggbiallym: java's thread pools are very well tested by now
10:48biallymI 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:48biallymis all*
10:50biallymI probably will end up using them, I just think it's stupid the way they are set up now >.>
10:52biallymEspecially for libraries... >.>
11:53Guest91650hello - can someone help me with understanding somtehing about symbols and functions?
11:53Guest91650if have the following source
11:53Guest91650(defn hello [x y] (str "hi " x " and " (apply y)))(defn robert [] (str "Rrrrobert "))
11:54Guest91650and when using (map hello '(1) '(robert))
11:54Guest91650i don't get the expected "hi 1 and Rrrrobert" but an exception.
11:55VinzentGuest91650, why (apply y)? just (y)
11:57Guest91650this 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:57Guest91650just (y) gives me the errpr #<IllegalArgumentException java.lang.IllegalArgumentException: Wrong number of args (0) passed to: Symbol>
11:58Guest91650and with apply i get the exception #<IllegalArgumentException java.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$apply>
11:58VinzentGuest91650, show the whole code, please, looks like you have ('f) or ((symbol "f"))
11:59Guest91650this is the whole code
11:59Guest91650just the 2 lines
11:59Guest91650(defn hello [x y] (str "hi " x " and " (apply y)))
11:59Guest91650and
11:59Guest91650(defn robert [] (str "Rrrrobert "))
11:59Guest91650and this is the call from the repl
11:59Guest91650(map hello '(1) '(robert))
12:00Vinzentoh, right - you should use [robert]
12:00Vinzentbecause ' prevents evaluation of robert, so it's a symbol, not a function, so it tries to call ('robert)
12:00Guest91650=> (map hello '(1) [robert])
12:00kephale,(let [hello (fn [x y] (str "hi " x " and " (y))) robert (fn [] (str "blah"))] (map hello [1] [robert]))
12:00Guest91650#<IllegalArgumentException java.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$apply>
12:00clojurebot("hi 1 and blah")
12:01VinzentGuest91650, as i sayed abive, (y), not (apply y)
12:06Guest91650Thank 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:06Guest91650...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:07Guest91650p.s. called by (y) and not by map - sorry.
12:07Guest91650to clarify - i look for something like symbol-function of common lisp.
12:08kephaleGuest91650: you also could have used (list robert)
12:09Guest91650that was it... forgot about ' being a shortcut to (list...)....
12:09Guest91650Thanky you again, kephale!
12:11Vinzentactually, ' is shortcut for (quote ...)
12:11biallym,(let [foo (fn [] ())] (macroexpand-1 '('foo)))
12:11clojurebot((quote foo))
12:12biallymAlso notice the difference:
12:12Guest91650yes, you are right
12:12biallym,(let [foo (fn [] ())] (macroexpand-1 `('foo)))
12:12clojurebot((quote sandbox/foo))
12:12biallymNot sure if that is relvent to what you were talking about but it might be
12:12biallym(the second one, not the first one)
12:15Guest91650biallym - ty, kephale and vinzent helped already a lot to reboot my head from lisp-2 hapbits :)
12:15Guest91650and sometimes to not see such things...
12:16biallymYea clojure has a lot of subtle differences from other lisps
12:16biallymmost of them good
12:16biallymi find it very rare that you ever need a quote, for example
12:16biallym(unless you are dealing with macros that is)
12:18Guest91650well - even without macros - each case where part of your program is represented as data - there could be a lot of quoting
12:18biallymLike 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:20Guest91650probably - i'm not yet that experienced in clojure.
12:25Guest91650while 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:58krunaldoI'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:58krunaldoany clue?
13:00krunaldojust tried it with jre1.6.0_29 did not work either.
13:01Vinzentare trying to start swank or what?
13:01Vinzent*are you
13:02krunaldoclojure -cp $jar clojure.main
13:03krunaldohahah, nvm I'm really stupid
13:03krunaldomy -cp pointed to the zip file
13:03krunaldoI'll just go into my corner of shame and shoot myself :)
13:12Vinzentkrunaldo, hah :) but, seriously, why don't you use leiningen?
13:16krunaldoVinzent: Getting to that, I just want to trial out some code. I'll get to the tool chain later on :)
13:17hhutchi'm having problems with clojurescript interop: http://paste.lisp.org/display/126064
13:17hhutchanybody have a suggestion?
13:19Vinzentkrunaldo, ok, but It's just so much easier to do this with leiningen (no classpath issues etc, just start lein repl and code!)
13:21Vinzenthhutch, I haven't tried clojurescript, but don't you think it should be (apply (. shortcut-handler registerShortcut) ...)?
13:26hhutchVinzent: no, i need to pass a list of arguments to registerShortcut (a mothod of shortcut-handler) ...
13:27hhutchjust like (apply str ["a" "b" "c"]) is (str "a" "b" "c")
13:27Vinzent(. shortcut-handler registerShortcut) returns that method (which actually is a function)
13:30hhutchVinzent: 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:33Vinzenthhutch, 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:36hhutchVinzent: that's all correct, but (. class method) will return a function you can run apply against?
13:36Vinzenthhutch, in clojurescript - yes, that's what I'm talking about
13:36hhutch (. shortcut-handler (registerShortcut "S" "s"))
13:36hhutch(apply (. shortcut-handler registerShortcut) ["S" "s"])
13:37hhutchare not equivalent though when I tested it
13:39Vinzentis it throws an exception or something? I don't have working clojurescript setup right now, so I can't test it, sorry...
13:40hhutchVinzent: no problem. it compiles, but the JS throws an exception
13:40hhutchi'm moving on, i'll figure it out later
14:06pyrahhh, the dreaded Don't know how to create ISeq from: clojure.lang.Symbol
14:44Vinzenthhutch, 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:45licenserVinzent: (. target (method))
14:46Vinzentlicenser, no, we need (apply (.method target) [args])
14:46Vinzentis it possible?
14:47Vinzentalso see this thread: http://tinyurl.com/cukhlgc
14:47licensergoogle wants me to log in the bugger
14:47licenserso you want to use apply with it?
14:48Vinzentyeah, I want treat function returned by (.m t) as a clojure function
14:52VinzentInteresting 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:52licenserVinzent: I have no clue, I ran in the problem myself but I actually wanted what (. target (method)) does
14:55Vinzentok, then i'd better ask about it on the group
15:07dmi3yHi, guys. Can you help me to find error in this function. It gives me timeout error. - http://pastebin.com/a0zSdnSV
15:11brehautdmi3y: mixing rest and next like that seems awkward
15:13brehautdmi3y: firstly, i wouldnt use loop recur to count a seq (ignoring count for now)
15:14brehautdmi3y: its an obvious case for a reduce #(reduce (fn [a _] (inc a)) 0 %) for instance
15:16brehautdmi3y: 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:18dmi3ythank you very much, I'll ponder that one
15:18brehautdmi3y: if i didnt have a head ache id step through the code and give you a real answer
15:19dmi3ythat was more than helpful, I appreciate your help
15:20dmi3ystill not clear, why was it stupid to mix next/rest that way?
15:20brehautim not sure id say stupid, but you are doing the same thing twice in slightly different ways
15:21brehaut'the same thing' bar the laziness change
15:21brehauta slight tweak to the recur version: (fn [coll] (loop [c 0 s (seq coll)] (if s (recur (inc c) (next s)) c)))
15:24dmi3ythank, it's clear now
15:24brehautcool
15:26brehautobligatory point free nonsense: (comp (partial apply +) (partial map (constantly 1)))
15:26fridim_clojurebot, def sin
15:31Raynesbrehaut: I can't wait for your brush to be in marginalia.
15:31RaynesI'm so sick of inconsistent symbol highlights.
15:32brehautRaynes: me too :D
15:33brehautRaynes: 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:34Raynesbrehaut: It didn't even highlight 'defn' consistently.
15:34brehautoh dear
15:46triyoAnyone had an opportunity to scale the jetty server via Ring library for some heavy hits?
15:46brehauttriyo: err
15:47brehautwhat counts as heavy?
15:47triyoerr? (error)
15:47brehautsorry, just your question is quite broad
15:47brehautive had no trouble surviving HN on my blog with ring + jetty (and an nginx gateway)
15:49triyomember:brehaut: We have growing number of consumers utilizing SmartMeter data from our data acquisition system.
15:49triyoThese are period reads via REST services
15:49triyo*periodic
15:50triyowe looking at about 5m reads a day
15:51triyoPretty short lived http requests though.
15:51triyosmall playloads
15:52brehautthats more information. unfortunately it means im not really qualified to answer
15:54triyothere is no conversation state at all though so I don't foresee any major problem in horizontally scale jetty servers.
15:57triyomeaning we don't have to worry about thing such as HTTP sessions, etc.
15:58triyoAnyways I'll report back, success or fail.
16:45mmarczykRaynes: ping?
17:03Raynesmmarczyk: Pong.
17:06patrkris_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:06RaynesNo idea.
17:06RaynesNever used vimclojure or ng.
17:07patrkris_ok… the task is part of cake, and if-ns is used to see if the vimclojure namespace is available
17:07patrkris_oh well, I'll keep trying
17:07mmarczykRaynes: hi
17:07RaynesHi.
17:08mmarczykwould you have a moment to try and run Marginalia's test suite?
17:08mmarczykjust want to check if I'm by any chance going crazy
17:08RaynesSure.
17:08mmarczykthanks
17:08Raynesmmarczyk: Master?
17:08mmarczykyup
17:08mmarczykno changes, btw
17:08mmarczykI think an existing commit breaks tests, but.....
17:09Raynesmmarczyk: Fails because contrib isn't around.
17:09mmarczykoh?
17:09mmarczykno mention of first_page.clj or the like?
17:09RaynesCan't find java-utils
17:09RaynesNope.
17:10mmarczykhm.
17:12mmarczykweird, works for me with a fresh checkout; or rather, doesn't work, but complains at a later stage
17:13Raynesmmarczyk: After I fix the contrib dependency, I get an error about first_part.clj
17:13mmarczykok, good :-)
17:13RaynesNot good that you have contrib on your classpath though.
17:14mmarczykI don't
17:14mmarczyk...I think?
17:14RaynesYou must.
17:14mmarczykcertainly not in lib or lib/dev
17:14mmarczykalso, where's the dependency?
17:14RaynesLook at helpers.clj
17:14RaynesIn the test dir.
17:15mmarczykwhoa.
17:16mmarczykand yet `lein classpath` contains no mention of contrib
17:16Raynesevil
17:16mmarczyksurely lein doesn't add contrib in when running tests?
17:16Raynesecho $CLASSPATH
17:16amalloymmarczyk: echo $CLASSPATH
17:16Raynesamalloy: o/
17:17mmarczykamalloy: not set at my box
17:17amalloyand probably also $JAVA_OPTS
17:17mmarczyk...on...
17:17amalloyor whatever it is
17:17mmarczyklikewise
17:17RaynesWhat version of Leiningen?
17:17mmarczyk1.6.2
17:18RaynesI suggest you see a doctor.
17:18mmarczykhm, actually a checkout of 1.x
17:18mmarczyk:-)
17:18RaynesBecause something about you is sick.
17:18mmarczykseems likely
17:18mmarczyksee -- that's why I asked you to run the tests, can't trust myself any more :-P
17:18Raynes:p
17:18RaynesAnyways, tests don't pass regardless, so you're good.
17:19mmarczykwhew ;-P
17:19mmarczykat any rate, first_rate.clj is a problem IMO because of a recent commit which drops try / catch around a require
17:19mmarczykso, 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:20Raynes:p
17:21mmarczyk:-)
17:23mmarczykok, pushed the fix to #45 and the revert... now to dive inside lein
19:09seancorfieldgee, web application development / deployment is so drop dead easy with Clojure on Heroku!
19:33romanandreghello… can someone give me a had with core.logic library?
19:33amalloy~anyone
19:33clojurebotJust 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:34romanandregwhenever I'm trying to use the defrel macro, I'm getting the following error:
19:34romanandreg"CompilerException java.lang.RuntimeException: Unable to resolve symbol: to-stream in this context"
19:35romanandregfor some reason, the maco expands to a method being used called "to-stream" that doesn't seem to be defined :-/
19:40amalloywell, ambrosebs might know. i certainly don't
19:41ambrosebsusing 0.6.5?
19:43ambrosebsromanandreg: throw up a gist of your code?
19:43ambrosebsand core.logic version
19:44romanandregambrosebs: https://gist.github.com/1392568
19:45romanandregcore.logic v0.6.5
19:46ambrosebsto fix use (:use [clojure.core.logic])
19:46ambrosebsquick fix at least
19:46romanandreguhmm
19:46amalloyoh ouch. non-fully-qualified macroexpansions?
19:47ambrosebsi'll have a look at the source
19:47romanandregambrosebs: heap that do the trick
19:47romanandregyeap that did the trick*
19:48ambrosebsyep it's a bug
19:48ambrosebscheers for that
19:48romanandregprobably is already fixed in 0.6.6 :-)
19:49ambrosebsnope, submitting a patch now :)
21:22romanandregambrosebs: still there? :-o
21:23ambrosebsyep
21:23romanandregI'm getting a strange behaviour on core.logic functions when calling doc to them
21:24romanandregis this normal?
21:24ambrosebswhich?
21:24amalloyhah. i think a "strange behavior" is not normal by definition. the problem is you definition of strange may be wrong
21:25romanandreghttp://pastie.org/2917274
21:25romanandregamalloy: by strange behaviour I mean, not showing the documentation
21:25romanandregambrosebs: however when calling source on them over the repl, it works as expected
21:26romanandregand 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:26romanandregs/there/their/
21:26ambrosebsright
21:27ambrosebswell defrel doesn't have a docstring in 0.6.5
21:27ambrosebsbut the rest do
21:27ambrosebs(I just patched defrel)
21:27ambrosebsI don't know why there no docstring printed :(
21:28romanandregambrosebs: at least we know there is a problem :-)
21:29romanandregambrosebs: can I ask you some questions about usage?
21:29romanandregof core.logic?
21:29ambrosebsshoot
21:29ambrosebs,(-> doc meta)
21:29clojurebot#<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.repl/doc, compiling:(NO_SOURCE_PATH:0)>
21:29ambrosebs,(-> + meta)
21:29clojurebotnil
21:30ambrosebs,(-> #'+ meta)
21:30clojurebot{:ns #<Namespace clojure.core>, :name +, :file "clojure/core.clj", :line 919, :arglists ([] [x] [x y] [x y & more]), ...}
21:30amalloyambrosebs: 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:30romanandregambrosebs: let me update the gists
21:30ambrosebsromanandreg: try and eval (-> #'fresh meta)
21:31romanandregambrosebs: http://pastie.org/2917274
21:32ambrosebsromanandreg: David wrote it, I've mentioned it in the ticket: http://dev.clojure.org/jira/browse/LOGIC-22
21:32ambrosebslots of weird hacks
21:32romanandregambrosebs: good to know ticket is there :-)
21:33ambrosebsromanandreg: weird, seems there's no :doc
21:35ambrosebswho 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:35amalloyew
21:35ambrosebsas in, it was probably supposed to be doc metadata, but it has to go before the args
21:35romanandregambrosebs: https://gist.github.com/1392568
21:35amalloy(defn get-db-host [context] "localhost")
21:35romanandregambrosebs: check the comments bellow
21:36ambrosebsclearly that's the edge case
21:36amalloybut i think i agree if more expressions follow
21:36amalloysince evaluating a string literal for side effects is pretty bizarre
21:36ambrosebsit's a very common error
21:36ambrosebseven clojure.core has suffered from it
21:37amalloyambrosebs: i think this problem probably wouldn't even exist if clojure didn't give you an implicit (do) around function bodies
21:37romanandregoh what is wrong is the order of the docstring and args
21:37ambrosebsromanandreg: good point!
21:37romanandregambrosebs: hehehe just stating the obvious :-p you figured that out
21:38ambrosebsno, I didn't think of it that way
21:39amalloywait, this conversation is getting fuzzy. is someone proposing (defn foo [x] "docstring" (...))?
21:39ambrosebsright
21:39ambrosebsbut I was proposing printing a warning
21:39amalloyno good, because of multiple arities
21:39amalloynever mind, i'm talking at cross-purposes here
21:40romanandregambrosebs: +1 on the warning, you can shoot yourself in the foot easily without it
21:41ambrosebsromanandreg: I do it all the time
21:42romanandregambrosebs: 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:42romanandregI'm obviously missing something there...
21:43ambrosebsfunction body needs to be in an "clojure.core.logic/all" form
21:43ambrosebssyntactically like "do"
21:43ambrosebsor wrap it in an empty fresh, same thing
21:44romanandregambrosebs: uhmm
21:44ambrosebs(defn father [f c] (all (parent f c) (man f)))
21:44romanandregin the second option, I don't see how that might work
21:44romanandregwith a fresh in the father function only I mean
21:45ambrosebs(defn father [f c] (fresh [] (parent f c) (man f)))
21:45ambrosebsprobably works :P
21:46romanandregoh… you just define a fresh with an empty vector, interesting
21:46romanandregambrosebs: what is the purpose of fresh exactly, I'm using it just because it makes it work
21:46romanandreg:-)
21:46ambrosebsuse "all"
21:47ambrosebs(defn father [f c] (all (parent f c) (man f)))
21:47romanandregambrosebs: ok
21:47ambrosebsbut fresh introduces "fresh" logical variables
21:47ambrosebsthink of fresh like this
21:47ambrosebs(fresh [x y z] (== x y))
21:47ambrosebsis like
21:47ambrosebs(let [x (lvar) y (lvar) z (lvar)] (all (== x y)))
21:48ambrosebsbut don't talk about lvar ;)
21:49romanandregambrosebs: 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:50ambrosebsI can go all day, ask away :)
21:50romanandregambrosebs: thanks… this is the third time I get to this channel I find awesome people like yourself, this community is amazing
21:50ambrosebsmy Clojure Conj talk will probably come out in the next few weeks, look out for it
21:51ambrosebs:D +!
21:51ambrosebs+1
21:51ambrosebsI go through how to think of core.logic's execution
21:51ambrosebsit's a simple concept, but very smart implementation
21:52romanandregambrosebs: by smart you suggest more complicated for it's own sake? :-)
21:52romanandregtoo complicated*
21:52ambrosebshmm :)
21:53ambrosebsI'll say that it is utter genius and only a handful of people understand it intimately
21:53ambrosebsno including me
21:53ambrosebs*not
21:53ambrosebsas in I don't know what's going on :D
21:53ambrosebsbut the original implementation is like a couple of hundred lines long
21:54romanandregambrosebs: well I tried to read it, and I felt a bit dumb, this is way over my clojure foo
21:54ambrosebsThe Reasoned Schemer's implementation of minikanren in scheme is easier to grap (ha!)
21:54ambrosebs*grasp
21:54romanandregambrosebs: I don't mind feeling dumb though, I'm used to that, luckily I'm stubborn
21:55ambrosebsromanandreg: that sounds too familiar.. :)
21:55romanandregambrosebs: no experience with schemer either (yet)… I got to this Clojure wagon through Haskell :-p
21:56romanandregscheme*
21:56ambrosebsscheme's pretty easy after Clojure
22:00romanandregambrosebs: 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:01ambrosebswhat does (match q f) do?
22:02romanandregambrosebs: 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:02romanandregthere is only one, but is repeated twice… once per child I guess
22:02ambrosebsor, where does it come from?
22:03romanandregambrosebs: I think I don't quite get the "where does it come from?" question :-/
22:03ambrosebsI don't recognize "match", what namespace is it in?
22:04romanandregoh
22:04romanandreg(use '[clojure.core.logic :rename {== match}])
22:04ambrosebsromanandreg: 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:05ambrosebs== is pronounced unify
22:05romanandregambrosebs: hehe good to know
22:05romanandregambrosebs: going to rename it like that then
22:06ambrosebscould you update the gist with your changes?
22:06ambrosebseasier if I see the whole story
22:07romanandregsure… well I'm testing on repl so I'm going to comment how I'm importing everything on it through comments
22:10romanandregambrosebs: https://gist.github.com/1392568
22:14ambrosebsdon't import unify
22:14ambrosebsit's just much easier to use the namespace decl I suggested
22:15ambrosebsunify is not the same as ==
22:15ambrosebsbut == is *pronounced* "unify" :P
22:16alexbaranoskydoes 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:29brweber2ambrosebs: Maybe IRC is better than twitter for this :)
22:29ambrosebsbrweber2: LOL
22:29ambrosebsgod twitter is hopeless with replies
22:29brweber2ambrosebs: Sure is. Anyway, (source identity) in 1.3.0 confirms that it was fixed.
22:31ambrosebs,(source identity)
22:31clojurebotSource not found
22:31ambrosebs:)
22:32ambrosebsbrweber2: did you see the minikanren demo at the conj?
22:32brweber2ambrosebs: No, stupidly I skipped it. 100% kicking myself for that....
22:32brweber2Hmmm, does clojurebot allow contrib libraries to be loaded?
22:33amalloybrweber2: if they happen to be on his classpath, sure. but i doubt if many are, especially since he's running on 1.3
22:34brweber2amalloy: Well, 1.3.0 is what I'd like to see in this case, but just thinking out loud :)
22:35ambrosebs,(use 'clojure.core.logic)
22:35clojurebot#<RuntimeException java.lang.RuntimeException: java.io.FileNotFoundException: Could not locate clojure/core/logic__init.class or clojure/core/logic.clj on classpath: >
22:36ambrosebsbrweber2: it was recorded, never fear
22:37brweber2,*clojure-version*
22:37clojurebot{:major 1, :minor 3, :incremental 0, :qualifier nil}
22:37brweber2,(doc source)
22:37clojurebot"([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:37brweber2,(source identity)
22:37clojurebotSource not found
22:39brweber2,(source println)
22:39clojurebotSource not found
22:41brweber2Hmm, source sure seems like it would be a useful function to have in clojurebot… I wonder if it was removed for sandbox reasons?
22:42wiseenis 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:43wiseenideally I would return two values from (swap!) but that can't be done afaik
22:43ambrosebs,(use 'clojure.repl)
22:43clojurebotnil
22:43ambrosebs,(source println)
22:43clojurebotSource not found
22:43ambrosebssource
22:44ambrosebs,source
22:44clojurebot#<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.repl/source, compiling:(NO_SOURCE_PATH:0)>
22:45amalloywiseen: i don't think your version is just un-pretty, it's actively not-working
22:46amalloyin case of contention
22:46wiseenamalloy, how so ?
22:47amalloywiseen: i guess it depends what you're doing with top. you're trying to deref it after the swap happens?
22:48wiseenamalloy, yes
22:48wiseenthat would happen at the end of let so it just returns top value
22:48wiseen(let [top (atom nil)] ... @top)
22:48amalloyin 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:49wiseenah but top is thread local
22:49wiseenit's a local scope variable
22:50amalloyoh, i see
22:50amalloywell, then this will work but is gross
22:50amalloythe easiest solution is to use a ref
22:51amalloywhich lets you (dosync (alter x f) (return whatever you want))
22:52amalloyit'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:53wiseenamalloy, your're right - nice !
22:54amalloyi've done that a few times in pointless pursuit of atoms, but a ref is less hacky
22:54wiseenstill 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 :))