#clojure logs

2012-10-13

00:17Sgeoivan, I think something like that already happened. So few new programmers capable of programming COBOL.
00:20tomojI hope fn-> and fn->> appear along with cond->
00:20SgeoWhat would fn-> and fn->> do?
00:21SgeoAlso, I still want the thing that I called let->
00:21tomojwell
00:22tomoj(defmacro fn-> [& forms] `#(-> % ~@forms))
00:22tomojbut
00:22tomojI guess #(-> %) is is OK
00:22SgeoAh
00:23SgeoSo, a macro that essentially does what comp does?
00:23SgeoIn reverse?
00:23SgeoExcept works with macros and never needing #() I guess
00:23SgeoI guess it's the thrust vs -> debate again
00:24tomoj(fn-> (rename-keys kmap))
00:25tomojI went with #(rename-keys % kmap) instead
00:25tomojfor some reason #,% seem like eyesores to me
00:25SgeoI don't know if your definition of fn-> might conflict with using #() inside the form, but that's easy to fix by using fn and an autogensym
00:26ivangah Java has no NullOutputStream built in?
00:26Sgeo(defmacro fn-> [& forms] `(fn [arg#] arg# ~@forms))
00:26SgeoErm, oops deleted the ->
00:27Sgeo(defmacro fn-> [& forms] `(fn [arg#] (-> arg# ~@forms)))
00:27tomojyeah, it seems to break otherwise
00:28tomojstrangely it doesn't cause an error
00:29tomojwait, no, it seems to work
00:53aperiodicwhat? it totally breaks without the gensym
00:53aperiodicyou can't have fully-qualified symbols as parameters
00:57SgeoI think I'm beginning to see a rationale behind the behavior of symbols in Clojure: It's slightly creepy for symbols to have magic information added to them on read
01:08amalloyivan: welcome to the glory of java.io
01:09amalloyclasses instead of interfaces, inheritance instead of composition, and no useful primitives
01:10amalloySgeo: using #() in a macro won't affect users of the macro, because #() is a reader macro
01:10tomojaperiodic: hmm
01:10ivananyone have some sort of Clojure thing to black-hole *out*?
01:10tomoj,(defmacro fn-> [& forms] `#(-> % ~@forms))
01:10clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
01:11Sgeoamalloy, ah, ok
01:11tomojwell, (= (macroexpand-1 '(fn-> inc)) (fn* [p1__5906__5907__auto__] (clojure.core/-> p1__5906__5907__auto__ inc)))
01:11ivanI guess I have to write a proxy if I want it in Clojure
01:11Sgeoblack-hole?
01:12tomojhmm
01:12tomoj(= (macroexpand-1 '(fn-> #(%))) (fn* [p1__5906__5907__auto__] (clojure.core/-> p1__5906__5907__auto__ (fn* [p1__5923#] (p1__5923#)))))
01:16SgeoUm.
01:16SgeoDoes ClojureScript not have promises?
01:17amalloySgeo: who would deliver to them while you block the only thread waiting?
01:17SgeoCould wait for one after it's delivered. e.g. using a promise to give an event handler the key to unregistering it
01:19tomojin (let [a 3 b 4]), are the bindings ([a 3] [b 4]) or (a b)? what's the other one called?
01:19amalloyso? if you never block on it, a promise is just an atom that you only write to once; easily implementable yourself without language support
01:20Raynesivan: https://www.refheap.com/paste/5065 something like this
01:20RaynesNot sure what class you have to proxy, but this is what it would look like.
01:20SgeoI guess promises seem more semantically accurate somehow, or I'm used to thinking about the answer to that question in terms of promises
01:21tomojyou have to cps
01:24tomojhmm
01:24tomojso you would prefer (cps (let [x @async-promise] (+ x 3))) ?
01:25tomojto, say, (cps (let [x async-promise] (+ x 3)))
01:25ivanRaynes: cool, thanks a lot
01:25tomojI was looking at http://taskjs.org/
01:26tomojyou have to explicitly yield (is that the opposite of deref?) for an async value
01:26tomojcan't decide whether that's good or bad
01:26ivanexplict yields reveal switch points which is good if you want your programs to work
01:26tomojswitch points?
01:26ivansome mutable state could change between yields
01:27ivanbad #python terminology I'm reusing
01:27tomojmutable state? :P
01:27ivan=)
01:27tomojthe point is to get rid of that..
01:27SgeoI think, as long as I can call some function that itself does yields, and expect it to work from within my own generator, I'm happy
01:28tomojI haven't figured out yet whether task.js is sufficiently composable
01:28SgeoI don't like the non-composibility I've been exposed to, where I can't abstract some lines that use yield into a function
01:31SgeoHmm, I don't have access to defmacro in Himera.... darn
01:31SgeoWell, that makes sense, because there's no defmacro in ClojureScript
01:31SgeoBut that means I don't see a way to get the server to run arbitrary code >:(
01:42shachafivan: You're alive?
01:49tomojif Named were a protocol, should java.util.UUID satisfy it?
01:50ivanshachaf: I'm alive
01:50shachafWeird.
01:52shachafAre you still in that place which isn't the bay area?
01:52ivanyep
01:53shachafYou should instead try being in that place which is the bay area.
01:53shachafYou should go to edwardk's talk next week!
01:54tomojthe incanter one?
02:25bfreisHello, I've just posted a question on SO, I'd be glad if anyone could take a look and give a hand! http://stackoverflow.com/questions/12870437/override-drop-for-a-custom-sequence
02:26bfreisIn short, I'm writing a custom seq that could be slow because it reads data (lazily) from disk, and I want to reimplement drop in a way that would avoid unecessary reads.
02:30brainproxyone of my deps is pulling in an older version of clj-stacktrace, but I can't figure out which one :/
02:31brainproxyis there a way to have `lein deps` spit out more verbose info, i.e. so you can figure out which dep is responsible for triggering a download/install
02:34tomojbfreis: strange, my implementation of drop seems to call more
02:36bfreistomoj: indeed, I've just checked core.clj and (drop) does call (rest), which calls (more). But I'm not sure I understand what you mean.
02:36bfreistomoj: I mean, my implementation of (more) calls (next), which will cause unecessary reads.
02:37tomojyeah
02:37bfreisOh, I see your point.
02:37tomojthe answer is "no"
02:37bfreisI could reimplement more in a way that it does not call next
02:38bfreismore would just drop cached items and increment the counter
02:38bfreisbrilliant
02:38bfreisthanks!
02:38tomojoh
02:38tomojbut it still will be O(n), yes?
02:38bfreisYes
02:39bfreisCould be better, but this is already way better than the first workaround I could figure out.
02:39bfreisI will update the question
02:39tomojisn't that what your next already does?
02:40bfreisMy next reads data into the cache if necessary
02:40bfreisOh, crap
02:40bfreisIt won't work!
02:40bfreisIf I (first (drop dataseq)), there would need to be some data available in the cache
02:41bfreisDamn, back to the original problem of my first workaround: I'd need some mutable state: a mutable cache to be populated by the first call to (first)
02:41tomojwell, you can return a lazy-seq ?
02:42bfreisHmmm, would that help? How would that be different?
02:42tomoj,(doc lazy-seq)
02:42bfreisYou mean, replace load-data by something like (defn load-data [id] (lazy-seq .....))
02:42clojurebot"([& body]); Takes a body of expressions that returns an ISeq or nil, and yields a Seqable object that will invoke the body only the first time seq is called, and will cache the result and return it on all subsequent seq calls. See also - realized?"
02:42tomojno, put the next impl in more but wrap it in lazy-seq
02:43tomojthen make next (seq (.more this))
02:43tomojI think
02:43tomojbut really, you should be building an IChunkedSeq I think
02:43tomoj(if a seq at all..)
02:44bfreisBut wouldn't that still have the same problem? A call to drop would just call more many times, reaching the "end" of the cache and causing a new read from the disk.
02:44tomojthe body of the (lazy-seq) is only evaluated when needed
02:44bfreisAn IChunkedSeq? Hmmm, I think that could be worse: it could potentially cause unecessary reads
02:45bfreis(I'm trying to avoid reads because: if I read too little data, it is fast, but many small reads is much much slower than a big read; therefore I'm doing big reads, which are slow, and I'd like to avoid if not needed)
02:45tomojI don't see why, you're already chunking
02:46bfreisYes, but I'm controlling very precisely how I chunk my data
02:46tomojthat's what the IChunkedSeq interface would let you do
02:46tomojmaybe I'm confused
02:46bfreisHmmm, I will take a look at it
02:47bfreisYou said "if a seq at all", do you have another suggestion?
02:47bfreisI like it being a seq because I'm processing it with map, filter, partition-by, etc
02:47tomojI was thinking of reducers
02:47tomojbut I don't think partition-by has been implemented
02:47bfreisreducers? o.O
02:47tomojand might not fit
02:47bfreisWhat is that?
02:48bfreisI don't think I've ever read about it!
02:48tomojhttp://clojure.com/blog/2012/05/08/reducers-a-library-and-model-for-collection-processing.html
02:48tomojhttp://clojure.com/blog/2012/05/15/anatomy-of-reducer.html
02:48tomojwhat are you doing with the seq?
02:49bfreisinteresting! but I'm not sure it fits
02:50bfreisI'm filtering the data, I'm producing derived data by partitioning the original sequence and reducing the partitions
02:50tomojwell
02:50tomojsounds like a good fit for reducers to me
02:50tomojexcept http://dev.clojure.org/jira/browse/CLJ-991
02:50bfreis:)
02:50bfreisdamn
02:51bfreisI see that reducers do things with fork/join
02:51bfreisie, in parallel
02:51tomojthose are called folders
02:51bfreisWould that help? I mean, I'm mostly IO bound
02:51bfreisoh
02:52tomojbut "reducers" I guess can mean "reducers and folders"
02:52bfreisoh, I see
02:52tomoja reducer can be a good fit for IO because (unlike folders) it's a one-shot thing
02:53tomojyou make one reduce call to the reducer you built up with the IO reducer at the bottom, and it can e.g. open a file, make a pass through the data, then close it, then your reduce returns
02:54tomojif you really want a seq, maybe seque could make your impl easier?
02:54bfreishmmm, looks interesting, I will certainly take a look at reducers
02:54bfreisseque? never heard of it!
02:54bfreis,(doc seque)
02:54clojurebot"([s] [n-or-q s]); Creates a queued seq on another (presumably lazy) seq s. The queued seq will produce a concrete seq in the background, and can get up to n items ahead of the consumer. n-or-q can be an integer n buffer size, or an instance of java.util.concurrent BlockingQueue. Note that reading from a seque can block if the reader gets ahead of the producer."
02:55tomojnot sure that helps, but it sounds vaguely similar to what you're doing
02:55bfreisindeed, good to know it exists, but I still think it wouldn't solve everything
02:56bfreisAs I understand it, it would still need to read all the file
02:56tomojyour IndexedSeq has to read all the file, right?
02:57bfreisSo, the reading would either: fill up my memory, or block until I read from que BlockingQueue to free some space
02:57bfreisNot necessarily, depends on how I will process it. Sometimes, yes, I need to fully read the file. Sometimes, no, I just want to drop a lot of data, process some data, drop more data, etc
02:58tomojbut doesn't your drop impl read everything as it goes?
02:58bfreisNo, it would jump right to the position it would need to read
02:59bfreis(note that I'm not using an InputStream to read data, but a memory mapped file)
03:00tomojhow? more only steps through one at a time
03:00bfreisI mean, *if* I could override the default implementation of drop
03:00tomojright, you can't :)
03:00bfreisdamn :)
03:02bfreiswell, I've got only two options left: to provide a (fast-drop [dataseq]) function, or to make my DataSeq even lazier, as I wrote on SO
03:02bfreisbut I'd need to deal with mutable state, which I've never done in clojure
03:02bfreis(actually, I've tried it a bit, but in other contexts)
03:03bfreistomoj, do you know if there's a reason we can't override drop?
03:03bfreisI mean, it is obvious that it can't be overriden, just by looking at core.clj
03:04bfreisBut do you have an idea why this has been implemented that way, and not like (seq), (first), (next), etc?
03:04bfreisIs what I'm looking for *THAT* unusual?
03:04tomojwould you rather there be an IDrop interface?
03:04bfreisExactly!
03:05bfreisJust like there's clojure.lang.Counted, which provides count()
03:09tomojI don't think I can explain why that isn't the case
03:09bfreisThere could be an IDrop interface, then drop (in clojure.core) would call RT.drop, which would check if the instance implements IDrop then call that method, otherwise would fallback to the default implementation that calls more n times
03:09tomojexcept with a slippery slope argument :/
03:09bfreis:P
03:10tomojit looks like IChunkedSeq won't work in place of IndexedSeq either
03:10tomojsince drop isn't chunk-aware
03:10tomojseems like it should be
03:10tomojif it were you could have a chunked seq of counted chunks
03:11bfreisindeed
03:11tomojand drop could just skip over chunks and they'd never be read
03:11bfreisbut the thing is:
03:11bfreisI could have a chunked sequence built from "iterate". In this case, the intermediate, thrown away, elements, might need to be built
03:12bfreisImagine a chunked version of the canonical implementation of fibonacci sequence using iterate
03:12bfreis(or something similar, but in which chunks make more sense)
03:13bfreis(map first (iterate (fn [[a b]] [b (+ a b)] [0 1]))
03:13bfreis(drop 1000000 fibs), that would need to calculate all the dropped fibs
03:14tomojsome chunked seqs might behave that way, but not all
03:14bfreisyes
03:15bfreisThe one that started this discussion would tremendously benefit from drop being chunk-aware
03:17tomojanyway I think reducers would be a good fit, but you'd need to copy the partition-by from the patch above. and defcurried and rfn from clojure probably, since they're private >:[. oh and reducers are only in 1.5.0-alpha4
03:17tomojer, alpha6 is the latest
03:20tomojwell, drop might still be problematic with reducers
03:21tomojyeah, I think r/drop still would force reading everything
03:21bfreis:/
03:22bfreisDo you think Rich would consider adding IDrop, RT.drop and modifying (drop), so that it would be similar to how (count) is implemented?
03:22bfreis*Rick
03:22bfreisRichHickey
03:22bfreisdamn
03:22tomojI would bet $50 he wouldn't
03:23bfreis:P
03:23tomoj(and I make $20K)
03:23bfreislol
03:23tomojbut I think a patch to make drop chunk-aware could happen
03:24bfreishmmmm
03:25bfreisAnd what's the standard way to suggest this?
03:25bfreisIs there any official "wish list"?
03:29brainproxybfreis: the google discussion group
03:30bfreisbrainproxy: thanks!
03:30brainproxynp
04:18amalloyit sounds like bfreis doesn't want to implement a seq, but something that's Indexed and just call nth on it for items he decides he actually wants
04:18bfreisamalloy: I usually do want a seq -- I process the data sequentially
04:19amalloyno you don't. you skip over it with drop
04:20bfreissorry, amalloy, it is not you who is processing the data, it is me.
04:20bfreisTrust me: I'm telling you I process the data as a whole some times, and parts of it other times.
04:21bfreisI experimented with nth, but opening a file, reading 3 bytes and closing it becomes very slow when you need more than a few entries -- especially if I need sequential entries, which, again, believe me, is what I need.
04:22bfreis(and to be clear, when I say "parts of it" I mean: long runs of sequential data, not necessarily in the beginning of the file)
04:25bfreisSeriously, I hate when people act as they know what I'm doing more then I know what I'm doing.
04:38samratI need to store username/password in a Noir session. What is the most secure way to do this?
04:38samratjust to be clear, the password is for another application's APi
04:41bfreissamrat: the decision on how to store that credentials depends on what you are trying to protect from.
04:42bfreisFor instance, you could have a hardcoded "master key" to encrypt the credentials, and store that in a database. Then you read and decrypt it whenever you need.
04:42bfreisThat way, if someone hacks into your database, the password won't be readable.
04:42bfreisHowever, if they have access to the source code (or the compiled code as well), they can obtain the master password.
04:43bfreisYou could store that master key it into a file, but again, if they have access to the file, security is gone.
04:44bfreisYou could have your application ask for the password at startup, so it would only be stored on your head. But I doubt you would like to type it everytime you launch your application
04:44bfreis(and, to be clear, there's still the possibility to read the password from memory)
04:45bfreisAnyways, the decision depends on what you are trying to protect from.
04:46samratbfreis: I'd like to have a hardcoded master key, what are my options?
04:47samratnoir does provide noir.util.crypt but that just provides an option to compare against a raw password, and not fully decrypt it
04:47bfreissamrat: (def master-key "my-m4st3r-k3y")
04:47bfreisoh, I don't know noir.util.crypt
04:47bfreisI'm talking about general approachs to this kind of problem
04:47samratbfreis: ok
04:48samratdo tell about the general approach
04:49bfreisAnother option is to have a different key per user: you generate a random key and store it along with the user information. But again, if this key is stolen, the encryption is useless.
04:49bfreisYou could encrypt the passwords with a combination of a master-key (either hardcoded, or typed on startup) and this random key.
04:50bfreisYou could also avoid saving this user-key by deriving the key from the user data.
04:50samratbfreis: any recommendations on encrypting libraries?
04:50bfreisWell, you have tons of options there, the decision really depends on the threats.
04:50bfreissamrat: javax.crypto already has a lot of useful classes
04:51bfreissamrat: if you need something else which is not provided in the standard distribution (for instance, GCM), you could try BouncyCastle
04:53bfreishttp://www.bouncycastle.org/java.html\
04:53bfreishttp://www.bouncycastle.org/java.html
04:53bfreisBut usually javax.crypto is enough
04:55samratbfreis: is javax.crypto included in the standard distribution?
04:56bfreissamrat: yes
04:57bfreisIn the book Programming Clojure, the authors use it to create a "crypto vault"
04:57bfreissomeone published a lib based on that: https://github.com/midpeter444/crypto-vault
05:02samratbfreis: I think I'll try using this https://github.com/macourtney/clj-crypto. crypto-vault seems to be specific to file encrypting
05:03bfreisDidn't know clj-crypto, looks interesting.
05:04bfreisIt is a wrapper around on javax.crypto, using the BouncyCastle provider (I don't know why, apparently it could use the standard, built-in JCE) -- but I might have missed something
05:05samratbfreis: I'll try it... but there's absolutely no docs, so might be a pain
05:07bfreisOh
05:07bfreisbe careful, though
05:07bfreisYou will be doing symmetric encryption for this
05:08bfreisAnd that library uses DES as the standard algorithm
05:08bfreisBut DES is considered very insecure nowadays
05:10bfreisFurthermore, he doesn't specify the mode and padding, therefore it should be DES/ECB/PCKS5Padding, which means: it is weak.
05:11samratbfreis: yeah... I think it breaks with 1.4 or something, not working for me(it depends on 1.2)
05:12samratany other wrappers for javax.crypto? I don't want to have to deal with java
05:14bfreisSorry, I don't know. I haven't done much crypto in clojure, and when I did, I just used javax.crypto.
05:34bfreistomoj: just posted the version of DataSeq using a mutable local cache updated by first to stop drop from reading from the disk!
05:34bfreishttp://stackoverflow.com/a/12871794/150339
05:40samrathow do I find the data type of something in clojurescript? (class ...) doesn't seem to work
05:48bfreissamrat: it looks like you'd profit from reading this http://blogs.msdn.com/b/ericlippert/archive/2011/09/27/keep-it-secret-keep-it-safe.aspx
05:48bfreis(I just came across that article and thought about what you are trying to do)
05:49bfreisit is a little bit long, but worth the time, from Eric Lipert
05:54samratbfreis: thanks, will go through it
08:26uvtc,(apply + 1 2 3)
08:26clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
08:26uvtc,(apply + 1 2 3 nil)
08:26clojurebot6
08:26uvtcWhy does that second one work?
08:26uvtcThere's still no seq to unpack (the contents of which `+` is applied to).
08:34terom,(apply + 1 2 3 '())
08:34clojurebot6
08:35ssiderishello. In clojurescript, do we throw exceptions as normal?
08:35ssiderisI guess one has to stick to the Exception class
08:36ssiderisbecause IllegalArgumentException does not exist
08:36ssideriscorrect?
08:36andrewmcveighuvtc: because apply calls 'seq', and (seq nil) => nil ?
08:36andrewmcveigh,(seq nil)
08:36clojurebotnil
08:37teromuvtc: only the last arg to apply should be a seq, other args before it are "added" to that seq: http://clojuredocs.org/clojure_core/clojure.core/apply#example_520
08:38uvtcterom: right, I understand that. But I was under the impression that the last arg must be a coll.
08:39AdmiralBumbleBeeuvtc: as far as I understand it, nil can be used anywhere a collection can (with obvious exceptions)
08:39AdmiralBumbleBee,(concat [1 2 3] nil)
08:39clojurebot(1 2 3)
08:39uvtcIn the source for `apply`, I see that call to `list*`.
08:40uvtc,(list* 1 nil)
08:40clojurebot(1)
08:40uvtcSo, that's it I suppose.
08:41uvtc...since `list*` calls `cons`, and `cons` seems happy to cons onto `nil`.
08:41uvtc,(cons 1 [1 2 3])
08:41clojurebot(1 1 2 3)
08:41uvtc,(cons 1 nil)
08:41clojurebot(1)
08:42uvtcAdmiralBumbleBee: That sounds odd. If it's the case, I wonder why that is.
08:44AdmiralBumbleBeeuvtc: I'm not sure why at all, but I noticed it and so I tried lots of permutations of it and it seems to be practically correct… if not technically correct
09:13nonrecursiveI'm trying to use weavejester's ragtime library but I keep getting this error: Exception in thread "main" java.lang.RuntimeException: java.lang.NoClassDefFoundError: clojure/lang/ILookupHost
09:13nonrecursivehas anyone seen that? know how to fix it?
09:23wtingHi, can someone explain how this returns the last element of a list? reduce #(-> %2)
09:25babilenwting: It always returns the second argument to the function that is reduced with. That argument is the current element (the first is the accumulator/result) to which "f" is applied
09:26babilenwting: I would use (last coll) though ;)
09:27wtingbabilen: Thanks, doing 4clojure koans and last isn't allowed. :p
09:27wtingThe goal was to recreate last.
09:27babilenwting: Ah, sure. In that case: Have fun!
09:28nonrecursiveHow would I modify my project's dependencies so that I can debug an issue? For example, I'm using ragtime and would like to throw some println statements in it, but I don't know where the code is actually located
09:29babilennonrecursive: You mean "throw some println statements [into ragtime]" ?
09:30nonrecursiveyeah
09:30nonrecursiveexactly :)
09:32babilennonrecursive: If you use leiningen 1 you'll find dependencies in PROJECT/lib and if you use leiningen 2 you would find it in ~/.m2/repository/ -- You cannot edit those directly though. I would personalyl recommend to just get hold of ragtime, make your changes and "install" it with "lein install" to ~/.m2/ (if you use lein2)
09:32babilennonrecursive: That assumes that ragtime doesn't provide any debug/loggin facilities itself that you can enable (e.g. by setting a dynamic variable somewhere in its namespace)
09:32nonrecursivebabilen: thanks, that helps a lot. I'm using leiningen 2 - I'll try what you described
09:33babilennonrecursive: ragtime is probably on github ... create a new local branch (e.g. dev/debug or whatev) so you can hack away. You might even want to change the version so you don't (by mistake) pick up the original.
09:34nonrecursivebabilen: yeah it's on github - thanks for the tips
11:35tickingI was wondering what is the best way to append elements to a seq?
11:37dnolenticking: concat, which is lazy.
11:37dnolen,(concat '(1 2 3) '(4 5 6))
11:37clojurebot(1 2 3 4 5 ...)
11:44tickingdnolen, thanks :) still kinda meh that one has to wrap the value first ;)
11:45ddeaguiarticking: use cons if appending single value? Though that won't return a lazy seq.
11:46dnolenddeaguiar: cons on a seq will add to the front
11:46tickingddeaguiar, and conj will add to the front or back depending on the collection type
11:46ddeaguiardnolen: ah yes,
11:46ticking(which drove me almost mad during debugging)
11:46dnolenticking: or something else entirely.
11:46tickingdnolen, right ^^
11:47dnolenticking: since you conj on a set or a hash map too
11:49tickingthanks and see you :D
12:34Bronsahttps://github.com/Bronsa/blind a complete clojure reader implemented in clojure
12:34Bronsabased on clojure's implementation and clojurescript's
13:14lynaghkping: alex_baranosky
13:15alex_baranoskypong: lynaghk
13:15alex_baranosky:)
13:16lynaghkalex_baranosky: have any tips on how to speed up midje? I'm using 1.4.0 under lein2 with the lein-midje 2.0.0-SNAPSHOT
13:16lynaghkalex_baranosky: I'm getting the sense that it loads every dep in every namespace rather than just what's required by stuff in the test/ dir
13:17alex_baranoskyspeed up Midje on a per assertion basis?
13:17lynaghkalex_baranosky: nah, just the startup. I just threw it into this project and have two assertions
13:17alex_baranoskyor speed up the load time?
13:18alex_baranoskyyour sense is correct: https://github.com/marick/lein-midje/blob/master/src/leiningen/midje.clj#L119
13:19alex_baranoskythe reason is, I think, that some users put assertions in their source???
13:19lazybotalex_baranosky: How could that be wrong?
13:19lynaghkalex_baranosky: okay, fair enough. I'll look into the lazytest solution then---is that still what's what? Sierra's project looks very unmaintained
13:20alex_baranoskythe issue could be resolved by adding a option to only load the test-path
13:21alex_baranoskylynaghk: regarding lazy test…. not sure what's going on with that . I don't use it myself
13:21lynaghkalex_baranosky: you just run "lein midje" manually?
13:22alex_baranoskylynaghk: there's a midge mode that could probably help your situation too
13:22lynaghkalex_baranosky: yeah, I was thinking maybe I'd just primarily run tests from within emacs/swank
13:23lynaghkalex_baranosky: thanks for the info!
13:24alex_baranoskylynaghk: yeah try that, and if it doesn't work out, a pull request to lein-midje to narrow the namespaces loaded could be good
13:24lynaghkalex_baranosky: okay, can do.
13:26alex_baranoskylynaghk: it also looks like if you specify a namespace wilcdcard you'll avoid the issue
13:26alex_baranoskylynaghk: try this `lein midje my.project.test.*` (see: https://github.com/marick/lein-midje/blob/master/src/leiningen/midje.clj#L133)
13:27Bronsahttp://sprunge.us/KXEe?clj is this expected behaviour or is it a bug?
13:28lynaghkalex_baranosky: yeah, that's the first thing I tried but it didn't pick up my test
13:28lynaghkalex_baranosky: test is in /test/ccplot/t_compile.clj; namespace is ccplot.t-compile
13:28alex_baranoskylynaghk: dang. I wonder if there's a bug in it. The lein-midje stuff isn't tested (which I hate)
13:28lynaghkalex_baranosky: running "lein midje ccplot.*" doesn't find any facts
13:29alex_baranoskywhat about `lein midje ccplot.t_compile` ?
13:30lynaghkalex_baranosky: yep, that works
13:31alex_baranoskylynaghk: ….. so something's a-rye with the wildcard code
13:32alex_baranoskylynaghk: it should be getting the namespace-on-classpath, using multitude. (https://github.com/marick/lein-midje/blob/master/src/leiningen/midje.clj#L88)
13:32alex_baranoskyok have to go. Let me know if you have any more questions. Take it easy.
13:32lynaghkalex_baranosky: okay. thanks
13:33lynaghkalex_baranosky: I'll open a ticket.
13:33alex_baranoskylynaghk: oh, and any fixes or improvements are welcome
13:50@rhickeydraft of the results from yesterday's cond-> discussion: https://gist.github.com/3885504
14:54zerokarmaleftrhickey: in let->, expr and forms needs to match ~init and steps
15:07tgoossensif i have two lists. Is there a "built-in" way to check if those two lists have overlapping elements?
15:09eggheadtgoossens: if they are sets you can use intersection
15:09frozenlockIf you don't mind using sets, there's quite a few interesting functions.
15:09frozenlockAww
15:09tgoossensthey are sets. But i'm also interested in the "general" way for a list
15:11frozenlockI was sure that 'if' would not evalutate before it needed to, but I have an 'if' function that lookups in a database even if it only needs to go to the else statement.
15:11frozenlockHow can I avoid evaluation?
15:12ChongLiyou can't do it with a function
15:13ChongLiyou need a macro
15:13egghead(if true (println true) (println false)) <-- in that you're saying the 'println false' is evaluating?
15:13frozenlockyeah
15:14frozenlockMore precisely: (if login (query-database-for-stuff) (print-some-msg))
15:14frozenlockAnd in my case even if login is false, the database is queried. (and throws an error)
15:16eggheadweird, according to the clojure docs if shouldn't evaluate the "then" form if the value of the test is falsy
15:18frozenlockThat was my original impression too.
15:19eggheadalso tgoossens you can filter down any one list by whether or not each member is within the other list using filter and contains? -- probably not super effecient tho :p
15:20ChongLihe's talking about an 'if' function
15:20eggheaderr wait
15:20raekfrozenlock: are you sure 'login' really is false?
15:20ChongLithat presumably he wrote
15:20eggheadcontains wouldn't work
15:20ChongLithe real 'if' is not a function
15:21@rhickeyzerokarmaleft: thanks, hasty rename before gifting - fixed
15:21@rhickeygisting
15:21frozenlockraek: I am, I've hardwritten false in it. Let me try to get a minimum working example...
15:23KaOSoFtrhickey, sorry to hijack, but any reason there a “reduce1” function? Sorry, I’m new to Clojure, but found it weird to find a “reduce1” function inside +, -, etc.
15:24KaOSoFtthere is*
15:25ChongLiit's used internally before protocols are up and running
15:25@rhickeyKaOSoFt: reduce gets redefined mid bootstrap
15:27frozenlockDamnit. I'm such an idiot.
15:27frozenlockLet see if you can see it too :P https://www.refheap.com/paste/5826
15:28frozenlockChongLi: I will probably have to make a macro as you suggested
15:30CubicWhy is [] true and (seq []) false? I find this somewhat confusing.
15:31ChongLieverything is true except nil or false
15:31ChongLiseq returns false
15:32Cubic,(println (seq []))
15:32clojurebotnil
15:32ChongLiah yeah
15:32CubicOh. Well that makes sense
15:32ChongLianyway, it makes easier to use it as part of a control structure for operation on seqables
15:33Cubic,(for [x nil] true)
15:33clojurebot()
15:53tgoossensegghead: thanks
16:50yedi /join #economics
17:02wingyhi
17:03wingyhow do you create mobile and tablet apps?
17:06CubicFor what mobile and for what tablets?
17:07wingyall of them
17:08CubicThen deploy it as a web application
17:09wingyCubic: i mean you do YOU do
17:09wingyi know there are different solutions
17:10wingypart of me things that native apps is an evolution and we will move away from HTML as native apps
17:10wingythinks
17:10Cubicwingy: Isn't it pretty much the other way round?
17:11wingyafter doing some research i found that native apps are really much more mature than html5 .. we always find a lot of inconsistencies using html5
17:11wingyall those frameworks abstracting away the bad parts
17:11wingyperhaps the foundation is wrong? just like mutable states
17:12wingyreminds me about why we love OOP .. since it hides the complexity
17:12Cubicwingy: I don't understand your problem
17:12AdmiralBumbleBeehis problem is that he talks in here about this stuff rather than #programming
17:13wingyit was on purpose since i wanted to know how clojure people do it .. here people tend to focus on simplicity
17:13Cubicwingy: So your question isn't about Clojure then?
17:14wingyyou could say it is if you look at it from a higher perspective where clojure is part of it
17:14SgeoAlways writing native apps means needing to write several times for each platform
17:14SgeoEven things like Java are abstracting away the annoyances of writing code for multiple platforms
17:15SgeoAnd a lot of the reason for inconsistencies with HTML5 is that not everything supports it yet
17:15SgeoWell, at least some of the reason
17:15clojurebotthe reason to use the immutable types is that it saves you from all that stuff; if you don't use them you don't get the benefit.
17:16CubicWhat's wrong with clojurebot?
17:18wingySgeo: you have a point
17:18SgeoI wouldn't say that HTML5 is in fact "good", but relative to the alternative of developing native apps for everything...
17:19wingySgeo: there is a point in whaty ou way
17:19wingysay
17:20wingythat would be like developing for different platforms on server side
17:26antares_ivan: are you gsnewmark on github?
17:26TimMcCubic: clojurebot treats random messages as being addressed to it.
17:26antares_man, the progress on CDS makes me all warn and fuzzy inside
17:27antares_in just a week we have like more than half of the guides in decent shape
17:27antares_and a dozen of contributors
17:36oichDo I simply ignore the throws clause of interfaces/classes when creating a proxy? Or, how does one specify a throws clause?
17:36antares_oich: Clojure compiler ignores checked exceptions
17:38oichthanks
17:47Raynesantares_: ping
17:48antares_Raynes: pong
17:49Raynesantares_: The Emacs tutorial on clojure-doc.org uses lein-clojars. If I want to point that out but not fix it right now myself, should I open an issue?
17:50RaynesI'm also a little bugged that it focuses on SLIME instead of nrepl.el just because of clojure-test-mode, but to a lesser extent.
17:50antares_Raynes: yes, please. Just mention why you think it is a bad idea and what's a better way.
17:50antares_Raynes: nrepl.el does not support clojure-test-mode
17:50antares_that's discussed in the pull request, take a look
17:50antares_well, that's exactly why I still use SLIME, for example
17:51RaynesI guess I don't know what clojure-test-mode is.
17:51antares_when you hit C-c C-, in a test namespace and it runs your tests instantly
17:52RaynesI'm tempted to think most new users aren't going to care either and would rather have something more future-proof than SLIME. Especially common lisp users who would almost certainly rather trade clojure-test-mode for keeping their SLIME installation working for CL.
17:52antares_Raynes: it very much depends on their background
17:52antares_Raynes: what % of people come from CL vs Ruby?
17:52antares_Ruby developers coming to clojure will certainly ask "how do I run tests quickly without JVM restarts"
17:52RaynesI'd be more interested in what percentage actually use clojure-test-mode though.
17:53antares_Raynes: almost every person coming from Ruby, I think
17:53RaynesI find that hard to believe.
17:54antares_people who don't use clojure-test-mode typically don't know about it
17:54RaynesAnyways, I'm not going to argue against it. I just hope people get clojure-test-mode going with nrepl fast, because I die a little inside every time we recommend SLIME to a new user.
17:54antares_because nothing in the Clojure ecosystem is documented for noobs or visible
17:54RaynesNobody likes providing support for that crap.
17:54antares_me and Gareth hope so too :)
18:01antares_Raynes: please do file issues for everything you don't like on CDS. I absolutely do not think that what we have right now is great.
18:02antares_Raynes: also, we need a new ground for arguing
18:02RaynesHah
18:02AdmiralBumbleBeewait, is CDS meant to be general documentation?
18:02RaynesYeah, I figure the clojure-test-mode stuff is too subjective to make an issue for.
18:03AdmiralBumbleBeeor is it an introduction to clojure for a certain population of people
18:03RaynesIt's an easy fix -- someone just needs to care enough to make clojure-test-mode work with nrepl.
18:06antares_AdmiralBumbleBee: it is primarily for newcomers but yes, it will cover most or even all expertise levels
18:06antares_and not just the language
18:06antares_there is value in simply centralizing and maintaining docs in one place
18:08AdmiralBumbleBeeantares_: I'm somewhat perplexed why you'd consider someone's background when writing documentation. Certainly there's some pre-requisite knowledge required
18:08AdmiralBumbleBeebut I would think that well written documentation would not need to cater to someone who knew python v ruby v C v CL etc..
18:09AdmiralBumbleBeeI do understand that there's a place for such targeted information, but in context of emacs+clojure it sounds weird to me for that to be a consideration
18:10antares_AdmiralBumbleBee: well, you develop using some kind of tools, right?
18:10AdmiralBumbleBeeof course
18:10antares_Emacs is a popular choice when it comes to Clojure
18:10AdmiralBumbleBeeyes, and I'm an emacs user for a long time
18:12AdmiralBumbleBeeantares_: I'm just a bit perplexed as to why a reader's background should be considered when writing general documentation
18:13antares_AdmiralBumbleBee: not sure I am following
18:13antares_you cannot please everybody with a single approach to docs
18:13AdmiralBumbleBeeok, I'm probably explaining myself badly
18:13antares_but that's why we are grouping things into Tutorials, Language Guides, Ecosystem and Cookbooks
18:15AdmiralBumbleBeeantares_: I think lust I'm sensitive to you bringing up what a Ruby user would want to see in documentation :) I've brought that up before, so I'm restating myself I suppose.
18:15AdmiralBumbleBeejust*
18:15Raynesantares_: I think he is referring to your response to my questions regarding clojure-test-mode that indicated a believe that everyone from Ruby uses it and most people probably come from Ruby so /thread. :p
18:15Raynesbelief*
18:21oichcan you invoke more than one constructor with proxy, i.e. the class a proxy is proxying for has more than one constructor
18:23yedianyone have suggestions for a great clojure dev environment on osx?
18:23AdmiralBumbleBeeyedi: emacs
18:23lpvbor CCW
18:23antares_Raynes: everybody who comes from Ruby will expect it, that's what I really mean
18:23antares_Raynes: and The State of survey suggests a good third of people come from ruby or python
18:24antares_yedi: Emacs, Vim, Eclipse and IDEA are all pretty good
18:24lpvbvim doesn't have autocomplete :(
18:25AdmiralBumbleBeevim is a pain to setup on OS X in my experience
18:25AdmiralBumbleBeefor clojure ^
18:28oichto answer my question about multiple constructors, I think I can't use proxy and have to use gen-class
18:30JonasH_AdmiralBumbleBee: true, I'm was just trying to get VimClojure working
18:30JonasH_only semisuccessful so far
18:31JonasH_can't get the key mappings to work
18:31AdmiralBumbleBeeCCW or emacs can be setup on os x in about 3-4 minutes on a standard OS X install
18:31AdmiralBumbleBeevimclojure… eh :)
18:31SgeoWhat's this about Ruby?
18:31SgeoI've had some interest in it, but I could never shake the impression that, if I'm using Ruby, I should really be using Smalltalk instead
18:32AdmiralBumbleBeeSgeo: not talking about ruby… talking about documentation
18:37ivaraasenstrange, clojure-doc.org doesn't seem to be working here
18:44aperiodici'm using vim for clojure on os x w/slimv and bits of vimclojure
18:44aperiodichad a few stumbles setting it up, but works great now
18:44aperiodici've also heard good things about vimclojure + lein-tarsier to handle the nailgun stuff
18:58antares_ivaraasen: can you ping and dig it? where you located?
19:10ivaraasenantares_: getting req timeouts. situated in Norway
19:11antares_ivaraasen: surprising, it is hosted in Germany
19:11antares_ivaraasen: for dig, too?
19:11antares_(ping's ICMP packets may be filtered out, actually)
19:15ivaraasenantares_: gives me back 5.9.20.53 as the IP address.
19:15antares_ivaraasen: that's the correct answer
19:15antares_ivaraasen: try traceroute-ing that IP?
19:16ivaraasenno route to host
19:16ivaraasenthis is extremely weird
19:16antares_ok, something must be up with one of the routing tables between your ISP and the hoster I use
19:17ivaraasenmy ISP is notorious for screwing things up, so you're probably correct
19:18ivaraasenI'll give them a call tomorrow to see what's up
19:21UrthwhyteAny recommendations for a CSV processing lib?
19:23amalloyoich: proxy doesn't create a named class, it creates an instance of an anonymous class. you can only ever call one constructor at a time, so why would there be two?
19:29frozenlo`Urthwhyte: clojure-csv? :p
19:31Urthwhytefrozenlo`: Thanks :) I've spent enough time dealing with horrible ruby/python libraries that happened to rank well for search terms that I usually ask first now :)
19:43mint`hello :) question: I just ran lein for the first time on a live linux installation (which supports persistence) and jack-in is not an available task. what should i do differently?
19:43technomancymint`: you need the lein-swank plugin
19:43technomancyor nrepl.el
19:43mint`ah
19:47mint`technomancy: what do i need to do after i install the nrepl emacs package?
19:48technomancyM-x nrepl-jack-in should do it
19:49mint`cool thanks!
20:06tickinglol, I wanted to implement partition-between, which is similar to partition-by but allows for arbitrary splits instead for value changes, turns out my slightly optimized implementation can do more than partition-by and is still faster
20:14amalloyticking: https://github.com/flatland/useful/blob/develop/src/useful/seq.clj#L222
20:15tickingamalloy ah cool, I asked a few days ago nobody pointed me to that :D I be mine is till faster though ;] I'll do a benchmark
20:16amalloy*shrug* it probably is. i don't see that it matters much either way
20:16AdmiralBumbleBeeamalloy: what is this magic!? this need to be in core
20:16AdmiralBumbleBeeeverything here
20:16tickingamalloy, yeah but for core functions speed is significant
20:31SgeoShould I rely on two different (Object.)s not being = in my programs?
20:32SgeoCome to think of it, I could probably just use a symbol
20:32technomancyyeah, gensym is usually nicer IMO
20:33amalloyi usually use (Object.)
20:33SgeoGood point, but I don't even need a unique object, not sure why I thought I did
20:48tickingso if anybody is interested, suggestions are welcome :)
20:48tickinghttps://gist.github.com/3886665
20:49clj_newb_234dumb question ... in clojre, how do I turn an character to a integer? i.e. \a -> 65
20:49tickingclj_newb_234 int
20:49clj_newb_234, (int \a)
20:49clojurebot97
20:49clj_newb_234, (int \A)
20:49clojurebot65
20:50clj_newb_234ah, cool; thanks :-)
20:50tickingnp :)
20:57Sgeo,(char 65)
20:57clojurebot\A
20:58clj_newb_234is ther a clojure builtin (extract-hashmap hashmap keys) <-- it takes hashmap, but only the [k v ] pairs where k \in keys ?
20:59Sgeo,(for [i (range 1000) :when (not= ((comp int char) i) i)] i)
20:59clojurebot()
20:59SgeoHmm, should probably have written that in terms of maps and filters
20:59Sgeomeh
21:00uvtcBut how do you turn a one-character string into a char? I see that this ##(first (seq "a")) works ...
21:00lazybot⇒ \a
21:00Sgeo,(.charAt "a" 0)
21:00clojurebot\a
21:01Sgeo,(first "a")
21:01clojurebot\a
21:01Sgeo,(nth "a" 0)
21:01clojurebot\a
21:01uvtcOh, of course, Sgeo. Right. :)
21:01Sgeo,("a" 0)]
21:01clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn>
21:01uvtc,(last "a")
21:01clojurebot\a
21:01Sgeo,(get "a" 0)
21:01clojurebot\a
21:01Sgeo,(get "a" 1 :oops)
21:01clojurebot:oops
21:02Sgeo,(get "a" 1)
21:02clojurebotnil
21:02uvtcI'd figured that `char` would do it, but `char` only takes an int.
21:02Sgeo,(nth "a" 1)
21:02clojurebot#<StringIndexOutOfBoundsException java.lang.StringIndexOutOfBoundsException: String index out of range: 1>
21:02Sgeo,(nth "a" 1 :oops)
21:02clojurebot:oops
21:02SgeoHrm.
21:02Sgeo,(nth {:a 1} :a)
21:02clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.lang.Number>
21:02AtKaaZhow do you turn a string into a list of chars?
21:03uvtc,(seq "hello")
21:03clojurebot(\h \e \l \l \o)
21:03AtKaaZlol i was afraid of that, thanks
21:03Sgeo,((comp type seq) "hello")
21:03clojurebotclojure.lang.StringSeq
21:03Sgeo,((comp class seq) "hello")
21:03clojurebotclojure.lang.StringSeq
21:03AtKaaZI remember hickey saying strings are sequences
21:03AdmiralBumbleBeeafraid of that?
21:04AtKaaZnot afraid, but more like guessing/hoping
21:04AdmiralBumbleBeeah
21:05Sgeo,(((partial partial apply) concat) [[1 2 3] [4 5 6]])
21:05clojurebot(1 2 3 4 5 ...)
21:06AdmiralBumbleBeeSgeo: ?
21:06uvtcHe's partial to `partial`.
21:07uvtc(er, sorry -- just guessed gender there, Sgeo)
21:08AdmiralBumbleBeeuvtc: maybe just as insulting to say you couldn't tell he was male ;)
21:08AdmiralBumbleBee(assuming 'he' is of course… heh)
21:08AdmiralBumbleBeequick, we need a gender abstraction!
21:08xeqithey
21:09uvtcs/he is in the `s` namespace...
21:09Sgeoe
21:09amalloySgeo: type is mostly obsolete now
21:09amalloy(the clojure function, not the concept, of course)
21:09SgeoI'm partial to Spivak pronouns, because nomics tend to use them a lot, and I grew up interested in nomic
21:10SgeoI am a guy
21:10uvtcamalloy: do you mean the concept of "type", or the function `type`? Or both?
21:10uvtcamalloy: and if either, why is it (or they) obsolete?
21:10amalloyuvtc: BAM! ninja'd
21:11Sgeo(partial apply blah) returns a version of blah that accepts a seq instead of a variable number of arguments
21:11amalloy<amalloy> (the clojure function, not the concept, of course)
21:11SgeoSo, if I want a general function to turn functions that accept varargs into functions that accept seqs, I want (partial partial apply)
21:11uvtcamalloy: why is the Clojure function `type` mostly obselete?
21:12Sgeoamalloy, am I insane for liking partial partial stuff?
21:12amalloyit's a holdover from the days before deftype and defrecord, when the only way to introduce new types was the convention of putting :type :mytype in the metadata of your object
21:13amalloySgeo: no, i like partial partial apply myself. i had convinced ninjudd to add it to useful but then he changed his mind
21:13Sgeo,(type ^{:type :foobar} 5)
21:13clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Metadata can only be applied to IMetas>
21:13amalloy(def ap (partial partial apply)) (map (ap concat) coll)
21:13uvtcamalloy: thanks!
21:13Sgeo,(type ^{:type :foobar} 'foo)
21:13clojurebotclojure.lang.Symbol
21:14amalloy,(type (with-meta 'foo {:type :foobar}))
21:14clojurebot:foobar
21:14Bronsawow
21:14amalloy,(type '^{:type :foobar} foo)
21:14clojurebot:foobar
21:15SgeoWait, what's with the '^
21:16uvtcamalloy: Heh, I see. Missed your comment ("ninja comment"). :)
21:16BronsaI'm guessing the reader that way is quoting the symbol foo after metadata has been attached to it
21:16Bronsawhether using ^{}' the metadata is being attached to the form (quote ..)
21:16amalloyindeed, Bronsa
21:31AtKaaZwhat should I look into if I wanted to read/process binary files into structs or something like that ?
21:33AtKaaZthis seems to be it right? https://github.com/ztellman/gloss/wiki/Introduction
21:33amalloyyes
22:27AtKaaZCompilerException java.lang.RuntimeException: Unable to resolve symbol:  in this context, compiling:(quil/core.clj:1)
22:28AtKaaZhow can I track down what's happening?
22:31AtKaaZthis is the file: https://github.com/quil/quil/blob/master/src/quil/core.clj
22:34AtKaaZ,(seq "  ")
22:34clojurebot(\space \ \space)
22:34AtKaaZ,(seq " ")
22:34clojurebot(\space \)
22:35AtKaaZ,,(int \)
22:35clojurebot65279
22:37AtKaaZwow seriously, this is how that file begins: (ns
22:41antares_AtKaaZ: this is UTF-8 BOM
22:42antares_most likely that file was saved from a weirdly configured editor, possibly on Windows
22:42AtKaaZthat makes sense, but still not even github diff can show that char
22:43AtKaaZlook how it (doesn't look: https://github.com/quil/quil/commit/d0312f0f119db066a8d613dec8803571b92bea39
22:43AtKaaZ:)
22:44AtKaaZmy concern is how to prevent that in the future?
23:25ChongLiok I'm really confused
23:25ChongLiI have 2 different projects
23:25ChongLiwith nearly identical project.clj
23:25ChongLi(same dependencies)
23:26ChongLione of them can import a class at the repl
23:26ChongLiand the other gets UnsatisfiedLinkError
23:26ChongLi> (import org.lwjgl.opengl.Display)
23:26ChongLiorg.lwjgl.opengl.Display
23:27ChongLi> (import org.lwjgl.opengl.Display)
23:27ChongLiUnsatisfiedLinkError no lwjgl in java.library.path...
23:33ChongLiwhen I print the classpath for both with (pprint (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader)))
23:33ChongLiit is virtually identical between the two (only the local project stuff differs)
23:41ChongLiahh, hmm
23:41ChongLitarget is different (native stuff in one but not the other)