#clojure logs

2011-03-16

00:00amalloybrehaut, mec: https://gist.github.com/871993
00:00amalloya haskell port now that i remember the goal :P
00:00brehauthaha
00:00amalloyprobably it's not at all lazy even though it looks like it
00:00brehautamalloy: did you port break or span?
00:01amalloyshit i dunno. it looked like break
00:01brehautdamn stupid hoogle anchors
00:01amalloyoh i see
00:01amalloyno i did span
00:01brehauti think break is just the revser though?
00:01amalloyright
00:02brehautyeah it is
00:02amalloypretty sure this isn't lazy at all
00:02amalloybut it's a start
00:02mecwhat does span do
00:02amalloymec: span is split-with
00:03amalloyi wrote span and called it break :P
00:05mechow isnt this lazy? it seems to work fine
00:06amalloymec: it forces the whole first half of the input even if you never ask for the second half
00:07amalloybrehaut: seriously, they had to note that the argument to reverse must be finite?
00:08brehautpervasive laziness makes people a wee bit more precise :P
00:08mecIt also causes a stack overflow if the pred takes too long to match
00:09amalloys/precise/crazy. obviously you can't reverse an infinite seq
00:09mecsounds like a challenge to me
00:09brehautbut you can call reverse on it and carry a thunk around
00:09brehautthat will explode somewhere else
00:10cemerickAm I missing something, or is this a comprehensive listing of canned cake plugins that are available? https://github.com/ninjudd/cake/wiki/Plugins
00:18technomancycemerick: what's your take on archiva vs nexus? are they pretty close in functionality?
00:24cemericktechnomancy: I'm afraid I've never really evaluated them in a comparative way. The only diff I noticed when making my decision was that (at the time, anyway) archiva didn't have as rich a set of permission controls. e.g. I wanted to be able to provide/restrict access to artifacts based on coordinate attributes, but archiva only offered permission controls per repo IIRC.
00:24cemerickNexus has always just worked for me, FWIW. There's a certain safety in going with the one made by the people that keep the keys to central et al. in any case.
00:24technomancyah, good to know. nexus's UI is a little slicker, but I think we picked archiva at work primarily due to lexographic sorting.
00:25cemerickof search results, you mean?
00:25technomancyno, just lexographic sorting of the names
00:25cemerickoh, I see
00:25technomancyarchiva is the undisputed winner in that regard
00:25cemerickI'm hoping that whatever is driving http://mavencentral.sonatype.com/ will get pushed into nexus at some point
00:26technomancyor the commercial nexus variant possibly
00:26cemerickbleh
00:26cemerickI'm not sure I could bring myself to pay for a glorified web server, just on principle.
00:26cemericktechnomancy: in case you'd like to make your eyes bleed: http://docs.codehaus.org/display/MAVENUSER/Maven+Repository+Manager+Feature+Matrix
00:27cemerickah, p2 repository interop was one feature that I found interesting about nexus pro
00:28technomancyhm; that first link looks a bit nicer than jarvana
00:28cemericktechnomancy: it's new in the last month; absolutely the way to go. It hits a "read slave" of the real central's index AFAIK.
00:29technomancywas using http://mvnrepository.com/ for a while, but the slowness+downtime pushed me away really quick
00:29technomancyly
00:29technomancythanks for the pointer
00:29cemerickah, the one with the absolutely killer charting! :-P
00:29technomancyI need to look into how those repos offer downloadable lucene indices; that sounds really handy
00:29technomancysee if we could get clojars offering that
00:30cemerickit does
00:30cemerickOr, eclipse is acting as if it does.
00:30technomancyeeeeenteresting
00:30technomancywonder when that happened
00:31technomancynew features don't make it into clojars very often
00:31cemerickit's been there from the start
00:31cemerickhttp://clojars.org/repo/.index/
00:31cemerickAFAIK, anyway
00:31cemerickI remember talking with ato about it a looong time ago.
00:32technomancyno kidding... thanks again for the pointer.
00:32cemericknp
00:32cemerickgotta work up out of that karma hole I've been in
00:33cemericktechnomancy: I see generalized deployment is in lein now, or imminent…
00:33cemerickthat's big news
00:33technomancyyeah, I'm thinking of making a pallet crate for nexus or archiva
00:34technomancysince it's a very common need
00:34technomancyjoining the Big Kids now =)
00:34cemerickI wonder if that makes it a good time to open up the notion of a less mosh-pit-esque community repo.
00:35technomancyhow have the sonatype free repos been treating you?
00:35gilicornsup
00:35phenom_hmmm in multimethods is there a way to do a conditional match? "defmethod my-test (or :key1 :key2) [...] .." ?
00:35cemericktechnomancy: the setup takes a day of waiting and an initial vetting of your first deployment, but it's now zero-admin
00:36gilicornpls send warez / serial numbers to x6763@gmail.com
00:36gilicornthx
00:36amalloyphenom_: you want isa/hierarchies
00:37amalloythat was such an honest, touching request. i can't help but find warez for him
00:37cemerickI'm just reusing the new-contrib deploy-to-OSS+central POMs as parents of my public Clojure projects, which makes the actual project setup roughly zero-config as well.
00:37technomancycemerick: I'm also in the middle of adding the ability to specify a repository as snapshots-only or releases-only, so adding new repos won't necessarily slow things down much in the future.
00:37cemerickI don't think a Clojure community repo needs anywhere near the sort of administrativia as Sonatype has around OSS, FWIW.
00:37technomancysure
00:38cemerickHonestly, clojars has just a couple of off-by-one issues. I'm not sure it'd make sense to change policies in-place though.
00:39technomancythe two problems are groupids are first-come-first-served and the lack of the snapshots/releases distinction, right? the latter being more serious in practice?
00:39technomancythe former is easy to solve with a more active admin team, I think
00:40cemerickgroupIds are *always* first come first serve, even in OSS/central
00:41technomancytrue, but for non-central repos there's a chance that someone could take a groupid that's been claimed on central.
00:41technomancybut yeah, that's much less of an issue
00:41technomancyI'd be perfectly happy with making lein 2.0 point to a clojars releases-only repo
00:42technomancyjust gotta do it during a breaking change
00:42cemerickgood point. I'm guessing we wouldn't worry about aligning with central's policies or names though. Central sync from a third-party repo is absolutely onerous, which is what prompted the OSS setup.
00:43technomancythis is the part where "I told you so" is perfectly ok. =)
00:43cemerickthe biggest issues IMO are the common practices of (a) deploying slightly-patched artifacts under org.clojars.username, (b) using clojars as a personal scratchpad e.g. deploying artifacts that aren't in central into clojars just because *your* project needs it, and…
00:44cemerickcrap, lost my third item.
00:45technomancymaking it easy to set up private nexii might help with b
00:45cemerickAnyway, the snapshots/releases thing is minor relative to those IMO. It screws up some features for downstream tooling, which sucks, but not being able to reasonably identify the authoritiative artifact for a particular project can be soooo painful.
00:46cemericktechnomancy: http://cemerick.com/2010/08/24/hosting-maven-repos-on-github/ was my feeble attempt at solving (b)
00:46cemericknot that I tried *that* hard
00:46technomancymaybe clojars could even relegate org.clojars.foo artifacts to a separate "mosh-pit" repository that's separate from snapshots/releases too
00:47technomancybut it's cultural; if a real release depends on a mosh-pit release you're contaminated =\
00:47cemerickThere was a fellow around here at some point that was tinkering with the idea of offering nexus hosting a la paid git or svn hosting.
00:48technomancyrevisiting the lein tutorial I was sure to make very clear the org.clojars route is a last-ditch measure for when you just can't make it work with upstream.
00:48cemerickThe whole org.clojars.foo notion is nonsensical to me though. That's not a "proper" groupId, it's just UUID scheme.
00:49cemerick"a UUID scheme" that is.
00:49technomancyso are you seeing real releases that depend upon org.clojars artifacts?
00:49cemerickI have, yeah.
00:49waxroseDo you all add JLine support if so, what exactly is it's purpose?
00:49technomancythat's a shame. I've only seen it for internal use ಠ_ಠ
00:50technomancywaxrose: it's for when you don't have rlwrap installed
00:50technomancywaxrose: rlwrap is better in every regard except for the fact that it's not a JVM-level dependency.
00:50tomojfor private nexus and lein, is there settings.xml wrangling required?
00:50cemerickit became very common around the time that 1.2.0 was released, and a lot of libraries were lagging in the transition
00:50technomancytomoj: no, it's all in project.clj
00:50tomojwhew
00:50waxrosetechnomancy, So it's suggested to go with rlwrap instead then?
00:51technomancycemerick: oh, I could see that. shame that people couldn't work with upstream!
00:51tomojgot it working with settings.xml but I knew there had to be a more leinish way
00:51technomancywaxrose: absolutely
00:51amalloywaxrose: 100%
00:51technomancylein 1.5 will issue a one-time warning if it has to fall back to jline in rlwrap's absence
00:51waxrosetechnomancy, Okay, thanks!
00:51waxroseI think I'm using an old installation guide. :/
00:52cemericktechnomancy: if there's a fast-path available, people will take it. fix,build,scp is *way* quicker and easier than fix,build,diff,email/pull-req,wait,wait,wait,get-new-release
00:52amalloywaxrose: just install cake and use cake repl; it bundles readline. lein probly does too
00:53waxroseamalloy, Alright, I'll try that. I was testing lein first before I decided without is easiest to get started with.
00:53waxrosewhich one*
00:53amalloygoing without lein/cake is *not* easier
00:53amalloyah
00:54amalloyhaha
00:54waxroselol
00:54waxroseSorry, I type too fast and often typo.
00:54amalloytoo fast, i see. are you using windows or something crazy like that?
00:54waxroseUbuntu.
00:54amalloycool beans
00:55amalloysudo gem install cake, cake repl
00:55waxroseI was using Arch but it seemed like it would be easier to set up GAE and Clojure on Ubuntu.
00:56waxrosegem? Ruby?
00:56amalloyyeah
00:56amalloycake uses ruby like lein uses bash
00:56amalloyas i understand it
00:56amalloyie, as a launching pad for all the core clojure goodness
00:56tomojhuh, I wonder if the ruby API lets you do cool cake stuff from ruby easy
00:57waxroseInteresting, that may be a little easier to start from since I actually left Ruby to for Clojure.
00:57waxrosefor*
00:58waxroseThanks for explaining further.
01:00technomancygem install on ubuntu doesn't work quite right
01:00technomancycemerick: rich talked to me at emerginglangs about fork-aware dependency resolution
01:01cemericktechnomancy: anything sane emerge from that?
01:01cemerickit's a tough problem
01:01technomancyI think with aether there's the flexibility needed to resolve that sanely so you could tell given a sha what's newer and how to specify a preference, but I haven't thought it all the way through.
01:01technomancyyou need a third-party DAG
01:01cemerickso, roughly, try to overlay the git and mvn trees?
01:02technomancyerr--a separate metadata repository for source DAG
01:02technomancyand each pom needs to be clear about scm
01:02technomancyright
01:02cemerickyeah, that previously extraneous pom metadata suddenly seems *way* more important
01:02technomancyvery half-baked in my head right now, but it could turn into something useful
01:03technomancythough of course the "just don't publish forks" approach has its allure too.
01:03cemerickyeah
01:04cemerickthe semver approach that mvn essentially relies upon and trees don't really mix
01:04technomancyI guess clojars forks are like using robert hooke; you only do it if you have to, and you never foist in on anybody downstream of you.
01:05cemerickThe thing is, even if fork-aware dep mgmt were made to work, nothing else in the toolchain would know what to do with it.
01:05cemericke.g. hudson, elastic beanstalk .war versioning, etc etc etc
01:06technomancyactually, scm-aware dependency resolution isn't just about forks; it's also useful to distinguish between 1.2.0-newnew and 1.2.0-alpha, etc
01:06technomancyback when we had those specifiers
01:06cemerickyeah, same thing conceptually
01:06technomancyyeah, that's another issue
01:06technomancyone step at a time though
01:07cemerickI'd suggest pinging jvanzyl et al., but it's hard to push on that rope.
01:07technomancyif you could gen-class up the kind of resolution plugin that aether needs it might be easy to share
01:08technomancyyeah... I'll give it some more hammock time for sure. we'll see.
01:10cemerickThe git and hg folks must have done some thinking about this as well. Everyone runs into the impedance mismatch eventually.
01:10technomancyit could be git people are too mired in autotools to come up for air
01:10cemerickhah
01:11technomancyand python has like three separate package managers, so they've got more pressing things to deal with maybe.
01:12technomancyruby had issues for a while where people were publishing $GITHUBUSER-$GEMNAME gems, but I think that got nipped in the bud before anyone was forced to come up with a clever solution.
01:15cemerickAnd that's all nothing compared to the trainwreck in the .NET world.
01:16cemerickEvery time I need to screw with dependencies in VS, I want to simply burn and die.
01:24waxrosehmm to rlwrap adds tab completion, param matching, and even emacs bindings?
01:24waxrosesweet
01:24waxroseso*
01:25technomancytomoj: hang on; you're deploying to nexus using lein deploy and using settings.xml?
01:25technomancyI didn't know that would actually work. =)
01:26tomojnot deploying
01:26tomoj..hadn't tried that yet. just the fetching of deps
01:26technomancyoh, passwords for downloading have worked for a while
01:27tomojno passwords either
01:27waxrosetechnomancy, Would you happen to know of any current, active Clojure oriented projects working with Firefox Fennec on Android?
01:28technomancywaxrose: there is only one clojure project on Android, a repl
01:28technomancyit has a loooooong way to go before it's viable for general-purpose apps
01:28waxrosehmm
01:28technomancytomoj: so just listing a non-authenticated repository?
01:28tomojseems now that :omit-default-repositories and putting only nexus in :repositories should be enough.. dunno if I tried that, or why I wouldn't have
01:28technomancytomoj: heh. =)
01:28technomancywell if you do have use for the deploy task let me know if it works for you.
01:29technomancyhaven't had anyone else report back on that yet.
01:32amalloywaxrose: i don't imagine you want it, but readline also has a vi mode
01:33technomancytab completion is doable but not so great in rlwrap; param matching is impossible. you need something like slime for that.
01:37waxroseamalloy, Wouldn't hurt to check it out though. I didn't even realize it had a vi-mode. >.>
01:38amalloyreadline is impressive
01:39waxroseWait, don't you go into vi mode with ctrl + alt + j?
01:40amalloywaxrose: looks like you can put the following into ~/.inputrc: set editing-mode vi
01:40waxroseset -o vi .....i believe, it's been a while since I've used vi[m] ... that would probably drive me crazy though
01:41amalloyyeah
01:41amalloymy goal is in fact to drive you crazy, so
01:41waxroseGood, I love the taste of insanity at 12:41am.
01:42amalloywhere on the east coast?
01:42waxroseI'm in Texas actually.
01:43amalloyoh right, east coast is 1:41
01:43waxroseYeah, Chicago time.
01:43amalloybut is texas really two time zones out? i guess i'm clueless
01:43amalloyapparenlty it is
01:43waxroseWhere are you, Cali?
01:43amalloyyeah
01:44amalloy(more specifically, afk in cali. brb)
01:44waxroseYeah, I have family from Riverside / San Deigo.
01:45tomojshit, when you said 12:41am I thought "glad I'm not in that timezone"
01:45waxroselol
01:45waxroseWhy's that?
01:45tomojI am in fact in that timezone
01:45tomojdidn't realize it was so late already
01:45waxrosehahha
01:45waxroseCrazy huh?
01:46waxroseMy window manager does not display time by default so I often lose track of time. So don't feel too bad.
01:47technomancyyeah, I only see the clock in my tmux status bar
01:47technomancyand the server I run my IRC tmux session in is in UTC, so who knows...
01:47waxroseeek
01:48waxroseI've been meaning to add some thing to StumpWM to actually remind me what time it is.
01:49waxrosetechnomancy, Are you planning on attending Clojure Conj?
01:50technomancywaxrose: yeah, sure.
01:50technomancyhopefully I can relax and not speak this time.
01:51waxroseI'm going to attend for sure. Were there a lot that attended last year?
01:51technomancyabout 200. a lot for a first-year conference I guess?
01:53waxroseNot bad for a first year. I just like to meet every body from the community that I can so, I probably would have just as much if only 50 people showed up.
01:53waxroseas much fun*
01:53amalloywaxrose: it's tough to have a good clojure party with 200 people all at once, is why. 50 at a time is plenty :)
01:53waxroseRuby Conf in Austin last year only had about 280.
01:53technomancyI'm hoping it can extend to three days this year.
01:54technomancywaxrose: it actually felt a lot like RubyConf 05
01:54waxroseamalloy, Lol, yeah. Just add some alcohol.
01:54technomancyback when not everyone was getting paid to hack in it.
01:56waxroseI'm not exposed to a lot of non .net developers where I live so I'm always excited to meet people from different communities.
01:57waxrosetechnomancy, I imagine that makes a big difference. Less greed and more passion.
02:21technomancyyeah, it's not as bad with rubyconf vs railsconf though
02:22waxroseI've never been to a Rails Conf, but I hear it's hectic.
02:26tomojI'm just glad I got to see ze :)
02:27waxroseze?
02:31tomojze frank
02:32waxroseoh, duh
02:32waxrose:P
02:36waxrosetomoj, I remember his ted talk, was quite funny.
03:18tsdhMoin!
03:20tsdhIn a deftest, I have something like (= (time (eval1)) (time (eval2))). eval2 might return a lazy seq. Am I correct that the timing will be wrong in that case, when I mean wrong in terms of "doesn't calculate everything"?
03:24tomoj&(let [x (time (range))])
03:24sexpbot⟹ "Elapsed time: 0.455126 msecs" nil
03:25tomojguess that's not too illuminating
03:25tomojyes, you're right
03:25tsdhYeah, I expected that. So I need to do something like (let [r (eval2)] (if (instance? LazySeq) (doall r) r)), right?
03:26tsdhI do that in a macro. How do I write the variable r there? I mean, what's the common lisp `gensym' in clojure?
03:27tomojI don't really understand what you're trying to do. but, we have gensym as well, and also "auto-gensyming": in a macro, names with # at the end will be gensymed
03:28tomoj&`foo#
03:28sexpbot⟹ foo__10853__auto__
03:29tsdhtomoj: Thanks, that's what I have looked for. :-)
03:30tomojwhat's `'s name?
03:30tomoj'symbol quote"?
03:35tsdhI have this working macro: http://pastebin.com/bUp2Un6t
03:35tsdhHow would I go to extend it to receive arbitrary many funqls, where the expansion contains the second `do' for each of them?
03:55tsdhNearly got it.
03:59tsdhWhat's wrong with ~(map quote forms) in a macro?
04:00tsdhI get error: java.lang.Exception: Unable to resolve symbol: quote in this context
04:00tomojquote is a special form
04:01tsdhAnd forms would be evaluated before passing to quote anyway...
04:02tomojmaybe '~forms ? dunno
04:28tsdhHm, now I got it that the expansion looks ok, but when executing the tests defined with my macro, it seems I have namespace issues. Probably, because I eval the forms... http://pastebin.com/TLU0M5zL
04:28tsdhAny ideas how to do that in a better way?
04:55ZabaQthere's a cheatsheet somewhere that maps clojure to common lisp equlvalent functions/specials - I can't find it anymore, anybody have an url?
04:58angermanZabaQ: apart from http://clojure.org/lisps, don't know.
05:05raektsdh: first, do you really need eval there?
05:05tsdhraek: Did you check the mailinglist? There I've posted the complete code and the problems/errors.
05:05raekI think it would be a better idea to generate (fn [] ...) forms and call them inside the (time ...)
05:07raekthe code you give to eval is not evaluated in the lexical scope of the eval call, but at the top level
05:07angermananyone can lend me a hand with defmulti? … it fails to dispatch right :(
05:07angermanhttps://gist.github.com/872217
05:07angermanThe error i get is: No method in multimethod 'depth-comp' for dispatch value: [geometry.renderer.Edge geometry.renderer.Point]
05:09raektsdh: (doseq [funql-fn# ~(for [funql funqls] `(fn [] ~funql))] ... (let [r# (funql-fn#)] ...
05:10raekangerman: are the objects you pass in records?
05:10angermanyes
05:11raektype returns a class in this case, and the multimethod looks for keywords
05:11angermanif I write out the full name geometry.rernderer.Point and …Edge it does work.
05:11angermanreak is there any "better" way to implement that?
05:11angermanreak: and can I turn a mutli-method into a comperator?
05:11raekangerman: you can (:import (geometry.rernderer Point Edge)) and then use the shorter names
05:11tsdhraek: Thank you.
05:12angermanreak they are defined in the same file…
05:13raekimports of classes behaves differently from vars in namespaces
05:13angermanreak ok
05:13raekyou can do a (import '(geometry.rernderer Point Edge)) after the defrecord (since the classes does not exist before)
05:14raek...with correct spelling, of course. :)
05:15angermanraek: thanks. Hm. And can I turn a multimethod into a comperator_
05:16raekhrm
05:16raek,(defmulti foo type)
05:16clojurebotDENIED
05:16raek&(defmulti foo type)
05:16sexpbotjava.lang.SecurityException: You tripped the alarm! def is bad!
05:16tsdhraek: Now I get java.lang.IllegalArgumentException: Wrong number of args (1) passed to: core$fn--732$fn
05:17raektsdh: oops.. what does the macro expansion look like?
05:17raekoh
05:17raekthe ~(for ...) becomes ((fn [] ...) (fn [] ...) ...)
05:18raekmake it ~(vec (for ...))
05:18raekthen the generated code will be [(fn [] ...) (fn [] ...) ...] instead, and it won't try to call the first fn with the rest as arguments
05:21raekangerman: doesn't look like multimethods implement Comparator, but ordinary fns do
05:21tsdhraek: Yes, that works. Thanks a lot!
05:21angermanraek: I think (comparator multi-fn) works… will have to experiment.
05:47bennyluhi, i want to embed a clojure repl to my java program - is there any class in clojure that can start an embeded repl?
05:50clgvbennylu: clojure.main/repl starts a repl
05:51bennyluclgv, thanks i look into it
05:51clgvbut probably you will have to build a wrapper for it
05:52bennyluclgv, its ok all i wanted is some sort of repl that connected to my program (hance can control it) and that i can connect to it in some way so that ill be able to let my users use it
05:53clgvfine :) I just think I needed to mention that it might still be some work
06:08ZabaQhas iterate been ported to clojure?
06:09clgvbennylu: I found something interesting - a swing repl. it is in the cljr project https://github.com/liebke/cljr
06:13clgvoh well, cljr only installs it. the swing repl is from here: https://github.com/alandipert/clj-swingrepl
06:22thorwili have [net.cgrand/moustache "1.0.0-SNAPSHOT"] in my project file, did "lein deps", the .jar is in lib, is use (:require [net.cgrand.enlive-html :as html]), but: java.io.FileNotFoundException: Could not locate net/cgrand/enlive_html__init.class or net/cgrand/enlive_html.clj on classpath
06:23thorwilwhat's the silly detail i must be forgetting?
06:29tsdhIs pmap guaranteed to deliver the same result as map with respect to the order?
06:30opqdonutyes
06:30opqdonutafaik
06:30opqdonuthttps://github.com/clojure/clojure/blob/b578c69d7480f621841ebcafdfa98e33fcb765f6/src/clj/clojure/core.clj#L5426 <- there's the source
06:31opqdonutas you can see by the "rets (map #(future (f %)) coll)", it works just like map, but evaluates the result later
06:33tsdhHm, ok.
06:33tomojthorwil: hmm, do you see the enlive jar in (System/getProperty "java.class.path") ?
06:33thorwil"lein classpath" tells me that enlive-1.0.0.jar is on my classpath.
06:34angermanhttp://dl.dropbox.com/u/281539/schwarz-lantern.pdf // Schwarz Lantern (clojure via TikZ)
06:34angermanhmm. well. It's written in clojure but compiles to tikz for rendering.
06:34tomojthorwil: I assume you started the jvm the error occurs in after running `lein deps`?
06:36thorwiltomoj: i suspect that is the silly detail i was looking for. thank you! :)
06:37thorwilindeed
06:37tsdhIs there a way to compare 2 seqs without respect to ordering?
06:39tsdhI mean, (= (into #{} s1) (into #{} s2)) would nuke duplicates, which I don't want...
06:39tomojanother perhaps almost equally distateful way is to sort both
06:40tsdhtomoj: Yep. Hm, I can define equals-no-order which checks the count and if that is true, converts to sets, right?
06:40tomoj(btw (set coll) is probably better than (into #{} coll))
06:40tsdhYep
06:40tomojif you're OK with [1 1 2 3] and [1 2 2 3] being equal..
06:41tsdhOh, I'm not. :-(
06:42tsdhThen sorting by natural order would be the right way, I think.
07:00tsdhHm, sorting doesn't work, if the seq contains other (lazy) seqs, cause these don't implement comparable... (sort (map (fn [x] (lazy-cat x x)) [1 2 3 4 5]))
07:01tsdhHm, sorting doesn't work, if the seq contains other (lazy) seqs, cause these don't implement comparable... (sort (map (fn [x] [x x]) [1 2 3 4 5]))
07:01tsdhUps, sorry.
07:05tomojhmm
07:06tomojyou want, say, '((1 2 3 4) 5 6) and '(5 4 (3 4 2 1)) to match?
07:06tomojer, '(5 6 (3 4 2 1)) for the latter
07:07tomojor only '((1 2 3 4) 5 6) and '(5 6 (1 2 3 4)) ?
07:07tsdhyes
07:08tsdhThe former
07:08tomojand arbitrarily deep?
07:09tsdhIf possible, yes.
07:09tsdhOh, wait.
07:09tomojI suppose I'm leading you on as I have no clue really
07:09tomojjust trying to establish how difficult exactly :)
07:10tsdhI think, I will be comparing seqs of tuples (also seqs), and the order of the surrounding seq should be ignored.
07:10tsdhSo: ((1 2) (3 4)) = ((3 4) (1 2)), but ((1 2) (3 4)) != ((4 3) (1 2))
07:12tomojdoes (= (frequencies x) (frequencies y)) work, then?
07:14tomojperhaps not the best solution even if so
07:14tsdhIt does!
07:15tsdhWell, it's only in my test suite, so I can live with possibly not too good performance, as long as it is correct.
07:16tsdhtomoj: Thanks a lot.
07:26angermanare there any limitations on resolve? does it need a repl?
07:27clgvangerman: what do you mean?
07:28angermanI'm trying to resolve a function from a glued together symbol
07:29angerman(resolve (symbol (str some-symb "/create")))
07:29angermanand it returns nil :/
07:29clgvok.
07:30clgvI think resolve does not load require namespaces for you
07:30angermanthe namespace is loaded.
07:30clgvyou have to "use" or "require" them before
07:31angermandoes *ns* get bound specially in the repl?
07:31angermanhmm… if I (:require … :as some)
07:32angermanI cannot (resolve "some/symb")?
07:34angermanhttps://gist.github.com/872353
07:34angermanhere's what I try to do
07:34angermanL33F
07:36angermanbut resolve just returns nil for 'cube/create as well as for the algorithm. even though it's (use imported)
07:39clgvhmm 'cube is no string how does that evaluate? ##(str 'cube)
07:39sexpbot⟹ "cube"
07:39clgvoh kk
07:41tomoj(resolve 'some/symb) seems to work fine
07:41angermantomoj: on the repl… yes.
07:42clgvI guess the compiler remebers the alias when you use it directly
07:42clgvso it cant handle the indirect approach via strings
07:44clgvangerman: you could write a macro that appendes the complete namespace automatically so that you dont need to use it everytime
07:44tomojhmm, I have equal success outside the repl
07:45tomojwith e.g. (resolve (symbol "clojure.java.io/resource")) in an ns that requires clojure.java.io
07:46tomojsimilarly with (:require [clojure.java.io :as jio]) and (resolve (symbol "jio/resource"))
07:49angermanhmm.. so whats wrong with my code? … hmm.
07:53clgvspoke the programmer right before the cpu meltdown ;)
07:55angermanclgv: fixing with liquid cooling...
08:26angermanyikes… some bugs are /really/ hard to track down.
08:31waterbuffalolol: (time (apply + (range 100000000))) = 5400 msec
08:31waterbuffalo(binding [+ unchecked-add] (time (apply + (range 1000000000)))) results in crash: out of memory
08:32waterbuffalo:(
08:32chouser&(= 100000000 1000000000)
08:32sexpbot⟹ false
08:33waterbuffalodeleted one zero
08:33waterbuffalosame exception lol
08:34chouserI like 1e8 syntax for this sort of thing
08:34chouser,1e8
08:34clojurebot1.0E8
08:34chouseroh. heh.
08:34waterbuffalobesides I clearly shouldn't run out of memory...I think
08:34chouserwaterbuffalo: I suspect the performance difference between checking for overflow or not will be overwhelmed by the boxing and unboxing going on there.
08:35waterbuffaloI heard something about not holding on to sequence head once
08:35chouserwaterbuffalo: but you can try reduce instead of apply and see if that avoids the memory error.
08:35waterbuffalobut I can never tell when I'm doing that
08:35waterbuffalotrying reduce
08:36chouserwaterbuffalo: this is Clojure 1.2 ?
08:36waterbuffaloyes
08:36clgvangerman: you found it?
08:36chouserwaterbuffalo: unchecked-add only takes 2 args. It's not varargs like +
08:37waterbuffaloreduce seems to fail also
08:38chouserwaterbuffalo: I think Clojure is trying to realize the entire range before checking to see if unchecked-add can take all those args. In the apply case, I mean.
08:38chouserI'm surprised reduce doesn't work.
08:38clgv&(binding [+ unchecked-add] (time (reduce + (range 100000000))))
08:39sexpbotExecution Timed Out!
08:39clgv&(binding [+ unchecked-add] (time (reduce + (range 1000000))))
08:39sexpbotExecution Timed Out!
08:39chousertry 1e5
08:40waterbuffalowell reduce hasn't crashed yet
08:40waterbuffaloits still running
08:40clgvthe reduce version isnt allocating an increasing amount of memory as htop shows
08:40tomojwhy is the version with the binding 170x slower?
08:40chouserI don't excpect unchecked-add to be much (any?) faster than + when used this way.
08:41tomojI wouldn't expect inlining to help here..
08:41waterbuffaloit's burning it's core to the max :P
08:41waterbuffalowell + did it in 5 sec
08:41chouseraccessing thread-locally-bound vars is slower than accessing root bindings
08:41waterbuffalowith binding it has been more than a minute and still not finshed
08:41tomojah
08:42waterbuffaloso there's no easy way for me to convert whole programs to unchecked arithmetic
08:42tomojwaterbuffalo: huh, seems like your jvm is 250x slower than mine somehow
08:42clgvwaterbuffalo(binding [+ unchecked-add] (time (reduce + (range 100000000))))
08:42waterbuffalohow do you reckon?
08:42clgvups sorry
08:42tomojI get 20ms with +, 4s with the rebinding
08:43clgvyou could use clojure.core/alter-var-root
08:43tomojon a relatively shitty netbook
08:43chouserbleh. what are you even trying to do?
08:43clgvbut then you have no checked adds anymore
08:43waterbuffaloI'm using core i7
08:43tomoji5 here. odd
08:44tomojoh
08:44waterbuffalooh shit..... it's stupid IBM JVM
08:44tomojI was doing it with 1e5
08:44waterbuffaloI've noticed that sun JVM is faster than IBM one for clojure
08:46chouser&(time (let [x (long 1e8)] (loop [i (long 0), a (long 0)] (if (< i x) (recur (inc i) (+ i a)) a))))
08:46sexpbot⟹ "Elapsed time: 995.548407 msecs" 4999999950000000
08:46clgvwhen using doubles you also have to check that you are running a 64bit JVM. occured to me when running my program on windows with 32bit jvm ;)
08:46chouser&(time (let [x (long 1e8)] (loop [i (long 0), a (long 0)] (if (< i x) (recur (inc i) (+ i a)) a))))
08:46sexpbot⟹ "Elapsed time: 833.750908 msecs" 4999999950000000
08:46waterbuffalowhy clgv?
08:47chouser&(time (let [x (long 1e8)] (loop [i (long 0), a (long 0)] (if (< i x) (recur (unchecked-inc i) (unchecked-add i a)) a))))
08:47sexpbot⟹ "Elapsed time: 593.003624 msecs" 4999999950000000
08:47clgvI think JVM doubles are emulated on 32Bit machines. thats the only explanation I can think of
08:47chouserThat's how to write fast loops in Clojure 1.2
08:48waterbuffalochouser, that why I tried binding...not only is replacing all + with unchecked calls in my programs annoying as hell, I would also have to do it for core library functions
08:48waterbuffalolike range
08:48chouserbut the boxing is going to hurt much more than the overflow checking
08:49clgvwaterbuffalo: unchecked-add is no holy water. I checked at a lot of code pieces and it didnt even speed up those
08:49waterbuffalochouser: I know that loop recur is the fastest way...but it produces butt-ugly code, even more so than java's iterative constructs
08:50chouserUsing binding like this isn't going to get you better performance.
08:50waterbuffaloclgv it usually shaves 33% off your arithmetic operations
08:50waterbuffaloI can see that :D
08:51clgvwhat I meant is that I doubt that replacing it everywhere will do that much impact. Just use it where you have your performance bottlenecks
08:52waterbuffalothat's why I loved the binding idea
08:52waterbuffalothe ability to dynamically specify what to do :)
08:54fliebelAre there any people in here with a good understanding of Sudoku and Clojure? I wrote this solver https://gist.github.com/871708 , but for the hard board it does not come up with a complete solution. Does this mean the board has multiple valid solutions, or that my solver is to simple?
08:55chouserfliebel: Everything I know about sudoku solvers I learned here: http://blog.n01se.net/?p=12
08:55clgvfliebel: hard boards often have multiple solutions
08:55fliebelchouser: Thanks, will read.
08:56waterbuffaloyeah generally with sudoku, if you have a few empty places, just do a depth first search
08:57clgvthe trick is to restrain possibilities and derive field values as long as you can. then you can simply pick a random of the valid values in e.g. the most restrained field
08:57fliebelHm, okay, so that means just assuming a number and trying if it works.
08:57waterbuffaloyes
08:58clgvalmost. It will definitiely work if you derived all constraints correctly
08:58waterbuffaloyou choudl conceiveably do this with empty board
08:58fliebelclgv: Well, I checked the solution, and my partial solution at least contains the give one.
08:59clgvmathematically speaking you'll have a hyper plane of solutions (multiple) at the point where you can't restrain the possibility sets anymore
08:59fliebelright, I need more math :)
09:00chouserOr a carefully constructed regex. :-)
09:00fliebelchouser: I like that idea...
09:00chouserfliebel: follow that link
09:00fliebelchouser: I'm reading :)
09:01clgvfliebel: if you are sure that all constraints apply and you cant restrain possibilities anymore, just pick a random value in one of the most restrained fields
09:04clgvor you could try for every possible value left to get to all possible solutions
09:04fliebelclgv: :)
09:05waterbuffalowhat are you using for fields? type from deftype?
09:06clgvfor sudoku in a plain functional style I'd use a set for every field
09:06fliebelwaterbuffalo: sets indeed
09:07waterbuffalo:)
09:07clgvin OOP versions they use custom classes with signaling-like functionality to avoid overhead in applying constraints to fields
09:07waterbuffaloit'd use type to also have info about the column, row
09:08clgvyou can put the sets in a grid and dont need the info about column and row then ;)
09:08fliebelI did consider to use something like an atom, to save me from the folding and unfolding of the rows, collumsna dn especially the blocks.
09:09waterbuffalointeresting...maybe have each field have a bunch of listeners registered on it
09:09fliebelwaterbuffalo: listeners? why? to make them update their neighbors?
09:10clgvit doesnt have to be listeners. it could be just updating counters when it is changed with these counters being organized in a priority queue
09:10fliebelclgv: hu? how did priority queues get involved?
09:11clgvthe german computer magazine "c't" had an article about that some years ago
09:11clgvyou select fields to update from that priority queue afair
09:11waterbuffalofliebel yes something like that
09:12clgvI assume the neighbor-updating listeners would get quite confusing
09:13fliebelclgv: yea, spageti updaters :)
09:14clgvthey solved it by gathering the constraint groups (rows, columns and blocks) in objects that had an update method afair
09:18waterbuffalo(time (reduce unchecked-add (range 1000000))) "Elapsed time: 23742.330576 msecs"
09:19waterbuffalo(time (reduce + (range 1000000))) "Elapsed time: 191.690584 msecs"
09:19waterbuffaloLOL
09:20tomojI don't get it
09:20clojurebotGabh mo leithscéal?
09:21dnolen,(time (reduce #(unchecked-add (int %1) (int %2)) (range 1000000)))
09:21clojurebot"Elapsed time: 845.265 msecs"
09:21clojurebot1783293664
09:21dnolen,(time (reduce + (range 1000000)))
09:21clojurebot"Elapsed time: 845.351 msecs"
09:21clojurebot499999500000
09:22dnolen,(time (reduce #(unchecked-add (long %1) (long %2)) (range 1000000)))
09:22clojurebot"Elapsed time: 815.014 msecs"
09:22clojurebot499999500000
09:29dnolen,(time (loop [x (long 1e6) r (long 0)] (if (zero? x) r (let [x (long (unchecked-dec x))] (recur x (unchecked-add r x))))))
09:29clojurebot"Elapsed time: 96.199 msecs"
09:29clojurebot499999500000
09:32waterbuffalointeresting
09:32waterbuffaloseems like casts alone ruin performance a ton
09:35dnolenwaterbuffalo: not in my experience. but in 1.3.0 you can write: (set! *unchceck-math* true) (loop [x 1e6 r 0] (if (zero? x) r (let [x (dec x)] (recur x (+ r x))))), and it will run just as fast as the above.
09:36waterbuffalointeresting
09:36dnolenwaterbuffalo: LOL interesting
09:36waterbuffaloI'll still need to deconstruct operations like range into loops?
09:37dnolenwaterbuffalo: if you want speed, don't use range for loop control.
09:39angermanclgv: no i didn...
09:39angermanclgv: i rewrote my for loop to take the resolved symbol and a string...
09:39waterbuffalowell range...reduce...map any of the list operations
09:40angermanclgv: e.g (for [[algo aname] [some/ns/fn "SomeAlgo"] ,…)
09:40clgvangerman: ah ok
09:40dnolenfliebel: a sudoku solver in CHR in 22 lines, http://people.cs.kuleuven.be/~tom.schrijvers/CHR/chr_benchmarks/sudoku.chr ;)
09:44fliebeldnolen: CHR?
09:44dnolenfliebel: Constraint Handling Rules.
09:44clgvdnolen: fliebel: oh no that reminds me of our professor frühwirt :P
09:45dnolenclgv: haha! you had him?
09:45dnolenclgv: I'm reading his book.
09:45clgvdnolen: yeah. one lecture in theoretical computer science and one in constraint programming
09:46dnolenclgv: tough guy?
09:46clgvoh no it was practical computer science...
09:46clgvdnolen: there are "strong" and different opinions about him amongst the students ;)
09:47dnolenclgv: did you enjoy the constraint programming lecture?
09:47clgvdnolen: the constraint programming lecture I heard was 3 years ago
09:47angermanaren't there always "strong" and different opinions on professors?
09:48waterbuffalono, sometimes everyone agrees he's shit
09:49clgvdnolen: the content was interesting
09:49angermanwaterbuffalo: ahh…
09:50angermanat first I read: "everyone agrees his shit" :?)
09:51clgvdnolen: you do research in the CHR / constraint programing field?
09:51dnolenclgv: not at all. But I have some interest in doing something like CHR for Clojure.
09:52fliebeldnolen: I can barely read the code. One good thing is that my code is shorter.
09:53dnolenfliebel: heh, yeah you'd have to read up on CHR, it's different from Prolog (Prolog is one host language for it)
09:53angerman,(time (filter (complement nil?) (range 1000)))
09:53clojurebot"Elapsed time: 0.135 msecs"
09:53clojurebot(0 1 2 3 4 5 6 7 8 9 ...)
09:53mecWhy is (time (for ...)) returning immediatly but continuing to process in the background?
09:53angerman,(time (filter identity (range 1000)))
09:53clojurebot"Elapsed time: 0.131 msecs"
09:54clojurebot(0 1 2 3 4 5 6 7 8 9 ...)
09:54angermanhmm.
09:54dnolenmec: you need (time (doall (for ...))), for returns a lazy sequences immediately.
09:55mecdnolen: it returns immediatly, but its still running some thread in the background
09:55angermanlazy sequences can be a real pita.
09:56clgvdnolen: I guess you can make a prettier CHR with Clojure.
09:56angerman(if you are not aware of of them :)
09:57dnolenclgv: heh, I think the syntax for CHR is not so bad, if you're OK w/ Prolog (whose syntax I like)
09:57clgvdnolen: I only remember that I didnt like it much ;)
09:57fliebeldnolen: I'm not sure what to do with Sudoku in Logos. I wrote a plain Clojure version that works, but the logos version does not finish within any reasonable time. I might try to write it in the same style as the Clojure version, but that feels less declarative.
09:59dnolenfliebel: not surprising. Perhaps you should revisit when I get disequality constraints and fix cond-a cond-u ?
10:00fliebeldnolen: Hm, I think that is a good idea. Pattern matching also might help a lot with tearing apart the board.
10:01angerman! TeX capacity exceeded, sorry [main memory size=3000000]. … lol
10:02clgvangerman: looks familiar ;)
10:03angermanwow. that tikz renderer has some funky features...
10:03angermancreate gray/glass like structures.
10:04angermanit could use some backface culling for better performance.
10:04angermanwould obviously destroy the glass like option though.
10:04angermanhttp://dl.dropbox.com/u/281539/cc-ds-pl-subdiv.pdf [900kb]
10:05clgvangerman: do you have your TikZ related code up on github?
10:06angermanyep
10:06angermanhttps://github.com/angerman/planarity
10:06clgvyou have been bookmarked ;)
10:06angermanthe geometry renderer is in https://github.com/angerman/planarity/blob/master/src/geometry/renderer.clj
10:07angermanand the tikz driver is in https://github.com/angerman/planarity/blob/master/src/tikz.clj
10:09clgvah you compile them with the skript. I used the externalize library in my last presentation
10:09clgvthis way the pictures are only recompiled on change. I built a tex file per animation manually.
10:11angermanwell most of the tikz compile and show stuff is mainly so I can take geometry from the repl, and just compile it and let Skim refresh.
10:11angermane.g. chaning the camera/eye position. Adding light (which does not work yet)...
10:12angermanhow on earth do I increate latex main memory?
10:12clgvcommandline param?
10:12angermanyep… anything that helps :D
10:13clgvmaybe you have an error in your generated latex that is causing that error
10:13angermanno. it's main memory.
10:13angermanthe file linked above is the result of the exhaustion. there are some more figures to come.
10:17waterbuffalowait, you are making 3d graphic renderers in clojure? O_O
10:19mec(reduce merge {} lots-o-maps) or (apply merge {} lots-o-maps) ?
10:22ChousukeI suggest apply
10:22Chousukethat way, merge is free to optimise with transients, for example. (no idea if it does)
10:23waterbuffalounless you have like 1000+ elements I don't think transients work that well :P
10:24mecI have at least 1 million
10:26angermanok. it did what I expected it to do...
10:26mecidentical?
10:26clgvwaterbuffalo: for me it works well for list with a maximum of 100 element
10:26angermannah. my latex memory increase.
10:26clgvit's definitely faster
10:27clgvangerman: how did you do it?
10:27waterbuffaloreally?
10:27AWizzArd_,(Math/PI)
10:27clojurebot3.141592653589793
10:27waterbuffaloamazing
10:27AWizzArd_Btw, why does this work? Is Math/PI a static method?
10:27waterbuffalostatic variable
10:27waterbuffalopublic final static
10:27AWizzArd_yes, so I would expect it to work without the parens which I used.
10:27AWizzArd_,Math/PI ; <-- OK, makes sense
10:27waterbuffaloyes
10:27clojurebot3.141592653589793
10:28AWizzArd_,(Math/PI) ;<-- I called a static method??
10:28clgv(1.0)
10:28clojurebot3.141592653589793
10:28clgv,(1.0)
10:28clojurebotjava.lang.ClassCastException: java.lang.Double cannot be cast to clojure.lang.IFn
10:28waterbuffalono such static method
10:28angermanclgv: basically followed http://doxdrum.wordpress.com/2011/02/25/increase-texs-main-memory/
10:28AWizzArd_Right, so this must be some Clojure magic then.
10:28waterbuffaloprobably
10:28clgvangerman: and it did the trick?
10:28AWizzArd_Maybe Clojure allows to call static fields then.
10:28angermanfull set of graphs http://dl.dropbox.com/u/281539/cc-ds-pl-subdiv.pdf
10:29angermanclgv: yes. I assume I can create 64pages worth of these kinds of graphs :D
10:29clgvwhy do you do these graphs anyway?
10:30angermanthesis in partial fulfillment of a degree of Diplom in Mathematik.
10:31clgvah. I was tempted to put you in computer graphics ;)
10:31angermanThe last 12 images show planar quadrilateral subdivision (or what is left).
10:31angermanThe first 12 show catmull clark subd. the next 12 doo sabin subd. and the final 12 planar subd.
10:32angermanclgv: well. It's closely related. I'm at the chair of geometry and visualization.
10:33clgvok. then I didn't guess too wrong ;)
10:34angermanyes. It's somewhere at the intersection of both.
10:39clgvwe dont have that intersection here - our mathematicians are in the nearby forest ;)
10:42fliebelCan I :use a set of things, and :reload only one?
10:42fliebelWith the correct mixture of parens...
10:44waterbuffalolies, I do everything by calling java classes I make beforehand
10:45clgvwaterbuffalo: really? why do you use clojure then? ;)
10:45waterbuffaloto look cool and wear sunglasses while programming
10:46clgvoh, is wearing sunglasses idiomatic?
10:46fliebelclgv: depends on the brand
11:03TobiasRaederIs there a way to typehint that something should be a primitive when calling an java function?
11:03TobiasRaederi need to call a function that takes float float float and float float Object
11:03mattmitchellanyone know how to make emacs NOT put my cursor in a slime error buffer after executing code? i want it to stay in my main code buffer.
11:03TobiasRaederneed to call the float float float one tho
11:30sattvikTobiasRaeder: I believe you can use ^Float.
11:31TobiasRaeder@sattvik tried that but it always get No matching method found exceptions :/
11:37sattvikTobiasRaeder: I tried doing a quick test. I am not getting a no matching method exception, but it also doesn't seem to pick the right method to call.
11:37TobiasRaeder@sattvik interesting
11:38Fossitried (float param)?
11:39raek^Float means boxed (non-primitive) float
11:40sattvikYes, doing (float .) does seem to do the trick. It won't work if the method is overloaded with both Float and float, I think.
11:41clgv"reference to field costs can't be resolved." do defrecords not have fields but only keywords?
11:43sattvikclgv: They have fields. You should be able to both (:field record) and (.field record) with a defrecord.
11:43waterbuffaloman I forgot the rules
11:43clgvsattvik: but I get the above reflection warning
11:43waterbuffalodoes autoboxing precede upcasting?
11:44sattvikYou may need to type hint the record. (.field ^Record record).
11:44waterbuffaloit was on my java certification exam
11:44clgvsattvik: right, forgot about that
11:45clgvall warnings gone :)
12:08mattmitchellusing clojure.contrib.mock.test-adapter and trying to figure out the has-args option -- how can i be more specific about the type of arg ?
12:09fliebelWho else besides dnolen who knows miniKanren? I run into trouble to frequently… :P
12:37sjlIs there a templating library for Clojure that a Jinja/Django user would feel at home with?
12:39fliebelsjl: Moustache probably, but I don;t know anything that lets you embed logic and stuff.
12:39fliebelah, dnolen, can I bother you with another Logos problem? :P
12:39dnolenfliebel: what's up?
12:40fliebeldnolen: I have a relation that is behaving strange, either that, or I don;t understand it. Let me gist it.
12:44fliebeluh, oh… one more moment… all my repls are doing weird stuff…
12:44sjlfliebel: Is that the same as the moustache templates in all the other languages (Chris Wanstrath's moustache)? If so, it's pretty close.
12:44sjlThanks
12:44fliebelsjl: it is
12:44sjlfliebel: Hmm, is this not the moustache I'm looking for? https://github.com/cgrand/moustache
12:45fliebelsjl: oh, right, it's u, not ou
12:45sjloh dear
12:46fliebeldnolen: problem solved… I renamed a function, but not the recursions, and the repl kept these around, so it used the new function, and the recurred into the old function.
12:58fliebeldnolen: I noticed you have some debug functions, how do they work?
12:59dnolenfliebel: they're a bit klunky since I use lazy sequences to avoid stack overflow.
12:59dnolenfliebel: they drop strings into an atom, you can then (print-debug *debug*), which will print out what happened.
13:00dnolenfliebel: in order to cleanup (reset-debug! *debug*)
13:01dnolenfliebel: I'm thinking I'll add a debug paramter to (run ...) to make this less tedious. Can't do this right now but I'll try to get to it later tonight.
13:01fliebeldnolen: But they are not a goal, nor do they project stuff, do they? So how do I use them?
13:01fliebeldnolen: oh, okay.
13:02dnolenfliebel: they are a goal, but they don't change anything, they're basically an s#, they would be problematic with cond-a cond-u I think tho.
13:04fliebeldnolen: Ah, so I can do stuff like (exist [x y] (== x 3) (project [x] (log "x is" x)) (== y 4))
13:05dnolenfliebel: yeah.
13:05fliebelokay, tres cool
13:12fliebeldnolen: Would it be possible to write a xml parser in Logos? That would result in stuff like http://www.seas.upenn.edu/~harmony/
13:18dnolenfliebel: perhaps. I think Logos needs to be a lot faster tho. I'm ruminating how one would combine CHR/Art of the Propagator with miniKanren. Seems like a fruitful direction.
13:20dnolenCHR is interesting because it seems like one of the few declarative paradigms that can really compete w/ imperative ones. clause order doesn't matter like it does in prolog, execution order doesn't matter either.
13:22fliebeldnolen: Sounds great. But I do have the feeling that I'm writing Scheme, Prolog and whatnot when using Logos, and use very little actual Clojure.
13:23dnolenfliebel: as it should be. multiparadigm programming all the way.
13:24fliebelBut maybe that is just a matter of adding a few high-level relations and iterations. think map-o, partition-o, etc :) Just thinking out loud here.
13:25Bronsahow do I exit from a for?
13:25fliebelBronsa: You don't, there is no break keyword or such. why do you need to exit? For is lazy, so you can use just what you need.
13:27dnolenfliebel: such constructs are low-level details for the Logic Programmer ;) LP is all about letting the computer figure out _how_.
13:27technomancy,(for [x (range 10) :while (< x 5)] x)
13:27clojurebot(0 1 2 3 4)
13:27cemerickBronsa: you can use :when and :while in for's let binding to cause the lazy seq for produces to terminate "early"
13:27Bronsauh
13:27pdkfor produces sequences, use doseq for iterative looping
13:27Bronsayeah that's what i needed
13:27Bronsathanks
13:27fliebeldnolen: But recursion is low-level as well.
13:30dnolenfliebel: recursion in LP has a different feel (I think). You're defining _what_ in terms of _what_. in FP _how_ in terms of _how_.
13:32fliebeldnolen: But in logos just as much in Clojure, there are a few kinds of recursion that are very common, which should be wrapped in something less verbose, leaving hand-made recursion for the complicated cases.
13:34dnolenfliebel: come up with some examples, helper relations, improvements. I want to see them :)
13:35fliebeldnolen: I have none, but as soon as I have, I will show them.
13:47mecis there a first-filter?
13:49danlarkinmec: (comp first filter)
13:53amalloymec: you can sometimes use (some pred coll), if your predicate returns elements unharmed when they match
13:53cemericktechnomancy: you should figure out an IPA version of lein's pronunciation
13:54raek[laWriting a logic one to PINxn toggles the value of PORTxn, independent on the value of DDRxn.
13:54raekoops
13:55raek['laɪnɪŋən]
13:57TimMcseems right
14:06joelrgood day! how do i install the native-deps plugin for leiningen? it appears to be just another clojure project
14:09raekjoelr: you add it as a :dev-dependency in your project.clj
14:10joelrraek: so i don't need to install it somehow then. i see
14:10mattmitchelli'm having a tough time figuring this out. basically, the docs for clojure.contrib.mock says the the has-args option accepts predicate fn's for testing arguments. I can't get this to work at all though. Anyone use contrib.mock?
14:10joelrlein native-deps
14:10joelrException in thread "main" java.lang.IllegalAccessError: default-repos does not exist (native_deps.clj:1)
14:10joelrraek: what about this error when running lein?
14:11raekjoelr: leiningen does find the "native-deps" task, but something else is wrong
14:11joelrraek: ok, thanks
14:11technomancyjoelr: probably an old version of native-deps; be sure to get the latest
14:12joelrtechnomancy: how do i get the latest? how do i even figure out what the latest is?!
14:12joelri did clone the native-deps repo and ran lein deps in it but what then?
14:12mattmitchellon a related note, what are most people using for testing/mocking in clojure?
14:12dnolenjoelr: what are you trying to do? I'm the maintainer of native-deps.
14:13technomancylooks like 1.0.5: https://github.com/swannodette/native-deps/blob/master/project.clj
14:13joelrdnolen: i'm trying to build this: https://github.com/mikejs/ring/tree/master/ring-mongrel2-adapter
14:13dnolenjoelr: you definitely need 1.0.5 as technomancy said.
14:13dnolenif you're using the latest released version of lein.
14:14joelri think i am... does lein self-update?
14:15technomancyjoelr: yeah, as long as you didn't install it from a package manager lein upgrade should work
14:16joelrtechnomancy, dnolen: thanks!
14:17joelrmore generally, i'm struggling with getting clojure/zeromq going against mongrel2
14:17joelrany tips?
14:17dnolenjoelr: the problem is that version of ring is requiring native-deps 1.0.1. You need to change it to require 1.0.5. You don't need to mess w/ the native-deps project directly at all, the latest is on clojars.
14:18joelrdnolen: thanks, that's likely part of my problem
14:19technomancydnolen: I can add in an alias for default-repos for backwards-compat; where's it looking for it?
14:19thorwili wrote my very first clojure macro. testing with macroexpand suggests it's correct, to me. yet, i get a "java.lang.IllegalArgumentException: Key must be integer". would someone be so kind to have a look at http://paste.pocoo.org/show/354684/ ?
14:22joelrdnolen: what is the best way to set the dyld library path with native-deps?
14:22dnolentechnomancy: lemme look.
14:22dnolenjoelr: you don't need to set it. lein does that.
14:22joelrdnolen: my java is looking at /usr/local/lib instead of the lein directory
14:22joelrdnolen: i did run lein deps and lein native-deps
14:22joelrand upgraded lein
14:22dnolenjoelr: are you using lein to start the repl or swank?
14:23joelrdnolen: ye[
14:23joelryep
14:23amalloythorwil: ([""] anything) looks like it must be wrong
14:23joelrdnolen: i get this error when using the ring adapter: /Users/joelr/Work/java/ring/ring-mongrel2-adapter/native/macosx/x86_64/libjzmq.dylib: Library not loaded: /usr/local/lib/libzmq.0.dylib Referenced from: /Users/joelr/Work/java/ring/ring-mongrel2-adapter/native/macosx/x86_64/libjzmq.dylib Reason: image not found
14:23dnolenjoelr: do you have a folder called native in your project now?
14:24joelrdnolen: one sec, i think i know why i get this error
14:24amalloyyou say that the "code to be replaced" is [""] (-> ...), but that's two deparate sexps
14:24dnolentechnomancy: in 1.0.1 I was using (:use [leiningen.pom :only [default-repos make-dependency]] ...)
14:25technomancydnolen: ok, I'll add an alias there; thanks.
14:25thorwilamalloy: it's for routing with moustache. [""] means root. this stuff is used within a an "app" macro from moustache
14:26amalloythorwil: bur [""] (...) is very different from ([""] (...)). which do you want?
14:26technomancydnolen: will it break things if default-repos entries become a map sometimes? "clojure" {:url "http://build.clojure.org/releases&quot; :snapshots false}
14:27technomancyif so it's probably not worth it
14:27thorwilamalloy: the first. i thought the outer () was macroexpands doing
14:27amalloythorwil: a macro cannot expand to multiple sexps. if (foo) somehow expanded to (bar) (baz), life would be very difficult for everyone
14:28amalloyso if you want your eventual code to look like (defroute [""] (...)), you need a macro that generates the whole defroute form, not just the first two args to it
14:29joelrdnolen: i had a version of jzmq installed in /usr/local/lib
14:29dnolentechnomancy: if that makes your life easier that's fine w/ me, I can check map? and do conditional logic.
14:29thorwilamalloy: i wasn't aware of that limitation, thank you
14:29dnolenjoelr: gotcha, so things are working for you now?
14:30amalloythorwil: it certainly can expand to ((bar) (baz)), as you saw, and *within* its single sexp it can do as much splicing and fiddling as it wants, but it cannot leave that sandbox
14:31technomancydnolen: yeah, it will speed up dependency checking quite a bit if we don't check non-snapshot repos for snapshots
14:32joelrdnolen: yep, otool -L reveals that native/macosx/x86_64/libjzmq.dylib wants /usr/local/lib/libjzmq.0.dylib even though there's a perfectly working native/macosx/x86_64/libjzmq.0.dylib
14:33hiredman~logs
14:33clojurebotlogs is http://clojure-log.n01se.net/
14:36dnolenjoelr: they are both on your path. It's not clear to me that there's a way to prefer one or the other. Global installs of Java native libs are a PITA in my experience. Open to insights on how to handle such cases.
14:38choffsteinHey all. This is going to be a very, very stupid question, but how do I find the max of a seq? Calling (max [1 2 3 4]) just returns [1 2 3 4]... is there any way to destructure the seq into the params max expects?
14:38amalloyapply max
14:38fliebelchoffstein: ##(apply max [1 2 3 4])
14:38sexpbot⟹ 4
14:38choffstein*smacks forehead8
14:39choffsteinYep...right. Apply. God damnit.
14:39dnolen,(reduce max [1 2 3 4])
14:39clojurebot4
14:39fliebeldnolen: I was about to say that. I think that is prefered in most cases, no?
14:39amalloyi don't think so
14:39dnolenamalloy: remind me why apply is preferred here?
14:39amalloyi mean, either is fine
14:40fliebel$source max
14:40sexpbotmax is http://is.gd/HUUFvJ
14:40amalloybut apply gives more room to the implementors of max to optimize, in future
14:40amalloyeg spin off some new threads to do a divide-and-conquer instead of mandating a linear pairwise thing
14:40fliebelamalloy: max reduces internally for more than 2 args, so reducing is cheaper here.
14:41amalloyfliebel: so? the difference is basically zero for that
14:41dnolenI'd rather implementors optimize, parallelize, primitivize reduce in the future, than bother with max ;)
14:41TimMcbrehaut: Grah, can't get the hang of fnparse.
14:41amalloydnolen: they can't parallelize reduce! reduce specifies that you have to work with o1, then o2, then o3...
14:42TimMcbrehaut: I think I'll just use regex for now and switch to fnparse later.
14:42fliebelamalloy: what about pvreduce?
14:42amalloythese performance concerns are basically pointless in either direction
14:42brehautTimMc: oh? what is causing you grief?
14:42amalloyTimMc: https://github.com/amalloy/claudius/blob/master/src/claudius/core.clj has a simple use of fnparse
14:42fliebelamalloy: that might be true, but I think some guru said reduce was better, except for str and a few others. I'd like ot find out why that was.
14:42amalloysuper-simple, maybe too simple for your use
14:43amalloyfliebel: it's worse for str because str *does* have the optimizations now that max *could* have in future :P
14:43brehautTimMc: sure thing
14:43amalloyanyway, executive summary: use reduce or apply for this case. some cases apply is necessary; sometimes reduce is necessary: keep them both in mind
14:44fliebelamalloy: I think there was another argument, namely that apply works one level above your code, rather than on the same level, but I don;t know what that is supposed to mean.
14:44brehautfliebel: have you got a link for this?
14:45fliebelbrehaut: No, just a random irc conversation months back. If my search feature was less crapy, I would try to find it.
14:46brehautfliebel: no worries
14:46fliebel~logs
14:46clojurebotlogs is http://clojure-log.n01se.net/
14:46amalloyfliebel: searching those is pretty dang hard too
14:49dnolenamalloy: isn't http://labs.oracle.com/projects/plrg/Publications/ICFPAugust2009Steele.pdf all about making reduce parallel for applicable operations?
14:49fliebelamalloy: Yea… Maybe the guru in question could enlighten us. Might be chouser or fogus who said it.
14:50amalloydnolen: that paper is new to me, and at a glance it looks like you are right. but i'm not sure how it's relevant: the contract for reduce, as it exists now, specifies an order of operations. some futuristic pvreduce on the par branch might allow parallelization, but the one we have now won't
14:51choffsteinIf I have a map and I want to apply a function to the vals and replace them, is there a function to do that? I wrote a macro using reduce and assoc on an empty map ... but it seems hacky.
14:51amalloyfmap, walk
14:51amalloyin clojure.contrib.generic.functors (i think) and clojure.walk, respectively
14:52choffsteinamalloy: if you charged me a penny for every question of mine you've answered, you'd have ... $10?
14:53amalloyheh
14:53dnolenamalloy: there is no contract for how reduce works as far as I'm aware. reduce already works differently for different datatypes.
14:53amalloyi should stop giving two answers at once, then
14:53amalloy$source reduce
14:53sexpbotreduce is http://is.gd/SRobxr
14:53brehautamalloy: turning down a chance to use juxt and comp?!
14:53amalloyIf val is not supplied,  returns the result of applying f to the first 2 items in coll, then  applying f to that result and the 3rd item, etc.
14:55amalloyif reduce didn't have such a contract how could it be usable? foldl vs foldr have hugely different characteristics for non-associative operations
14:55joelrdnolen: how do you deal with native libraries that want to be installed in /usr/local/lib?
14:55amalloylike, you could certainly specify a new special-case of reduce that allows parallelization and is vaguer in its contract
14:55amalloybut i don't see reduce itself changing
14:56dnolenjoelr: I don't know how to handle that case. I meant that I was open to ideas on how to deal w/ that.
14:56dnolenjoelr: short answer, don't global install native extensions if you're a JVM language developer.
14:57joelrdnolen: let me try something (i'm on the mac)
14:59dnolenamalloy: not in disagreement, but the door seems wide open for optimizing reduce. But I see nothing similar for apply.
15:00amalloydnolen: apply itself can't be optimized, for sure. but it can benefit from optimizations to the function being applied
15:01amalloywhich is different from reduce: you could optimize reduce itself but that's less likely to happen in a hurry because of the way reduce is specified
15:11dnolenamalloy: my experience is that Clojure tends to prefer global optimizations over specific ones. My bets are on reduce :)
15:13joelrdnolen: any clues on this? i copied the native libraries to /usr/local/lib/, just symlinking them didn't do it but now i get Could not initialize class org.zeromq.ZMQ [Thrown class java.lang.NoClassDefFoundError]
15:13chouseris clojure-conj.org down?
15:14amalloyhttp://www.downforeveryoneorjustme.com/clojure-conj.org says it's just you
15:14fliebelchouser: not for me
15:14amalloyand i can see their page too, fwiw
15:14chouserheh, ok, thanks.
15:15amalloy(well. they say it's just me, cause i didn't tell them i was asking on your behalf)
15:15chouser"The server encountered an error and could not complete your request." Hm...
15:16amalloychouser: it only works for people with at least two Ls in their irc name. weird bug
15:16dnolenjoelr: I would remove your global install. how did you install?
15:16chousermakes sense
15:16joelrdnolen: i removed my global install a long time ago if you are talking about libraries in /usr/local/lib
15:18joelrdnolen: is there anything else to do to remove my global install?
15:18fliebelchouser: You can always try wget/curl, but set the X-irc-name header ;)
15:18dnolenjoelr: so it's still looking there? that baffles me. I don't know anything abut jzmq so I can't say.
15:18joelrdnolen: i did install that lib into my local maven repo when installing globally, does that matter?
15:19dnolenjoelr: probably.
15:23joelrdnolen: tried that, doesn't help. i'm still getting Could not initialize class org.zeromq.ZMQ [Thrown class java.lang.NoClassDefFoundError]
15:23joelrdnolen: i don't know if this helps but it works if i build manually and install using maven
15:24joelrdnolen: and use the :native-path "/usr/local/lib" variant instead of native-deps
15:24Licenseraloa :)
15:26joelrdnolen: question... in addition to the native deps, won't i also need something like [org.zmq/jzmq "2.0.7-SNAPSHOT"]? or is the assumption that the jar is packaged with the native deps?
15:27hiredmanapparently 'if' vs. 'when' is the most divisive issue in clojure
15:28dnolenjoelr: you definitely need that, :native-dependencies [some/native/jar "version"]
15:28Licenseri kind of like if
15:28hiredmancalled out a use of 'if' with a single branch an hour or so ago, and the argument is still waging on sonian's irc channel as to which is appropriate where
15:29amalloyhaha
15:29joelrdnolen: but that would include the jar with the java wrapper code, correct?
15:29amalloyif you use if when you should use when, you deserve what you get
15:29Licenseramalloy: brilliant statement
15:30hiredmansome claim it doesn't matter which you use where, some claim when is only for sideeffects because of the implicit do, etc
15:30amalloysure, i see both sides of the argument, it's just that every side but mine is wrong
15:30joelrdnolen: because that class-not-def error is clearly due to the jar not being found
15:30fogus`awayhiredman: http://www.xach.com/naggum/articles/3215299538573186@naggum.net.html
15:31hiredmanugh, common lisp
15:31dnolenjoelr: native-deps assumes that all your native stuff is in a single jar, not packaged up with the other stuff.
15:31hiredmanfogus`away: fns and let have an implicit do
15:31technomancyyeah; bring down the naggum-hammer
15:32LicenserI found it not to be too much of a trouble to have a lib directory for additonal deps
15:32dnolenjoelr: native-deps also assumes a specific layout that lein expects.
15:32fogus`naggum-hammer, good name for a project
15:32joelrdnolen: does it mean that :native-dependencies [[org.clojars.mikejs/jzmq-native-deps "2.0.7-SNAPSHOT"]] was not packaged correctly?
15:32joelrdnolen: how can i check?
15:33fogus`hiredman: substitute progn for do
15:33dnolenjoelr: do you have a native folder in your project directory now?
15:33joelrdnolen: 100%
15:33technomancyfogus`: yeah, I wasn't even thinking of the norwegian connection.
15:33dnolenjoelr: it's also important to run, lein deps, lein native-deps _always_ in that order.
15:33hiredmanfogus`: it's not 'oh clisp, I can't read this' it's 'oh, this is digusting, I don't want to read this'
15:33joelrdnolen: i do that, in that order. i also do lein clean before lein deps and lein native-deps
15:34fogus`hiredman: fair enough ;-)
15:34dnolenjoelr: is the zeromq jar in your lib folder?
15:35joelrdnolen: no, although there's zeromq stuff in ~/.m2/repositories/...
15:36dnolenjoelr: something is wrong then, you need the jar in your lib folder.
15:36joelre.g. lein native-deps
15:36joelrExpanding: /Users/joelr/.m2/repository/org/clojars/mikejs/jzmq-native-deps/2.0.7-SNAPSHOT/jzmq-native-deps-2.0.7-20100821.141701-5.jar into /Users/joelr/work/java/ring/ring-mongrel2-adapter
15:36joelrdnolen: ^
15:37dnolenjoelr: I would erase all zeromq stuff from your maven dir. lein clean, lein deps, lein-native-deps.
15:37joelrdnolen: ok, i see jzmq.jar in my lib
15:38dnolenjoelr: progress.
15:38joelrlet me try swank...
15:41joelrdnolen: what bit of code makes lein automagically load jzmq.jar for me?
15:43thorwilhow can i deal with -> in a macro?
15:43amalloythorwil: start by explaining what you mean :P
15:44thorwilamalloy: with (defmacro urgh [] `(-> foo bar baz)) what i want is expansion to (-> foo bar baz)
15:45thorwili guess i'm stumbling over the fact that -> is a macro itself?
15:45amalloyum, looks like you're all set then. is your issue that instead you're getting user/foo instead?
15:46joelrdoes lein automatically load all the jars from the lib directory?
15:46thorwilamalloy: i get (user/baz (clojure.core/-> user/foo user/bar))
15:46joelrlein swank that is
15:47amalloywell, that's sorta two different issues. the first is that you aren't quite getting how macroexpansion works
15:47amalloywhen that code gets actually run, the -> will expand again, getting you the eventual (user/baz (user/bar user/foo))
15:48amalloyyou can see the end result with clojure.walk/macroexpand-all, if you want
15:48amalloy&(macroexpand-all '(-> x y z))
15:48sexpbot⟹ (z (y x))
15:48dnolenjoelr: it's in lib, so it's automatically loaded.
15:48amalloycontrast with ##(macroexpand '(-> x y z))
15:48sexpbot⟹ (z (clojure.core/-> x y))
15:49joelrdnolen: can i check? because that NoClassDefFound error means it's not being loaded
15:49dnolenjoelr: are you using swank?
15:49joelrdnolen: 100%
15:49joelrlein swank
15:49dnolenjoelr: and you restarting when your jars change?
15:50joelrdnolen: i think so. let me restart just in case...
15:50amalloythe other is that unqualified symbols in macros are automatically namespace-qualified, to prevent you accidentally using symbols for different things in the calling scope
15:50amalloy&`x
15:50sexpbot⟹ clojure.core/x
15:51thorwilyes, i got aware of that already
15:52thorwilmaybe i have to rewrite what i'm trying to generate without ->, to find the damn bug hiding somewhere :)
15:52thorwilthanks
15:53joelrdnolen: this is the thing... i copy the libs from native/... to /usr/local/lib. i lein swank and try to use the project. i get the library image not found blah blah blah error. but the libs are there, i just copied them! if i copy the libs at that moment and try to use the project again (w/o restarting swank) then i get the no class def error
15:55dnolenjoelr: curious as to why you keep moving things to /usr/local/lib, how does anyone (java) know anything is there?
15:56joelrdnolen: the jzmq dylibs want /usr/local/lib
15:56joelrdnolen: i'm on the mac so i verify this with otool -L
15:57joelrthe funky thing is that i get this error regardless of whether i have the libs in /usr/local/lib or not
15:58joelrsee how it wants /usr/local/lib? /usr/local/lib/libjzmq.dylib: Library not loaded: /usr/local/lib/libzmq.0.dylib Referenced from: /Users/joelr/work/java/ring/ring-mongrel2-adapter/native/macosx/x86_64/libjzmq.dylib Reason: image not found
15:58joelrdnolen: the error is saying that native/macosx/x86_64/libjzmq.dylib is linked against /usr/local/lib/libjzmq.dylib
15:59dnolenjoelr: that seems broken to me.
15:59joelrdnolen: i concur
16:00dnolenjoelr: you can explicitly set your library path and load from there I guess, in this case it's probably best to avoid native-deps entirely.
16:00fliebelhuh… ArityException Wrong number of args (-1) passed to
16:02joelrdnolen: how can i tell if my java is running in 64-bit mode or force it to do so?
16:03joelrdnolen: because i think that's the issue
16:03fliebeljoelr: Mac has a preference pane for that in application/utitilties
16:03joelrthe libs are 64-bit
16:03joelrfliebel: java pref pane?
16:03fliebeljoelr: mac 10.6?
16:03joelrfliebel: yep. latest java too.
16:03fliebelJava Preferences.app
16:04joelr;latest for 10.6 anyway
16:04joelrfliebel: what do i set to only allow 64-bit?
16:04fliebel(that was supposed to be the app name and path, dunno what it did)
16:05joelrfliebel: it can't seem to uncheck or check just one of the boxes
16:05fliebeljoelr: yea the java pref pane, you can drag them in the right order.
16:05joelrfliebel: i do have 64-bit first
16:05amalloyfliebel: -1 args is something to do with macros expecting automatic env and body arguments
16:06amalloyiirc
16:06fliebelamalloy: It;s a macro for sure, but what does that mean?
16:06joelrfliebel: and activity monitor shows that i'm indeed running 64-bit java. damn, there goes my theory.
16:07amalloyfliebel: it indicates that something has gone wrong :) but that's as specific as i can get
16:08fliebelamalloy: Oh, okay… lol I even want to go as far as to say something went wrong in a weird way.
16:08joelrcan i force-load a jar from the clojure prompt?
16:09fliebeljoelr: force load?
16:09joelrfliebel: i mean just load
16:10joelrfliebel: i'm having trouble with a jar in lib/ and i want to see exactly what happens when i load it
16:10fliebelamalloy: Maybe you see something out of place? http://pastebin.com/26ZAY4QT
16:10fliebeljoelr: Besides using import and checking the classpath and lib path I wouldn;t know.
16:10joelrok
16:11joelrthanks
16:11joelrfliebel: how do i check the classpath and lib path?
16:13raek(doseq [url (.getURLs (java.lang.ClassLoader/getSystemClassLoader))] (println url))
16:13amalloyfliebel: aside from the evil repetition of (map (fn ...)) stuff
16:13fliebelamalloy: I think it is a greater evil to write another loop/macro for 3 lines.
16:14amalloyfliebel: but those three functions are exactly the same function
16:14amalloyyou don't even need another macro or loop
16:14fliebelamalloy: That is true...
16:14amalloyfliebel: see also https://github.com/amalloy/amalloy-utils/blob/master/src/amalloy/utils/macro.clj#L9 for cases where the function isn't exactly the same
16:15hiredmanclojurebot: what does the hyperspec have to say about it?
16:15clojurebothyperspec is not applicable
16:15fliebelamalloy: But that does not make the macro technically broken..
16:15amalloyno
16:16amalloythe macro looks fine to me, modulo the prolog stuff that i have to just assume works
16:16fliebelamalloy: That wouldn't break when doing a macroexpand-1, would it?
16:16amalloywhat?
16:16clojurebotwhat is exceptions
16:17fliebelamalloy: The prolog stuff has nothing to do with expanding the macro, as far as I can tell.
16:19amalloyfliebel: hard for me to know when you haven't told me where the breakage is :P. eg if slice is throwing the arityexception, that's happening inside the macroexpansion
16:19fliebelamalloy: Hm, true, let me look at the exception
16:20fliebelamalloy: Funny how it does not mention anything that has my namespace.
16:21amalloygist up the stacktrace, perhaps
16:21fliebelamalloy: sure: http://pastebin.com/Em4qNXmD
16:22amalloywhoa -1 args to map, that's funny stuff
16:24amalloyfliebel: i think it's seeing only-one arg passed to map, and accidentally subtracting two because it thinks it's a macro
16:25amalloywhat's the form you're calling macroexpand-1 on?
16:25joelrdnolen: the nativelibs in clojars have not been packaged correctly, not for the mac.
16:25fliebelamalloy: something random with 2 args, like (macroexpand-1 '(pruning-sudoku [1 2 3] :a))
16:26joelrdnolen: i built the libs from source, installed them into /usr/local/lib, used :native-path "/usr/local/lib" and removed the libs from native/macosx/... now it works like a charm
16:27amalloythen my best guess is that (slice (reduceable-board [1 2 3])) causes a problem?
16:27fliebelamalloy: As long as the first is a seq, I get the same error.
16:28amalloythen i'm out of guesses
16:28fliebelclose… ArityException Wrong number of args (1) passed to: core$map wehn executing that.
16:29fliebelamalloy: but range 81 works… wait… ['range 81] does not of course ;)
16:30fliebelthere we go!
16:30dnolenjoelr: good to hear that you got that sorted, sorry for the trouble.
16:31amalloytold you it was the prolog stuff :)
16:31fliebelamalloy: Nah, it's the literal macro argument stuf that tricked me up again.
16:32fliebelamalloy: I somehow expect clojure to know whether I mean the result of (range 81) or the literal form.
16:39choffsteinHey all ... i'm back with more questions :D This one is more code design. I have a list of maps, like [{:date <date> :value 0.1} {:date <date> :value 0.2} ...], and a function that takes a list and constructs a moving average over it. Basically, what I would like to do is yank out all the :value data from the list, pass it to my moving average function, then construct a new map with the associated date values...
16:39choffsteinthoughts on the best way to design this one?
16:41raeksomething like this maybe? (map #(assoc %1 :value %2) originals (moving-average (map :value originals)))
16:42choffsteinmmm ... i like that
16:42raek(--> (map :value the-list) ;;Basically, what I would like to do is yank out all the :value data from the list,
16:43raek (moving-average)
16:43raek ;; pass it to my moving average function
16:43raek (map #(assoc %1 :value %2) the-list)) ;; then construct a new map with the associated date values...
16:43raekeh, you get the idea :)
16:44raekalso, --> should be ->>
16:44raekoh, you wanted a map...
16:45raekor wait, maybe I did interpreted it correctly...
16:50raekchoffstein: this is what I meant: https://gist.github.com/raw/873272/f3f1dcf77243be32f0e6e7079b9b3d4a94811579/moving_average.clj
16:51choffsteinthanks raek. that looks like exactly what I am doing. appreciate it.
16:56angermanreak the last "the-list" is in error. no?
16:56angermanahh. sorry
16:57waxroseo_o
17:07choffsteinis there a way to tell what classes are inside a jar?
17:07amalloychoffstein: jar tf <myjar>?
17:08choffsteinthanks.
17:09choffsteinokay -- question for ya. I named one of my namespaces 'moving-averages' in a different library. When my program tries to find it, I get an error that moving_averages.clj can't be found -- but moving-averages.clj is in the jar. Are namespaces allowed to have dashes in them?
17:10amalloyyes, but files aren't. my-cool-ns should be in my_cool_ns.clj
17:10choffsteinohhhh
17:10choffsteinthat ... explains a lot
17:10amalloyhaha i'm glad it does. still seems crazy to me :P
17:11fliebelamalloy: Maybe there is a platform with a JVM that uses dashes as path separators.
17:11amalloyfliebel: no; java classes just can't have dashes in them, is the root cause
17:11choffsteinyep, that fixed everything
17:11amalloyi just don't really understand how this causes a ripple to clj filenames
17:11fliebelamalloy: Maybe something with gen-class?
17:12amalloyprobably
17:16fliebelOh, great, I coded myself into a corner.
17:16raekwould be weird to have the source of my-cool-ns.foo in my-cool-ns/foo.clj but the AOT compiled class in my_cool_ns/foo_init.class
17:16fliebelWhat donald duck did, is put up a hammock, and wait. *goes to bed*
17:22quizmere-match doesn't work on arrays. What's a good way to handle re-matching in a type-insensitive way on arrays or strings ?
17:22quizmehow do you test if something is an array ?
17:27brehautquizme: i dont think there is one 'array' type; each type of primative and object has its own array type
17:27brehautquizme: how would you explect re-match to work on an array?
17:29hiredman,(->> Class .getMethods (map bean) (map :name) set)
17:29bultersgday all
17:29clojurebot#{"getComponentType" "getName" "getEnclosingClass" "isAnnotationPresent" "getClass" "getDeclaredMethods" "getEnclosingConstructor" "getResource" "getConstructor" "getField" ...}
17:29hiredman,(->> Class .getMethods (map bean) (map :name) (filter #(.startsWith % "is")) set)
17:29clojurebot#{"isAnnotationPresent" "isEnum" "isInterface" "isArray" "isMemberClass" "isAnonymousClass" "isLocalClass" "isAnnotation" "isSynthetic" "isAssignableFrom" ...}
17:29quizmebrehaut return an array of matched sub items
17:30quizmebrehaut and nil if nothing matched
17:30quizmeby "Array" i mean vector
17:30brehautquizme: re-matches returns a vector
17:31brehaut&((juxt vector? nil?) (re-matches #"a(b)c" "abc"))
17:31sexpbot⟹ [true false]
17:31quizme(re-find #"abc|123" ["abc"])
17:31quizmejava.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.
17:31quizmeCharSequence (NO_SOURCE_FILE:0)
17:32brehaut&(map #(re-matches #"a(b)c" %) ["abc" "ac"])
17:32sexpbot⟹ (["abc" "b"] nil)
17:33hiredmanquizme: that is not an array
17:33brehautif you only want the ones that are actually values then ##(keep #(re-matches #"a(b)c" %) ["abc" "ac"])
17:33sexpbot⟹ (["abc" "b"])
17:33quizmehiredman it's a vector ?
17:33hiredmanquizme: yes
17:34brehaut&(.getBytes "abc")
17:34sexpbot⟹ #<byte[] [B@2af631>
17:34brehautthats an array
17:34quizmehiredman k thanks
17:34quizmebrehaut: thanks I guess i'm ok for now
17:35hiredmanclojurebot: the policy on names is http://en.wikipedia.org/wiki/Rectification_of_names
17:35clojurebotc'est bon!
18:23riddochcSo, it looks like the current leiningen wants robert-hooke already available, in order to build. robert-hooke is buildable with leiningen. I seem to have caught an infinite loop. :)
18:24riddochcThe clojars website doesn't make it terribly obvious how I'd get a prebuilt jar of robert-hooke.
18:24riddochcAny suggestions?
18:25raekriddochc: the jar is available here: http://clojars.org/repo/robert/hooke/
18:25technomancyriddochc: "building" in the bottom of the readme shows how to do it. you can go sourdough-style or bootstrap with maven
18:26riddochcAha! Thanks raek, and technomancy - I should've kept reading, obviously.
18:30joelrhow do you split a string at character N?
18:31joelra combination of take and drop?
18:32raekjoelr: at a certain index, or at a certain character (e.g. \, in "foo,bar")?
18:32joelrraek: index
18:32brehaut&(vec (.split "a,b,c" ","))
18:32sexpbot⟹ ["a" "b" "c"]
18:32brehautoh sorry, misread
18:32raekjoelr: use subs
18:33joelrsubs?
18:33brehaut(doc subs)
18:33clojurebot"([s start] [s start end]); Returns the substring of s beginning at start inclusive, and ending at end (defaults to length of string), exclusive."
18:33raek...twice
18:33joelrraek: which is the same as take and drop, no?
18:33lazy1,(map #(apply str %) (split-at 3 "abcdefg"))
18:33clojurebot("abc" "defg")
18:34raekjoelr: not exactly... take and drop return sequences, but subs returns a string
18:34joelrright
18:34joelrlazy1: i like that
18:35riddochcI've made some effort at using sequence functions (take/drop/etc.) for parsing text, and it gets rather complicated, very quickly.
18:36lazy1For splitting at a character, you have clojure.contrib.str-utils2/split
18:36riddochcParticularly since I wind up trying to return some structure along with the remaining section of input, and then all the parsing functions need to do destructuring, and then I think that it might have been easier to use fnparse to begin with.
18:37raek,(let [s "abcdefg", i 3, left (subs s 0 i), right (subs s i (count s))] [left right])
18:37clojurebot["abc" "defg"]
18:37joelrbasically, i need to parse a mongrel2 header, e.g.
18:37joelr82209006-86FF-4982-B5EA-D1E29E55D481 0 /python 568:{"PATH":"/python","accept-language":"en-US,en;q=0.8","user-agent":"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.134
18:37joelr82209006-86FF-4982-B5EA-D1E29E55D481 0 /python 568:{"PATH":"/python","accept-language":"en-US,en;q=0.8","user-agent":"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.134
18:37joelr82209006-86FF-4982-B5EA-D1E29E55D481 0 /python 568:{"PATH":"/python","accept-language":"en-US,en;q=0.8","user-agent":"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.134
18:37joelr82209006-86FF-4982-B5EA-D1E29E55D481 0 /python 568:{"PATH":"/python","accept-language":"en-US,en;q=0.8","user-agent":"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.134
18:37joelr82209006-86FF-4982-B5EA-D1E29E55D481 0 /python 568:{"PATH":"/python","accept-language":"en-US,en;q=0.8","user-agent":"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.134
18:37joelr82209006-86FF-4982-B5EA-D1E29E55D481 0 /python 568:{"PATH":"/python","accept-language":"en-US,en;q=0.8","user-agent":"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_6; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.134
18:38joelr82209006-86FF-4982-B5EA-D1E29E55D481 0 /python 568:{...},0:,; Evaluation aborted.
18:38brehautraek: subs has a 1-ary fn that takes the start and runs to the end
18:38joelrwhere {...} is 568 chars worth of JSON
18:38riddochcI wonder if it would be easier if we clojure could support multiple return values... or if that would just make it more complicated.
18:38raekbrehaut: ah, yes. that is indeed better.
18:39lazy1There is clojure.contrib.json, so you can parse the log with that
18:39brehautraek: im just disappointed that i cant work out how to do it with juxt
18:39pdksometimes i wish it still had something like that to indicate whether it returns nil as an actual value pulled from a structure or nil as a dummy value
18:39raek,(let [i 3] ((juxt #(subs % 0 i) #(subs % i)) "abcdefg"))
18:39clojurebot["abc" "defg"]
18:40brehaut((juxt #(subs %1 0 %2) subs) "abcd" 2)
18:40joelrlazy1: parsing json is not the issue, i already do that. the issue is elegantly taking the 1st 3 elements of that message, then splitting on : to grab 568 and the rest, then taking 568 chars worth of json then processing what's left
18:40brehaut&((juxt #(subs %1 0 %2) subs) "abcd" 2)
18:40sexpbot⟹ ["ab" "cd"]
18:40raekyeah, closing over the index as I did is cheating... :)
18:40brehaut:)
18:40joelrso i'm doing (split #" " req 4) then (split #":" rest 2) then Integer/parseInt
18:41joelrthen (map #(apply str %) (split-at header-len (second rest)))
18:41joelrit all seems rather inelegant to me
18:46brehautjoelr: ## (->> " 1:2 2:3 " .trim (re-seq #"(?:\s+|(\d+):(\d+))") (take-nth 2) (map (comp vec rest)) (into {}))
18:46sexpbot⟹ {"1" "2", "2" "3"}
18:46brehautbah ##(->> " 1:2 2:3 " .trim (re-seq #"(?:\s+|(\d+):(\d+))") (take-nth 2) (map (comp vec rest)) (into {}))
18:46sexpbot⟹ {"1" "2", "2" "3"}
18:46brehaut&(->> " 1:2 2:3 " .trim (re-seq #"(?:\s+|(\d+):(\d+))") (take-nth 2) (map (comp vec rest)) (into {}))
18:46sexpbot⟹ {"1" "2", "2" "3"}
18:47brehautsorry about that
18:47joelrbrehaut: thanks
18:48brehautjoelr: sorry i didnt solve the actual problem you mention though
18:53hsuhi'm creating an "uberjar" with lein, but then when i do java -jar xxx.jar, i get Exception in thread "main" java.lang.NoClassDefFoundError: myprj/test/core... what going be going on ?
18:55brehauthsuh: you have a :main defined in your project?
18:55clojurebotproject euler is http://ProjectEuler.net
18:56hsuhbrehaut: yep, its :main myprj.test.core) and in this file there is a defn main
18:56brehautdefn -main ?
18:56brehautwith varargs?
18:56hsuhno, (defn main []
18:56brehauthmm, try -main
18:56brehautdo you also have :gen-class in your ns ?
18:56hsuhhm
18:56hsuhno
18:57brehautand give it [ & args ]
18:57hsuhok, lemme try
18:58hsuhwhats -main instead of main though?
18:58brehauti dont know if the entrypoint is allowd to be defined with a 0 arity main method
18:59hsuhsure
18:59brehauthsuh: i cribbed it from http://clojure.org/compilation
18:59raekI think you just get a IllegalArgumentException at run time
19:00amalloyyes, his actual problem is probably caused by missing :gen-class; missing -main will show up as a problem later
19:01hsuhso i need gen-class? this is kinda new right?
19:01brehautnot really
19:01amalloyuhh
19:01hsuhi just installed a new lein version
19:01hsuhand for the first time i'm getting this error, thats what i find strange
19:01brehautgen class is at least a couple of years old i think
19:02rata_I miss so much third, fourth, fifth and so on
19:02amalloyrata_: write them with a macro
19:03rata_amalloy: no problem with that, but I think they are common enough to be in c.core, at least third, which is the one I definitely miss
19:04brehaut,((meta #'gen-class) :added)
19:04clojurebot"1.0"
19:04raekrata_: destructuring tends to solve those problems for me
19:05hsuhbrehaut, amalloy: yeah, adding a gen-class to the file with the main function did the trick, i just wonder why i didnt needed it before ... thanks anyway
19:05rata_raek: for me too, but this time it made it more verbose
19:06amalloyrata_: https://gist.github.com/6f6d7f5811c232c93c25 is a quickie
19:06amalloyneeds my macro-utils package tho :P
19:07rata_hahaha =) do-template does something similar and is in c.template
19:08rata_thanks anyway amalloy =)
19:08amalloyyeah?
19:09rata_amalloy: (do-template [name pos] (defn name [s] (nth s pos)) third 2 fourth 3)
19:10amalloyah. couldn't find that when i was writing mine. mine's more general anyway
19:10amalloythanks for the pointer
19:16sjlCan anyone point me at a guide to handling POST data in Compojure that works?
19:26brehautsjl: have you included the wrap-params etc middlewares?
19:26brehaut(to actually decode the forms data)
19:26sjlbrehaut: No, but I think handler/site does that. I figured it out though, it was that I had [] before {params :params} and didn't notice
19:27brehautah right
19:32amalloywow, i did not know about C-x a C-a. this will make coding in verbose languages less painful, i'm sure
19:34phenom_does anyone have an example of a non trivial compojure app? one that keeps state around
19:35brehautphenom_: you might want to try #compjure too
19:35waxrosecabalamalloy, Yeah, it will. :D
19:35amalloyphenom_: maybe ask rata_
19:35waxrosecabalbrehaut, Greetings.
19:35brehautwaxrosecabal: hi
19:39brehautphenom_: its not really the responsibility of compojure to help you manage your state though
19:39ZabaQ1..hmm..should I really have my static content in classes/public.. ?
19:50phenom_rata_ around ?
19:55rata_phenom_: yes, sorry, I was eating something
19:56rata_phenom_: I don't use compojure, but ring+moustache... that won't make a difference probably
19:58rata_phenom_: you don't need anything special to handle state in ring, just do it as you would in any clojure app
19:58rata_use an atom or a ref
19:58rata_I use a ref
19:58rata_or use a db
19:59rata_sorry, I use an atom
20:03TimMcSo there is a single process with multiple server threads and they can potentially share some references?
20:04phenom_rata_ I understand ... but how would you structure your functions for a chat application for example ... chat is made up of multiple rooms, each room with multiple users
20:04rata_TimMc: I don't know if ring spawns multiple server threads under the hood
20:06rata_phenom_: your state there would be users and chat rooms, if I understood correctly
20:06phenom_im trying to wrap my head around mutable state and side effects ... like what if whenever you created a room you also needed to send off an email
20:06rata_you can store them in refs
20:06rata_or in atoms if you don't need to update both at the same time atomically
20:07rata_phenom_: what have emails to do here?
20:07phenom_just for example ...
20:08phenom_how would you structure such a function
20:08TimMcphenom_: I think you might send an agent off to do the emailing.
20:09phenom_but the agent has no state ... so use a future ?
20:09rata_agents have state
20:10rata_they're one of the mutable things in clojure
20:10rata_futures don't
20:11rata_phenom_: (defn create-room [name] (swap! *rooms* conj name) (send email))
20:11rata_if you use atoms
20:12phenom_that's how i would do it but all of it is side-effects and mutable state
20:12phenom_for some reason i feel that it's wrong lol
20:13rata_it's not wrong, not for me at least
20:13rata_mutable state is in clojure to help you when state is required
20:16TimMcThere's nothing wrong with mutability, it just shouldn't be the default.
20:31riddochcHey, anybody awake who's familiar with using fnparse?
20:32riddochcI'm having a bit of trouble making use of the 'validate' function correctly. I can't seem to find any examples that use it.
20:38brehautriddochc: i have dabbled with it
20:41riddochcHmmm. Okay, I can get it to identify that there's an error, by returning false from my validator function, but I'm not sure how to make it give a decent error message...
20:41brehautriddochc: validate is pretty simple, what trouble are you having with it?
20:42brehautriddochc: that isnt the purpose of it
20:42riddochcYou can assume that most of my code is just like the example json parser, and I've made something like so...
20:42riddochc(def digits
20:42riddochc (validate (complex [digit-seq (rep<= 12 decimal-digit)]
20:42riddochc (-> digit-seq apply-str Long/parseLong))
20:42riddochc (fn [n] (if (> n 2147483647)
20:42riddochc false
20:42riddochc n))))
20:43riddochcWhat I'm trying to do here is to make sure that whatever number I read isn't larger than 2147483647. If it is, I should error out...
20:43brehautriddochc: instead of using complex i would semantics
20:44riddochcYeah? I'm mainly using complex because that's what the json example uses...
20:44brehautriddochc: put Long/parseLong etc into the body of the semanitcs function; if it raises an exception you can catch that with intercept
20:46riddochcHm. Except it's not about whether it fits in a long, but whether it's actually in so many bits... Seems a long can fit bigger numbers than I can allow.
20:46brehautriddochc: sure. its not bad per se, but its just a bit heavy weight when you only have one parser in the comprehension
20:46brehautanyway, validate is about causing the parser to backtrack and try a different parsing strategy
20:47brehautwhereas intercept is about capturing an actual error
20:48brehautriddochc: again, i think thats an exception rather than a parser 'failure'
20:48riddochcWell, sure... I could have some logic go over the structure built up afterwards and validate it.
20:49riddochcBut this number needs to be used to determine how many arbitrary bytes to read, later in the parser.
20:49riddochcWhat do you suggest for that situation?
20:49brehautriddochc: you could, but your semantics (or the body of complex) is able to throw an exception
20:51riddochcThe json parser pretty much only handles errors by using (failpoint (expectation-error-fn ...)) which kind of obscures how to use it any other way.
20:52riddochcI feel like I'm sort of cookbook-programming, rather than really understanding what's going on. :/
20:52brehautlet me check i understand everything. a) you are parsing longs out of json b) that value is later used to determine how many bytes to read c) if that value is greater than a certain threshold, its in error and your entire parse has failed?
20:52brehautim going to go look at this example
20:53riddochcMy protocol isn't actually json, it's something else... but yes, essentially. I'm just reading the json example code that comes with fnparse as a starting point.
20:53brehautlets take a step back then; what do you understand about the underpinnings of the library?
20:53brehautok
20:53riddochcI understand it uses monads to handle the passing of the input through the series of functions I'm defining.
20:54brehautriddochc: and do you know what that actually means?
20:54riddochcEssentially, that it's doing composition... but dealing with the fact that these functions take and return more than one value.
20:54brehautriddochc: do you understand that its doing nondetermistic depth first search ?
20:55riddochcHuh, I wasn't aware that that was the specific mechanism involved.
20:56riddochcIt's been a rather long time since I've written formal grammars, but I studied this stuff, once upon a time. LL(k), etc.
20:57riddochcI *think* that the idea of having part of what's already parsed determine future parsing behavior makes it not so context-free, doesn't it?
20:57brehautok. so the mechanics of the parser are actually a monad transformer around a monad; it has state-t around maybe-m
20:57brehautstate-t lets it track states and maybe-m provides the failure handling logic
20:59riddochcTell you what, I just discovered the articles you wrote about using fnparse, I should probably go read that, and ask questions later -- I've only been woring off the documentation that's directly associated with fnparse.
21:00riddochcer, working.
21:00brehauti think so; you have access to the clojure stack in any case, 'as well as' the state stored within the state machine (which includes the remainder, and any other data you wish to track)
21:00brehauthah no worries
21:00riddochcI'll send you an email after I've had some time to think about what I'm doing.
21:01brehautriddochc: sure thing; ive got a couple of other articles on there about state monads and they also link to some other articles about it
21:02carlo_aubrehaut: where are these articles? Are they on monads in Clojure (as opposed to Haskell)?
21:02riddochcIn case you're curious, the specific purpose of this is to implement a rather obscure but useful protocol in clojure... I emailed the author of aleph about it, because it's remarkably similar to aleph's concepts. Check out RFCs 3117 and then 3080 - BEEP is what websockets *wishes* it were. :)
21:03riddochcI was planning on seeing how I can implement BEEP tied in with aleph, etc.
21:03brehautriddochc: apparently my explaination of complex is a bit weak and the rule-to-set function is also poorly introduced
21:03brehautcarlo_au: yeah they are. jsut a moment
21:03brehauthehe awesome
21:04riddochcIt was designed in the late 90s, when people first started realizing that HTTP was being badly abused, and were thinking about how to handle things better.
21:05riddochcI forget the guy's name, but its author helped design some pretty significant protocols before that, and it really seems like some pretty smart people worked on BEEP.
21:06riddochcI kinda doubt I can resurrect it for its intended purpose of doing better than HTTP, but that doesn't mean it isn't useful for being the basis of some application-specific protocols. I had a major brainstorm about uses for it last weekend.
21:06riddochcAnyway.
21:07riddochcI should go get some food. Have fun clojuring.
21:07brehautcarlo_au: http://khinsen.wordpress.com/2009/04/22/monad-tutorial-for-clojure-programmers/ http://intensivesystems.net/writings.html are your starting points; the first is by the author of the clojure monads lib in contrib, the second becomes quite a deep dive; i also have some of my own ramblings at http://brehaut.net/blog/tag/monads but they arent 'introductions to monads'
21:07brehautriddochc: interesting. cheers for the pointers
21:07brehautcarlo_au: that should be http://brehaut.net/blog/tags/monads sorry.
21:07brehautgood luck
21:08brehautriddochc: if you really want to get a deep understanding, implement state-m your self
21:09carlo_aubrehaut: cool, thanks
21:11brehautcarlo_au: no worries; just keep in mind that as interesting as they are, the application is much narrower in clojure than haskell.
21:11devnhello all
21:11brehauthi devn
21:13carlo_aubrehaut: is that because Haskell forces anything to do with state to go through a monad/arrow, whereas Clojure allows impure functional code?
21:13devncarlo_au: i dont think impure and functional should be used together there
21:13brehautcarlo_au: its imprecise but its good neough
21:13devncarlo_au: stuart halloway put it like this: clojure is a "consenting adults" language
21:13brehautcarlo_au: 99% of monads in haskell are pure
21:13devnyou can do I/O if you want
21:14carlo_auyeah
21:14devnbut most of clojure is geared towards making the things you do pure by default
21:14devnso yes, you can do things which are not pure, but rich's example of Google is apropos
21:14brehautand the impure stuff (IO) is available as more than monads and arrows too; also functors and applicative functors
21:14devnGoogle is not a pure function
21:14devnyou wanna build google? You need to change some stuff.
21:15devnthe nice thing is that in clojure after a little bit of reading you can look at some clojure code and be fairly certain about where things are getting impure
21:16devnthe do* functions for instance are a pretty good indicator
21:16devnthere's also the implicit (let [k 10] (println k) (+ k 1) (+ k 2))
21:16devnsome side effects there, but that's still pretty obvious there is something impure happening
21:17carlo_auyep
21:17devncarlo_au: hope that answers your question?
21:17carlo_audevn: it does, yes
21:17brehautcarlo_au: its more that haskell has optimized for monads. they are a bit krufty in clojure.
21:17devnbrehaut: sort of true, but ive seen some haskell hackers implement lots of haskelly stuff in clojure with quite a bit of ease
21:18devncarlo_au: are you coming from haskell?
21:20carlo_audevn: I dabbled in Haskell about 10 years ago in undergrad, but never did much with it
21:21carlo_aumy current day job involves writing a lot of C, and that spontaneously made me learn Lisp in my spare time
21:21carlo_audevn: this is the extent of my experience with monads: http://carlo-hamalainen.net/blog/2011/02/11/monad-motivation/
21:21brehautdevn: you sure can, but you have to overcome the additional syntax barrier. curried functions and infix operators (and do notation) make haskell a much more suitable target for that style of programming. we end up with (comp this) (partial that) (domonad whatever-m ...) everywhere
21:21devnbrehaut: yeah good poin
21:21devnpoint*
21:22devn(defm m-sequence [monads] (let [f (fn [ms m] (let-bind [result m results ms] (return (monad-type m) (conj results result))))] (reduce f (return (-> monads first monad-type) nil) (reverse monads))))
21:22brehautdevn: on the other hand, the stuff that jim duey is doing with conduit is pretty cool :)
21:22devnyeah jim's monad tutorials for clojure are great
21:23devnreally enjoyed those.
21:23devnconduit is still something im sort of getting my head around tbqh
21:23brehautdevn: im slowly coming to grips with conduit but its pretty heavy stuff
21:23devni havent had much of a need
21:23brehauthah
21:23devn:D
21:24devnyeah, but im beginning to see /now/ where it would be useful
21:24devnlikewise with aleph and lamina
21:24brehautyeah likewise
21:24devni was like "cool, not sure if ill ever use that, but cool"
21:24devnand now it's like "ohhhh!!!!"
21:25devnmakes me feel kind of behind the times -- someday im gonna be like "rabbitmq!" and some whippersnapper is going to laugh at me and show me some newfangled way of doing it that is 10x better
21:25devnim still like, uh, i could use a priority queue, or somethin'...
21:25brehauti want to have a play with github.com/stuartsierra/cljque and the async thing hiredman wrote
21:26brehauthttps://github.com/hiredman/die-geister i think
21:26devnyeah jim duey referenced hiredman's work -- think he did a hornet queue thing for conduit
21:26brehauthornet queue?
21:26dnolenhttp://www.jboss.org/hornetq
21:27devndnolen: FTW
21:27brehautdnolen: cheers :)
21:27devnwhat's up david
21:27dnolendevn: happily crafting macros
21:27devni saw your gist yesterday without the context -- whatcha playin with palindromes for, eh?
21:28devneuler fun?
21:28dnolendevn: just comparing calculating palindromes with miniKanren vs. for lisp comprehension.
21:28dnolener list
21:28devnbratko-logos
21:28devndude, you're always up to no good
21:29devnand by no good i mean working on awesome stuff
21:29devni dont think i can resist looking at code that contains "monkey-banana" in the commit message
21:30dnolendevn: heh, we'll see where all this goes, but it fun so far.
21:30brehautdnolen: i forgot to mention, i ran my benchmarks yesteray with version 2 of my monkey-banana thing; when i ran it with version 3 (which uses the unifier) it was 2 orders of magnitude slower
21:30dnolenbrehaut: your own unifier?
21:30brehautdnolen: just fogus's unifycle
21:30brehauti dont think im smart enough to write my own
21:31dnolenbrehaut: yeah, it uses postwalk, postwalk is like molasses.
21:32brehautdnolen: i was going to use your one, but my project is 1.2 so that i can get the monads lib
21:32devni just went through a bunch of old OSX86 installs on this mac while building up my NAS and found all sorts of half-finished projects laying around my hard drive. working on putting it into a "clj-garden" kind of thing. that's neither here nor there, but brehaut, suggestion: grab a white paper on something interesting and write some code for it.
21:32brehautdevn: dnolen gave me a link to Oleg et al's LogicT paper
21:33devnive doing that for the last 8 months or so and it's amazing how much insight you get just by plugging away at a whitepaper
21:33dnolenbrehaut: postwalk makes it 2 orders of magnitude slower. In logos.unifier, unifier will only work with pre-walked exprs. unifier' will call postwalk for you, and run dog slow.
21:33brehautdnolen: does the unifier rely on any 1.3 features?
21:33dnolenbrehaut: not, really I've actually slowly been removing dependencies on 1.3.
21:34brehautdnolen: i'll have to give that a shot
21:34devnbtw, i havent been keeping up as keenly as i was, what's new on 1.3? anything beyond static/dynamic, pods?
21:34dnolenit was almost all syntactical anyway, using ' in symbols.
21:36amalloydevn: primitives
21:36amalloyand unchecked-math by default
21:36dnolenamalloy: unchecked math is not the default.
21:37amalloydnolen: well. the default has changed
21:37amalloyfrom "expand as needed" to "throw an error if it's bigger than a long"
21:38amalloythat's not really unchecked but for someone sitting on 1.2 (ie me) it feels about the same
21:38brehautdnolen: one thing that has surprised me about the LogicT is that i dont think there is a logic var type
21:47dnolenbrehaut: yeah I haven't looked LogicT closely enough to understand how it works. LogicT seems like it's deals with the ideas from the goal/goal constructor portion of miniKanren.
21:49brehautdnolen: i'll have to take your word for it having not looked at that portion of miniKanren
21:49brehautdnolen: it definately looks like a layer of additional abstraction and some more opperations on the 'basic' nondeterminsitc state monads
21:49dnolenbrehaut: unification is considerably less tricky then it sounds. It amounts to recursively traversing two terms and storing what ever is on the "other side" when you encounter a logic variables.
21:50brehautinteresting
21:50dnolenbrehaut: like bidirectional destructuring.
21:52brehautdnolen: i presume that it only gets tricky when there are logic var chains ?
21:52brehautor is that a seperate concern?
21:53dnolenbrehaut: yes that the essence of the tricky part, binding a variable to another variable.
21:53dnolenwhen people mention occurs-check, they mean preventing variable cycles.
22:02devni totally missed :refer, forgot about :rename
22:03devnwhat's the best way to alias a defn?
22:04devnim used to alias_method in Ruby
22:07scottjI think there's a defalias in contrib
22:07scottjprobably c.c.def
22:08sjlAnyone used clj-oauth with a site that only needs signed requests, not request tokens?
22:11devnscottj: thanks
22:36mecIs there any good place that explains the difference between defstruct deftype and defrecord?
22:36brehautmec: defstruct is deprecated
22:38mecand thats the only one with an example on the main site :X
22:38brehautreally?
22:38brehautmec youve read http://clojure.org/datatypes ?
22:39amalloymec: ken wesson put together an excellent example of a deftype on the mailing list recently
22:39scottjbtw are you sure defstruct is deprecated? doesn't say so in the source
22:39amalloyscottj: yes
22:39mecbrehaut: that's mostly the whys not the hows
22:40amalloyhttp://groups.google.com/group/clojure/msg/66a09ed29b488854
22:40brehautmec hmm thats true
22:40mecamalloy: thanks
23:22hiredmanamalloy: neat
23:54rata_does anybody know how to optimize this fn? https://gist.github.com/871248
23:54rata_would typehinting be useful there?
23:55rata_(if so, how would you do it? I've never done typehinting on my own code, just saw others doing it)
23:57technomancyrata_: don't type-hint until you've verified it's a bottleneck by profiling
23:57rata_technomancy: I've verified it
23:57rata_it takes ~80% of the time
23:58technomancyshould have been more clear: unless you've verified that reflection is the bottleneck.
23:58rata_oh ok... how do I do that?
23:59technomancyvisualvm is one way, I think. haven't done it myself.