#clojure logs

2011-09-16

00:01iceyDoes this java interop seem a little better? https://github.com/pmn/noir-messageboard/blob/master/src/noir_messageboard/utils/utils.clj#L14
00:02brehautyes
00:03iceyawesome, thanks again
00:09amalloyicey: you can cut out a lot of the duplication in describe-time-elapsed
00:10amalloy(let [[hours days months years] (for [amt [60.0 1440.0 43829.0639 525948.766]] (Math/round (/ minutes amt)))] ...)
00:10iceyamalloy: oh, that's pretty cool
00:10amalloythen you don't even waste the cpu to count out the years unless you end up using them, as a nice side effect
00:11amalloythough i guess vector seqs are chunked, and for preserves chunkiness...feh, whatever
00:11iceyit's pretty slick, i like it
00:12brehauticey, id lean towards making human-date take a second argument (the reference point)
00:12brehautrather than implicitly using ctime/now
00:12amalloygood idea
00:13iceybrehaut: out of curiosity, why? future flexibility or another reason?
00:13brehautit makes that code pure which drasticly improves both reasonability and testability
00:14brehaut(reasonability: you can reason about what its doing)
00:14iceybrehaut: ahhh that makes sense
00:14iceyi'm still working on thinking functionally :)
00:14brehautarent we all :)
01:12jamiltronI'm having some problems interfacing to a java class that has a public constructor, but whose main functionality is in a private method that reads from System/in.
01:13jamiltronMaybe I'm oblivious, but I want to be able to "lein run" my project with a supplied file name to be read and supplied as System/in.
01:15amalloyjamiltron: $ lein run < somefile.txt?
01:16jamiltronThat seems to still be producing -1 as System/in
01:16amalloySystem/in is a stream. it is impossible for its value to be -1, so i don't understand the assertion you just made
01:17amalloyit's entirely possible (technomancy?) that lein run forks a new java process and doesn't forward stdin to it, but that would surprise me
01:21jamiltronMaybe its the way I'm running it. I have a parser that reads from System/in. When I do java myParser < testinput.txt, it runs fine.
01:21gstamp1does apply work on methods defined with a protocol?
01:22jamiltronWhen I try interloping with Clojure, I instantialize the object and call the parse method (.parse (new myParser)), and when running lein run < testinput.txt I get a java.lang.ArrayIndexOutOfBoundsException: -1 error
01:24amalloygstamp1: yes. protocol functions are functions, not methods, and so anything that works for a function works for them
01:28amalloysounds more like an issue with mis-initializing your parser
01:29amalloyjamiltron: try using clojure.main instead of lein run, so that you can eliminate lein as the source of the problem
01:30amalloyor write your program to take a filename as an arg, and open the file yourself, so that you can stop worrying you're redirecting wrong. if you want, you can System/setIn some-stream
01:31jamiltronI normally read files with slurp, would that be the preferred method in this case?
01:32amalloyif you want an input stream...get the input stream however you want. slurp will produce a string, and it's not trivial to go from characters back to bytes
01:44jamiltronI think I'm just screwing this up. All the file io I've done in Clojure revolves around slurp. I'm having a pretty rough time getting the format right for System/setIn. Is there a better method than slurp to just get a stream in Clojure?
01:46amalloy&(find-doc "input-stream")
01:46lazybot⇒ ------------------------- clojure.java.io/IOFactory nil Factory functions that create ready-to-use, buffered versions of the various Java I/O stream types, on top of anything that can be unequivocally converted to the requested kind of stream. Common op... https://gist.github.com/1221294
01:47amalloy&(clojure.java.io/input-stream "project.clj")
01:47lazybotjava.security.AccessControlException: access denied (java.io.FilePermission project.clj read)
01:47amalloy^ would work if the bots weren't sandboxed
01:57jamiltronamalloy: Thanks
01:58jamiltronI had to end up using (System/setIn (clojure.java.io/input-stream args))
01:58jamiltronNot sure if that's the best way but its at least working.
01:58raekwhy do you need to set System.in?
01:58jamiltronlein run doesn't seem to capture redirection
01:58amalloyraek: he has some crazy library that operates by reading System/in
01:59raekoh. dang.
01:59jamiltronYeah, it's not fun.
01:59jamiltronBut its either figure this out or do the rest of this course in Java or C++, neither of which I'm especially thrilled about.
03:31robermannhello, I'm using clojurebox; is clojure-jack-in available out of the box or I am supposed to install something else?
03:38khaliGrobermann, try M-x clojure-jack-in
03:38khaliGrobermann, if it works then yes, otherwise you'll need to install it
03:39khaliG(swank-clojure that is)
03:40robermannkhaliG: I tryied, and it does not exist. I thought it would be there, because clojurebox have clojure-mode and swank-clojure preinstalled
03:41khaliGrobermann, not necessarily. are you on windows?
03:41robermannyes .. :)
03:43khaliGrobermann, if you really want c-j-i you might have to set it up from scratch yourself
03:44robermannBTW, what is the difference between running "lein swank" / clojure-jack-in versus M-x swank-clojure-project > set root project?
03:45robermannDon't both start a REPL in the specified lein project?
03:46khaliGjack-in takes care of the lein swank; m-x slime-connect for you,
03:52raekI think swank-clojure-project duplicates what leiningen does nowadays
03:53raekalso, it is not maintained anymore
03:53raekwith "lein swank" / clojure-jack-in, Leiningen starts the swank server. with swank-clojure-project the deprecated swank-clojure.el elisp package does it.
03:55raekrobermann: I recommend getting rid of clojure-box, install emacs the normal way and install clojure-mode.el
03:55raekclojure-mode is the only thing you need on the emacs side since clojure-jack-in
03:56robermannmmm so in the latest "best practice setup" by technomancy (http://technomancy.us/149) I'm supposed to find only clojure-jack-in, not clojure-swank-project, right? Whereas in Clojurebox I find clojure-swank-project and not clojure-jack-in.
03:57raekyes
03:57raekpretty much
03:58scottjclojurebox is a year old
03:58raekyou can install slime, start the swank server manually and slime-connect to it too, if you want to
03:58raekbut with clojure-jack-in you use the slime version that swank-clojure supplies
03:59raekwhich (hopefully) makes ones configuration less brittle
03:59thorwilthe only thing i miss with clojure-jack-in is triggering a startup script automatically
03:59robermannok raek thanks, now this stuff make sense for me. Googling it was quite confusing
04:00amalloythorwil: eh? c-j-i should honor the settings in project.clj
04:00raekwhat's currently the "best practice setup" has varied a lot from time to time
04:01raekthe clojure-box approach stems from the time before leiningen
04:02raekso does the deprecated swank-clojure.el
04:02robermannok
04:02thorwilamalloy: oh, i have to try that, then
04:02raeknot easy to know since lots of old tutorials are out there
04:03Fossi"a lot" :D
04:04Fossithat's an enormous understatement
04:04Fossi(is that even a word?)
04:04robermannclojure-jack-in calls (after slime ecc) "lein swank" right? and "lein swank" pipes the forms into a "lein repl" subprocess?
04:05Fossii still start my swank and slime by hand and have projects added in my classpath XD
04:05amalloyrobermann: lein swank and lein repl are two different ways to communicate with a running clojure process
04:05amalloyswank (almost certainly) doesn't communicate with a repl
04:07khaliGso a lot of the time when something goes wrong - there is nothing printed in the repl - no stacktraces, to get those I've got to look at *swank*
04:08robermannBTW this seems very clarifying: http://stackoverflow.com/questions/7238766/what-exactly-does-clojure-jack-in-do-and-how-to-config-the-settings-with-slime
04:35thorwilif i do clojure-jack-in and then paste the following into the slime-repl, it works: http://paste.pocoo.org/show/476890/
04:35thorwilbut if i trigger it via :repl-init-script, i get: No such var: ae/start
04:36amalloyyou probably need to wrap it in a (do)?
04:36raekmaybe this is the "IDE sniffing" appengine-magic does
04:37raekae/start is conditionally compiled and is only there if ae-m thinks you are using an IDE
04:37amalloyjesus
04:37clgvthorwill: I guess you using :require in a ns named user isnt the same as if you do (require ..) on repl with standard ns user for alter execution within the repl in both cases
04:39raekhttps://github.com/gcv/appengine-magic/blob/master/src/appengine_magic/core.clj#L5
04:39raek*seriously*, there must a better way to do this
04:39thorwil(do) doesn't help. guess i should try falt require and use, no ns
04:40raekthorwil: this is a bug in appengine-magic
04:40clgvthorwil: do you really need that strange compile & in-ns for the startup?
04:40raekthe same one I recall that I investigated with you once before
04:42thorwilraek: i do recall it, but didn't think of it here
04:43clgvhumm why does "lein repl" swallow newlines that should be printed?
04:43thorwilclgv: the compile is there to make sure i get served the latest state. the in-ns i could get rid of
05:12pyrdoes anyone use ring.middleware.resource ?
05:12pyrinstead of passing through when it doesn't find a resource it throws exceptions
05:17pyrmeh, alright found the way to do it
05:35mcstar(example.gpgpu.mandelbrot/start) how can i make this shorter?
05:35mcstaris there something like (in-package)?
05:36Chousukeis that a java package?
05:36mcstar(ns example.gpgpu.mandelbrot
05:36raekfrom your own namespace: (ns your-ns (:use [example.gpgpu.mandelbrot :only [start]]))
05:36mcstari guess not
05:36clojurebotllahna: anyway the answer is no. you can use #(some-fn %1 default-arg %2), for example
05:37raekor from the repl: (use '[example.gpgpu.mandelbrot :only [start]])
05:37Chousukeyou can do :require ... :as foo too in the ns form
05:37Chousukeso that you can do foo/start
05:37raekor if you want to actually be in that namespace: (in-ns 'example.gpgpu.mandelbrot)
05:37mcstarraek: yes, that is appropriate thx
05:38raekafter one of those, you can call it with (start)
05:38mcstaryes :)
05:38raekthe other common approach is what Chousuke said. that way is probably more convenient if you are going to use many vars from that namespace
05:39raekin-ns requires that the namespace has been loaded first (with a 'require' or 'use' call)
05:39mcstarthe project's main sorce creates this namespace, so i want to be in it, when using the repl
05:40mcstarwhen youre developing you dont create just another package/namespace just to use the just-defined functions
05:40raekyou can also use 'use' without the :only option. then you will have access to all public vars of that namespace in your current namespace
05:40raekwhich is similar to being in that namespace
05:41raekbut yeah, while developing or testing the namespace, in-ns makes perfect sense
05:41mcstarraek: is there something like :export in clojure?
05:42mcstarto control what symbol can be accessed with a :use?
05:42raekevery def* thing is exported by default, unless you have ^{:private true} metadata on the var
05:42mcstarim coming from cl
05:42mcstari see
05:42raekfor 'defn' there is a shortcut: 'defn-'
05:42raekto make a private function
05:43raek(def ^{:private true} ordinary-constant 123)
06:21tsdhOn clojars, can I delete some jar (or even a complete group where I'm the only member)?
07:13khaliGhm. my uberjar is 15mb. are there any tricks to shrinking these down?
07:15clgvkhaliG: checking your dependencies, maybe there a superfluous ones
07:15scottjkhaliG: there's a slim version of clojure I think
07:16scottjalso pack200. see thread "mini-version of clojure.jar"
07:17scottjactually slim version of clojure might only decrease the size by 2mb
07:21khaliGclgv, yep i just went through and did that, lein is pretty clever - it removed duplicates (ie those occuring in lib/ and lib/dev) already
07:21khaliGscottj, from 3mb? that's pretty good!
07:22clgvkhaliG: maybe you can only select a part of a dependency instead of the whole thing. I know thats possible for incanter for example
07:22scottjkhaliG: 15mb -> 13mb though isn't
07:22khaliGclgv, does lein do that?
07:22khaliGtrue scottj
07:22clgvkhaliG: you do it by specifying "incanter.core" instead of "incanter" to lein
07:23khaliGclgv, as it happens i do use incanter as a dependency. i shall investigate..
07:23clgvbut that only works since incanter is structured into these subprojects
07:23khaliGthanks for the hint :)
07:23clgvI use it myself as one of 3 deps and it pulls that much stuff withit
07:24khaliGyep parallelcolt for exmaple is 3.4mb
07:24clgvI tried to exclude parallelcolt but got an error. I dont use it at all^^
07:24khaliGclgv, so how do you restrict, in project.clj ?
07:25clgvyou can :exclude jars as well, thats what I tried with parallelcolt
07:25khaliGi see!
07:34khaliG42% of the 15mb is taken up clojure-1.2.0.jar and parallelcolt-0.9.4.jar
07:37clgv11.8MB for incanter and its deps
07:37khaliGdamn.. lol
07:37clgvyeah, have to change it when I know exactly what sublibs i need
07:38khaliGdoes that include the clojure jars too?
07:38clgvnope
07:38khaliGinteresting
07:38clgvstill 5.7MB when I only have incanter.core listed
07:42khaliGclgv, makes you wonder why incanter is so heavy. lispstat wouldnt have been more than a mb :P
07:42clgvkhaliG: I think they should remove some more stuff from core^^
07:43khaliGhere we go - ftp://ftp.stat.umn.edu/pub/xlispstat/3-52/xlispstat-3-52-20.tar.gz 1492 kB
07:43khaliGand that includes an entire lisp as well
07:43kharringtonkhaliG: doesn't incanter come with example data?
07:44clgvkharrington: and zillions of dependencies ;)
07:44kharringtonmmm
07:45khaliGkharrington, not sure
07:45kharringtoni've often wanted optional dependencies in leiningen-based projects anyway
07:46clgv37 deps for [incanter "1.2.3"]
07:47clgv16MB with clojure and clojure contrib
07:51khaliGwow, xlispstat still builds and runs .. amazing :)
07:53kharringtonkhaliG: no, it looks like datasets fetch from github by default
10:13rqcursqhttp://wiki.theory.org/YourLanguageSucks
10:29clgvlol what? :P
10:40bprwhy does leiningen include the project.clj file in generated jar files?
10:40pyrso you can slurp it ?
10:41bprI'm trying to write some code for android, and I'm depending on multiple clojure libraries. Therefore there are multiple files named "project.clj" and the android build process is choking on that :-/
10:41khaliGclgv, have you tried using proguard on your app?
10:41clgvkhaliG: no. what's that?
10:42khaliGclgv, its a jar optimiser/obfuscator thingy
10:42bprSo, as a quick hack can I remove the project.clj files from the jars?
10:42khaliGjust ran it on my uberjar and it choked though
10:42clgvit's free?
10:42khaliGthe oracle app pack200 worked better reducing the file size from 15mb to 13mb though
10:42khaliGclgv, yup
10:43khaliGclgv, pack200 lives in $JAVA_HOME/bin if you want to try it
10:46clgvkhaliG: humm maybe it could do more if you did AOT for all files and removed the clj-files, but I never tried that. It's also not encouraged to AOT all ;)
10:47khaliGclgv, worth a try!
10:47bproh... scratch my question lol I was being assinine
10:48stuartsierraAOT is fine for delivering an app.
10:48clgvah ok, I remember one comment that you shouldnt do it if you dont need to
10:48stuartsierraIt's bad for distributing a librar.
10:48clojurebotlibraries is http://clojure.org/libraries
10:48kharringtonrqcursq: the best thing from that link is: "Object-oriented programming is an exceptionally bad idea which could only have originated in California." --Edsger Dijkstra
10:48stuartsierralibrary.
10:51clgvah right I noticed it once when trying a lib with AOT from clojure 1.2 in 1.3 ;)
10:52rqcursqkharrington: yes, is the best :D
10:53dnolenHaskell is purely object oriented http://www.mail-archive.com/haskell-cafe@haskell.org/msg72409.html
10:53clgvrqcursq: that site would be better if they agreed on criteria in advance to criticize the languages, so it's reading as just random opinions about the listed languages
10:55clgvs/so/now/
10:55lazybot<clgv> rqcursq: that site would be better if they agreed on criteria in advance to criticize the languages, now it's reading as just random opinions about the listed languages
10:55rqcursqyoure right
10:57rqcursqthere is no such a thing like clojure! a ha!
10:58khaliGit's annoying having to decide whether to include a 2mb jar into your project or write 200 lines of clojure doing the same thing :(
10:59rqcursqI think from now on Lisp dialects will go popular for production line of sw
10:59rqcursqor enterprise systems
10:59rqcursqcause they need logical instruments like this… not a functional static foolish things
11:01khaliGespecially when you only need a tiny class from that jar!
11:03rqcursqany clojure based computer algebra system released ?
11:04clgvkhaliG: humm if it fits your license you can just use their code snippet (not to forget attributing) ;)
11:04rqcursqor mathematical lib written in clj?
11:04khaliGclgv, true, i might just do that. it's LGPL code though
11:04khaliGrqcursq, incanter is the only one i can think of
11:24rqcursqwhat project is needed for clojure?
11:25rqcursqwhich types of projects are *
11:35gtrakrqcursq, clojure's a general purpose language
12:42SergeyD,(prn "test")
12:42clojurebot"test"
12:42SergeyD,(defn tt []
12:42clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
12:42SergeyD (loop [i 0 tset #{}]
12:42SergeyD (if (= i (int 5e5))
12:42SergeyD (count tset)
12:42SergeyD (recur (inc i)
12:42SergeyD (let [nn (rem (* i (int 1e3)) 131071)
12:42SergeyD plus (count (filter #(contains? tset %) (range nn (+ nn 10))))
12:42TimMc...
12:42SergeyD ]
12:42SergeyD (conj tset (+ plus nn)))))))
12:42SergeyD(tt)
12:43SergeyDShould be one-liner, I guess
12:43gtrakSergeyD, paste in a pastebin
12:43TimMcSergeyD: You shouldn't paste that much to the channel anyway.
12:43manutterSergeyD: also, the bot won't let you defn
12:43TimMcIf you really need to eval that much code in clojurebot, do it in /query clojurebot
12:44SergeyDSorry, ok
12:44sridis this the idiomatic way to print a list of maps? -- (map #(println (dissoc % :message :foo :json :level :component)) events)))
12:45TimMcsrid: You'll need a doall around that at least.
12:45TimMcdoseq sounds better
13:07PPPauluse pmap
13:12technomancysrid: you can generate pngs for web apps using incanter
13:21amalloyyeah, it's not clear what "not web-based" means for...a math library? like, you can't use it if you have an internet connection?
13:21amalloy4clojure uses incanter to generate graphs on the fly
13:28TimMcPPPaul: Why?
13:42rqcursqwhat is the difference between def and defn ?
13:43hiredmanplease read the docs
13:43amalloyin fairness, ##(doc def) doesn't exactly work
13:43lazybotjava.lang.SecurityException: You tripped the alarm! def is bad!
13:44Raynesdef names something and defn creates a function and names it with def. defn is implemented in terms of defn.
13:45Raynesin terms of def, even.
13:45Raynesamalloy: I'm shocked that you let that pass for a whole minute with no amusing comment.
13:46amalloyRaynes: i /msg'd everyone but you to tell them you were wrong
13:46rqcursq#(doc def)
13:48hiredmanamalloy: there are docs for it
13:48rqcursqRaynes: thank you
13:49manutterrqcursq: if you didn't have defn, you'd define functions like this: (def some-func (fn [x] (println x)))
13:50manutterdefn is a bit shorter, and I think it might also set some meta-data? Or not, I haven't looked at the src for that one.
13:51manutterbut consider (defn p-add [a b] (if (zero? a) b (p-add (dec a) (inc b)))) -- the function calls itself
13:54rqcursqmanutter: i understand and defn also provides documentation?
13:54rqcursqlike "this" ?
13:55manutterThere you go, that's the metadata I was thinking of: if you say (defn my-func "prints out x" [x] (println x)) you get the doc string automatically tucked away inside the metadata for my-func
13:57rqcursqmanutter: Thanks for your information :)
13:57manutternp
14:01rqcursq.git/ directory has more bytes than codes itself...
14:02amalloyrqcursq: i hope you can spare the thousandth of a cent that a few megabytes cost you
14:02amalloyand of course it's larger than your source code directory: it contains *every version* of source code you've ever checked in
14:03TimMcin a manner of speaking
14:04TimMcIt contains enough information to reconstruct those versions.
14:05rqcursqbut i want to latest version to clone not the all heads… :(
14:05amalloyTimMc: the hard drive only contains enough information to reconstruct the current version, in the same manner of speaking: it just has a bunch of bits, and a very clever algorithm for turning those into pixels on your screen
14:06amalloyrqcursq: even in 1995 the amount of hard drive space taken up by .git would be only a little burdensome
14:13TimMcamalloy: I'm not sure what you're trying to say.
14:20amalloyTimMc: you were asserting that .git doesn't "actually" contain all the previous version
14:21TimMcNot as such -- they are not all side-by-side as independent copies.
14:21Chousukeof course not, that would be dumb
14:22Chousukebut the information is all there :P
14:22TimMc:-)
14:22amalloymy point is that it contains the previous versions in the same way the hard drive contains the current version: it stores enough bits to reproduce the characters, in the same way that git stores enough bits to reproduce the versions
14:22Chousukeso in a mathematical sense it does contain all previous versions
14:23TimMcI don't think we actually disagree on anything in an objective sense. :-P
14:34iceyhmm. i think i'm going to have to change my irccloud setup
14:45manutterdoh, now I'm going to have to google irccloud, it sounds cool (whatever it is)
14:45amalloymanutter: it's like a bouncer, except not as good
14:45iceymanutter: it's a service that provides irc over the web
14:46iceyit was a good idea, but the implementation has been kind of meh. it goes down a lot
14:46manutterah
14:59lnostdaljust wanna say clojure is quite nice .. it feels like a very solid core
15:01lnostdal..some tools are lacking here and there of course; it's a new thing or language .. perhaps this emphasizes the "solidness" of the core, because it still all works out somehow ......... :)
15:08konrIsn't swank-clojure.el missing from https://github.com/technomancy/swank-clojure ?
15:08technomancykonr: it's deprecated
15:40rqcursqhow to include another source file in clojure ?
15:42TimMcrqcursq: http://blog.8thlight.com/articles/2010/12/6/clojure-libs-and-namespaces-require-use-import-and-nshttp://blog.8thlight.com/articles/2010/12/6/clojure-libs-and-namespaces-require-use-import-and-ns
15:42TimMcgrah
15:42TimMcrqcursq: Rather, http://blog.8thlight.com/articles/2010/12/6/clojure-libs-and-namespaces-require-use-import-and-ns
15:46rqcursqTimMc: luvvv it!! thanks
15:47TimMcI still refer to that for syntax.
15:59rqcursqdnolen: inc dnolen
16:00konroh wow, clojurescript!
16:00dnolenand looking forward to fixing delimc to work w/ ClojureScript so you can write AJAX w/o callbacks.
16:00rqcursqwriting discrete math functions for clojure
16:04hugoddoes clojure.test exist for clojurescript?
16:08rqcursq(assoc {:a 1 :b 2} :c 3)
16:09rqcursqis this >:c 3< expression assigned everytime to first key-vale binding ?
16:09rqcursqlike {:c 3, :a 1, :b 2} this ?
16:09iceyis there currently a recommended way for doing comet with clojure web apps? i know about aleph, but is there anything like socket.io for clojure?
16:09_fogus_hugod: Not that I', aware of.
16:09iceyor is it all long-polling still?
16:09amalloyrqcursq: maps have no ordering
16:10amalloyany ordering that you see is coincidental and should not be relied on
16:11dnolenicey: aleph is the closest that I'm aware of.
16:13sridfor my log analysis - looks I will have to create a separate process for pulling the log files, and another for processing them into list of maps. these maps need to be stored somewhere, from which the web process can pull them for visualization.
16:14sridpulses uses 'redis' for this. is redis a good choice for storing processed log records?
16:15konrwhat text editor/IDE do you use?
16:23iceydnolen: hmm, thanks
16:33srid*must* i learn the concurrency primitives of clojure (atoms, state, identity, etc..) before implementing a multi-threaded program with producers and consumers interacting with redis/rabbitmq?
16:33technomancysrid: I'm going to go with yes
16:34amalloyyou could always try just guessing, in the same way you don't need to learn clojure to write a clojure program - just pound letters and parens at random until you get the program you wanted by luck
16:38sridi'm inclined go with multi-process, as I'm not sure how easy it is to develop multi-threaded programs in REPL. (with multi-process, i can open multiple REPLs)
16:44rqcursqcan we make a giant framework like rails ?
16:44rqcursqis it possible ?_
16:45stuartsierrarqcursq: Define "we." :)
16:45rqcursqalllll of clojurians :D
16:45stuartsierraOf course we can.
16:46fliebelDo we want to?
16:46stuartsierraI certainly don't.
16:46hiredmannot it
16:48fliebelBut a giant pile of independent composeable utilities would be fine with me.
16:48stuartsierraI'd prefer it.
16:49rqcursqutilities ?
16:49fliebelSomething that can be explained as "an X for Y" ;)
16:51tsdhHi
16:51tsdhCan someone tell my why the extend-type form at http://pastebin.com/Z8J0X6S4 does only compile (and work) if I extend it to one type only?
16:52tsdhAh, it's extend-protocol, but anyway...
16:59stuartsierratsdh: It may have something to do with the macroexpansion of extend-protocol
17:00stuartsierraI've never tried using that with expressions like `(class "s")`
17:01tsdhstuartsierra: In my case, I want to extend a protocol to objects of classes that were compiled in memory. So I don't have a class literal.
17:01stuartsierraTry using the `extend` function directly.
17:02tsdhhiredman: I don't have 1.2 handy, but I'll try tomorrow.
17:02tsdhstuartsierra: Ok, I'll try.
17:07tsdhstuartsierra: That works. Well, but then I need 3 extend forms which are even less convenient than 3 extend-protocol or extend-type forms that work, too.
17:08stuartsierraThere may be a bug in one of the extend-* macros that prevents your example from compiling. The same code with literal class names works fine.
17:09stuartsierraAha, the doc string to `extend-type` says that it "Propagates the class as a type hint on the first argument of all fns."
17:09stuartsierraAnd `extend-protocol` expands to multiple calls to `extend-type`.
17:10tsdhstuartsierra: Yes, but it's still a bug, right?
17:11stuartsierradepends. Nothing in the docstrings promises that extend-* work on arbitrary expressions.
17:11stuartsierraWorth bringing up on the mailing list, however.
17:11tsdhIf the class is a list, then it should omit the hint, I'd say
17:11tsdhOk, I'll write a mail.
17:11stuartsierrathanks.
17:15hiredman,((fn [^(Class/forName "java.lang.String") x] (.getBytes x)) "foo")
17:15clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Metadata must be Symbol,Keyword,String or Map>
17:44rqcursqI dont know how to write tests i googled but icannot find any solution ?
17:45dnolenrqcursq: https://github.com/swannodette/delimc/blob/master/test/delimc/test/core.clj
17:45dnolenthere are fancier things like midje, but this way works for me.
17:46rqcursqdnolen: use travis for tests little suggestion from me :)
17:47rqcursqdump this in yaml file
17:47rqcursqlanguage: clojure
17:47rqcursqscript: "lein test"
17:47rqcursqrest is on every commit you do on travis
17:47rqcursqsorry github**
17:50dnolenrqcursq: sounds nice, but "mvn test" "lien test" at the REPL isn't much overhead
17:50dnolener command line :)
17:56neroothUnable to connect to mongo db with clojure (congomongo "(mongo! :db "test") function), but it works with the mongo shell. Using mongo 2.0.0, clojure 1.2.1 and congomongo 1.7-snapshot. What's up?
17:57amalloy:db :test maybe?
17:59neroothamalloy: nope. According to the congomongo examples the syntax should be (mongo! :db "name"), with host and port defaulting to localhost and 27017 (which is the port that mongo is running on)
18:00amalloymaybe ask seancorfield - congomongo 0.1.4-SNAPSHOT is working fine for me on several machines
18:01neroothThe fault is probably on my part, I just can't figure out what could be wrong. I've had it working on another project but now it's just not doing anything.
18:02neroothIt should work as usual via lein repl, right?
18:08seancorfieldhmm, i just installed mongodb 2.0 on my netbook but haven't tested congomongo against it yet
18:09seancorfieldwe're using congomongo 0.1.7 snapshot with mongodb 1.8.2 in production
18:09nerooththat's one thing that I remember has changed - will try downgrading mongodb
18:09nerooththanks for the pointer
18:35NetpilgrimHi. In case one of the operators of 4clojure.com is around, I'm currently getting a 502 Bad Gateway for the site.
18:37amalloydang it, again?
18:38amalloythanks Netpilgrim, up again
18:40konrWhat was the function to map an entire tree, again? like (maptree #(>% 1) [[1 0] 4]) -> [[false false] true]?
18:41Netpilgrimamalloy: Thanks. Great tech support! :)
18:42amalloyNetpilgrim: the best tech support will be if one of our users figures out what is going wrong and fixes it for us
18:43Netpilgrimamalloy: Sorry, probably out of my area of expertise.
18:50Netpilgrimamalloy: There is a typo in the description of problem 69. “the rest of the maps conj-ed onto the first” should probably read “the result of the maps conj-ed onto the first”.
18:51Netpilgrimamalloy: Hm, reading it again, it also makes sense the way it's written.
18:52Netpilgrimamalloy: I'm probably just tired but I had to read the whole description about three times before I got it.
18:52amalloyyeah, "result" doesn't make any sense, especially because ##(doc merge-with)
18:52lazybot⇒ "([f & maps]); Returns a map that consists of the rest of the maps conj-ed onto the first. If a key occurs in more than one map, the mapping(s) from the latter (left-to-right) will be combined with the mapping in the result by calling (f val-in-result val-in-latter)."
18:54Netpilgrimamalloy: This doc string could really be improved. “the latter (left-to-right)” is almost obfuscation.
18:57amalloythat said, please do let me know about typos or whatever. i'm itching to try out the new and improved question-editing UI
18:58Netpilgrimamalloy: I'll keep on the lookout.
19:43Netpilgrimamalloy: The questions often read “Write a function which …”. I’m not a native speaker and it might be nitpicking, but since what follows is not just some additional information but essential for the definition of the function talked about, shouldn’t it be “a function that”?
19:45amalloyyou're probably right, and in many contexts i would care, but in this context it seems more like nitpicking
19:45Netpilgrimamalloy: Well, you were looking for something to edit. :)
19:46amalloyhah. okay, i'll fix one. example of a problem with that issue?
19:46Netpilgrimamalloy: Problem 70.
19:47Netpilgrimamalloy: But without looking through the problem, I think the phrase comes up very often.
19:48amalloyhm. that worked, but it set the "number of times solved" to 0
19:49amalloybugggg
19:50konrhaha, it's so cool. I'm running pretty much the same algorithm I ran on Elisp in Clojure and the processing time went from minutes to about a second.
20:01konrWhat's the fastest way to write 9 million strings in a vector to a file?
20:13seancorfieldnerooth: i just tried congomongo 0.1.7 snapshot with mongodb 2.0 and it connected just fine (i had to swap to another machine to try it - i don't have 2.0 on this machine)
20:46shep-homeHowdy all, what's the best way to debug a NPE?
20:46shep-homeI've been adding println calls, but that feels inefficient
20:47shep-home(and they aren't really helping in this case, either)
20:48hiredmanread the stacktrace
20:49technomancybefore swank.break existed I'd stuff def calls into the middle of known problematic functions
20:52shep-homehiredman: yes, I did do that :-) The problem is that I must be missing something obvious
20:52shep-homeThe line in question has a agent reference and a function name
20:52shep-homeand I println the reference in the line before
20:53shep-hometechnomancy: I'm a super-n00b (like 2 days of Clojure), so I'm not sure what kind of stuff I'd put in those defs... :-)
20:55shep-homehttps://gist.github.com/1223469
20:55shep-home(please feel free to give me formatting tips too)
20:55amalloy#(do ...), not #((...))
20:56technomancyshep-home: if, not cond
20:56amalloyamusingly, it's your debugging code that's breaking it
20:57technomancyshep-home: in general, break things up into smaller and smaller pieces of functionality that can be called independently from the repl until you've isolated the problem
20:57shep-hometechnomancy: if/cond is a style tip, right?
20:57shep-homeamalloy: which line are you referring to?
20:57technomancyshep-home: yeah, it's not causing the problem
20:57shep-homeamalloy: oh, I see
20:58shep-homeOK, I had previously been bitten by '((', I should have known better
20:59shep-homeI'll admit the cod was on purpose... I like the :else
20:59shep-homecond*
21:02shep-homeThanks for the tips technomancy and amalloy (and hiredman, of course)
21:03konrIt's strange. my SLIME buffer is very slow and non-responsive, yet I've already cleared it with slime-repl-clear-buffer. Any idea of what's going on?
21:08shep-homeThanks for the tips technomancy and amalloy (and hiredman, of course)
21:09shep-homedoh, wrong window :-)
21:09amalloyprobably wrong message too
21:45mmarczykhi, is there someone experienced in Clojure's JIRA workflow around and willing to answer a basic question or two? :-)
21:45dnolenmmarczyk: I'm not experienced but what's up?
21:45mmarczykoh yes you are :-)
21:45mmarczykanyway
21:46mmarczyksay in the use-only case, if I change my mind about impl, is it better form to attach a patch based off of the previous one or a new one to be applied in one go?
21:48mmarczykand another thing, what's the established convention around bug reports: straight to JIRA (& be prepared to be flagged invalid if appropriate etc.) or always post on dev group first?
21:48dnolenmmarczyk: I think people tend to delete the old path and replace with a new one. Though personally I think it's nice to have the history of the various patches to see what design decisions came into play.
21:48dnolenmmarczyk: I got straight JIRA unless there's some kind of design question involved.
21:48dnolengo
21:49mmarczykok, thanks
21:49mmarczykI like having the history around too... oh well
21:49mmarczykoh, one more thing
21:49mmarczykdo you have a reference to the upcoming Friedman paper you mentioned?
21:50dnolennot published yet and I can't share the copy I have. But it'll be out in for Scheme Workshop next month.
21:50mmarczykgot it, thanks
21:51hiredmandnolen: how do I negate a relation?
21:51dnolenhiredman: you can do a limited sort of thing with disequality constraints, which prevents two things from ever being unified.
21:52dnolenI've been thinking about stratified negation, but it's not a priority at the moment.
21:55dnolenhiredman: if you're looking for (not some-relation), no support for that.
21:57hiredman_dnolen: thanks (dunno if that came through be I got disconnected)
21:59dnolenhiredman: reading through the literature negation is suprisingly hard to implement. and event stratified negation seems … hacky (at least to this noob)
22:03dnolenhiredman: you can do negation as failure in core.logic as you would in Prolog. if the goal succeeds, cut and fail.
22:04dnolenprevents reversibility, but that may not be important for your particularly case.
22:04hiredmanI'll just do with
22:24konrAny recipe to apply function X to the elements with odd position in a list?
22:27bhenry,(doc map-indexed)
22:27clojurebot"([f coll]); Returns a lazy sequence consisting of the result of applying f to 0 and the first item of coll, followed by applying f to 1 and the second item in coll, etc, until coll is exhausted. Thus function f should accept 2 arguments, index and item."
22:27bhenrykonr: you can figure it out from there i presume
22:27konrthanks bhenry