#clojure logs

2011-01-20

00:03amalloygtech: i don't even know what jswat is, but have you thought about using george jahad's clojure debugging toolkit?
00:19mabeshow can I tell if a lazy seq has been realized fully?
00:19mabes(this is for a test)
00:27amalloymabes: haven't you been asking about this on the mailing list? make each element of the sequence have side effects, and test to see how many side effects have triggered
00:28mabesamalloy: no, I don't check the ML too often either so I will if there is some discussion on it
00:28amalloymabes: yeah, i think someone's been asking about this in the last week or so
00:29mabesah, I see the thread.. thanks amalloy
00:30gtechamalloy: cool that's a step in the right direction, thanks!
00:30amalloywelcome folks
02:40TobiasRaedermorning
02:40Scriptormorning TobiasRaeder
02:52afekzanyone here have much experience setting up enclojure on OSX? I can't see any "Libraries" node on my Project Properties and I'm starting to feel like I need to ask for a smack with a clue-by-four
03:44Licensermorning
03:46LauJensenMorning
03:49raekmorning, europe
03:50LauJensenGood morning UGT
03:51Licenseryay UGT!
04:05frank(+ 1 1)
04:05clojurebot2
04:05Fossi\o/
04:05Licenser(* 1 1)
04:05clojurebot1
04:06Licenser(<3 "cookies")
04:13pareidoliaHi all
04:14pareidoliaDoes anyone know of a way to tell cake to use a specific version of swank? My emacs has an older slime installed
04:15pareidoliaI could tell the clojure-maven-plugin which version of the protocol to use, but I'd like to try cake
04:15Licenserthe cake is a lie!
04:15octethe cake is there, you'll see
04:16octei feel good for finally playing through portal and understanding the cake references
04:17raekpareidolia: from the swank-clojure docs "It may also warn you that your SLIME version doesn't match your Swank version; this should be OK."
04:18raekpareidolia: is the warning all you get, or does something break?
04:21Dranikhello all! I'm playing with macros trying to generate a template function but has stuck with the symbols names. I have defined a parameter msg# but can't use it in the function body
04:21Dranikcould you please look at https://gist.github.com/787621#
04:27raekDranik: 1) Close parens on the same line 2) You generally don't use string operations to generate code. use syntax-quote as you have done at the other places 3) an autogensymed symbol only spans the current syntax-quote
04:28Dranikraek, thanks, I'll give it a try
04:28raek3) can be solved by (let [sym (gensym "msg")] `(foo ... ~msg ... ~(bar ... `(baz ... ~msg ...) ...) ...)
04:29Dranikoh wow!!
04:29Dranikthanks!
04:30raekalso, code using map + anon function is often more prettily written using 'for'
04:32Dranikraek, thanks for your advise, I'll check it out!
04:34raekDranik: I reformatted it and applied 3): https://gist.github.com/787632
04:35raekbeware, I have not tested this
04:35Dranikraek, thank, I'll try to run it
04:36raekhrm, I already realized an error: you need a (apply concat ...) call around for, or you can use mapcat the way you used map before
04:36raekevery f needs to generate two forms, so all these pairs has to be concatenated somehow
04:38Dranikseems like (apply concat didn't help....
04:38raekDranik: you can test the macro using (macroexpand-1 '(create-object ...))
04:39raekthat way you will se what the code expand too
04:39raek*to
04:39Dranikyep, doiing that
04:39raekgotta go, good luck.
04:40Dranikthanks!
04:51Licenserout of curiosity how is the status of clojure and databases?
04:51LauJensen?
04:51Licenseras in what solutions exist, how 'good
04:51Licenser' are they compared to each other
04:52LauJensenWell, ClojureQL is the way to go if its relational databases. For non-relational I've only really looked at FleetDB which I really didn't like.
04:54LicenserI was also wonderinger about mongodb and hadoop but I am entirely not sure
04:55Licensersince I am at the position of a fresh start I have the freedome to choose weather I go for a relational or document based DB
05:01Licenseractualy couchdb not hadoop
05:03pareidoliaraek: Thanks
05:03pareidoliaraek: I remembery trying it once, and encountering exotic looking errors and unpredictable behaviour
05:04pareidoliaraek: Or am I fooling myself? Does setting the protocol version actually do anything with clojure-maven-plugin ?
05:07pareidoliaI hope I don't offend anyone with this noob question... Is it possible to define a function that takes a map, and implicitly all map keys are available as variables which evaluate to the keys' values ?
05:09raekit would be possible to do with a macro. if enumerating the keys is acceptable, then (let [{:keys [a b c d]} m] ...) should be sufficient
05:11clgvpareidolia: raek's proposal seems to be the easiest way
05:13raekcode with "magic symbols" (i.e. variables whose binding forms are hidden) tends to be hard to read anyway
05:14raekpareidolia: also, it would only be possible if the map was known at compile time.
05:15raek(it = the idea in your question)
05:15pareidoliaAh, it's a large map
05:16pareidoliaI'm comfortable with (:keyword themap), but I always wonder if there is a "better" way
05:16clgvyes it's the one raek showed you ;)
05:16clgvbut you have to know the keys on compile time
05:19pareidoliaI'm customizing the example at http://www.learningclojure.com/2010/10/generating-xml-to-make-svg-vector.html for my use
05:26clgvhow do I include resources, like images, into my clojure project? where do I have to put them? how do I tell leiningen to include them?
05:27raekclgv: resources/
05:27raekleiningen includes that dir by default (if present)
05:28clgvok. and it's top level directory within the created jar?
05:28raekthat dir will be on the classpath and the contents will be included in produced jar files
05:28raekyes
05:28clgvok thanks.
05:29raekif you meant that resource/foo/bar.txt will end up in <jarfile>/foo/bar.txt
05:30raekit behaves as src/
05:33pareidoliaAre spaces allowed in :keywords ?
05:38clgvpareidolia: I dont think so. but you can use "-"
05:40pareidoliaI vaguely remember reading something about a special escaping notation... ah well, if anyone knows...
05:48clgvwhy would you want to make it that complicated?
05:56pareidoliaclgv: I'm exploring borders haha
05:57clgvlol. you should have a look at borders of symbol names ;)
07:11clgvis there some version of "get" that can be used within nested maps like update-in?
07:11clgve.g. (get mymap [key1 key2] default-value)
07:17rrc7czif I (defmacro defn' [name params & body] `(defn ~name ~params (binding [*foo* this] ~@body))), "this" seems to bind to a var in the local namespace. What if "this" is actually a paramater in params (gen-class fns)? How do you prevent it from trying to resolve to #'somens/this and instead capture the local parameter?
07:17mduerksenclgv: get-in
07:18clgvmduerksen: thx. that seems so easy to guess, but I didnt :P
07:19_na_ka_na_where's clj-time repo, github gives a 404
07:21mduerksenrrc7cz: i'm not sure i get what you want, but havin local params in macros lets me think of mylocalvar#. example: (defmacro test [coll] `(let [f# (first coll)] (println f#)))
07:21mduerksenin that case, for f# a local symbol is generated
07:23rrc7czmduerksen: but that generates a unique local symbol. I need to instead capture an existing one
07:24rrc7czmduerksen: here is the problem: I have a large number of fns that look like this (defn one [this] (binding [*api-key* (.apiKey this)] (do something)))
07:24mduerksenrrc7cz: ok, then i didn't understand your goal correctly, sorry
07:24rrc7czmduerksen: I'd like to make a def+key macro that just wraps all the bodys in that binding form to reduce duplication
07:26mduerksenrcc7cz: and you need 'this' in the bodies, right?
07:28rrc7czmduerksen: maybe, maybe not. These are gen-class fns, so "this" is the required first param. It can be used to pull the object's state, like @(.state this)...
07:28rrc7czmduerksen: I definitely need 'this' for the binding form to work correctly, because it pulls the object's state (.apiKey) and binds it to *api-key*
07:29rrc7czmduerksen: it all expands correctly, except 'this' is bound to #'myns/this, which doesn't exist, instead of leaving it as a symbol 'this' which captures the fn param at runtime
07:30clgvif "this" is visible just use "~this" and you should capture the right one, dont you?
07:30mduerksenrrc7cz: i'm not sure it will work, but maybe just put a ' in front?
07:31mduerksenin front of 'this, i mean
07:32clgvrrc7cz: try that one: (defmacro defn' [name params & body] `(defn ~name ~params (binding [*api-key* (.apiKey ~'this)] ~@body)))
07:37rrc7czmduerksen: the form is already syntax quoted with a backtick `
07:38rrc7czclgv: let me try that..
07:38clgvrrc7cz: you should rename the macro. it causes problems in clojure 1.2 ;)
07:39rrc7czclgv: really? why? they're depricating symbols in identifiers or somethign? no +?
07:39clgvno I took the version with defn'
07:39clgvthat wont work here
07:39rrc7czI read that as clojure 1.3, not sure why
07:39rrc7czclgv: oh, ha, yeah I know ' isn't valid. It's a haskell convention. i was just writing it as an example
07:39clgvI am still on stable 1.2 ;)
07:40clgvfor: (defmacro defn-api [name params & body] `(defn ~name ~params (binding [*api-key* (.apiKey ~'this)] ~@body)))
07:41clgvI get:
07:41clgvuser=> (macroexpand-1 '(defn-api one [this] (do something)))
07:41clgv(clojure.core/defn one [this] (clojure.core/binding [user/*api-key* (.apiKey this)] (do something)))
07:41rrc7czclgv: your version works! I don't understand why though..
07:41rrc7czI thought the backtick ` quoted everything unless it was explicitly unquoted with ~
07:42rrc7czso you're quoting this... then unquoting it?
07:42clgvits a bit tricky. I asked that some weeks ago ;)
07:42clgvsymbols get resolved during macroexpansion afaik
07:42rrc7czclgv: well thank you, I don't think I would have figured out that trickery myself
07:43rrc7czclgv: I guess the issue is around the actual code that resolves.. for some reason it's resolving not to the local fn param, but to the ns var
07:44clgvyou should reread what the templating syntax with the syntax-quote means
07:44rrc7czokay
07:45clgvI got my head twisted around that too... ;)
07:45clgvthere are actually cases where you would write something like: '~this
07:45clgv;)
07:46rrc7cznow I feel stupid. I found this in Practical Clojure in the Code Templating section, "Also, symbols directly referenced within a syntax quote are assumed to be top level, namespacequalified
07:46rrc7czsymbols and will be expanded as such."
07:46rrc7czalthough it doesn't mention your trick
07:47clgvonly quoting doesnt work since it's then still part of the template-body
07:47clgvand gets resolved too
07:47clgvso you have to get it out of the template body with ~ and then quote it so that it isnt resolved.
07:49rrc7czclgv: interesting. And your oposite, '~ is expanded, but then quoted so it isn't evaluated?
07:49clgvright. I did it for code rewriting
07:50clgvit was a list of clojure statements like you would put in the body of a defn
07:50rrc7czokay
07:51clgvI learned one lesson from it: develop complicated macros step by step and macroexpand is your best friend ;)
07:52rrc7czmakes sense. I'm hoping I can keep this defn macro simple, skipping the optional docstring, attr-map, different artiy+bodies, etc
07:53clgvoh thats not that complicated since you have the clojure source ;)
07:54clgvyou can have a look at the implementation of defn ;) I did that. but I am not supporting attributes at the moment
07:55rrc7czright now I think the only fn *with extras* is multiple artify+body
07:55rrc7czso it'll need it to generate a binding wrapper for each body
07:55rrc7czso we'll see. Lot's of macroexpand for sure
07:55rrc7czI'm definitely planning on looking at the defn impl as you suggested. should make it easy
07:57clgvthey just check the body for being a vector and then they know that there is only one paramter+body ;)
07:58clgvI meant they check the first element of body for being a vector...
09:34chouserAnyone up for a pop quiz? You can read docs now, but not after I ask the question!
09:36tonylmmm.. too early for me, but shoot
09:37chouserheh, ok
09:37chouserre-find looks for a regex match in a string. What does find do?
09:38dnolenget the map entry (kv pair) out of a map by key, return nil if not found :)
09:39tonyli was going to say kinda like contains?, but that was my guess
09:39chouserdnolen: hmph. very good.
09:39tonylhaven't use that function
09:41chouserI've used it in the past, but just now when wanting a write a function named 'find' I was suprised it was already there and couldn't remember what it did.
09:41tonylhehe it happens
09:43tonylneed to hit clojure-quiz sometime this weekend
09:45clgvhow can I extract only few KeyValuePairs from a bigger map into a standalone map?
09:45Chousuke(doc select-keys)
09:45clojurebot"([map keyseq]); Returns a map containing only those entries in map whose key is in keys"
09:46clgvoh thx. I was stuck on "project" which only works for sets
09:59lpetitmorning/afternoon/evening
10:00chouserlpetit: indeed!
10:01lpetitmaybe we could invent a new term for that : mae, or morafe
10:01lpetit:)
10:01lpetitmorafev, I meant
10:02tonylmorafev haha
10:02chouserhow about "greetings!"
10:03chouserand of course the symmetric "partings!" :-P
10:04lpetitchouser: yea, greetings, of course. I'll go with this for now on
10:04chouser:-)
10:04chouserwell, that's solved then!
10:05clgvhm if I guess right, I might get an answer to the following question: when will the next stable update for CCW be released? ;)
10:09lpetitclgv: actually 0.2.0.RC04 is quite stable. But it introduces features which may change/be refined, "semantically speaking" (though not so much, the last "hard work" on it will be a refinement of details of the repl UI)
10:09lpetitclgv: so I'd say it's not "temerary" at all to install it.
10:09lpetitclgv: but I did not answer your question :)
10:10clgvlpetit: I adopted the habit to install software, I depend on, only if the authors consider their release as stable ;)
10:10lpetitclgv: expect a new release candidate this week. Mostly correcting stuff. Then another release candidate with a new bunch of repl UI enhancements from Chas. Then maybe another RC if what Chas introduced needs to be polished a little bit more. Then we'll say "good enough" and release it
10:11lpetitSo the "merge" of the branch repl-ui into the branch "master" of ccw will probably happen during february. I hope closer to the beginning than to the end, but who knows.
10:12clgvlpetit: thx. that are much more detailed infos than those communicated about clojure 1.3 ;)
10:14clgvfebruary sounds fine - not too long to wait ;)
10:58digashl
11:20fliebelMorning
11:21markskilbeckGuten morgen.
11:35fliebelAre there any functions for dealing with chunks directly?
11:36jcromartieas in chunked seqs?
11:36fliebelyes
11:37fliebelHaving things like first, rest, conj and map for chunks would be very nice in some cases.
11:38jcromartieYou want to inspect the chunk itself, eh?
11:39fliebelyes :)
11:39jcromartieI don't see any "chunk" here http://clojure.github.com/clojure/
11:39jcromartiehm
11:39jcromartieinteresting question though
11:39jcromartiewhy do you want to do this?
11:40tomoj(doc chunk-first)
11:40clojurebot"([s]); "
11:40fliebelJust playing around. I was wondering if it would make sense to turn some binary tree into a 32tree, sortof. In fact i could just do (take 32), but what fun is that.
11:41jcromartiethat sounds fine to me :)
11:41jcromartieusing undocumented API means it could break later
11:42fliebelIt's not like this will end up in mission critical applications ;)
11:48fliebelBut I don wonder what type of stuff implements IChunkedSeq.
11:48fliebel*do
11:49tonyl&(filter (fn [[k v]] (if (re-find #"chunk" (str k)) true false)) (ns-publics 'clojure.core))
11:49sexpbotjava.lang.SecurityException: You tripped the alarm! ns-publics is bad!
11:55tomoj&(map chunked-seq? ((juxt identity next) (range)))
11:55sexpbot⟹ (false true)
11:57fliebel:)
12:05fliebelSo, if I need to take subseqs of any length from a long list real fast, is it wise to use chunks? Either directly, or by 'aligning' your data to them, and trust core functions to handle the chunks?
12:07fliebelSo, either (chunk-first), (take 32) or (take 10)
13:34lenwhi all
13:36tonylhello
13:36fliebelhi
13:36lenwany prefs re nosql backends for clojure :)
13:37ohpauleezleafw: I'd use whatever backend fits your problem space. All of the major ones have at least one wrapper, interface, or library
13:37ohpauleezI've used both Cassandra and MongoDB with Clojure to great success
13:38lenwany prefereed wrappers over couchdb ?
13:38lenwyeah mongo seems easy hey
13:38fliebellenw: clutch
13:38fliebelIt has a Clojure view server ;)
13:38ohpauleezlenw: Yeah clutch is what you'll want to use
13:39lenwbrilliant - knew i should ask you guys - thanks !
13:40ohpauleeznp, good luck!
13:55jweiss_can someone point me to a github project where src/ and test/ are laid out in a "standard" way? trying to set up my own project
13:55ohpauleezjweiss: if you use lein or cake, you'll get the structure for free
13:56ohpauleeztypically it's src/project-name/file.clj and test/project-name/file.clj
13:56technomancyno, you can't have the same ns in src/ and test/
13:56ohpauleezyes, you're right
13:57ohpauleeztest/project-name/test/file.clj
13:57ohpauleezmy b
14:06kencauseyperhaps wrongly I downloaded the 'master version' of lein and am trying to use it but even self-install chokes because it can't find leiningen-1.5.0-SNAPSHOT-standalone.jar
14:07technomancykencausey: check the bottom of the readme like it says in the error message; it explains that
14:07kencauseyRelated are maven and ant pre-installation requirements? The instructions could really be clearer on what you are expected to have installed versus what lein gets for you
14:07kencauseytechnomancy: which is where I found self-install, but I will read again more closely
14:07jweiss_is this convention of creating a file "core.clj" in the src something i should use? my lib will probably always be just a single file
14:08jweiss_it's an error handling lib, was thinking just src/error/handler.clj
14:08fliebelI am bothered by the same question as jweiss_
14:09fliebelI even did just src/my_file.clj sometime.
14:10technomancykencausey: it's best to keep a lein-stable or lein-1.4 around to sourdough-bootstrap development versions
14:11ohpauleezjweiss: In the case you have a single file, you can also do this:
14:12ohpauleezsrc/project-name.clj
14:12ohpauleezsometimes it's helpful to do this:
14:12ohpauleezsrc/project-name/file.clj and make a src/project-name.clj
14:12ohpauleezthat has all the active endpoints/actions/functions that the user actually needs
14:13ohpauleezit is convention to have a core.clj, but if it doesn't fit the project, don't do it
14:13ohpauleezcore is for the underlying functions and operations... the core to your app or lib
14:13kencauseytechnomancy: OK, doing as suggested
14:13ohpauleezsometimes projects have many "cores," in that case, it doesn't make sense and you can do something like this:
14:14ohpauleezsrc/project-name/backend/core.clj ... src/project-name/middleware/thismiddleware.clj etc
14:15meliponehello
14:15technomancykencausey: cool; suggestions for clearer wording are welcome
14:15ohpauleezjweiss_: fliebel ^
14:15ohpauleezdoes that make sense?
14:16lpetitohpauleez: of course, it would be src/project_name/file.clj, not src/project-name/file.clj
14:16ohpauleezright right
14:18kencauseytechnomancy: ok, first, did I get this right?: downloaded standard lein, put at ~/bin/lein-old, cloned lein github repo and ran lein-old deps in it. Got to intended location for new project and type lein (symlink to leiningen/bin/lein) new project, etc Exception '...*jure names no longer allowed'
14:18kencauseys/etc/got/
14:18sexpbot<kencausey> technomancy: ok, first, did I get this right?: downloaded standard lein, put at ~/bin/lein-old, cloned lein github repo and ran lein-old deps in it. Got to intended location for new project and type lein (symlink to leiningen/bin/lein) new project, got Exception '...*jure names no longer allowed'
14:19kencauseyhmm, I guess I should clarify that the actual name of the project was ClojureInAction as I'm going through the book
14:19kencauseyperhaps I should believe the error message even if I wonder why
14:19kencauseylein new cia seems fine
14:21technomancyoh... the *jure regex needs to be case-insensitive; doh
14:24technomancyhaving "clojure" in the name is fine, but the regex is just twitchy there wrt case.
14:24technomancyanyway, you have the right idea for lein-old
14:25kencauseytechnomancy: Regarding the wording it might be clearer if you clearly stated that lein can install everything other than Java (if that is true) and maybe clarify what version of Java is required for Clojure/Lein
14:25technomancybeen using Clojure for years and I don't think I'll ever remember case-insensitive regex syntax =(
14:25technomancy/foo/i is so much nicer
14:25Raynes(?i)
14:25technomancythanks
14:25kencauseyglad found a corner case then I guess ;)
14:29jweiss_ohpauleez: good info, thanks
14:29ohpauleezjweiss_: np, happy to help
14:30fliebelWhat is the fastest way to take 32-ish items from a seq? subvec and chunks seem to be able to do this, but take and partition are all cons-based(so one-by-one recursion?)
14:44fliebelCan anyone give me a useful example of rsubseq?
14:49lpetit,(doc rsubseq)
14:49clojurebot"([sc test key] [sc start-test start-key end-test end-key]); sc must be a sorted collection, test(s) one of <, <=, > or >=. Returns a reverse seq of those entries with keys ek for which (test (.. sc ...
14:50lpetitfliebel: if the only assumption you can make on the object you have is that it's a seq ...
14:53kencauseytechnomancy: is http://groups.google.com/group/clojure/browse_thread/thread/c178bed30fd9d704# still valid?
14:53kencauseytechnomancy: I'm trying the trunk version of package.el in 23.2
14:55kencauseyI tried to perhaps install too many things as it doesn't appear to get past slime, there is a message "url-http-parse-response: Trying to parse HTTP response code in odd buffer: *http repo.technomancy.us:80*"
14:57technomancyyeah, there are still a few bugs in package.el when the HTTP connections are shaky
14:57technomancyyou could also try marmalade as the source: http://technomancy.us/144
14:58kencauseyseems like it is working this way
14:58technomancyyeah, stabilizing that is on my list =\
15:32kencauseyWhat have I done wrong if lein is missing swank?
15:32mefestokencausey: did you add a dependency for it in your project.clj?
15:32kencauseythis being dev lein
15:33kencauseyoh, yeah
15:36mefestoIs there a preferred set of tools for piecing together a restful json server? Right now I'm messing with (ring, ring-json-params, compojure, ring-jetty-adapter) but also saw moustache and aleph as another possible route.
15:44meliponehelp with enlive/lein
15:44ohpauleezmelipone: What are you specifically having an issue with?
15:45meliponeI'm trying up enlive with lein repl and I get this message: Var *classpath* not marked :dynamic true, setting to :dynamic. You should fix this before next release!
15:45melipone
15:45meliponenot sure if it's an enlive or lein message
15:45meliponehow do I set variables like that?
15:46ohpauleezit has to do with you using Clojure 1.3, which changed the def behavior
15:46ohpauleezit's just a warning
15:47ohpauleezif you use Clojure 1.2 the warning will go away
15:49meliponeokay thanks!
15:49meliponeis it the right place to ask newbie questions?
15:49ohpauleezmelipone: totally!
15:49pdkany type of questions roll here, i don't think there's a separate beginners channel
15:50meliponegreat!
15:50fliebelEven non-Clojure questions, sometimes *hides*
15:53ohpauleezfliebel: Do we need to talk about window managers again?
15:53ohpauleezhaha :)
15:54tonylor politics... :P
15:54fliebelohpauleez: I don't think OS X does window managers… I was thinking algortithms.
16:03meliponeclojure-contrib was missing from enlive's project.clj ...
16:04fliebelmelipone: If you are using 1.3, there is no such ting ;)
16:05fliebelclojure-contrib has been split up into separate projects.
16:05meliponeI replaced clojure 1.3 with 1.2
16:06Scriptorwait, there's no clojure-contrib in 1.3?
16:07fliebelScriptor: Not in the classical sense. There is a package that contains all the new projects, and you can get all the parts separately.
16:08meliponefliebel: isn't it like that already?
16:08meliponefliebel: I mean you can specify :only to get what you want
16:09amalloymelipone: :only is part of (require) - fliebel is talking about adding it as a project dependency in maven or project.clj
16:10fliebelamalloy: Ah, thanks, I was thinking I had missed something in Leiningen ;)
16:14lazy1Can someone explain why I get NullPointerException when running iterdir (https://gist.github.com/788685) on an empty directory?
16:16S11001001(branch? nil) => NPE
16:18lazy1Thanks!
16:27meliponewhat's good for parsing html in clojure? enlive might be overkill ...
16:27ohpauleezmelipone: enlive is the best in my opinion
16:27ohpauleezare you scraping for something?
16:27meliponeyes, web scraping
16:28ohpauleezI think enlive is the best clojure solution for web scraping, but there are wrappers for tagsoup in clojure
16:28ohpauleezyou can also use any java library
16:29lazy1melipone: https://github.com/antoniogarrote/apricot-soup
16:38brehautmelipone: re ohpauleez's comment about using any java library, enlive uses tagsoup under the hood i believe
16:39brehautmelipone: so even if you dont use enlive itself, it may prove a useful resource for just using tagsoup from clojure
16:40meliponeokay, I'll give enlive another try. I found another tutorial on the enlive wiki
16:40brehautmelipone: dont be put off by the somewhat imposing first impression enlive gives off; its actually really easy to use. david nolen's tutorial is a great starting point
16:41LauJensenmelipone: There is no reasonable alternative to Enlive and Enlive is in fact fantastic
16:43ohpauleezthese are all facts
16:43ohpauleez:)
16:43meliponethe problem is that I'm learning clojure as I go along
16:44amalloymelipone: if learning clojure is a "problem" you live a pretty good life
16:44brehautmelipone: just start small. dnolen's tutorial starts with scrapping anyway.
16:45LauJensenmelipone: You can check out my blog, my most recent post is about Enlive, but I use it in a couple of other posts as well, http://www.bestinclass.dk/blog.html
16:45LauJensenI always try to explain everything so carefully that even amalloy can understan
16:45LauJensend
16:46tonyleven me
16:46amalloyLauJensen: i'm home sick from work today and actually reading your blog right now. there are too many damn entries though
16:46LauJensenamalloy: hehe, oh, sorry about that - from which end should I start deleting? :)
16:46meliponefor example, the "->" macro just threw me
16:47Raynesmelipone: Did the comp function catch you?
16:48meliponeokay, comp is not so bad
16:49LauJensen-> ->> -?> -?>> -=@?> and comp are all easy once you see a couple of examples
16:49brehautLau, -=@?> ?
16:49tonyljuxt still blows me in how weird it looks but the many uses you can have for it
16:50LauJensenyea juxt is pretty cool
16:50brehautjuxt is great :)
16:50meliponeyeah, it's weird
16:50LauJensenbrehaut: -=@?> is just a speeding fish or something
16:50brehauthaha
16:50Raynestonyl: juxt blows you, eh? ;)
16:50tonylindeed haha, that is why i keep using it
16:52amalloy&'-=@?>
16:52sexpbot⟹ -=
16:52brehautfnil boggles my brain. amalloy showed me some examples of it in use, but its not gotten wedged into my head enough for me to actually have usecases
16:53amalloyLauJensen: sadly that's not a legal symbol. if it were i'd love for you to write a useful function with that name, then write a blog post about it
16:53LauJensenamalloy: Did you see my implementation of factorial 5? I might actually have used that symbol in there
16:53LauJensen,(letfn [(!-?>[&$ &!](if(>,&!,1)(!-?>@(->>,&$,(*,&!)ref)(->,&!,dec))&$))](!-?>,1,5))
16:53clojurebot120
16:54LauJensenSo Clojure is quite easy once you get the hang of it
16:54brehautLau, this is #clojure, not #apl
16:54amalloyLauJensen: lol
16:54LauJensenbrehaut: I was inspired by J actually :)
16:54LauJensen(I love J)
16:54brehauthaha
16:54amalloyi don't see that one in your factorial article
16:54LauJensenamalloy: It was something I posted on twitter a while ago
16:54brehautamalloy, link please
16:55amalloybrehaut: http://www.bestinclass.dk/index.clj/2009/09/scala-vs-clojure-lets-get-down-to-business.html
16:55brehautcheers
16:55amalloyLauJensen: we should start a business cross-pimping blogs
16:55LauJensenIf you're interested in J, check out this article where I explain some funky J code
16:55LauJensenhttp://bestinclass.dk/index.clj/2009/11/mind-games-ascension.html
16:55LauJensenAnd then this one, where I show how it inspires concise Clojure code
16:55LauJensenhttp://bestinclass.dk/index.clj/2009/11/life1d-in-clojur.html
16:55LauJensenamalloy: Im in! :)
16:56brehauti feel that i need to write another clojure blog post, but im currently lacking ideas
16:56LauJensenbrehaut: You should definitely write about ClojureQL and how it has improved your quality of life
16:56LauJensenI'd read that
16:56brehautLauJensen: hah yes :) i'll be doing that once i have my site ported over properly
16:56LauJensenbrehaut: Im fine with that ... if your site is up and running by monday :)
16:56brehauthaha
16:57brehautits up and running now!
16:57brehautjust not with clojureql
16:57LauJensen:(
16:57LauJensenI've seen it already. Pretty layout, hard to read
16:57brehauthah yeah, hacker news hates me
16:57LauJensenLike to opposite of amalloy who's easy to read but hard to look at :)
16:57brehauthaha
16:57LauJensens/to/the
16:57sexpbot<LauJensen> Like the opposite of amalloy who's easy the read but hard the look at :)
16:58brehautive discovered its really monitor sensitive
16:58amalloyLauJensen: that actually made your sentence less readable :P
16:58LauJensenbrehaut: Its not though, its because you have the same background as your text color :)
16:58LauJensenQuite moronic when you stop and think about it :D
16:59brehautLauJensen: black on white is the same background color as text color :P just happens to have a larger difference in lumiance
16:59brehaut(1 rather than 0.45 for reference)
17:00LauJensenbrehaut: Im beginning to understand where you're going wrong with this whole design thing
17:00jweiss_anyone ever get this error in the clojars UI? "Thundering typhoons! I think we lost it. Sorry!"
17:01jweiss_i scp'd my pom and jar to it, and the ssh output shows that it appeared to work. but i get the above error if i try to click on it on the clojars webpage
17:02brehautin any case, monitor does have a huge effect; the effective contrast that a given monitor can produce becomes reallly significant when the contrast between text and background is small. some cheap panels also make yellows quite vicious
17:04LauJensenbrehaut: Thats true. Ive had some awful experiences with that
17:04brehautLauJensen: yeah. i checked out my site on my former coworkers cheap ass dell panels
17:04brehautresult is eye bleeding
17:08brehautLauJensen: i am trying to make the design more readable though. but i want to keep the visual identity at the same time
17:09LauJensenbrehaut: Okay, so I say keep the URL and change the design completely :)
17:09brehauthahaha
17:10brehautits more likely that i'll eventually change to not-yellow
17:10brehautbut leave the rest of the design
17:11LauJensenThat sounds perfect since its the yellow thats causing the problems
17:12clizzin_soooo often during development i'll do some refactoring that involves breaking some function f out from ns1 into ns2 and having ns1 use ns2, and that results in namespace conflicts because f has already been defined in ns1. the only solution i know of is to restart the jvm. does anyone out there have a better solution?
17:13S11001001clizzin_: ns-unmap
17:14clizzin_S11001001: is there a way to unmap all bindings in a given ns?
17:15clizzin_S11001001: another common problem is that i forgot to set up the proper use/requires, and so some code is still referring to the old functions that i've deleted/moved and i just don't realise it until something goes wrong. being able to clear the namespace wholesale and recompile would be nice.
17:15clizzin_as opposed to manually remembering each function i've deleted/moved
17:17amalloyclizzin_: (doseq [[f _] (ns-publics *ns*)] (ns-unmap *ns* f)) feels about right
17:18amalloyand hey look at that, i just tried it and it's exactly right
17:19clizzin_amalloy: awesome, didn't know about ns-publics. tahnks!
17:19clizzin_thanks*
17:21mreynoldsNewb question : I'm seeing a defmethod without finding the defmulti in the same file. What's the best way to find the defmulti associated with the defmethod? (I'm using emacs/swank, if that helps)
17:21technomancymreynolds: M-. should do it
17:21amalloymreynolds: M-. on the multimethod's name might work?
17:22mreynoldsIt's asking for a tags table, which I don't think I have setup
17:22amalloymreynolds: you'll have to compile the file
17:22mreynoldsOr, the defaults aren't working, since it can't find the tags file
17:22mreynoldsahhh, k, I'll start from there
17:22technomancyyou must not have slime connected
17:22amalloythat is, have slime connected, then C-c C-k the file; then M-.
17:23mreynoldstechnomancy: I don't, not in this one. I'm debugging the library at the same time that I'm working on my code (fixing docs mostly)
17:23mreynoldsK, I'll setup another instance
17:24mreynoldsthanks all
17:34meliponeokay, I'm getting the hang of it, slowly ... more tomorrow, bye
17:39hiredman,(.replaceAll "foo\bar" "\\\\" "/")
17:39clojurebot"foo\bar"
17:39hiredman,(.replaceAll "foo\bar" "\\" "/")
17:39clojurebotjava.util.regex.PatternSyntaxException: Unexpected internal error near index 1
17:39clojurebot\
17:39clojurebot ^
17:39hiredmanclojurebot: thanks dude
17:39clojurebotNo entiendo
17:39amalloyhiredman: "foo\\bar"?
17:40technomancyhiredman: this is how you do it, bro: https://github.com/technomancy/lein-tar/commit/bfef514ff36542a6c036fceb5f6471da7f9587ac
17:40hiredmancool story
17:56frank`good night
18:01kclwho
18:01kclwhois
18:06S11001001I too am a member of the secret society of those who have written \\\\\\\\ in earnest for production code
18:06S11001001oops
18:08keithlDoes anyone know if the moustache micro-framework is dead? Seems no checkins since May.
18:10dnolenkeithl: I think the feature set was always meant to be quite minimal. but cgrand has been quite busy of late, when he has a free moment I think he tends to work on parsley.
18:10dnolenkeithl: the only thing I'd like to see added to moustache is reverse lookup.
18:10keithldnolen: It has all the features I need - was wondering if it had issues with 1.2.
18:11keithldnolen: What is parsley if I may ask?
18:11dnolenkeithl: I don't think so.
18:11dnolena Clojure parser
18:11ohpauleezkeithl: I haven't had any issues using it with 1.2
18:12keithlohpauleez: Thanks. I just need to build a small web service, and it seemed like a good approach.
18:12ohpauleezand yes, moustache's feature set is pretty small and quite solid, so besides some nice-to-haves, it's a pretty complete package that doesn't really need continual work
18:12ohpauleezkeithl: It's my favorite for most clojure web development, I even wrap it occasionally to use with aleph
18:14keithlHmm - had not looked at aleph. Looks interesting.
18:14keithlI used compojure for a small project, but its changing quite fast and I find that I struggle a bit knowing how to approach some things.
18:14keithlNewbie to clojure - and not a java person generally.
19:17zakwilsonIs Moustache displacing Compojure in new projects?
19:20keithlzakwilson: It is for me, but maybe just for this small project. Compojure is quite nice, but as I mentioned, it is changing pretty rapidly and the docs are not up to date.
19:20zakwilsonAs I understand it, both mainly serve to map URLs to handlers.
19:21keithlzakwilson: I think that's right. Just more capabilities in Compojure - more sophisticated route handling, etc.
19:22zakwilsonI see. I think I'll try sticking with Compojure and only investigate switching if I have problems.
19:22keithlMakes sense I think - but I am no expert :-)
19:23keithlThe one thing that bugged me - again related to changes - was that I ended up doing a lot of googling because the api changed so much.
19:23keithlThat really was the only issue I had with it.
19:26zakwilsonTo be expected with a small somewhat experimental thing.
19:26keithlyup
19:26keithlbleeding edge, as it were.
19:27keithlWent through the same things w/rails - first project was on 0.13
19:27zakwilsonOn that subject... I wonder if everything I need works with 1.3 now.
20:18currentBif I have an ordered sequence of dates (longs) from varying time intervals (ie there might be 10 one day then three the next) is there an easy way to partition them by a given time interval?
20:18hiredmangroup-by?
20:20currentBhmmm just trying to wrap my brain around what the grouping function would have to be
20:22currentBit could return what nth item the date would belong to, ok I think that could work, thanks!
20:24amalloycurrentB: like you want to group them by day of week regardless of day of month?
20:25currentBgrouping by 24hr period is all that really matters, actually if possible I'd like to keep it general, for example allowing the function to take as parameters the sequence of longs and the amount of milliseconds to do the grouping by
20:26amalloycurrentB: then it sounds like you just want div
20:28amalloy&(group-by #(div % 86400000) (repeatedly 20 #(rand-int (* 10 86400000))))
20:28sexpbotjava.lang.Exception: Unable to resolve symbol: div in this context
20:29amalloy&(group-by #(rem % 86400000) (repeatedly 20 #(rand-int (* 10 86400000))))
20:29sexpbot⟹ {43091328 [43091328], 85823489 [777023489], 19147458 [710347458], 48212099 [134612099], 34379782 [725579782], 29852840 [461852840], 36766920 [641566920], 37551370 [555951370], 4857802 [4857802], 41098220 [386698220], 64125390 [841725390], 47243887 [306443887], 752616... http://gist.github.com/789091
20:29currentBok sweet that's similar to what I was messing with, thanks!
20:29amalloyer, damn it, quot
20:29amalloy&(group-by #(quot % 86400000) (repeatedly 20 #(rand-int (* 10 86400000))))
20:29sexpbot⟹ {0 [60216224], 1 [115823748], 2 [245325431 205820251 188400044 185196259 196982624], 3 [266483468], 4 [411494513 379197832], 5 [470114010 470576693], 6 [588959862], 7 [649107250 633158285], 8 [744349997 776718958], 9 [818622453 835503570 790813983]}
20:30currentByes, even better thanks!
20:31amalloylol, "even better" in the sense that it works instead of the complete nonsense i said earlier
20:31currentBhaha exactly
20:50zakwilsonI just tried updating my version of hiccup.core and I'm getting "as-str does not exist" when I try to use it in my namespace.
21:02pdk(doc :>>)
21:02clojurebotjava.lang.ClassCastException: clojure.lang.Keyword cannot be cast to clojure.lang.Symbol
21:03amalloy&(doc ->>)?
21:03sexpbot⟹ "Macro ([x form] [x form & more]); Threads the expr through the forms. Inserts x as the last item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the last item in second form, etc."
21:08amalloyzakwilson: that function is in clojure.contrib.string, right? perhaps hiccup is old and expecting it somewhere else?
21:08pdksay
21:08pdkif you use recur outside of a loop form
21:09pdkwill it still be tco'd
21:09amalloypdk: yes, it recurs to the innermost containing loop or function
21:09zakwilsonamalloy: actually, hiccup is new and expects it in clojure.contrib.java-utils. I just reverted to the old version.
21:09pdkso loop is pretty much optional
21:09pdkand even if i'm recurring on a function defined at toplevel with defn it'll still tco it
21:09amalloypdk: um. yes to your second statement; your first is pretty confus{ed,ing}
21:10amalloyi mean, loop is never "necessary" because you could use a new anonymous function instead, but the same could be said of let
21:10pdki.e. if i'm defining a function with defn and use recur within that function
21:11pdkthere's no arbitrarily limits on which cases it'll tco the function it's called within as long as it's a proper tail call
21:11amalloypdk: as long as it's a *self-recursive* tail call. there's no provision for tail-calling some other function
21:13amalloy(fn [x] (when-not (= x 10) (recur (dec x))) will work fine, yes
21:13amalloybut if you want to recur to some level other than the top one you need to declare either a new function or a new loop marker
21:14pdkhmm ok
21:19amalloypdk: here's an example of loop being used because it would be inconvenient otherwise: https://github.com/liebke/incanter/blob/master/modules/incanter-core/src/incanter/distributions.clj#L195
21:20amalloyhope it helps; i'm afk a while
21:52qbgHmm... Cliff Click thinks languages on the JVM should expose primitives.
21:55brehautqbg: link?
21:55qbghttp://www.infoq.com/interviews/click-gc-azul
21:55qbgHe has also mentioned it in the past
21:56qbgThat link also has a ton of awesome in it
21:56brehautcheers
22:08dnolenqpg: are you skeptical of exposing primitives?
22:08qbgI've grown to love them
22:09qbgThey aren't a hard concept at all; a ton of other languages do the same thing, only worse
22:09qbge.g. Java
22:10dnolenqbg: ?, who think primitives are a hard concept ?
22:10qbgMy main problem is with the current implementation of primitive function support (it is broken in a few ways)
22:10qbgdnolen: That is the feeling I get when I read messages on the group freaking out about it
22:11qbgThe limit of 4 args is somewhat disappointing
22:11qbgAlso, I think there is a bug if you type hint the return of the function to be a subtype of Object
22:12hiredmanugh
22:13hiredmanblogure? who did that?
22:13qbghiredman: At least it isn't blojure
22:14danlarkinhotdogsladies: This is pretty cool.
22:14danlarkinIn Vi?
22:14danlarkinpardon me
22:15dnolenqbg: haven't seen that bug. I have no problem w/ the 4 arg limitation tho. Beats bleeding your eyes with type coercions or writing crazy macros to tag symbols everywhere pre 1.3.0 .
22:16qbgdnolen: It existed a while back at least; it only appears if the return type is a subtype of Object and one of the positional arguments is a primitive
22:17qbgI remember getting an AbstractMethodError when I tried to evaluate the defined function
22:22qbgTry this: (defn foo ^List [^long x] (doto (ArrayList.) (.add x)))
22:23qbg(foo 5) gives me AbstractMethodError user$foo.invokePrim(J)Ljava/lang/Object; user/eval7
22:24dnolenqbg: ah yeah that makes sense, not a bug, there's no interface that can match that.
22:24dnolento discard ^List would be a lie.
22:25hiredmanI'd try (defn ^List foo …
22:26qbgdefn should at least give an exception, or the compiler returns Object and at the call sites it is cast/whatever appropriately
22:29dnolenqbg: what hiredman said.
22:29dnolentype hints before the arg list are only for hinting primitive fns.
22:30hiredmanbasically the primitive type hint way and the non-primitive type hint mechanism haven't been unified yet
22:30dnolenor that's what I recall anyhow.
22:32qbgHmm... If I put the ^List on foo, the type information isn't propagated to the users of foo
22:33qbgAlso (.add ^List (foo 5) 4) generates a reflection warning, but (let [^List x (foo 5)] (.add x 4)) doesn't
22:35dnolenqbg: huh, I don't see a reflection warning.
22:35qbgDo you have *warn-on-reflection* on?
22:36dnolenqbg: yes
22:36qbgI get it on the latest master
22:36dnolen(do (set! *warn-on-reflection* true) (.add ^java.util.List (foo 5) 4))
22:36qbgDon't do it in a do
22:39dnolenthere's nothing wrong with the do. Definitely an issue with the way primitive fn's get compiled.
22:40dnolenstill question how much of a legitimate issue that is, the example is questionable. More likely you'd be returning a gvec, which doesn't need a type-hint anyway.
22:41brehauthow on earth did i achieve things before multimethods
22:58pdkwould binding be an appropriate alternative to letfn if i want to define things other than exclusively functions within the binding form
22:59pdksay if i wanted to define some recursive functions locally a la letfn but i also wanted to define some objects in the same let/binding form that weren't functions
23:00amalloypdk: no binding is crazy there
23:00amalloyyou just want let
23:01pdkhmm
23:01amalloy&(let [x 1 f (fn [arg] (+ arg x))] (f 10))
23:01sexpbot⟹ 11
23:01pdkin this case i'd want f in that example to be recursive
23:01pdkthat's the rub
23:01qbgSelf recursive only?
23:01pdkyep
23:02qbg(fn f [arg] ...)
23:02qbgf will be the name of the fn it the fn's body
23:02pdkoh cool beans
23:02pdkdidn't know you could name a fn from within
23:03amalloy&(let [! (fn ! [num] (if-not (pos? num) 1 (* num (! (dec num)))))] (! 10))
23:03sexpbot⟹ 3628800
23:03a_strange_guy&((fn self [x] (if (<= 1 x) x (self (- x 1) (- x 2)))) 6)
23:03sexpbot⟹ 6
23:03a_strange_guy&((fn self [x] (if (<= x 1) x (self (- x 1) (- x 2)))) 6)
23:03sexpbotjava.lang.IllegalArgumentException: Wrong number of args (2) passed to: sandbox9236$eval11185$self
23:04a_strange_guy&((fn self [x] (if (<= x 1) x (self (+ (- x 1) (- x 2))))) 6)
23:04sexpbotjava.lang.StackOverflowError
23:04qbg&((fn self [x] (if (<= x 1) x (+ (self (- x 1)) (self (- x 2))))) 6)
23:04sexpbot⟹ 8
23:04a_strange_guybleh, that happens at 5 in the morning...
23:21amalloyLauJensen: you around? http://www.bestinclass.dk/index.clj/2009/10/python-vs-clojure-reloaded.html looks really wonky. i can't read the code examples
23:21amalloyor maybe i can, in which case i need to stab my eyes out; tell me or="or" log10="log10" isn't an actual code snippet