#clojure logs

2011-01-04

00:18jfkw\quit
00:22auserhah
01:44amalloy$source into-array
01:44sexpbotinto-array is http://is.gd/k44VO
02:01_na_ka_na_how do I get clojure-contrib 1.3alpha4 from lein ?
02:38LauJensenDerander_: Did you solve your problem?
02:49Derander_LauJensen: no, but I haven't put any more work into it since then
02:49Derander_I've gotten sidelined
02:49Derander_I'll figure it out tomorrow
02:52LauJensenok, it should be like amalloy said. You can inspect ClojureQLs own project.clj to see artifacts for mysql, postgres and sqlite
03:19Derander_LauJensen: good idea. thank you.
04:35ejacksonmorning all
04:54LauJensenMorning ejackson
04:57ejacksonLauJensen: my apologies for not taking a look at ClojureQL yet. I opted to use redis instead of SQL for the current piece of work. I will use SQL at some point, but not just yet.
04:57LauJensenejackson: I'll forgive you if you write a Redis compiler for ClojureQL (it has pluggable compilers)
04:58ejacksonis that a fact....
04:58ejacksonvery interesting indeed
04:58ejackson,(swap! edmunds-todo-list inc)
04:58clojurebotjava.lang.Exception: Unable to resolve symbol: edmunds-todo-list in this context
04:58ejackson:)
05:00ejacksonactually clojurebot, the correct Exception is numeric overflow
05:04Fossishameless plug: http://the-deadline.appspot.com
05:04Fossiall clojure ;)
05:04Fossiand also nice for keeping your todos
05:04bobo_Fossi: what did you use?
05:04Fossias in?
05:05Fossia lot of coffee
05:05ejacksonFossi: nice !
05:06LauJensenbobo_: Theres a nice talk on Hack Fwd about the deadline
05:13bobo_Fossi: as in libraries for the web =)
05:13bobo_LauJensen: ah il check
05:14LauJensenbobo_: I think they used all the wrong libraries, but their architecture idea was great
05:14bobo_:-p
05:17Fossiit's been changed a whole lot
05:17bobo_i dont think the site is for me. way to much stuff
05:18bobo_im still to find a todolist that beats postit notes
05:18Fossithere are actually quite a few really simple ones
05:18midsLauJensen: what is Hack Fwd? (got an url?)
05:19Fossihackfwd.com
05:19midsoh that just seemed to be some random site, guess I got to look deeper
05:20Fossiit's a vc-group, by lars hinrichs (xing founder)
05:20Fossithey also have quite a few tech talks
05:20midsthanks
05:21midsah, http://hackfwd.com/companies#thedeadline
05:23bobo_cant find any talk there though?
05:25Fossihttp://passionmeetsmomentum.com/
05:25Fossii think
05:26LauJensenYea I think that was the name. Just stay clear of passionmeetsfashion.com :)
05:32companion_cubeis there a way to change the way to compare objects in a set ?
05:33ejacksoncompanion_cube: yes, a custom comparator function
05:35ejacksoncompanion_cube: if you use sorted-set-by you just pass in a comparator and it uses that to compare elements in the set
05:35companion_cubeoh, ok, thanks
07:09ejacksonwhen destructuring a map is there a way to use the :keys directive to pull out *all* the keys, rather than list them individually ?
07:11mduerksenejackson: how would you know which keys are in your map?
07:12mduerksenwhen you want to use the keys, i mean
07:13ejacksonits fixed. in this case the map is a bunch of parameters for another function, so I know at design time what's going to be there, and I'm just coding that using the keys of the map.
07:14ejacksonoh bollkcs
07:14ejacksoni see what you mean, the compiler won't know the symbols when it tries to compile the funciton
07:15ejacksontoo much dynamics, i'm beginning to believe in miracles :)
07:16mduerksen^^
07:19ejacksonmduerksen: well, I know what the keys are, as I would need to in order to write {:keys k1 k2 k3}, so if I could magically write {:all-keys} I could then use call k1 k2 k3 in the code. However, the compiler wouldn't know where those vars/locals and couldn't work.
07:19ejacksonat least, that's what I think, i'm reliably wrong though.
07:25LauJensenuser> (defmacro destructured [m & body]
07:25LauJensen `(let [~@(interleave (map (comp symbol name) (keys m)) (vals m))]
07:25LauJensen (do ~@body)))
07:25LauJensen#'user/destructured
07:25LauJensenuser> (destructured {:a 5 :b 10} (+ a b))
07:26LauJensen15
07:26LauJensen
07:26LauJensenejackson: its a hack, but its there :)
07:27ejacksonLauJensen: nicely done, thanks :)
07:28LauJensennp
07:28ejacksonreally illustrative code actually.
07:30LauJensenIt just occured to me, that it should simply be named let-map... :)
07:30ejacksonthat's exactly correct, it captures the semantics
07:31ejacksonwith the usual confusion over the overloading of map
07:34mfexejackson, note that the destructure macro is only different syntax for (let [a 1 b 2] ..) it will not work with (let [m {:a 1}] (destructure m (inc a))) etc.
07:40ejacksonmfex: I see that (at the repl), and am trying to figure out why...
07:40LauJensenejackson: because macros dont evaluate their arguments, so it just sees the literal symbol m, does not resolve it
07:40ejackson~m ?
07:40clojurebotslime-install is an automated elisp install script at http://github.com/technomancy/emacs-starter-kit/blob/2b7678e9a331d243bf32cd8b591f826739dad2d9/starter-kit-lisp.el#-72
07:42ejacksonsorry what I meant was, my first guess was exactly that, and was then confused by ~m didn't resolve it
07:44ejacksonbut i get it now, thanks.
08:23serp__if I understand things correctly, when using multimethods the function to use is picked based on the result of a function passed to defmulti. I want to do select which function to use based on the result of a predicate applied to the arguments. something like (defn print-type [arg] (is-number? arg) (println "a number!")) (defn print-type (constantly true) (println "something other than a number!")) where the first thing af
08:24serp__(print-type 4) would then print "a number!" and (print-type "abc") wouldn't... is there something like this in clojure already, or am I approaching the problem in a weird way?
08:32chouserserp__: the main benefit of using a multimethod instead of an if or case is that it is "open"
08:32chouserthat is, you can define several conrete functions now, but you or others can add more later
08:33chouserif your dispatch function is a predicate, there are only two possible concrete functions, one for true and one for false, so your set of functions is essentially closed anyway.
08:34serp__I want it to keep trying until it finds a true predicate
08:34chouserso, there's less reason to use a multimethod in that case, but I suppose that doesn't necessarily mean you shouldn't.
08:34chouserah...
08:34chouseryeah, that's not how multimethods work.
08:35bsteuberserp__: probably you need to build your own dispatch facility then
08:35bsteuberwith an atom holding a map from predicates to functions
08:35chouserbut order is going to matter
08:36serp__there won't ever be two true predicates
08:36bsteuberok so not a map
08:36bsteuberserp__: not even a default catch-all?
08:36serp__no
08:37chouserserp__: you're sure you can't map those predicates into values in a heirarchy? You can define your own heirarchies that are independant of Java classes.
08:38serp__hm... I don't know how multimethods and hierarchies are related
08:39chouserserp__: you provide a single dispatch function whose return value may be an item in a heirarchy, say ::Number or ::EnglishText
08:40chouserthen you define methods, each of which handles one branch of the heirarchy, so either ::Number or, say, ::String
08:40serp__aha.. so the method for ::String will handle ::EnglishText, unless there is a method for ::EnglishText ?
08:40chouserif you declare that ::EnglishText is derived from ::String, then if your dispatch fn returns ::EnglishText, your ::String handler ... exactly.
08:40serp__(why two : btw?)
08:41chouserserp__: keywords in a heirarchy must be namespaced
08:41chousertwo : gives you that for cheap
08:41serp__hmm
08:41serp__neat trick this hierarchy business
08:42serp__it will do fine :)
08:42serp__thanks
08:43chouseryou can also tie your own namespaced keywords into the main heirarchy that includes Java classes, if that's at all helpful.
08:44serp__I am doing pure clojure for now
08:44serp__maybe one day I'm ready for mixing in java
08:46chouser,(derive ::EnglishText java.lang.String)
08:46clojurebotjava.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.Named
08:46chouseroops, ignore that.
08:46chouser,(derive java.lang.String ::Value)
08:46clojurebotnil
08:46chouser,(isa? (class "hello") ::Value)
08:46clojurebottrue
08:47serp__,(derive java.lang.String :lala)
08:47clojurebotjava.lang.AssertionError: Assert failed: (namespace parent)
08:47chouserserp__: two : please. :-)
08:47chouseror :serp/lala
08:47serp__,(derive java.lang.String :serp/lala)
08:47clojurebotnil
08:47serp__hm
08:48chouserso now Strings are ::Values, :serp/lalas, and Objects, among other things.
08:48serp__:)
09:22markskilbeckComing from PHP... I'd like to say thank-you.
09:22markskilbeckSo very much.
09:23markskilbeckProgramming has become enjoyable again.
09:24chouserI suppose most "non-main-stream" language communities are made up primarily of grateful refugees of other languages.
09:24chouserAnyway, welcome. :-)
09:24LauJensengreat, one less PHP programmer out there, please accept our thanks as well markskilbeck :)
09:24markskilbeck\o/
09:25Dranikmarkskilbeck, do you develop web-sites with clojure?
09:30rseniorI was reading in a JSON doc this morning with contrib.json, where the key of a JSON map happend to be a URI, such as {"http://clojure/reader":1}. This gets turns into {:http://clojure/reader 1}, and calling (name :http://clojure/reader) just yields "reader"
09:30rseniorI found this a little unexpected, though reading the rules for symbols it makes sense now
09:31rsenioris there something that can/should be done to be smarter about this?
09:33chouserrsenior: good question. Clojure symbols and keywords are designed to allow their prefix part be partials URLs such as in your example.
09:34rseniorchouser: right, I was looking at the source and it looks like the goal is stripping out the ns prefix
09:34chouserfor symbols, 'str' will rebuild the original string, but I'm not aware of a similar function for keywords
09:34rseniorthat worked for keywords as well
09:34rseniorhowever I had typically been using name to get the string representation of the keyword
09:35chouserbut for keywords, 'str' will return a string that begins wth :
09:35rsenioroh right, I was thinking about a straight symbol
09:36chouserhm... since json keys don't generally use / to indicate a namespace in a key, perhaps the clojure json lib should explicitly build keywords with no namespace.
09:37chouser,(name (keyword "" "http://foo/bar"))
09:37clojurebot"http://foo/bar"
09:38rsenioroh, so it's the combo of it having the namespace and the URL for the value
09:51rsenioryeah, looks like calling keyword with a single string arg, that has a slash in that string causes this: "return new Symbol(nsname.substring(0, i).intern(), nsname.substring(i + 1).intern());"
09:51rseniormeaning it's treating the left half of the url as the namespace
09:52rsenior,(namespace (keyword "http://foo/bar"))
09:52clojurebot"http://foo"
09:52rsenior,(name (keyword "http://foo/bar"))
09:52clojurebot"bar"
09:54chouserexactly
09:55rsenioris this a bug report sort of thing? filed in contrib.json?
09:55rseniorseems like it's a pretty easy fix
09:59chouserrsenior: I'd say it's probably worth an email to the maintainer. This is probably a situation he hadn't considered.
09:59rsenioralright, will do
10:22ejacksoni'm sad not to be able to make a financial contribution to Clojure this year :(
10:22lpetitme too
10:28StartsWithKsame here
10:29chouserthese are for economic reasons?
10:30lpetitMaybe Rich's decision is irreversible, maybe not. In either case, I think he must hear testimonies like these.
10:30fyuryulpetit: what decision?
10:31chouseroh, there's a ggroup thread
10:31StartsWithKwe need a petition/pledge for this
10:31lpetitto stop requiring community funding for 2011, see If I'm less communicative now, it is only because I am trying to attain that level of focus once again.
10:31lpetitargh, bad copy'paste
10:32lpetitsee http://clojure.org/funding
10:32mikejsif the development of clojure can be adequately funded w/o individual contributions then why reverse the decision?
10:37lpetitmikejs: those seem to be 2 orthogonal topics, wrt to the decision motivating http://clojure.org/funding
10:39lpetitmikejs: what I mean is. Not every people has the ability/time etc. to "contribute" back to clojure (Rich) by sending patches, etc. Those people had the opportunity to show their commitment, faith, etc. via the funding effort.
10:39ejacksonThe last thing I want to do is second guess Rich - its his project, and his reasoning has been shown to impeccable. I'm just saddened that misunderstanding or mean-spiritedness on the part of some has caused what I thought of as a great funding model to be overturned.
10:40ejacksonlpetit: exactly
10:52fyuryuanother reason to hate trolls...
10:53lpetitfyuryu: beware of "duck-trolling" too rapidly, though ;-) (it's not ruby, it's clojure :-D)
11:02danlarkin'
11:03danlarkinwhoops
11:04raekooh! an U+0027 APOSTROPHE! *yoink*
11:32TobiasRaederhey :)
11:33TobiasRaederanyone ever used custom cake tasks that had some dependencies (as in some .jar file)?
11:38stevepsorry, lein here
11:55lpetitsorry, just POMU (Poor Old Maven User) here
11:55lpetits/Poor/Plain/ :-)
12:08S11001001shell & curl, who needs that fancy dep fetching stuff
12:27ejacksonlpetit: s/Poor/Productive/ :)
12:36stevephttp://tech.puredanger.com/2011/01/04/forkjoin-clojure/
13:03markskilbeckDo any of you guys have experience using nailgun & VimClojure?
13:05RaynesTobiasRaeder: There is a channel dedicated to cake over in #cake.clj. If you don't get any cake answers here, you'll probably get some answers in a little while there when activity is up.
13:05TobiasRaeder@Raynes alright, i will try that. thanks
13:10Berengal_Is there a nice way to define a way of combining records based on fields?
13:11raekwhat does "combining" mean in this case?
13:11Berengalraek: Adding them together, in a general sense
13:11duncanma question about API design: is there a reason why merge and concat need to exist separately from conj?
13:12Berengalraek: Given two records, return a new one that's the "sum" of the input
13:13mrBlissBerengal: merge or merge-with
13:13mrBlissor into
13:13BerengalmrBliss: That assumes the data is homogenus.
13:14BerengalmrBliss: Consider merging records with fields [:word-count :word-list]
13:15BerengalIt's no big deal writing the function myself. I just wondered if there was a builder-function for this already
13:16BerengalSomething like (reduce (merge-fields {:word-count +, :word-list concat} record-list)
13:17BerengalLost a paren there, after the map...
13:19mrBlissBerengal: I'll think you'll have to come up with a function. rename-keys or select-keys seem to be good functions to start from.
13:19BerengalmrBliss: Got it
13:19mrBliss(btw: rename-keys lives in clojure.set)
13:20duncanmmrBliss: in a similar topic, any ideas about conj/concat/merge?
13:21duncanmautomatically, i go to 'conj', but it's bit me a few times, took me a while to realize that i should be using merge or concat instead
13:27mrBlissduncanm: I don't quite understand your question. But I can say that what conj does, depends on the coll it is passed (vector, list or map). I use conj when I know how many elements I'm gonna add to a collection (1 to 3). I use into when I want to 'conj' 2 collections together. Merge is solely used for maps and records. I use concat to join multiple collections together, knowing that the order will be preserved (unlike into used with
13:27mrBlisslists). I hope this helps a bit :-)
13:28midsmarkskilbeck: tried it but didn't like it. I am back to using slime.vim
13:30markskilbeckmids: slime.vim was being a pain for me - it complained about not being able to open a file in /tmp/blahblah
13:30markskilbeckGoing to try vimclojure and see if it plays nice.
13:31midsmarkskilbeck: slime.vim or slimv.vim?
13:31markskilbeckslime.vim, mids.
13:31mids(I am using the one that just pipes stuff to screen
13:31markskilbeckmids: yeah, that'n.
13:31kryftI'm going to try emacs with vimpulse when I have the time.
13:33markskilbeckkryft: seems like emacs is the de facto and best tool to use for clojure dev, though I CANNOT be bothered learning how to use it.
13:35midstbh since I started using an autotest loop I stopped using all the fancy stuff
13:36kryftmarkskilbeck: Well, with vimpulse you shouldn't have to. =)
13:36scodeWhich repository is clojure-maven-plugin supposed to be in?
13:36scodeIt seems to be missing from central, but I thought it was there before. I just noticed because I cleaned out my ~/.m2/repository on purpose to make sure dependencies would resolve.
13:37markskilbeckkryft: I saw "emacs" and stopped reading ><
13:38midsscode: http://repo2.maven.org/maven2/com/theoryinpractise/clojure-maven-plugin/ still there?
13:38scodemids: Sorry, yes
13:38scodeI just realized...
13:38scodeI had -SNAPSHOT for historical reasons.
13:38scodeI presumably didn't realize that because I did a local 'mvn install'.
13:38scodeSorry for the noise.
13:40Raynesmarkskilbeck: You're going to see a lot of "emacs" 'round these parts.
13:40cemerickmarkskilbeck: Many use the eclipse plugin, FWIW.
13:41kryftIf vimpulse works well enough, emacs+vimpulse should be the best of both worlds: the cool modes and extensibility of emacs with the editing interface of vim.
13:42programble<markskilbeck> kryft: I saw "emacs" and stopped reading ><
13:42programblethat kind of attitude will get you nowhere in life
13:43kryftErm, best for me, that is; I'm well aware of the hordes of people that would rather gnaw their hand off than use a vi-style editor. :)
13:43kryftWell, it got him to #clojure, so how bad can it be?
13:44RaynesHehe.
13:44markskilbeckprogramble: my apologies for not being interested in emacs, right now. But I can only do so much.
13:45programbleeven if you aren't, ignoring anything pertaining to something you are not interested in will not get you far
13:45markskilbeckIt was a small sentence.
13:45programblethat would be illegal
13:45programbledon't give alcohol to minors :P
13:46programblebetter
13:46kryftI think IRC counts as international waters.
13:47chouservirtual beers are legal for all ages
13:47programbledom96: you have a bad habit of doing that
13:47dom96huh?
13:49amalloyi would be willing to use vi if the alternative were gnawing off a hand
13:49Raynesamalloy: o/
13:49dom96amalloy: That statement offends me.
13:50amalloyRaynes: but when the alternative was spending two hours looking up how to configure tramp to use ssh+sudo, i chose that instead :P
13:50Raynesamalloy: Tramp is unnecessarily difficult to use, I think.
13:53LuytWould it also try to redefine the language it's written in?
13:54chouserLuyt: you mean as rails does to ruby?
13:54devnTramp isn't so bad...
13:54devnLuyt: That's part of the language, is it not?
13:54Raynesdevn: Have you ever tried to set it up so that you could edit files with root?
13:55cemerickdevn: I've not had the same thoughts, simply because rails doesn't do much I'm interested in. *shrug*
13:55devnRaynes: :D hahaha oh right
13:55devnI gave up on that
13:55LuytA friend of mine who is into conspiracy theories, suggested that the ongoing monkeypatching of Ruby by the rails developers set some angry blood in Japan, that's why they refuse to open their process to the english-speaking world, and introduce unicode incompatibilities. I think he's a bit weird.
13:55cemerickThere is a rails-inspired framework out there...
13:55cemerickhttps://github.com/macourtney/Conjure maybe?
13:55devncemerick: I've played with it
13:56cemerickhrm, hiccup, nevermind :-|
13:56devnI've been toying with the idea of building my own
13:56chouserI think there are lots of people who want something that could be named InstaCRUD
13:56LuytI'd be a killer app ;-)
13:56cemerickdevn: there's your name ^^ ;-P
13:57devnhahaha I will not be naming it InstaCRUD
13:57chouserI'm probably one of them
13:57devnbut yeah chouser that's the idea
13:57cemerickIf it could have a couch backend, that might be interesting.
13:58chousercemerick: don't see why not
13:58devnI think it will come with time -- I'm already starting to see a number of people toying with ways of doing templating in Clojure
13:58devnslim, haml-macro, hiccup, enlive, etc.
13:58devnring is well on its way, and so on
13:58stevepyeah, seen enlive mentioned a few places
13:59stevephaven't looked at it yet
13:59cemerickchouser: AFAICT, Rails ≈ CRUD ≈ RDBMS
13:59devnenlive is a brilliant piece of software but it certainly isn't for someone who just wants to get up and running and start doing stuff
13:59cemerickJust conceptually of course, not technically.
13:59stevep*nods*
14:01devnive showed people insanely simple clojure code next to their ruby code and they are dumbfounded -- granted we don't want to pander to the LCD, but I think there needs to be more of a focus on making life easy (at least at first) for people who just want to build a little dynamic website
14:02stevephiccup + ring get you pretty far
14:03LuytBut is it web scale? http://mongodb-is-web-scale.com/
14:05chousercemerick: I simply mean that someone doing CRUD generally doesn't care if it's RDBMS underneath or not. Many of them use MySQL, after all.
14:35ssiderisdevn: was the insanely simple code written with enlive?
14:47hiredmanhttp://clojure.org/funding god damn it lau
14:47RaynesI'll second that notion.
14:47LauJensen?
14:48RaynesIsn't it obvious? You've destroyed the world. Cursed us all. Turned all that was good and holy to evil. Water to poison; etc. ;p
14:48LauJensenhiredman: Im not sure I can take credit for that :)
14:49qbgMore fallout from LauGate
14:49LauJensenhehe
14:50benreesmanhey can anyone point me in the right direction for the idiomatic way to get a lazy sequence that takes it's contents from a LinkedBlockingQueue?
14:50qbgI'd write a function that uses lazy-seq
14:50chouserbenreesman: probably (repeatedly #(.take lbq))
14:50qbgNot sure if there is a better way
14:50hiredmanthere is no single way to do it, if you want the contents without blocking or removing stuff you can just call seq
14:51benreesmani want it to block
14:51hiredmanthen chouser's repeatedly will work
14:51benreesmanexcellent, thanks guys
14:51qbg(inc chouser)
14:51sexpbot⟹ 3
15:00devn(some #(and (= (mod % 5) 0) (= (mod % 7) 0)) (range 1 100))
15:00devn(1..100).detect {|i| i % 5 == 0 and i % 7 == 0 }
15:01devnThese don't work alike, perhaps I meant to use filter:?
15:01chouserrough count of syntax rules employed: 2, 5
15:02qbgchouser: ?
15:02chouser,(some #(and (= (mod % 5) 0) (= (mod % 7) 0) %) (range 1 100))
15:02clojurebot35
15:02amalloyqbg: not syntax-rules, but "rules of syntax" for ruby/clojure code just posted
15:03qbgAh
15:03chouserqbg: to understand the clojure you need 2 rules, (foo x y) calls a function, #(mod % x) defines a function
15:04chouserfor the ruby, () .. . {} |i|
15:05qbg,(some #(= (mod % 5) (mod % 7) 0) (range 1 100))
15:05clojurebottrue
15:05chouserof course that's only rough. both use whitespace, some non-alpha for equality, etc.
15:05qbg,(some #(and (= (mod % 5) (mod % 7) 0) %) (range 1 100))
15:05clojurebot35
15:05chouserdevn: so either be explicit about what your fn returns, or use (first (filter ...))
15:08amalloychouser: the first/filter idiom annoys me: i wish (some) behaved that way; surely it's a more common usage than the way it currently behaves, which i guess is (first (filter identity (map f coll)))
15:10chouserI think some is meant as a correlary to every? not-every? and not-any?, but with a bit more power
15:10qbg,(first (filter #(apply = 0 (map (partial mod %) [5 7])) (range 1 100)))
15:10clojurebot35
15:12amalloychouser: ##(some even? (range)) reads like "some even integer", not "is there an even integer?"
15:12sexpbot⟹ true
15:12amalloyi'd be happy to have a (some?) function that fits in with every? and family
15:12chouserI think it'd be called 'any?'
15:12qbgMaybe example is a good name for (first (filter ...))
15:13amalloysure, any? is good. better to avoid overloading "some"
15:13chouserbut surely there's not much value in having 'any?' or 'some?' when we have 'some'
15:14chouser,(->> (range 1 100) (filter #(zero? (mod % 5))) (filter #(zero? (mod % 7))) first)
15:14clojurebot35
15:15devnthanks -- i ended up just making it a filter and taking first
15:15chouserisn't there another way to say (iterate inc 0) ?
15:16amalloychouser: if 'some' were redefined to be first/filter, then there might be a desire for 'any?': ##(first (filter #(instance? Boolean %) [1 false]))
15:16sexpbot⟹ false
15:16devn,(type (filter #(and (= (mod % 5) 0) (= (mod % 7) 0)) (range 1 100)))
15:16clojurebotclojure.lang.LazySeq
15:16devnIs there a function to return that it is a "vector"?
15:17amalloydevn: it's not a vector
15:17devnerr im sorry that's not what i meant
15:17qbg,(vec (range 10))
15:17clojurebot[0 1 2 3 4 5 6 7 8 9]
15:18devnqbg: yeah that's not my question -- im interested in having it tell me if it's a vector, a set, etc. instead of returning clojure.lang.LazySeq
15:18devnis that possible with any of the core fns?
15:18chouseramalloy: I do find some ...dissonance? around 'some' and (first (filter identity ...)), but I'm don't really like most of the proposed solutions.
15:18qbg,(vector? [1 2 3])
15:18clojurebottrue
15:19devnagain, that's not the question im asking
15:19chouseramalloy: I'd be happy if calling (filter foo) were like (filter identity foo)
15:19chouserbut that's a small improvement
15:19chousermaybe we need a ffilter
15:19chouserI'd use that much more often than I use ffirst
15:20amalloychouser: true that
15:20devni want to ask whether "it" (where "it" could be [1 2 3], {:a 1}, or (1 2 3))
15:20qbgdevn: A clojure.lang.LazySeq is a seq, not a vector nor a set
15:20devnso i'd like to have it return 'seq'
15:21amalloydevn: so you want some function f of a collection, so that (f (range)) is seq, and (f [10]) is vector?
15:21chouserdevn: what would you like it to return when given a PersistentList, which is a seq but also a list and a stack?
15:22devnhonestly im just looking for a "pretty" way of printing its type without all of the java.lang.Foo
15:22devnI could write this, sure -- but I'm wondering if anything in core already does this
15:22hiredmanthe type is really some set of interfaces
15:23amalloy&(-> [] class .getName)?
15:23sexpbot⟹ "clojure.lang.PersistentVector"
15:23amalloyhrm
15:23hiredmanbut the concrete jvm type name is a detail
15:24devnit's not the end of the world or anything, but I'm trying to mimic how Ruby acts when you say "foo".class? => String
15:24devnI want to "sell" clojure to some friends of mine and am looking for a pretty way of displaying this
15:24qbgIs it really that different?
15:24hiredmanthat just because ruby doesn't have packages
15:24devnRubyists hate things that even casually resemble java
15:24qbg,(supers (type (range 10)))
15:24clojurebot#{clojure.lang.Seqable java.util.List clojure.lang.Sequential clojure.lang.IMeta java.io.Serializable java.lang.Iterable clojure.lang.Obj clojure.lang.ISeq java.lang.Object clojure.lang.IObj ...}
15:25devnI'm just trying to get rid of any hints of java where possible
15:26S11001001find-first in clojure.contrib.seq-utils
15:26Raynesdevn: If they're that opposed to Java in any form, I seriously doubt your efforts will be rewarded. Clojure is a JVM language, and thus you don't really get away from Java.
15:26mikejsdevn: they're going to have to get over that if they consider using clojure
15:27RaynesIf they aren't willing to accept the JVM as a platform, then there isn't much hope for them.
15:27chouser,(map #(symbol (.getSimpleName %)) (supers (type (range 10))))
15:27clojurebot(Seqable List Sequential IMeta Serializable Iterable Obj ISeq Object IObj ...)
15:27chouserthat's a bit less messy, though it obscures some important details.
15:27stevep@Raynes +1
15:28amalloy(inc Raynes)
15:28sexpbot⟹ 2
15:28amalloystevep: ^ :)
16:26kjeldahlHm. ring.middleware.reload isn't found by cake. Anybody know what it's called these days?
16:27raekkjeldahl: ring/ring-devel "0.3.5"
16:34kjeldahlraek: Thanks. I suspect a dependency declaration wasn't needed.
16:45BufferUnderpantsHi.
16:46BufferUnderpantsI'm toying with lein-war and I'm wondering how would one put an arbitrary file in the resulting WEB-INF folder.
16:49raekBufferUnderpants: looks like everything in src/html/ ends up in / in the jar, so maybe you can put the stuff in src/html/WEB-INF/
16:49raek(this is what I can tell from https://github.com/alienscience/leiningen-war)
16:49BufferUnderpantsYeah, some other helpful fellow suggested it on the #leiningen channel too, thanks
16:49BufferUnderpants(how didn't I think of that)
17:47rata_hi
17:48rata_is there a fn like nth that takes the number first, then the coll?
17:49tonylnot that i know of. seems a bit unidiomatic. why?
17:50raekrata_: #(nth %2 %1) ;; <-- now there is :-)
17:51rata_tonyl: because (nth (big-expression) n) is less easier to read than (nth n (big-expression))
17:52raekthis is why -> was invented
17:52raek(-> (big-expression) (nth n))
17:53rata_raek: (#(nth n %) (big-expression)) and (-> (big-expression) (nth n)) are harder to read imo
17:53amalloyrata_: -> is very nice once you get used to it
17:53rata_I use it a lot, but here it's ugly
17:53raekwell, regarding the first one, I agree
17:54rata_btw, it's a pity there's no third, fourth, etc
17:54S11001001named-nths.lisp
17:54raekI thought you needed to pass the fn to some other higher order fn that expects the args in the other order
17:54raekI usually use destructuring in those cases
17:56rata_raek: yes, using destructuring gets better
18:06ossarehlo all
18:06auserola
18:53ossarehreasonable? (defn within? [key coll] (not (empty? (drop-while #(not= key %) coll))))
18:53ossarehI feel like this is already in core but I don't know what the name is likely to be.
18:54amalloyossareh: (some) does this
18:54amalloy&(some #{4} [1 2 3])
18:54sexpbot⟹ nil
18:54amalloy&(some #{4} [1 2 3 4 5])
18:54sexpbot⟹ 4
18:55amalloy(this takes advantage of the fact that sets act like predicates testing for their contents)
18:55ossarehye, I actually use that elsewhere.
18:56ossarehthanks amalloy
18:57amalloywelcome!
19:07ossareh(inc amalloy)
19:07sexpbot⟹ 1
19:28_ViUsual Clojure is for JVM and easily mixed with Java code. I also heard about .NET and JS versions. Will there be Clojure that can be easily mixed with Perl code? (e.g. clojure for Parrot VM)
19:29qbg_Vi once the Clojure complier is ported to Clojure and core data structures are rewritten in clojure, that sort of port will be easier
19:29_Viqbg, Is it moving to that "self-hosted"-ness?
19:29qbgSome progress has been made
19:30qbgProtocols/types introduced in 1.2 will help with the data structures
19:30qbgThe gvec stuff is already implemented using them
19:30_ViIn general, is it expected that there will be Clojure for many things (parrot, Qt, python) in future or clojure.net and clojure for JS will die out and it will be locked to JVM?
19:31qbgIt'll be a while though before clojure is rewritten in terms of itself
19:32_Vi(It's good to write lispy things using convenient libraries and with possibility to just implement things in low-level language in case of problems with Clojure)
19:32qbgThe downside of ports to other platforms is the lack of the ability to use java libs
19:33_Viqbg, Compensated with ability to use that native things (.NET libraries, JS libraries, Qt libraries, etc.)
19:33qbgSure, you could in theory have clojure on <your favorite vm>, but a lot of existing code won't transfer over that easily
19:33_Viqbg, I think they should be as easy to use in clojure ports as Java libraries in common Clojure.
19:33qbgThey depend on java though
19:34_Viqbg, "<your favorite vm>", So don't wait for things like "Clojure4Qt", right?
19:35qbgIts going to be a while
19:35qbgRight now, a lot of Clojure is still written in Java
19:35_Vi(let [q (QWidget. nil)] (.add (QLabel. "qweqe")))...
19:36qbgI'm not sure how much of that will be easy to do on a non-JVM
19:36qbgor java-like vm
19:37_Vis/or java-like vm/or non-java-like vm/?
19:37qbgCorrect
19:37hiredmanthere alread was a js port, but it hasn't been kept up be cause clojure was developing so fast it was hard to keep pace with
19:38qbgAlso, I can imagine running Clojure in a C++ native land to be very painful
19:38_ViMay be Clojure would inspire creating similar things (lispy, immutable, STM, easy native lib calls) for other frameworks.
19:40_Viqbg, I don't expect "Clojure++" to integrate that well with any C/C++ code, but expect it to integrate well with Qt and GObject things (which provides reflection and other things).
19:41qbgGood GC support and dynamic code loading should be there too
19:42_Viqbg, There are GC for C code. Dynamic code loading? Should be possible (at least as saving temp lib and dlopen-ing it).
19:42qbgECL does it, so in theory it isn't a problem
20:08devnso am I crazy or is using camelCaseForVarNamesCompleteInsanity?
20:10devnI suppose my next question is: Would I be a huge jerk if I took someone's library and submitted a pull request with proper source formatting and renamed vars to be foo-bar instead of fooBar
20:11qbgcamelCase = not good
20:11lancepantzthis is known as github trolling
20:11lancepantzand yes, you should do it
20:19devnpull request coming
20:19qbgIf code had blood, it would be everywhere right now
20:21devni love clojure, but people with no aesthetic value tend to make awful messes
20:23devnhttps://gist.github.com/765778 -- Check out this dandy...
20:24qbgDid that person come from Haskell?
20:26devnyes.
20:26qbgKnew it
20:26devnobviously a really smart guy, but this syntax is...not clojure
20:26qbgThe let-bind and >>== gave it away
20:28devnactually, I just realized that this library I'm playing with was built off of another library he wrote that is likely bigger and even worse
20:29qbgWhat does this library do?
20:30hiredmanlooks like a parser
20:43ossarehqbg: what is the haskell give away?
20:43ossarehignore ^
20:44devnqbg: the >>=
20:44devnerr ossareh
20:44devnI found another haskell give away: <|>
20:44devn(defn <|> ...)
20:55devnit's just a little jolting to see someone write code where they don't even seem to be looking at examples of other people's code for guidance on style and idioms
20:55qbgWho wrote this?
20:55KirinDavedevn: Not so unusual for lisp-haskell expats.
20:55KirinDavedevn: CommonLisp folks do what they want, when they want. It's sort of a thing.
21:09devnqbg: It'd be rude to say
21:09qbgI hope they are not currently on this channel
21:10devnKirinDave: Yeah, that's not something I guess I'm very familiar with. It seems like all of the languages I've learned I always cared a great deal about style.
21:10devnqbg: they aren't.
21:12qbgThe patient has survived their first surgery; it can now rest before its next one
21:17chett``Programming Clojure refers to clojure.contrib.repl-utils/show to enumerate fields of Java Objects.
21:17chett``O can't find this method in clojure.contrib 1.2
21:18qbgShould still be there: http://clojure.github.com/clojure-contrib/repl-utils-api.html#clojure.contrib.repl-utils/show
21:24amalloychett``: it's there. i had a lot of trouble finding it when i was new to clojure because i couldn't figure out the ns/use/require forms
21:24amalloyyou want (use '[clojure.contrib.repl-utils :only [show]]) for standalone, or within an ns form (:use [clojure.contrib.repl-utils :only [show]])
21:27chett``amalloy: thanks, I thought I had it covered by including it in the project dependencies
21:27chett``minor oversight
21:27amalloychett``: that makes the library available, but you have to require it for use in a given source file
21:31chett``I also need to read an erc tutorial as my evil twin and his evil twin chett` and chett`` are in here too
21:31amalloychett``: no, only chett`` is in #clojure
21:31chett``thanks
21:32amalloybut you probably need to read that tutorial just the same, since i bet you want chett :)
21:38cemerickHTTP/REST/HATEOS fans: what response code best indicates a situation where content at some URI isn't available yet, but will be eventually? My best guess at the moment is a straight 300, with perhaps an indication of an expected ETA in the response body.
21:41amalloycemerick: 307 looks right to me?
21:42amalloy300 afaict implies that there are multiple near-equivalent copies of the same resource
21:42cemerickamalloy: except the requested URI is right, just not yet…
21:43hiredman418
21:43amalloycemerick: it's a temporary redirect to the "nothing here yet" uri
21:45amalloyhiredman: lol. i like 418
21:45cemerick419 Godot
21:46amalloyhiredman: almost as entertaining as 500 The Bees They're In My Eyes
21:47cemerickhere I am looking at the HTTP/1.1 RFC, but the perfect one was waiting for me in the webdav spec
21:47cemerick102 Processing – This code indicates that the server has received and is processing the request, but no response is available yet.
21:47amalloycemerick: that doesn't sound anything like what you want
21:48cemerickamalloy: that describes the situation exactly, actually
21:48cemerickMaybe my initial description was poor…
21:48amalloycemerick: 1xx (in http 1.1, anyway) is for "informational content" while the server is working on creating a real 200+ response
21:49cemerickamalloy: Right -- perfect. The content for the URI in question is being generated, but isn't available yet.
21:50amalloycemerick: so you expect it to be available in a few seconds, not a few weeks?
21:50cemerickYeah, seconds, minutes maybe, not hours or weeks.
21:50amalloyah. then 1xx sounds fine
21:51bridgethillyer102 implies actual processing is going on
21:51bridgethillyerie by a CPU :)
21:52amalloycemerick: or maybe 202?
21:52cemerickbridgethillyer: exactly right -- thing's in the oven, will be out shortly.
21:52bridgethillyerI think 404 is really the best option even though it would be cool to have something like what you suggest
21:52amalloyi'm not sure 102 is allowed for plain http
21:53daleGiven a Reader in Clojure, is there a nice way to say "read N bytes into a String" other than just doing (.read ...) with a char[]?
21:56cemerickamalloy: doesn't 202 imply that that request is what started the processing?
21:56amalloycemerick: it doesn't look that way to me from the rfc, but it's not clear
21:57qbg,(let [sr (java.io.StringReader. "hello, world!")] (apply str (repeatedly 5 #(.read sr))))
21:57clojurebot"104101108108111"
21:57qbg,(let [sr (java.io.StringReader. "hello, world!")] (apply str (repeatedly 5 #(char (.read sr)))))
21:57clojurebot"hello"
21:57daleHeh.
21:57qbgNot sure I'd recommend that...
21:58daleAgreed.
21:58hiredmanbetter to use a bytearrayinputstream
21:58qbg(slurp (java.io.StringReader. "hello, world!"))
21:58qbg,(slurp (java.io.StringReader. "hello, world!"))
21:58clojurebot"hello, world!"
21:58qbgUse that
21:58qbgIf you want all of it
21:59daleqbg: I need to read N bytes, not the whole file.
22:00dalehiredman: That only reads from a byte array though, right? I have an InputStream from a Socket.
22:01hiredmandale: was in response to StringReader
22:01daleOK.
22:02hiredmandale: inputstreams don't read chars regardless
22:03hiredmanin that case (byte-array n) is a great way to do what you want
22:04dalehiredman: Given s/want/have to do/, it is. Thanks. :)
22:05daleI'm just chafing against java.io. I'll eventually get used to its regular beatings.
22:07cemerickamalloy: yikes, I see what 102 means by "prevents the client from timing out": curl sits and waits for a "real" response.
22:07cemerick202 it is
22:07hiredmanfile and copy from clojure.java.io are great for that, but I can't speak for the quality of anything else in there
22:07amalloycemerick: muahaha
22:08hiredmanlast time I tried to use a function from either there or contrib (back when it was in contrib) for reading a file into a byte array it did it via a Reader, very bad
22:08daleReaders are for characters, InputStreams for bytes, right?
22:09amalloydale: yeah
22:09hiredmaninputstreams for everything unless I need a reader
22:09daleclojure.java.io looks suspiciously like clojure.contrib.io looks suspiciously like clojure.contrib.duck-streams.
22:09hiredmancorrect
22:10hiredmanin the process of a lot of duck-streams stuff being promoted from contrib to clojure the namespace was renamed and juggled around
22:11daleI see.
22:14amalloywhat's the clojure naming convention for type conversions? eg what to name a function that takes lisp-named-strings and turns them into lispLikeStrings?
22:14hiredmanthats not a type conversion
22:14hiredmanString in, String out
22:14amalloyhiredman: yes, sorry
22:15amalloyi figured it would follow the same convention since it's a translation of sorts
22:16hiredmanI like a->b
22:43devnwhat is >== in Haskell? <|> ?
22:59hiredman>>= is bind
23:06devnhiredman: ah of course, thanks
23:26clizzinis there a difference between (require '[foo :as f]) and (use '[foo :as f]) ?
23:28devnclizzin: http://stackoverflow.com/questions/871997/use-vs-require-in-clojure
23:30clizzindevn: that doesn't cover if there's a difference when i have the :as keyword in my call to use
23:31devnclizzin: right you are. im not sure the answer to your question. i read a post that i could swear had some info on this exact problem but im having trouble finding it.
23:32clizzindevn: interesting, let me know if you find it
23:32devnclizzin: is there any reason in particular you're asking?
23:33devnmy wild guess here is that require is preferred
23:33clizzindevn: no, just curious. it does seem silly to have two ways of doing the exact same thing
23:33devnclizzin: im trying to imagine the use case myself :)
23:36devnclizzin: you understand that use accepts extra opts right?
23:36clizzindevn: yeah, although the only ones i'm familiar with are :only and :exclude
23:37devnclizzin: there's also a :rename
23:38devnclizzin: but i think it's probably best to look at hosw similar require and use are under the covers
23:39clizzindevn: gotcha. thanks for the info
23:39devn'use is (defn use [& args] (apply load-libs :require :use args)
23:40devn'require is (defn require [& args] (apply load-libs :require args))
23:48devnclizzin: it seems like they're the same thing in that case, but in one case you have access to the extra options, but someone smarter than me will likely correct my mistake at any moment
23:51clizzindevn: cool thanks
23:53daleI suspect the difference between use and require there is that use will (refer) to foo, require will not?
23:53daleAnd the fact that use accepts :as is probably just a side-effect of the fact that it's implemented as a superset of require's functionality?
23:54devnclizzin: heh, ill quit talking at you now, but skim the 1.2.0 source (or search) for load-one, load-all, load-lib, load-libs, require, use, defmacro ns, refer-clojure, and alias
23:54daleI guess (use '[foo :as f :only y]) might be useful to only bring y into scope while leaving the rest of the namespace accessible through f.
23:54devndale: yeah it's a chisel where use is a machete
23:54devni think that you're explanation is correct
23:58clizzindale, devn: pretty sure that's not what (use '[foo :as f :only y]) does; see http://clojuredocs.org/clojure_core/clojure.core/use#example_170 for a counterexample
23:59clizzinactually, that's the code snippet that first alerted me to the fact that you can have :as with use