#clojure logs

2011-06-28

02:30ebaxtHi, I'm currently working on my first real clojure project, and I find myself wanting a mocking tool. So I was wondering what you are using? I tried googling, but I can't seem to find the "Mockito of the clojure world" :)
02:32raekebaxt: https://github.com/marick/Midje is built for top-down TDD
02:33raekhaven't used Mockito, so dunno if this is what you are really looking for
02:38ebaxtraek: Thanks. Mockito has sort of turned into the "next generation" mocking fwk for Java (JMock being first generation), and since the adoption is huge there is little risk of it being abandoned by it's maintainers.
02:39ebaxtraek: Searching for a mocking tool in Clojure it looks like there is a lot of small tools being thrown together, but maybe not being used by many. But would you say Midje is a safe bet in that regard?
02:43raekebaxt: I don't have much experience with the mocking tools, so I don't know...
02:43raekebaxt: also consider asking this on the google group
02:44ebaxtraek: Sure, I'll do that as well
04:24Cozeyis it possible to use swank-cdt to break on ring middleware ? Usually the actual function called is a closure returned by some wrap-*
05:18bsteuber,(:foo :bar)
05:18clojurebotnil
05:19bsteuberI expected this throws an exception
05:20Fossiwhy should it?
05:20Fossiclojure rarely throws exceptions
05:20Fossiand :foo is just an accessor
05:21Fossiit can't find :foo in :bar, so...
05:21Fossi,(:foo {})
05:21clojurebotnil
05:21Fossisame really
05:56lnostdal-laptophi guys; (refer 'clojure.core :exclude '(resultset-seq)) works .. but (use 'clojure.core :exclude '(resultset-seq)) states "unsupported option :exclude"
05:56lnostdal-laptopthough, IIUC, the docs for USE state that i can use :exclude as done for REFER
06:00terom(use '[clojure.core :exclude (resultset-seq)])
06:00lnostdal-laptop..but whyyyy? ... heh :}
06:01teromuse behaves likes require, which takes a libspec which is a vector
06:01teromrefer on the other hand does not
06:02lnostdal-laptopok, thanks
06:02lnostdal-laptop:)
06:02lnostdal-laptopthe docs should state these things btw.
06:08teromwell, (doc require) states that, but the docs does not have very many examples
06:09teromthis could be helpful: http://blog.8thlight.com/articles/2010/12/6/clojure-libs-and-namespaces-require-use-import-and-ns
07:59khaliG(foo 20 [10 20 30]) -> [10 30] .. is there such a foo?
08:01TobiasRaederwell
08:01TobiasRaeder&(remove #(= % 20) [10 20 30])
08:01sexpbot⟹ (10 30)
08:01TobiasRaedershould do the trick
08:01TobiasRaeder;)
08:01TobiasRaederremove is pretty much a inverse filter
08:02jcromartie,(remove #{20} [10 20 30])
08:02clojurebot(10 30)
08:02khaliGthanks :)
08:03TobiasRaeder(defn remove
08:03TobiasRaeder "Returns a lazy sequence of the items in coll for which
08:03TobiasRaeder (pred item) returns false. pred must be free of side-effects."
08:03TobiasRaeder {:added "1.0"
08:03TobiasRaeder :static true}
08:03TobiasRaeder [pred coll]
08:03TobiasRaeder (filter (complement pred) coll))
08:03TobiasRaederso yeah it is exactly the same
09:04jcromartieI find it odd when the clojure docs say "_ must be free of side effects"
09:05jcromartiethat's never really true
09:07gfrlog`jcromartie: why not?
09:07jcromartie,(doc filter)
09:07clojurebot"([pred coll]); Returns a lazy sequence of the items in coll for which (pred item) returns true. pred must be free of side-effects."
09:08jcromartieif pred has side-effects, filter will go right along its merry way
09:08gfrlog`jcromartie: ooh, I thought you meant that all functions have side effects
09:08jcromartie,(filter print [1 2 3])
09:08clojurebot123
09:08clojurebot()
09:08jcromartiethe world didn't end
09:08gfrlog`jcromartie: maybe there are edge cases where something is repeated
09:08jcromartiedefinitely
09:09gfrlog`jcromartie: so wouldn't that justify the clause?
09:09jcromartiebut I just find the language "must" to imply "otherwise it won't work"
09:09gfrlog`yeah...I guess "should" might be clearer.
09:11clgvwell, it's written as condition for guaranteed functionality so "must" is alright ;)
09:12gfrlog`it's unnecesarily restrictive
09:12gfrlog`it could also say that the function must return a boolean
09:13jcromartieI'm wondering if there's any case where a pred with side-effects would break filter
09:13clgvwell, if you want a guarantee you must follow the rules ;)
09:13jcromartieyes
09:13gfrlog`clgv: we're saying there's not a clear relevance -- what's being guaranteed?
09:14clgvfilter is lazy, so if the side-effect state of the predicate changes from definining the lazy filter sequence until it consumption, you might get an entirely different result
09:15gfrlog`clgv: side effects don't have to change the return value of the function
09:15clgvI think, if you are using doall on filter you can use any predicate you like - side-effect free or not
09:15gfrlog`and you can have a side-effect-free function that still depends on state
09:15gfrlog`so I think that issue is orthogonal
09:16clgvgfrlog`: well then it's "practical side-effect free" if the side-effects have no impact on any result of that predicate ;)
09:16gfrlog`on another note, looking at the source, I can't imagine pred being called twice
09:16gfrlog`clgv: elsewhere "side-effect-free" is a requirement because the function might be called multiple times (e.g. swap!)
09:17clgv gfrlog`: calling a function multiple times is only one case where side-effects can do harm
09:17clgv gfrlog`: calling it delayed is another
09:17gfrlog`it seems rather arbitrary to tack that onto the filter docs though. If it works there, I would think it could apply to any higher-order-function
09:18jcromartieI guess if the pred has some mutable state
09:18gfrlog`if you're not using pure functions, you could get unexpected results. has nothing to do with filter
09:18jcromartiesay, if the pred uses and changes an atom or ref
09:19gfrlog`jcromartie: certainly, but I think that issue is orthogonal to the behavior of filter
09:19jcromartieI think that's probably the meaning
09:19clgvgfrlog`: but thats very likely the reason for the side-effect free requirement in the docs when you look at the source
09:20gfrlog`,(doc map)
09:20clojurebot"([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]); Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments."
09:21gfrlog`clgv: you would want the requirement on map as well?
09:21DerGuteMoritzhow about dorun
09:21clgvgfrlog`: lol, so you want to reason with probably incomplete documentation? :P
09:22DerGuteMoritzoh well, not really a HOF
09:22gfrlog`clgv: I just think it's distracting; any clojure user should know that pure functions make things simpler
09:22jcromartieI think it's fine to require side-effect free functions for things like map and filter
09:22clgv gfrlog`: and I guess documentation in clojure is intended to be used to get the programmers started - dont confuse it with exact specification
09:22gfrlog`there's nothing mystical about how filter works that makes it unclear how a stateful function would behave
09:22DerGuteMoritz"just follow the simple rules"
09:22jcromartieI just think it's odd to say "must" when the language can't enforce anything
09:22jcromartieit's not Haskell
09:23jcromartie:P
09:23gfrlog`lol, here's a fun contrast: ##(doc swap!)
09:23sexpbot⟹ "([atom f] [atom f x] [atom f x y] [atom f x y & args]); Atomically swaps the value of atom to be: (apply f current-value-of-atom args). Note that f may be called multiple times, and thus should be free of side effects. Returns the value that was swapped in."
09:23gfrlog`in that function, where it really matters, it uses "should" :)
09:24clgvjcromartie: I guess you have to read "must" as dont "cry and complain if it doesnt work otherwise" ;)
09:24sritchiegfrlog`, what does hof stand for?
09:24gfrlog`sritchie: higher-order-function
09:24sritchieI've been seeing hof? in the cascalog code and can't figure it out
09:24sritchiethere we go :)
09:24sritchiethanks
09:24gfrlog`np
09:24TimMclet's see...
09:24TimMchof?
09:24gfrlog`hand-over.
09:24TimMcclojurebot: hof?
09:24clojurebotHuh?
09:24gfrlog`foot?
09:25jcromartie(defn hof? "Returns true if x is David Hasselhoff" [x] ...)
09:25TimMcSomeone inform the bot.
09:25clgvclojurebot: HOF is Higher-Order Function
09:25clojurebotc'est bon!
09:25clgvHOF?
09:25clojurebotHOF is Higher-Order Function
09:25sritchieHippies on Funyuns
09:25clgv:)
09:25TimMcyay
09:25gfrlog`~hof
09:25clojurebotHOF is Higher-Order Function
09:25sritchienice, clojurebot
09:26clgvhe is quite a learner ;)
09:26gfrlog`~botsnack
09:26clojurebotThanks! Can I have chocolate next time
09:26TimMcsometimes a little too much of one
09:26gfrlog`~botsnack chocolate
09:26clojurebotCool story bro.
09:26sritchiehaha
09:26sritchie~42
09:26clojurebotI don't understand.
09:26gfrlog`clojurebot: #42
09:26clojurebot42. You can measure a programmer's perspective by noting his attitude on the continuing vitality of FORTRAN.
09:26clgvclojurebot: #1
09:26clojurebot1. One man's constant is another man's variable.
09:27clgvlol
09:27TimMcWhere's the list?
09:27TimMcAre these Perlisisms?
09:27gfrlog`$google "attitude on the continuing vitality of FORTRAN"
09:27sexpbotFirst out of 41 results is: Vitality Quotes Page 2 - BrainyQuote
09:27sexpbothttp://www.brainyquote.com/quotes/keywords/vitality_2.html
09:27gfrlog`hmm
09:28gfrlog`I'm going to guess it googled w/o quotes
09:28TimMcLooks like Alan Perlis, yeah.
09:28clgvseems to be brainyquote statements
09:28gfrlog`man googling with quotes isn't much better
09:28TimMchttp://www.cs.yale.edu/quotes.html
09:29gfrlog`if you add clojurebot to the query it just returns IRC logs
09:30gfrlog`clojurebot: #41
09:30clojurebot41. Some programming languages manage to absorb change, but withstand progress.
09:30clgvclojurebot: #128
09:30clojurebotTitim gan éirí ort.
09:31gfrlog`they're all turing-complete, what's the difference
09:33DerGuteMoritzwhy does a Ring request split the URI into its components and associate the path component with the :uri key?
09:33gfrlog`DerGuteMoritz: you mean splitting the path from the host and port?
09:34DerGuteMoritzgfrlog`: and the query-string, yes
09:34DerGuteMoritzI would expect the path to end up under :path
09:34DerGuteMoritzbut its under :uri
09:34DerGuteMoritzhysterical raisins?
09:34gfrlog`well the host and port part I would say is because they're not ever together in HTTP I don't think
09:34gfrlog`as to why it splits the query string...I dunno, but it doesn't seem all that weighty either way :)
09:35DerGuteMoritzyeah sure, and :scheme is also not in there explicitly
09:35DerGuteMoritzoh well
09:35DerGuteMoritznow I know it anyway
09:58khaliGis there a but-nth?
09:59gfrlog`$findfn [1 2 3 4 5 6 7] 3 [1 2 3 4]
09:59sexpbot[]
09:59gfrlog`$findfn 2 [1 2 3 4 5 6 7] [1 2 3 4 5]
09:59sexpbot[clojure.core/drop-last]
09:59gfrlog`khaliG: that looks like it?
10:01khaliGmm not quite!
10:01raek,(loop [v [1 2 3 4 5 6 7], n 3] (if (zero? n) v (recur (pop v) (dec n))))
10:01clojurebot[1 2 3 4]
10:01khaliG$findfn [1 2 3 4 5] 2 [1 2 4 5]
10:01sexpbot[]
10:02raekkhaliG: or did you want to remove a certain element?
10:02khaliGraek, yes
10:02khaliGi have a list of row data and wish to remove a given row item (indexing the list by row)
10:02raekkhaliG: well, there's remove
10:03raekif the row has place structure (i.e. there are a fixed number of element and each mean something special) one way is to use destructuring and then build a new one
10:04wastreli went to that 99 lisp questions site but what's a "box"
10:04raekwastrel: cons cell
10:05raek,(let [row [123 "abc" 456], [x y z] row] [x z])
10:05clojurebot[123 456]
10:05wastrelthx
10:05raekkhaliG: do you use the row as a collection with varying number of elements or as a tuple with fixed number of elements
10:06raek(vectors no dot have an efficient way of removing elements from the middle)
10:06khaliGraek, my collection is made up of rows - and i wish to remove one, sorry i wasn't very clear before!
10:07teromwould something like this be inefficient?: (defn but-nth [coll n] (concat (take (dec n) coll) (drop n coll)))
10:07raekkhaliG: do you want to remove rows based on a certain rule or by index?
10:07khaliGraek, by index
10:07raekwhere do you get the index from?
10:07DerGuteMoritzterom: you could use split-with to avoid traversing the list twice
10:08khaliGraek, from a user click on a JTable
10:08raekah, Java stuff...
10:08khaliGyep!
10:09raekyou can do it like this: (defn remove-from-vector [v i] (into (subvec v 0 i) (subvec v (inc i))))
10:10raekwhich is basically like terom's solution but with vectors
10:10raekit's probably best to keep the data in vectors since the Java stuff wants to access the data by index
10:11khaliGsure, thank you
10:13raekI've seen code where people do tons of operations with indices that would simply have been much cleaner with functions like remove and filer...
10:13khaliGraek, okay. well, i could look for the row and then remove the result?
10:13raekso that's why I'm a bit reluctant to "accept" a solution that uses indices exstesively
10:13khaliGah, understood
10:14raekin this case, the design decision was not yours... :)
10:14khaliG:)
10:16teromDerGuteMoritz: how to write the predicate for that? I assume the predicate fn gets the value from coll, but now it should filter by index. (Ok, probably could iterate the coll with some index...)
10:17clgv&(println (System/currentTimeMillis), (System/nanoTime))
10:17sexpbot⟹ 1309270635780 4587247584252735 nil
10:17DerGuteMoritzterom: true, that's a bit tricky
10:18clgvhmm nanoTime seems to be something different than I thought
10:18clgvIs it related to a timer that was zero when the hosting system booted?
10:20gfrlog`you could see if that's plausible by converting it to seconds
10:20gfrlog`in this case it's 1mo22days
10:21gfrlog`I guess by "seconds" I meant "normal time"
10:21clgvhmm I had a look at the javadoc: it is a timer of the hosting system
10:21gfrlog`the milliseconds is ~41 years as you'd expect
10:22clgvso I'll use currentTimeMillis since I need a timestamp
10:22gfrlog`nanos I guess would be gooder for execution time and such
10:23clgvyep. that's where I found it in my code base ;)
10:23gfrlog`&(System/femtoTime)
10:23sexpbotjava.lang.NoSuchFieldException: femtoTime
10:24clgvlol. even nanoTime has no guaranteed accuracy of nano seconds ;)
10:25gfrlog`I don't think a Long is big enough to measure time in planck units :/
10:26Fossiit would just wrap pretty often
10:26gfrlog`:)
10:27clgvhmm if I have a function there is no possibility to get back a symbol of it's var, right?
10:27gfrlog`functions don't have vars
10:27clgvall my defns have :P
10:27gfrlog`it might have some info in the metadata some of the time though
10:27gfrlog`,(meta remove)
10:27clojurebot{:ns #<Namespace clojure.core>, :name remove, :file "clojure/core.clj", :line 2145, :arglists ([pred coll]), :added "1.0", :doc "Returns a lazy sequence of the items in coll for which\n (pred item) returns false. pred must be free of side-effects."}
10:28gfrlog`looks like you could get the var from :ns and :name there
10:28gfrlog`,(meta #(% %))
10:28clojurebotnil
10:28gfrlog`the point being don't assume an arbitrary function has such a thing
10:29gfrlog`,(let [m (meta remove)] (class ((:ns m) (:name))))
10:29clojurebotjava.lang.ClassCastException: clojure.lang.Namespace cannot be cast to clojure.lang.IFn
10:30clgvI have defns so it should work with meta
10:30DerGuteMoritz,(:name (meta remove))
10:30clojurebotremove
10:30DerGuteMoritzno?
10:30gfrlog`,(let [m (meta remove)] (class ((ns-map (:ns m)) (:name))))
10:30clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to keyword: :name
10:30gfrlog`,(let [m (meta remove)] (class ((ns-map (:ns m)) (:name m))))
10:30clojurebotclojure.lang.Var
10:30gfrlog`ah hah there it is
10:31gfrlog`DerGuteMoritz: ##(-> remove meta :name class)
10:31sexpbot⟹ clojure.lang.Symbol
10:31clgvwell the symbol with name and namespace is enough
10:31DerGuteMoritzoh I thought he just wanted the name
10:31gfrlog`clgv: I'm not sure if you can get the name from a var...hmm
10:31clgvit's both in meta
10:32gfrlog`,(meta (var remove))
10:32clojurebot{:ns #<Namespace clojure.core>, :name remove, :file "clojure/core.clj", :line 2145, :arglists ([pred coll]), :added "1.0", :doc "Returns a lazy sequence of the items in coll for which\n (pred item) returns false. pred must be free of side-effects."}
10:32gfrlog`nope there it is
10:33gfrlog`,(= (meta remove) (meta (var remove)))
10:33clojurebottrue
10:33clgvI just need a full qualified symbol to be able to load that function again later if I need to.
10:34gfrlog`clgv: I'm curious what you're doing and what "load" means
10:34clgv:ns and :name will do
10:35clgvI am storing an execution configuration for later analysis. I might not have to load it later on but I must be able to identify which one was used
10:36clgvbut with enough metadata (e.g. :doc) attached it would be easier to display what the function is supposed to do
10:37gfrlog`cool
10:38clgvyeah the execution framework with its configuration dsl turned out pretty cool :)
10:38DerGuteMoritzwhat is an execution framework?
10:39DerGuteMoritza shell?
10:39solussd_it's a java threading framework
10:40DerGuteMoritzI see
10:40clgvnope in my case it's a framework that takes a dsl that specifies functions and parameters that shall be used and executes a given function for all possible combinations of those "values"
10:41DerGuteMoritzis there an auto runner for clojure.test?
10:45jcromartieclgv: what is that used for?
10:46clgvstraight forward: running experiments with certain ranges and different strategies to see which one works best or what influences which parameter has.
10:47clgvs/ranges/ranges for parameters/
10:47sexpbot<clgv> straight forward: running experiments with certain ranges for parameters and different strategies to see which one works best or what influences which parameter has.
11:15halfprogrammer,(list? '(0 1 2 3))
11:15clojurebottrue
11:15halfprogrammer,(list? (range 4))
11:15clojurebotfalse
11:16halfprogrammerwhy do we have this behavior?
11:16jcromartie,(type '())
11:16clojurebotclojure.lang.PersistentList$EmptyList
11:16jcromartie,(type (range 4))
11:16clojurebotclojure.lang.LazySeq
11:17halfprogrammerjcromartie: hmmm. just the printed representation of (range x y) looks like a list...
11:17jcromartieyes
11:17jcromartiethere are more general predicates
11:17halfprogrammercoll? etc..?
11:17raekhalfprogrammer: a seq and a persistent list is not the same thing, but all lists are seqs
11:17raek,(seq? '(0 1 2 3))
11:17clojurebottrue
11:18raek,(seq? (range 4))
11:18clojurebottrue
11:18jcromartie,(map (juxt seq? coll? vector? list?) '(() [] (range 10)))
11:18clojurebot([true true false true] [false true true false] [true true false true])
11:18raeka list keeps track of the length
11:18halfprogrammerwhat is the difference between seq? and sequential?
11:18raekhalfprogrammer: vectors and sorted sets are sequential, but not seqs
11:18jcromartie,(map (juxt seq? coll? vector? list? sequential? assocaitive?) '(() [] (range 10) {} #{}))
11:18clojurebotjava.lang.Exception: Unable to resolve symbol: assocaitive? in this context
11:18halfprogrammerraek: oh.. I dint know that
11:18jcromartiepp[s
11:18jcromartie,(map (juxt seq? coll? vector? list? sequential? associative?) '(() [] (range 10) {} #{}))
11:18clojurebot([true true false true true false] [false true true false true true] [true true false true true false] [false true false false false true] [false true false false false false])
11:19jcromartiethis could go on :)
11:19gfrlog`jcromartie: then there's seqable as well
11:19halfprogrammerjcromartie: that's a nice table you have generated :)
11:19jcromartie,(sequential? (sorted-set))
11:19clojurebotfalse
11:20jcromartiewasn't sure about that one...
11:20raekI think that is a bug...
11:20gfrlog`here's an error that could be reported better: ##{:a}
11:20raekI recall hearing about it before
11:20gfrlog`&{:a}
11:20sexpbotjava.lang.ArrayIndexOutOfBoundsException: 1
11:20jcromartiegfrlog`: what's the problem?
11:21gfrlog`jcromartie: it just took me a dang while to figure out what was going on :)
11:21raekgfrlog`: iirc, they made that throw a better message in 1.3
11:21jcromartieah o
11:21manutter&{:a 1 :b}
11:21sexpbotjava.lang.ArrayIndexOutOfBoundsException: 3
11:21gfrlog`I had (fn [{:keys method path-pattern}] on one line
11:21manutterinteresting
11:21gfrlog`raek: that is good news
11:23halfprogrammerguys, what's the coolest clojure code you've seen?
11:24halfprogrammeri was looking into the destructuring code a couple of days back. It was nice
11:24gfrlog`halfprogrammer: I never admit that anybody else's code is cool, so my answer is http://twitter.com/#!/gfrlog/status/38726503944552448
11:25manutterI saw a blog post where somebody used closures to manipulate a red-black tree in a loop/recur
11:26halfprogrammergfrlog`: short & sweet
11:26gfrlog`halfprogrammer: yeah I was surprised
11:27manutterhttp://goo.gl/XlYHR
11:30halfprogrammermanutter: looks scary when people go out of the way to write a (awesome) tail recursive algorithm
11:31jcromartiegfrlog`: that's cool
11:31manutterhalfprogrammer: I was certainly impressed
11:33halfprogrammerany word on cemerick's clojure survey?
11:34cemerickhalfprogrammer: the squirrels are working on the results post right now
11:34cemerickhonestly, I'm swamped with the book at the moment, which has put a pinch on my blogging deadlines
11:35cemerickThe results post will go out either later today or Thursday
11:36halfprogrammercemerick: excited both abt the book & the survey results :)
11:37cemerick:-)
11:39jcromartieed
11:39halfprogrammergfrlog`: so, how's ur experience with emacs been?
11:40gfrlog`halfprogrammer: I've totally resisted doing anything besides clunking around ERC
11:40gfrlog`my flashiest skill is that I can pull up previous statements using Alt+p
11:41halfprogrammeris lisp development with vim good?
11:41gfrlog`it might be halfway good, but I'm not even good at it :) I just use it as a text editor and if it colors things then I'm happy
11:42gfrlog`everything else for me is just tmux and lein
11:42TimMchalfprogrammer: No, iti s chartreuse.
11:42TimMcStupid ergonomic keyboard.
11:43halfprogrammer:P
11:43TimMctyponomic
11:45halfprogrammerclojure vs scala war has started in my office (ThoughtWorks)
11:46halfprogrammersome clojure fanboy (I think) wrote an internal mail with "is scala dead?" as the subject
11:46sritchiehey all, is anyone here using marginalia 1.6?
11:46sritchie0.6.0, rather
11:46gfrlog`have a competition to see who can write parsers for their respective languages the fastest
11:46halfprogrammerwhole discussion was both heated & informative
11:50Cozeydoes leiningen plugin has some kind of an init function?
11:50Cozeyi'd like to create a plugin which creates hooks for other plugins
11:52solussdscala seems 'over-engineered' to me. It's a continuation of the layering of features on top of fortran and C-like languages to modernize them rather than the more natural approach to new features available to lisp/lisp-like languages. Didn't Backus warn us about scala 35 years ago? :D
11:53halfprogrammersolussd: :D
11:54jcromartiegfrlog`: spend some time with paredit-mode
11:54jcromartieit's really really really great
11:55jcromartiehalfprogrammer: how big is ThoughtWorks, BTW? I got the impression that it was small
11:56halfprogrammerapprox 1600 people I guess
11:56halfprogrammerincluding ppl other than engineers
11:58jcromartieoh wow, huh
11:58jcromartieis Clojure really in use there?
11:59halfprogrammerI find a lot of guys using it for their personal projects and stuff.
11:59halfprogrammerNo client projects in Clojure yet
11:59fliebelwhere?
11:59clojurebotwhere is log
11:59halfprogrammerThoughtWorks
12:07bprdoes anyone know why https://github.com/briprowe/timer-oddity would hang the clojure compiler?
12:07bpri type "lein jar" and it hangs
12:08TimMcclojurebot: forget where is log
12:08clojurebotYou don't have to tell me twice.
12:08bproddly if i remove ":main timer-oddity.core" from the project.clj file it compiles fine
12:09hiredmanbpr: making a jar is not compiling
12:09bprok
12:09bprbut, i still need to compile the thing
12:10halfprogrammerclojurebot: you're awesome
12:10clojurebotPardon?
12:11bprhiredman: lein compile hangs as well (also, only when i declare a "main")
12:13jcromartiebpr: I cannot accept the Eclipse Public License to troubleshoot this
12:13jcromartie:P kidding of course
12:13bprhaha
12:14bpryeah that's leinengen boilerplate
12:15cemerickbpr: my guess is that the Timer you're creating isn't using a daemon thread, and so will prevent the JVM from exiting
12:15cemerickuse (Timer. true)
12:16bprcemerick: that's most likely it... /facepalm
12:17bprty
12:17cemerick:-)
12:17jcromartieRTFMFTW
12:19semperosI've asked a similar q recently, but wanted to get more details
12:19semperosI'd like to use Clojure datastructures for defining configuration files in my app
12:19semperosthese files should not be kept under version control
12:20semperosdoes it make sense just to use a regular namespaced Clojure file with vars for hodling config values, and just provide a "blank" file for the user to fill in and possibly rename (to be able to pass around a consistent .gitignore)
12:23jcromartielook at how project.clj works in Leiningen
12:23jcromartieI think that's a decent model
12:24jcromartiethe idea is to just read the file (as in the "read" functions) and use that result
12:24jcromartieyou can control the loading of the file that way, and what is executed and what is not
12:24technomancyleiningen's model is a little different as it involves the defproject macro
12:24technomancybut you can just use load-file on a file that contains an arbitrary data structure
12:25gfrlog`technomancy: read would be safer than load-file, right?
12:25jcromartieload-file looks good
12:25technomancygfrlog`: only if you disable eval-at-read
12:26gfrlog`ah hah
12:26technomancyeven then, if someone's compromised your config files, it's probably a lost cause
12:26gfrlog`which only concerns #=(), right?
12:26technomancyaye
12:27semperosyeah, for config files, dealing with "malicious" code not as big a deal
12:27technomancywe have some code in our config files that allows things like queue names to be uniquified during concurrent test runs but uses canonical names in production.
12:27technomancywhich you can't do with read
12:27semperoshmm
12:27semperosthanks for the feedback, everyone, I'll play around with it
12:33halfprogrammerI am having to write stupid code like (is (= true (falsey? (before lst 2 1)))) etc
12:34halfprogrammerbecause (false? nil) is false
12:34hiredmanclojure.test's (is ) treats nil the same as false
12:34halfprogrammeris there any proper way to write these things?
12:35bendlas,(nil? nil)
12:35clojurebottrue
12:35bendlas,(nil? false)
12:35clojurebotfalse
12:35halfprogrammer,(false? nil)
12:35clojurebotfalse
12:35halfprogrammerthis is the problem for me
12:36dakronewhy do you need to use 'false?' ?
12:36cemerick,(doc false?)
12:36clojurebot"([x]); Returns true if x is the value false, false otherwise."
12:36halfprogrammerhiredman: you mean (is (not before lst 2 1)))
12:36cemerick,(if nil 5 6)
12:36clojurebot6
12:36halfprogrammersomething like ^ this would work?
12:36raek(is (not (before lst 2 1)))
12:36hiredmanhalfprogrammer: what do you mean?
12:37halfprogrammerraek: sorry, i left out a pair of ()
12:37hiredmanhave you just tried it?
12:37halfprogrammerhiredman: am about to try it...give me 1 sec
12:38raekhalfprogrammer: if you have something that is truthy or falsey, just use it in the (is ...) form directly.
12:38raekyou can use the 'boolean' function in cases where you really need it to be either true of false (e.g. calling a java method that takes a boolean)
12:39halfprogrammerraek: hiredman: that works. I don't know why I dint try it :D
13:08derp__dang it, yesterday I had "lein swank" working fine, and today when I try it I get this: https://gist.github.com/1051619
13:09derp__man I have bad luck with computers
13:09technomancyderp__: you have multiple versions of swank again
13:11derp__technomancy: again, you were right :P
13:14derp__should I include swank as a :dev requirement for my projects? I mean if that conflicts with lein, what's the point?
13:14technomancybetter to keep it as a user-level plugin
13:15technomancytheoretically non-emacs-users could work on your project; why make them pull in a dep they won't use
13:15derp__okay, well thank you for that explanation technomancy
13:18technomancysure
13:22gfrlog`somebody creating a clojure library for dating?
13:22cemerickHot Clojure singles are waiting for you!
13:23gfrlog`:)
13:24cemerickMost apps I've written don't need much more than milliseconds since the epoch + ISO date strings.
13:24cemerickFor anything beyond that, I presume simply using jodatime is recommended.
13:25gfrlog`leap-seconds might get removed from UTC
13:26cemerickThis is all I've ever needed, but again, I'm a simpleton in this area: https://github.com/cemerick/utc-dates
13:26technomancythat's it; I'm switching to Stardates
13:27gfrlog`one simplifying technique I use is to never make software that will be used by people in different time zones
13:28cemerickthings get a whole lot simpler if you just assume everyone is in London.
13:28gfrlog`because they are, aren't they?
13:28technomancyand if they aren't, they wish they were
13:28gfrlog`we're just helping them fantasize
13:29jcromartiegfrlog`: that's a great idea
13:29jcromartiewe just added a "country" dropdown which includes Canada, but we still only list US states
13:29hiredmancemerick: OH'ed
13:31gfrlog`jcromartie: it's easy enough to imagine that Canada is a US State, so that makes sense to me
13:31hiredmanimagine?
13:32gfrlog`hiredman: rather than two US states of Canada and Quebec?
13:32jcromartiegfrlog`: agreed
13:33hiredman:/
13:50cemerickIt looks like lein-ring is not yet 1.3-friendly?
13:51cemerickor, it depends upon hiccup apparently, which isn't? (e.g. Can't dynamically bind non-dynamic var: hiccup.core/*html-mode*)
13:52technomancywait, lein-ring depends on hiccup? =(
13:52amalloycemerick: i'm a leetle surprised lein-ring has anything to do with hiccup
13:52amalloymore likely, it seems to me, your app is trying to bind hiccup, and lein is just obediently starting your server
13:52cemerickNot sure what to say; I've never used it before, but `lein deps`; `lein ring server` dumps on me.
13:53cemerickamalloy: this is a hello world app — no hiccup anywhere in my code
13:53davekongIs sort guarenteed to be a stable sort?
13:53amalloywell, gross
13:53amalloy&(doc sort)
13:53sexpbot⟹ "([coll] [comp coll]); Returns a sorted sequence of the items in coll. If no comparator is supplied, uses compare. comparator must implement java.util.Comparator."
13:54davekongThat does not say
13:54amalloydavekong: looks like it's not guaranteed, but i wouldn't really mind relying on it myself
13:54cemerickIs there any dependency graph visualization in lein?
13:55technomancyhiredman: you had something like that, didn't you?
13:55amalloysince (a) j.u.Collections.sort has been stable for like a decade, and (b) clojure is likely to keep using it
13:55cemericktechnomancy: nm, I just used Eclipse
13:55hiredmannot really, mine was on the namespace level, not project level
13:55hugodlein pom; mvn dependency:tree
13:55cemerickThe ironies are deep. ;-)
13:55technomancydependency:tree *is* really nice.
13:55technomancyI still keep mvn around mostly for that.
13:56cemerickso, it goes: lein-ring ----> ring-devel ----> hiccup
13:56cemericktechnomancy: I'm permanently hooked on m2eclilpse's dep hierarchy view.
13:56cemerickso, yeah, hiccup is required by lein-ring. Why, I can't imagine.
13:57technomancyI would have a hard time classifying that as anything but a bug.
13:58cemerickhttps://github.com/mmcgrana/ring/blob/master/ring-devel/project.clj
13:58cemerick:-(
13:58cemerickbeen like that for a while; likely not going to change quicly
13:58cemerickquickly*
13:59technomancyexclusions maybe?
14:01technomancyoh, it may be that it uses hiccup to generate HTML versions of stack traces? that seems not unreasonable.
14:01cemerickThis is for the book (thus why I'm tripping around with lein-ring to begin with); if I can't get the simple stuff to be simple, then the point is lost. Hopefully a message to the list will prompt the 1.3-ification of hiccup.
14:02technomancydefinitely
14:03cemerickis there not a dedicated ring ML?
14:03hiredmanthere is
14:03hiredmana google group
14:03cemerickah, ring-clojure, thanks
14:03hiredmanvery low traffic
14:04hiredmanI asked a question a week or two ago and have yet to get a response
14:04cemerickWe'll see how it goes. I'd lobby for the elimination of hiccup entirely, but one step at a time. :-P
14:05hiredmanhttp://groups.google.com/group/ring-clojure/browse_thread/thread/8f35a9c811a2c381
14:05cemerickyuck
14:07technomancyI wonder why the prags' ring book fell through.
14:08jcromartietechnomancy: maybe there wasn't enough to say?
14:08jcromartieIt's a pretty small librarry.
14:09technomancyjcromartie: well, I think it was targeting ring and the ring ecosystem
14:09jcromartieI am pretty sure that things like Ring and Rack are just chapters in books on frameworks sitting on top.
14:09technomancyand they were shooting for a shorter ebook
14:09technomancybut perhaps things were just changing too rapidly
14:09jcromartieoops
14:09cemerickIt's really early for topical books like that, I'd think.
14:09jcromartieCommand + W'ed
14:10cemerickI know people would appreciate a dedicated Incanter book, but again, really small market.
14:10technomancyprobably true, though mini-ebooks have a much lower barrier
14:11technomancybut it would probably be a better book if it waited for the ecosystem to solidify a bit
14:11technomancyhave a few more tools for common tasks like user handling and form construction
14:15derp__if I have a bunch of clojure projects folder, should I run swank in the toplevel directory containing them all, or can I only run it within project folders?
14:37Dranikhi all!
14:38timvisherhi
14:42derp__is there a way to run swank on multiple projects simultaneously?
14:42derp__or do I have to run separate versions and connect to each independently
14:43manutterderp__: I don't think you necessarily want to, at least in the general case
14:43derp__?
14:44manutteryou should run each swank in its own project because of the classpaths
14:44derp__but how do you work on multiple projects simulataneously
14:44derp__and then connect to each separately?
14:44manutterthat said, you may have a specific case where all your projects are using the same libs, in which case my caveat would be moot
14:45manutterbut I'm not sure the usual tools will find the classpaths for multiple projects at once
14:47manutteri'm guessing you can connect to multiple swanks, but I don't know what that would cost in ram terms
14:47derp__um, how do I connect to different versions? I am running "lein swank 4011" and trying to connect, but I get this weird warning: "Close old connections first? (y or n)"
14:48amalloyi'd say, press y if and only if you want to close your old connections first :P
14:48manutteruse different ports
14:48derp__yeah, I am using 4010 for the other swank server
14:48manutteroh wait I see what you mean
14:49manutteryou're trying to connect to different swank servers from the same session
14:49derp__yep
14:49manutterI'd run separate emacs instances myself
14:49derp__really?
14:49manutterbut that may be just because I don't know any better
14:49technomancymanutter: no, that's what I do
14:50technomancyslime is pretty crappy at handling multiple connections
14:50manutterI'm going to have to bail out now, later all
14:50technomancyderp__: you might be interested in checkout dependencies though; see lein help readme in the faq
14:52coopernursegeneral design question.. let's say you're writing an app that consumes a web service, does some transforms on the data and saves to a sql db. I assume the functional approach would be to isolate the i/o (impure) code off from the pure transform code.
14:52coopernurseis that the right way to think about things generally?
14:53timvishercoopernurse: i'd say yes
14:53timvisherbut i'm not authoritative
14:53timvisherthat's what i've tried to do in my apps
14:53derp__technomancy: so if I understand that faq right, I should do this: *project-dir*/checkouts/*sym-link-to-other-project-dir*
14:53coopernursetimvisher: great. are you using some mocking lib to test the functions that do i/o
14:53derp__and I can have multiple symlinks?
14:53technomancyderp__: indeed
14:53derp__sweet
14:53Cozeytechnomancy: hello. I've got an issue with Lancet's coerce multi function: https://github.com/technomancy/lancet/blob/master/src/lancet/core.clj#L28 in my scenario dest-cls is int, so I guess Integer/TYPE. the obj is Clojure number, so a Long. I'd like to add some coerce defmultis, but I'm not sure which ones: it would be good to cover also Short values - should we use (.intValue obj) yielding int, or should we just convert to Integer, and let
14:53Cozeyauto-unbox it to int, if it needs?
14:54Cozeythe problem is (cast int 123) will throw classcastexception
14:55technomancyCozey: lein is on clojure 1.2, so all return values are going to have to be boxed
14:56Cozeymhm, so it sohuld be (Short. (.shortValue 123)) ?
14:56technomancyI'm not sure; I don't really know what coerce is used for
14:57Cozeyit's used when an 'Scp' ant task wants setPort(int)
14:57Cozeyand lancet tries to fill in the properties
14:57Cozeyusing coerce multi-fun to change clojure types to something ant task object can accept
14:58technomancyInteger. is probably what you want?
14:58Cozeyunder clojure 1.2, all numbers are Long or Integer ?
14:58hiredmanyou wonder why it just doesn't call it reflectively
14:59Cozeytechnomancy: yes for this case yes, but i want to commit a patch so I'd like to add Short support as well
14:59Cozeyand Long
14:59Cozeybut: clj 1.3 uses Long by default
14:59Cozeyand clj 1.2 ?
15:00Cozeyhiredman: yeah it uses some writermethod
15:00hiredman(clojure.lang.Reflector/invokeInstanceMethod obj "setPort" (into-array [port-number]))
15:01Cozeyhiredman: any better idea?
15:01hiredmanCozey: ^-
15:01CozeyO_o
15:16michigan101https://market.android.com/details?id=com.game.WarStrategy
15:30tufflaxCan I use hiccup for arbitrary XML, not just HTML?
15:31amalloytufflax: i think you want c.c.prxml for that. hiccup might be based on it, even
15:31amalloybut they take basically the same format
15:32tufflaxok, thanks
15:40rindolfHi all.
15:40rindolfWhen trying to follow the instructions here - http://dev.clojure.org/display/doc/Getting+Started+with+Eclipse+and+Counterclockwise - I'm getting this - http://pastie.org/2135881 . What should I do?
15:47cemerickrindolf: what version of Eclipse are you using?
15:49rindolfcemerick: eclipse-3.6.2-13.mga2.src.rpm
15:50cemerickSeems sane enough
15:51cemerickrindolf: hrm, that's a src bundle from some linux distro?
15:52rindolfcemerick: it's the Mageia Cauldron source rpm.
15:52rindolfcemerick: it ends up as eclipse-jdt-3.6.2-13.mga2
15:52cemerickrindolf: my first suggestion would be to go get a suitable binary from eclipse.org
15:52rindolfcemerick: why?
15:52rindolfcemerick: it is a binary.
15:53cemerickI mean an officially-packaged binary.
15:53cemerickWho knows what got left on the repository packager's cutting room floor.
15:54cemerickThat error indicates that eclipse is looking for a package (some OSGI dependency?, presumably a fairly sane thing to do), but the set of configured repositories you have doesn't include the one it needs.
15:55cemerickrindolf: You could pass that paste to the people in #eclipse, and they might have a better clue.
15:55rindolfcemerick: OK.
15:56cemerickrindolf: let me know how it pans out either way
15:57rindolfcemerick: OK.
16:07pcavs_,(seq? [1 2 3])
16:07clojurebotfalse
16:07pcavs_,(doc seq)
16:07clojurebot"([coll]); Returns a seq on the collection. If the collection is empty, returns nil. (seq nil) returns nil. seq also works on Strings, native Java arrays (of reference types) and any objects that implement Iterable."
16:08amalloy&(map (juxt seq seq? sequential?) ['(1) [1] []])
16:08sexpbot⟹ ([(1) true true] [(1) false true] [nil false true])
16:09amalloyhuh, i didn't realize ##(seq? '(1)) returned a non-boolean
16:09sexpbot⟹ true
16:09amalloymaybe i just can't read
16:11jcromartie,(seq? (seq []))
16:11clojurebotfalse
16:11jcromartie:)
16:12cemerickIt seems that lein-ring requires a :target-dir key in project.clj — but I don't see any documentation of this anywhere. Am I missing something obvious?
16:13cemerick(e.g. perhaps :target-dir should be getting set to a default — "target" or ".", perhaps — but isn't for some reason in my environment?)
16:13derp__why is it that lein converts projects with dashes into underscores?
16:13technomancycemerick: it's set by default since lein 1.5
16:13derp__my-project becomes my_project
16:13hiredmancemerick: didn't require it for me
16:14technomancyor rather, it defaults to the project root
16:14hiredmanah
16:14hiredmanwell, there you go
16:14cemericktechnomancy: Bah! I just did a clean self-install and I see I have 1.2.0! :-(
16:14devncemerick: private msg
16:14devn(when you have a moment)
16:15cemerickBugger; an old `lein` bootstrap on my PATH.
16:15cemericktechnomancy, hiredman: thanks
16:17technomancyI hope to have .debs at some point to make that one less thing to worry about
16:17technomancythough if you're on os x it's already in brew
16:18cemericktechnomancy: no worries, my bad. I chafe at any repo manager in OS X anyways.
16:18technomancyagreed
16:18technomancythough I chafe more at not having a package manager at all. but there's an easy solution to that.
16:20cemerickLots of easy solutions, actually.
16:20wastrelhi
16:20wastrelmy friend has a farm
16:21cemerickWe should chuck all these newfangled computer things until they actually work properly.
16:21wastrelthey rent their fields out to their neighbors, they don't farm on them actually
16:21ibdknoxlol
16:21ibdknoxthat's awesome
16:21ibdknoxtenant farmers
16:30rpglover64I come seeking enlightenment, after not finding it in the vast open web.
16:31rpglover64I'm using deftype to implement an interface
16:32rpglover64the problem is that it also needs to have a nullary constructor
16:33rpglover64how could I add one to it?
16:33hiredmanwhich deftype has if you don't specify fields
16:33rpglover64but it needs to store data somehow
16:34rpglover64and the nullary constructor would have to do initialization
16:36rpglover64I guess i could ask, how could I have things that behave like private data fields without specifying them to deftype
16:37rindolfcemerick: it works fine with the Eclipse build from http://www.eclipse.org/ .
16:37cemerickrindolf: Excellent, good to know :-)
16:38cemerickrindolf: tell your distro's package manager to stop messing with things ;-)
16:38cemericks/manager/maintainer
16:38sexpbot<cemerick> rindolf: tell your distro's package maintainer to stop messing with things ;-)
16:40dnolenrpglover64: not possible really.
16:40rpglover64That's what I thought
16:41rpglover64which is why I asked "how do I add a nullary constructor to a deftype'd class"
16:41dnolenrpglover64: deftype is hosty, but is opinionated enough that you can really think of it as interop.
16:42dnolens/can/can't
16:42sexpbot<dnolen> rpglover64: deftype is hosty, but is opinionated enough that you can't really think of it as interop.
16:42dnolenrpglover64: perhaps proxy is better suited for this task.
16:42rpglover64cool!
16:42rpglover64it actually needs to be a class :(
16:43rpglover64off to gen-class land? :(
16:43dnolenrpglover64: what interface are you implementing?
16:44rpglover64it's part of an intro to programming in java final assignment
16:45rindolfcemerick: OK, I'm following this - http://dev.clojure.org/display/doc/Getting+Started+with+Eclipse+and+Counterclockwise and it says: «Run it: Select the firstClojureProject>src>helloworld.clj file, then menu Run > Run as > Clojure REPL.» but I cannot find it anywhere under src/ in the project view.
16:45rpglover64so I'm using it to learn clojure
16:45derp__I'm trying to write documentation, when a word is in brackets it's assumed to be a dir, a la [dir], right?
16:46derp__or is that a fictitious standard I just muddled up
16:46cemerickrindolf: you created the helloworld.clj file, right?
16:46rindolfcemerick: yes, I did.
16:46cemerickrindolf: and you can't find that file in the project view?
16:46rindolfcemerick: yes, exactly.
16:47cemerickso you created the file somewhere other than `src`, I presume.
16:48rindolfcemerick: I did not.
16:48rpglover64dnolen: the problem is that to make the pretty graphical part of the assignment (that the instructor wrote) use the student's implementation of the logic, the object that would start the game expects to be passed in a class implementing the interface, and will proceed to use it for all its logic needs.
16:49rindolfcemerick: and I cannot find it anywhere else.
16:50cemerickrindolf: OK; right-click the src dir, and choose New > File; name it helloworld.clj, and go from there.
16:50rindolfcemerick: it says the file already exists.
16:50cemerickrindolf: did you create the file outside of eclipse (e.g. in a terminal?)
16:51rindolfcemerick: no, I did not.
16:52rpglover64can a proxy be passed to a java method that expects a class (no, right?)
16:52cemerickrindolf: select the top-level project node, and hit F5 (refresh); does the file appear where you think it should be?
16:52dnolenrpglover64: interface dictating ctors seems weird, but perhaps normal in the Java world?
16:52rpglover64interface doesn't have constructors
16:52rpglover64java forbids it syntactically
16:53rindolfcemerick: no, it does not.
16:53rpglover64but in this case, it's like an obj-c informal protocol
16:53rpglover64the object receiving the class expects it to have a nullary constructor
16:53rindolfcemerick: nothing happens upon refresh.
17:01coopernurseI'm reading this page: http://freegeek.in/blog/2011/06/10-clojure-one-liners/
17:02coopernurseand when I try out #7 - (clojure.xml/parse "http://search.twitter.com/search.atom?&amp;q=clojure&quot;)
17:02coopernursein emacs/slime I get a huge backtrace / debug buffer
17:02coopernursethat I'm not sure how to make sense of.. Is there anything obviously wrong with that #7 example? If I paste it into a browser I get XML back from twitter
17:02rpglover64,(clojure.xml/parse "http://search.twitter.com/search.atom?&amp;q=clojure&quot;)
17:03clojurebotjava.security.AccessControlException: access denied (java.net.SocketPermission search.twitter.com:80 connect,resolve)
17:03rpglover64makes sense
17:03dnolen_rpglover64: so the assignment requires you to create those ctors - in Clojure it's idiomatic to provide them as fns.
17:03rpglover64yes
17:04hiredmancoopernurse: read the doc string for parse
17:05rpglover64dnolen_: do I pretty much need gen-class to do that?
17:05coopernursehiredman: ok
17:05hiredmanactually, I take that back, read the stacktrace instead
17:06coopernurseit hoses my swank process.. so I'm restarting it
17:06coopernursehiredman: you're getting the same error I assume?
17:06dnolen_rpglover64: well I mean were you planning on writting it Clojure and converting it back to Java? :)
17:06rpglover64no, i'm not in the class
17:06hiredmancoopernurse: no, I'm not
17:07rpglover64i'm just using the the final project to learn clojure interop
17:07coopernursehiredman: ah. ok.. let me verify my clojure version real quick
17:07rpglover64and clojure in general
17:07hiredmancoopernurse: I am not running the code at all
17:07dnolen_rpglover64: but why limit yourself to the arbitrary constraint?
17:08rpglover64dnolen_: i'm not sure i understand how it's an arbitrary constraint
17:09rpglover64i'm looking at it from the perspective of "I have some java code I need to interop with"
17:09rpglover64and to interop, I need to have the constructor
17:10dnolen_rpglover64: sorry, I forgot it's the Java code that will call your ctor.
17:11dnolen_rpglover64: and you said the Java code will call your initializer ?
17:12rpglover64initializer?
17:12dnolen_rpglover64: you said something about initialization.
17:13rpglover64the java code will call a nullary constructor, which is expected to do the initialization
17:15dnolen_rpglover64: what about a interop deftype which just calls the actual ctor fn?
17:17coopernurseI think perhaps the URL is getting mangled
17:17coopernursegoing to try another URL.
17:19rpglover64dnolen_: that either doesn't implement the interface or needs to have something like a field that isn't a field (afa deftype is concerned)
17:20dnolen_rpglover64: because the Java side isn't functional, it's going to side effect the result of the ctor call?
17:21rpglover64dnolen_: it's going to construct the object and then start using it... i'm not sure what you mean by side effect in this case
17:23dnolen_rpglover64: in Clojure you construct instances, but using it means producing new instances.
17:24dnolen_not always of course, but a considerable amount of the time.
17:24rpglover64dnolen_: but isn't that the primary effect, not a side-effect?
17:26DerGuteMoritzis there a function like Scheme's string-prefix? in clojure.core or .contrib?
17:26DerGuteMoritzi.e. a function that checks whether one string is a prefix of the other
17:27dnolen_rpglover64: part of the problem is ctors in Java are notorious for state/concurrency bugs, since a nullary ctor means you have this gap between object instantiation and initialization. deftype avoids that, but it means it's hard to make it work for your use case.
17:27amalloy$google java lang string startsWith
17:27sexpbotFirst out of 23700 results is: String (Java Platform SE 6)
17:27sexpbothttp://download.oracle.com/javase/6/docs/api/java/lang/String.html
17:27technomancy,(.startsWith "stella" "ste")
17:28clojurebottrue
17:28amalloytechnomancy: ninja'd?
17:28amalloykinda not sure. yours might be more practical
17:28technomancywe'll call it a draw
17:28DerGuteMoritzah, keep forgetting to check the Java APIs
17:28DerGuteMoritzthanks!
17:28rpglover64dnolen_: well, in this case, I expect the constructor to return an initialized object
17:29bhenryis there a way to walk through a collection and have a counter given to me for each run?
17:29amalloy&(doc map-indexed)
17:29sexpbot⟹ "([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."
17:29amalloyor, ##(map vector (range) [:a :b :c])
17:29sexpbot⟹ ([0 :a] [1 :b] [2 :c])
17:30derp__I can't figure out how to call a function from another file
17:30amalloytechnomancy: 50% seems like it might be low
17:30derp__https://gist.github.com/1052284
17:30derp__I ran lein uberjar and run the standalone, and then I get this error: https://gist.github.com/1052292
17:31derp__here's the original with syntax highlighting: https://gist.github.com/1052284
17:34bhenryamalloy: thanks
17:38derp__I must be screwing up something obvious, but it's not apparent to me
17:51bprwhere does contrib.repl-utils live now that the contrib library has been broken up?
17:54brehautbpr: not all the old contrib libs have been moved to new contrib yet (in fact, very few have)
17:55brehautbpr: looking at http://dev.clojure.org/display/design/Contrib+Projects it appears to be one of the libs not migrated yet
18:01bprsweet, didn't know about that url. thanks, brehaut
18:11rpglover64brehaut: I was told that I should ask you about coming to clojure from a haskell background
18:12brehautrpglover64: really? curious
18:12brehautrpglover64: how much haskell do you know?
18:13amalloybrehaut: surely i wasn't wrong to recommend you
18:13brehautamalloy: if im one of the more experienced haskellers here, im surprised
18:14amalloyyou're the loudest, as far as i've noticed
18:14brehautfair enough
18:14rpglover64brehaut: enough that I think about whether to use the Applicative interface to Parsec instead of the Monadic one
18:14brehautrpglover64: do you use Category with it?
18:14brehaut(it being applicative)
18:15rpglover64brehaut: I haven't jumped into regularly using Category or Arrow yet
18:15rpglover64so no
18:16brehautrpglover64: i think with category and applicative you can avoid most uses for arrow
18:16brehautclojurebot: arrows
18:16clojurebotarrows is http://ro-che.info/ccc/12.html
18:16brehautgold
18:16rpglover64Aren't Arrows isomorphic to Applicative Categories?
18:16brehautindeed
18:16rpglover64I remember reading something about that and not understanding it
18:17brehautanyways, what do you want to know about clj from hs?
18:18rpglover64nothing in particular, unless there's a nice tutorial or introduction to it aimed at haskellers
18:18rpglover64it's just that your name was mentioned, and I saw it in scrollback and happend to be around
18:19brehauti doubt it; clojure is largely straight forward. fnparse is approximately equivalent to parsec (although the combinators are different) you dont need monads for most things (for and doseq are list comprehensions) -?> and -?>> provide a good chunk of what you might use maybe for
18:20brehautand point free is uncommon (because it gets lumpy fast)
18:20rpglover64gathered as much
18:21rpglover64although the -> and ->> macros are nice sometimes
18:21brehautdefinately, but they arent point free
18:22rpglover64they're kinda similar
18:22brehautyeah they perform similar purposes
18:22brehautbut its form rewriting rather than first class functions
18:23rpglover64right
18:23rpglover64but if I don't have a nice type system, I don't _want_ to be passing around and composing lots of first class functions
18:24brehautnews to me ;)
18:24clojurebotexcusez-moi
18:24AWizzArdrpglover64: like the guys in Haskell I guess
18:25rpglover64also, I've realized that the weirdest thing for me to get used to is the lack of currying
18:26brehautyou do still have partial and the #(…) reader macro available;
18:27brehautits maybe not as elegant as currying, but it does the job well enough, and #() is particularly useful because it allows you to work with methods as well as functions
18:29amalloybrehaut: poor memfn. everyone uses #(...) isntead
18:38amalloy&(map (memfn length) ["test" "some strings"])
18:38sexpbot⟹ (4 12)
18:39gfrlog`#(.length %) is shorter
18:39gfrlog`and has three more punctuation marks
18:40amalloysure, i usually use # too. but for one thing you can nest memfn inside of #() forms
18:40brehautgfrlog`: potentially for a method with a really long signature memfn might become clearer because you name the arguments
18:40tomojannotations in my deftype don't work when I use a macro to create it: https://gist.github.com/1052434 ideas?
18:41tomojmust be dropping the metadata somewhere somehow
18:42amalloytomoj: fwiw, that comment form doesn't "work":
18:42amalloy&(comment works:)
18:42sexpbotjava.lang.Exception: Invalid token: works:
18:43gfrlog`there's one thing that a with-dyslexia macro can't help you with
18:43tomojalso unreadable forms
18:43tomojhad them ;;'d out but wanted syntax highlighting
18:45tomoj(defmacro deffoo [name] `(deftype ~(with-meta name {Foo true}) []))
18:45tomojshouldn't (deffoo Bar) define a Bar class with the Foo annotation?
18:46amalloytomoj: i think so. emitting metadata from macros always seems to have some traps for me
18:47tomoj(->> '(deffoo Bar) macroexpand-1 second meta) is as expected but no annotations...
19:40gfrlog`if I want to thread a map through a series of reduces, I need a threading macro that makes something the second argument :(
19:44amalloyor a reduce that wants the initial element first
19:46gfrlog`I'll bet you half a pence that exactly one of the two is in amalloy-utils
19:46amalloyhah, no
19:46gfrlog`you won't bet because I'm right!
19:47amalloyactually i accept your bet and tell you you're wrong
19:47gfrlog`aw dang
19:48gfrlog`(defn preduce ...)
19:55coopernursehow can I tell what version of swank and clojure I'm running from a repl
19:55coopernurseafter running: clojure-jack-in
19:55coopernurseI assume the clojure version is based on the project.clj?
19:55hiredman,(clojure-version)
19:55clojurebot"1.2.0"
19:55coopernursehiredman: thank you
19:58coopernurseyes, there's something odd going on with the swank/slime repl
19:58coopernursewith this line
19:58coopernurse(clojure.xml/parse "http://search.twitter.com/search.atom?&amp;q=clojure&quot;)
19:58coopernurseif I run: java -jar clojure.jar
19:58coopernurseand paste that in
19:58coopernurseit works fine
19:58coopernursefrom the standard clojure REPL
19:59coopernursebut over swank I get dropped into a debugger
20:01coopernursehttps://gist.github.com/1052546
20:02coopernurse"Unable to resolve symbol: q in this context" seems relevant
20:13pcavsDoes anyone know (1) How Kawa Implements TCO (2) Why Clojure does something else (3) What that something else is?
20:13technomancykawa is an interpreter, innit?
20:13technomancyor is that just sisc?
20:14DerGuteMoritzpcavs: Kawa only has optional TCO and it's very expensive AFAIR
20:14pcavsOh, I thought Kawa was a full Scheme implementation
20:14pcavsDerGuteMoritz: Interesting...
20:14DerGuteMoritzif you enable it, yes :-)
20:14DerGuteMoritztechnomancy: Kawa compiles to bytecode actually
20:15DerGuteMoritzwell, it also has an interpreter of course
20:15technomancyok, it just sacrifices by not compiling every function call to a method invocation
20:16scgilardihttp://www.rhinocerus.net/forum/lang-scheme/559925-recommendations-kawa-sisc.html
20:17DerGuteMoritzah, Per Bothner replies in that thread, he is the creator of Kawa
20:18DerGuteMoritzI have used Kawa for an Android app and have quite liked it
20:19pcavsThanks DerGuteMoritz
20:19DerGuteMoritzyou're welcome
22:03symboleWhat is the meaning of #^"[B"? Does that indicate that whatever follows is a byte array?
22:10dnolen,(type (byte-array []))
22:10clojurebot[B
22:10dnolensymbole: yes it's a primitive byte array type hint
22:11dnolensymbole: old type hint syntax tho. ^ preferred over #^ these days.
22:12symboleAh, thanks.
22:14gfrlog`if I call (first (filter ...)) on a non-chunked seq, it shouldn't ever process more than necessary should it?
22:14gfrlog`like...exactly 32 more than necessary? :(
22:29dnolengfrlog`: filter does the chunking.
22:30gfrlog`dnolen: man. that sounds like valuable information.
22:30gfrlog`wouldn't you want that kind of thing in the docs?
22:30dnolengfrlog`: actually it's not filter so much as seq.
22:31dnolen,(type (seq [1]))
22:31clojurebotclojure.lang.PersistentVector$ChunkedSeq
22:31gfrlog`oh maybe it's cause I call (chunked-seq?) without calling seq
22:31gfrlog`so I was wrong about it not being chunked
22:31dnolen,(type (seq {1 2}))
22:31clojurebotclojure.lang.PersistentArrayMap$Seq
22:31gfrlog`ah yes
22:32gfrlog`,(chunked-seq? (seq (shuffle (range 1000))))
22:32clojurebottrue
22:32gfrlog`that threw me off because it returned false w/o (seq)
22:32Scriptor,(type (range 10000))
22:32clojurebotclojure.lang.LazySeq
22:32dnolen,(type (seq (range 10)))
22:32clojurebotclojure.lang.ChunkedCons
22:33dnolengfrlog`: in anycase, if you want to prevent chunking you need to wrap the seqable thing in something which ensures one at a time, which is easy to do.
22:33gfrlog`I used a manual (loop)
23:13technomancyany DDs in the house?
23:14amalloytechnomancy: you need a ride home?
23:14technomancyhehe
23:14technomancyDebian Developers
23:16pcavstechnomancy: nobody's taking the bait...
23:18technomancypcavs: well you never know, Debian has a reputation for moving very slowly.
23:18technomancyzing!~
23:31kencauseytechnomancy: What do you mean by Developer in this sense? I use Debian and develop software on the platform, I have not packaged anything for Debian though.
23:32kencauseys/sense/instance/
23:32sexpbot<kencausey> technomancy: What do you mean by Developer in this instance? I use Debian and develop software on the platform, I have not packaged anything for Debian though.
23:32technomancykencausey: right... Debian Developer is a pretty specific term for people who have upload privileges
23:32technomancythanks though =)
23:33technomancyit looks like clojure is up to date in sid, but contrib is still on 1.1.0
23:33kencauseyyes, not me, sorry
23:35technomancyapparently to create a legit lein .deb I have to first package clucy, lancet, and hooke.
23:35technomancy...without the help of leiningen itself
23:36technomancycurse you, self-hosting!
23:40technomancywhooo-wee! apt-get install maven2 pulls in not one, not two, but _three_ languages.
23:40amalloytechnomancy: a lein deb would be pretty great though
23:41ibdknoxyou can never have too many languages ;)
23:41technomancyamalloy: there will definitely be a deb. the question is whether it will be a compliant one or not.
23:41technomancythe uberjar-in-a-deb approach is easy peasy
23:42technomancycomplying with every jot and tittle of the hallowed Debian Policy is daunting
23:45technomancyibdknox: unless one of them is groovy
23:45ibdknoxhahaha
23:45ibdknoxseriously? It bring down groovy for Maven2?
23:45technomancyif I released a lein deb that depended on groovy I would probably die of embarrassment
23:45ibdknoxIf you weren't shot first ;)
23:46ibdknoxlol
23:46technomancyit looks like there's no way around Recommend'ing gcj though =(
23:46amalloy!
23:46hiredman^- also an embarrassment
23:47amalloytechnomancy: that sounds worse to me than groovy
23:47technomancyamalloy: for portability; apparently ant is too slow to be usable on non-i386 architectures using hotspot?
23:47technomancyand you can't have arch-specific Recommends fields
23:47technomancythough users can disable the auto-installation of Recommend'ed packages
23:47amalloytechnomancy: gcj barely works at all. last i checked it didn't support all of jdk4, let alone 5 or 6
23:48technomancyyeah but think of the sparc users. or something.
23:51hiredmanI think it is safe to presume that sparc users are a hardy bunch that need no hand holding
23:52technomancyhiredman: you should suggest this to the debian maintainers, I'm sure a lively discussion could be had.
23:52technomancy"lively"
23:52hiredmancontinued use of sparc seems to point to a particular streak of hard headedness
23:53technomancywhoa; m86k is still supported as well
23:56cemerick;-)
23:57technomancycemerick: just looking to pick a fight =)
23:58technomancy"no, I will _not_ put copyright boilerplate at the top of every source file. I prefer to use that 30% of my screen space for things that are relevant, like the code."
23:58cemericktechnomancy: if it's with the .deb folks, I'm behind you :-)
23:58technomancyluckily that is only strongly recommended, not required.