#clojure logs

2011-12-05

01:02radsalso why do fully qualified keywords always give the user namespace in clojurescript?
01:20sunngit looks a strange behavior when using `case`:
01:20sunng,(let [c (int 1)] (case c (int 1) "matches"))
01:20clojurebot"matches"
01:21sunng,(let [c (short 1)] (case c (short 1) "matches"))
01:21clojurebot"matches"
01:21sunng,*clojure-version*
01:21clojurebot{:major 1, :minor 3, :incremental 0, :qualifier nil}
01:21sunngwow, I think it's a bug in clojure 1.2 and fixed in 1.3
03:12amalloysunng: the test-expressions in case clauses have to be compile-time constants; i believe 1.3 made it possible for more things to be regarded as constants. but in general, ##(case 1 (2 1) "either 2 or 1") is how lists are supposed to be used in a case expression
03:12lazybot⇒ "either 2 or 1"
03:16sunngamalloy: I just find that in clojure 1.2 (case (int 1) (int 1) "ok") could return "ok" but (case (short 1) (short 1) "ok") failed. The inconsistency just confuses me a lot.
03:16amalloy&(hash (short 1))
03:16lazybot⇒ 1
05:11ambrosebsI want to convert (fn. [[a :- type1] [b :- type2]] ...) to (fn [a b] ..) , with (meta a) = {::type type1}
05:11ambrosebsany suggestions as to how to go about this?
05:11ambrosebsalso the more general case of the multi-arity syntax
05:12ambrosebsI would use assoc but it doesn't work with lists
05:15ambrosebsnvm, forgot about map :)
05:30siancumorning
06:01triyoI have a list of maps that I wish to merge; merge as in structural merge. Example [{:cons_data {:day {:cost {:total {} :data {}}}}} {:cons_data {:day {:volume {:total {} :data {}}}}}]. In this case, I'd expect the :cost {} and :volume nodes to be merged in to a single list. However, what happens is that the second map's :volume becomes a member but :cost node doesn't appear at all in the merged map.
06:01triyo*single list = I mean into the merged map
06:05triyoHm, it seems that merge with is what I'm after.
06:06triyo*merge-with
06:10Chousuketriyo: if you need recursive mergeing then you can write a function that uses merge-with to merge the map using itself as the merge function :P
06:11triyohehe, talking about eating your own dog food
06:11triyo:_)
06:11ChousukeJust don't forget the base case
06:12triyoHehe, yip wont forget. thx
06:13triyoThere is something I remember in contrib right the does deeper merge?
06:14triyoyip, deep-merge-with
06:15raektriyo: if the structure is small enough, it might be easy to just use destructuring: (let [[{{{cost :cost} :day} :cons_data} {{{volume :volume} :day} :cons_data}] m] {:cons_data {:day {:cost cost, :volume volume}}})
06:16raekwhere m is your pair of maps
06:18triyoIts not necessary a pair of maps. Its nondetermanistic
06:21raekare there any other keys at the same level of :cons_data and :day?
06:26triyoyip, there will be other timespans: week, month, etc.
06:27triyodeep-merge-with seems to work as it does recursive merge.... Only thing I'm thinking about is what should by function look like...
06:32triyoNo clashing occurs on my end except for the start_date and end_date that are under :day. However those date are the same in the maps so something simple as (fn [l r] l) will do
08:08TimMcRaynes: No plans, just following the examples in the blog post.
09:38xianHi. I'm using some Java code in a Clojure/leiningen project. The Java code requires an external jar which is (of course) not on the leiningen classpath. Since it is not obvious how to alter the classpath of a leiningen project I am looking for another way to make my Java code accessible from Clojure (putting the jar in my_project/resources didn't help).
09:43xianBasically, I'm looking for a way to add a local jar as dependency for the leiningen project.
09:44raekxian: first, have you checked if this "external jar" is in the maven repo?
09:44raek(seach engine: http://jarvana.com/)
09:45raekin case the java code is your own and small, you might want to include it in your clojure project (leiningen can build java code too)
09:47raekthe last resort is to put the jar file in the lib/ directory and add :disable-deps-clean false to the project.clj file. there is usually a better way than this to solve the problem, though
09:49raekif the java code is it's own project, you should really make an artifact for it so that you can use it the usual way (add it as a dependency)
10:11xianraek: My dependency is the tools.jar from the JDK distribution (which I need for some JDI interaction).
10:17xianSo it's not in the maven repo.
10:18TimMcxian: You can add it as an extra classpath element in your project.clj.
10:19raeklooks like that .jar is usually declared with a special systemPath option in maven (which I don't think Leiningen supports)
10:20TimMcxian: https://github.com/technomancy/leiningen/blob/1.x/sample.project.clj
10:21TimMc:extra-classpath-dirs
10:21raekso in this case maybe :extra-classpath-dirs ["path/to/tools.jar"] is the best you can do
10:22raekthis path depends on which OS you have, so this will be messy when/if you try to work on this project on another computer
10:22TimMcclojurebot: sample project |is| https://github.com/technomancy/leiningen/blob/1.x/sample.project.clj
10:22clojurebotYou don't have to tell me twice.
10:34lemoqhi folksk
10:35lemoqgot a question: how do i add the content of a seq to an exception? something like (throw (Exception. "elements in seq: " theseq)), where it lists all elements in theseq??
10:35lazybotlemoq: What are you, crazy? Of course not!
10:38joegallo,(doc prn-str)
10:38clojurebot"([& xs]); prn to a string, returning it"
10:38erujolcis there an issue with documentation being out of date: http://clojure.org/vars (a tutorial that is probably high traffic for beginners) that wont work with clojure 1.3 due to not being declare dynamic
10:38joegalloso, for instance, you might do something like (appy prn-str the-seq)
10:40joegalloerujolc: specifically the part about (binding [x 2 y3] (+ x y))?
10:40joegallos/y3/y 3/
10:42Raynes&(str "Exception and stuff: " (prn-str [1 2 3]))
10:42lazybot⇒ "Exception and stuff: [1 2 3]\n"
10:43Raynes&(str "Exception and stuff: " (apply prn-str [1 2 3]))
10:43lazybot⇒ "Exception and stuff: 1 2 3\n"
10:43erujolcjoegallo, i mean that the example wont work
10:43erujolcyou need to declare the vars with (def ^:dynamic x 1)
10:43Rayneslemoq: Pick your poison.
10:43erujolcfor example
10:44lemoqRaynes, joegallo, thanks, prn-str perfectly does the job
10:46joegalloerujolc: right, that's what i was asking -- was that the problematic part of the example?
10:46joegalloand your answer is yes
10:47erujolcbut theres more...http://ideone.com/EAthN
10:48erujolcfuture is in another thread so I expected the out to be 42nill not 44nil
10:50xianraek, TimMc: Thanks, that works nicely. I don't worry too much about different OSes..
10:51ckirkendall`erujolc: the future was created under a given binding thus inheriting its thread locals for those bindings.
10:52ckirkendall`erujolc: Its my understanding the bindings apply to all child threads created inside the binding.
10:57erujolcckirkendall`, that would make sense but cant see this documented anywhere
10:57ckirkendall`erujolc: I am trying to validate but I believe bindings use InheritableThreadLocal
11:16ckirkendall`eurjolc: It doesn't using the built in InheritableThreadLocal but it does seem to implement a custom form of inheritance by passing a copy of the parent bindings into binding frame.
11:19erujolcthanks for the clarification, it does seem to make sense when I think about it a bit longer
11:24RaynesI feel so powerful to be able to release marginalia to clojars.
11:24michael_campbellGood deal with Manning's "deal of the day" today.
11:25cemerickRaynes: when did that happen?
11:26cemericksqueaky wheel effect? ;-)
11:26Raynescemerick: Fogus and I had a night of passion at the conj.
11:26RaynesOr, he just got tired of me whining at him to release new snapshots.
11:26cemerickBetween him and the no starch guys, you really get around!
11:26michael_campbellman, I'm not sure if I'm happy or sad that I just ate, and read that
11:27Raynescemerick: It took me 30 minutes to tone that tweet down enough to make it even remotely acceptable.
11:27RaynesYou should have seen the first draft.
11:27cemerickRaynes: so, we'll have indexes in marg output soon?
11:27RaynesIndexes?
11:29Raynescemerick: Indexes like outlines? Like on http://jedahu.github.com/story/
11:29cemerickyeah; indexes, outlines, whatever
11:30RaynesI hope so. I made an issue about it and story, but no responses so far. I'm not sure where one would fit in marg output. If fogus is really attached to the docco format, I bet we're screwed.
11:31RaynesStory is pretty great though. I think it is an excellent compromise between the marginalia-style literate programming and the API-docish stuff that autodoc brings to the table.
11:31cemerickThat's closer to what I really want.
11:31cemerickesp. an index that is fixed to the top, just like the ToC in story.
11:31Raynes Me too.
11:32RaynesThe one on the left?
11:32cemerickyeah
11:32RaynesYeah, that's pretty awesome.
11:32RaynesIt's the index on the right that I like the most.
11:33RaynesIt isn't intrusive but is very useful if you need to scan through the API.
11:33cemerickmake the index a selection panel for larger projects, and it's money
11:33RaynesI'm just not sure it could ever work with the side-by-side layout.
11:34cemerickhow do you mean?
11:34Rayneshttp://raynes.github.com/ororo/ given the side-by-side layout, where would such an outline fit?
11:34cemerickoh
11:35cemerickI'm not attached to that. :-P
11:35RaynesNor am I.
11:35cemerickI'll probably just start using story.
11:35RaynesYeah, I'm not really seeing anything wrong with story at this point.
11:35cemerickI'd tinkered with marginalia, but it wasn't useful enough for stuff I wrote.
11:36RaynesI mean, it doesn't rip docstrings, but in what universe would that be useful for a non-side-by-side layout?
11:36cemericki.e. reference material
11:36Raynescemerick: I'll write a Leiningen plugin for it in a little while.
11:40cemerickRaynes: Perhaps the outline could go under the TOC?
11:40Raynescemerick: What really got me thinking was when I did that tentacles blog post and Laurent Petit was completely baffled as to why I had marginalia docs and no autodoc. He pointed out that it wasn't very useful for looking at the API.
11:41Raynescemerick: That would be excellent, I think.
11:41cemerickIt's certainly seems opinionated towards the literate programming thing, which I confess I've not really grokked.
11:41cemerickRaynes: The the side-by-side will work fine.
11:41RaynesI've been doing a form of half-assed literate programming that I really like.
11:41RaynesSee my irclj docs for an example.
11:42Rayneshttp://flatland.org/irclj
11:42cemerickhalf-assed is the path to salvation.
11:42RaynesI don't think I could ever buy into full-assed literate programming.
11:44cemerickah, "accordion" is what I was trying to think of… http://jqueryui.com/demos/accordion/
11:44cemericks/selection panels/accordion
11:44RaynesFoldable!
11:44RaynesThat would be great and would fit in marginalia fine, wouldn't it?
11:45RaynesOnly see what you want to see.
11:45RaynesI love you so much, Chas.
11:45cemerickThere are tradeoffs.
11:45chad_Raynes: your comment on full-assed literate programming reminds me of the strange southern french colloquillism "Avoir le cul bordé de nouilles"
11:45cemerickfor smaller libs, seeing everything is far preferable and superior
11:46cemerickFor libs that have larger namespaces, you need something like an accordion with a scrollable list of vars.
11:46RaynesIt seems like a nice compromise.
11:46cemerick…or other namespaces just roll below the frame.
11:47cemerickBoth story and marg are javascript-heavy, so a decision could easily be made at load-time as to which is most appropriate.
11:47RaynesOkay, let me know when you've finished implementing all of that.
11:47cemerickWhat, I'm not ordering off a menu or something? :-P
11:47Raynes;p
11:52Raynescemerick: Hah. Story is one big ol' story.clj file.
11:53pdkstory.clj has a story all its own to tell
11:53cemerick700 lines isn't *too* bad
11:54pdkyeah that's about the length of your average java hello world
11:54cemerickmmm, test-free yumminess
11:54Raynescemerick: To be fair, marginalia's tests weren't passing the last I checked.
11:54cemerickit's a bummer that both have markdown bolted in
11:55RaynesSurely it wouldn't be difficult to have pluggable parsing backends?
11:55Raynes"Dear Marg: Piss off, I like asciidoc."
11:56cemerickno, probably not
11:56cemerick"Quick and dirty dsl for inline css rules, similar to hiccup." Run away, run away! :-P
11:57RaynesHeh
11:57RaynesI'm a fan of hiccup, but not sure how I feel about inline CSS.
11:58cemerickit's wanting for some enlive and gaka.
11:59RaynesGaka still depends on 1.2.0-master-SNAPSHOT.
11:59cemerickThis is unfortunately true.
12:14mccraigcemerick: dyu know what's happening with clojure.core.strint (it's in the core.incubator git repo, but not in the core.incubator 0.1.0 jar on mvnrepository) ?
12:14cemerickit's in 0.1.1-SNAPSHOT
12:15cemerickI think abedra is the lead on incubator, so it's up to him to push a release. You can mail the list about it if you like.
12:16mccraigthx
12:40TimMcShould I bring up the results of ##(list? (list* 1 ())) on the ML?
12:40lazybot⇒ false
12:41technomancylist? is the worst function in clojure.core, hands down
12:42zakwilsonI have never had any desire to call list? that I can recall.
12:42TimMctechnomancy: The whole confusion between lists and seqs bothers me.
12:43technomancylists and seqs is one thing; distinguishing between list and cons is dumb
12:43hiredmancons in clojure is for seqs
12:44technomancyif you care whether something is counted, there's a function for that called counted?
12:44TimMcWell, I like to think there is an abstraction barrier there.
12:45TimMcseqs are a type of coll, `seq` takes you from any coll to a seq, `into` and company take you to various colls.
12:45TimMcBut list* returns a seq, not a list.
12:46TimMctechnomancy: The use case was someone writing a DSL or whatever the other day. They wanted to distinguish between [] and ().
12:46technomancyTimMc: yeah, that's where I learned to avoid list? too, inside a macro
12:47TimMc&(map list? ['foo (quote foo)])
12:47lazybot⇒ (false false)
12:48TimMcHrm, what was the example?
12:49ChousukeTimMc: code doesn't actually have to be a list so the more robust way is to check for the vector and assume it's a list otherwise :P
12:50technomancycould be a map
12:50Chousukeor check for seq? or something I guess
12:51technomancyanyway, fixing it is a breaking change since the docs state "Returns true if x implements IPersistentList", so IMO it should just be deprecated
12:51technomancyif you really want it, you can type out the whole (instance? clojure.lang.IPersistentList x) call; it's only one more token
12:57technomancyso goooood: http://www.qwantz.com/index.php?comic=2096
12:59zakwilsonIs there a test for whether something is a lazy seq or a non-lazy collection?
13:01Raynescemerick: Do you actually plan to do anything about the marginalia stuff we were talking about earlier? Just asking because, if not, I'm going to post the logs on my existing issue as food for thought for people who might actually do something at some point (we're probably both too lazy).
13:03RaynesPlus, if I did it... well, we all remember what Try Clojure looked like before LauJensen and apgwoz.
13:04cemerickRaynes: It's in my todo. But, if I could predict when stuff from there would get done, civilization might collapse.
13:05Raynescemerick: Well, it's on there. That's all that matters.
13:08scgilardiChousuke: seq? has worked well so far for me as a test for "form" in macro expansions: clojure code rendered in text as "(operator operand1, operand2, ...)" appears always to be lists or conses in the code-as-data seen by macros.
13:09drewris `lein run` not supposed to work with lein 1.6.2?
13:09drewrI keep getting an exception regarding PersistentList <-> String
13:09technomancy=(
13:10Raynescemerick: I've got world domination and porn stardom on my TODO list. I'd love to see yours.
13:10technomancydrewr: it worked with 1.6.1?
13:10cemerickRaynes: stop stealing my TODOs
13:10drewrtechnomancy: no. I updated my 1.x branch because of it too, which is why I'm at 1.6.2
13:10RaynesOh man, I'm so sorry.
13:11technomancydrewr: paste the invocation and/or relevant bits of project.clj?
13:11cemerickzakwilson: (instance? clojure.lang.LazySeq x)
13:12TimMczakwilson: counted? may be more appropriate.
13:12drewrtechnomancy: is it supposed to be (defproject... :main 'foo.bar)?
13:12drewrmaybe I'm missing some syntax in there
13:12technomancydrewr: no need to quote
13:13technomancydrewr: that's a common mistake though; maybe open an issue about getting a better error message?
13:13gtrak`why is there no advantage to lists being able to be transient?
13:14drewrtechnomancy: or just silently accept a symbol
13:14hiredmantechnomancy: or check for a seq that starts with quote
13:14bartjfolks, is anyone aware of scraping libraries in Clojure ?
13:15technomancyif it were just that place, I'd totally pull a postel's, but I need it to be consistent with every other place namespaces are accepted as symbols.
13:15drewrpedantry will get you nowhere technomancy
13:17Raynestechnomancy: Is your init.el file up anywhere?
13:18technomancyRaynes: sure: https://github.com/technomancy/dotfiles
13:18Raynestechnomancy: I keep wanting to show everyone my ERC configuration now.
13:19technomancymy own init.el is comprised only of things that aren't generally useful though; I outsource as much of that stuff as I can to the starter kit
13:19Raynestechnomancy: https://gist.github.com/1434060 I wrote most of that code all by myself. :>
13:19drewrtechnomancy: https://github.com/technomancy/leiningen/issues/347
13:20technomancyRaynes: setq accepts an arbitrary number of symbol/value pairs; you can collapse them into a single call. also read up on eval-after-load.
13:20technomancydrewr: cool; that'll help me remember it for 1.6.3
13:22drewrack
13:32cemerickTimMc: ##(counted? (range 5))
13:32lazybot⇒ false
13:39rickmodeWhen calling a java method which takes a Integer parameter, I'm having to construct an Integer. Evidently the int primitive returned by the int function is boxed by a Long. Am I missing something?
13:41nickmbaileyyes that changed in 1.3
13:41nickmbaileyints are boxed to longs automatically
13:41nickmbaileyyou have to use Integer for interop
13:43nickmbaileyhttp://dev.clojure.org/display/doc/Documentation+for+1.3+Numerics
13:44nickmbaileyboxing shouldn't occur during the interop call though so something like (.javaMethod Object (int 43)) should work
13:44TimMccemerick: What about it? range is a lazy (chunked) seq.
13:46rickmodenickmbailey: thanks
13:48rickmodewell.. the method signature is an Integer, so it has to box somehow. The error when I call with (Foo/bar (int 1)) is java.lang.Long cannot be case to java.lang.Integer. Calling with (Foo/bar (Integer. 1)) works
13:48rickmodeSignature is something like "public static void bar(Integer i)"
13:49rickmodeobviously this was built before auto-boxing :(
13:49pjstadig(int 1) will create a Long in a boxing context
13:50pjstadigyou have to use (Integer. 1) to get a Integer
13:50pjstadig(int 1) is a primitive int cast, which will cause Clojure to box according to it's own boxing rules
13:51TimMcrickmode: Probably wants to allow null.
13:51TimMctechnomancy: So... how would *you* define "list"?
13:52TimMc(the Clojure concept, not the fn)
13:53technomancyTimMc: #(.startsWith (pr-str %) "(")) obviously
13:53TimMc>_<
13:53technomancyjust kidding, that returns true for clojure.lang.PersistentQueue.
13:54technomancyTimMc: I'd just add (or (instance? clojure.lang.Cons x) ...)
13:55TimMctechnomancy: Would you say that the result of cons is also a seq?
13:56TimMcOr that "seq" and "list" are usage patterns, not discoverable from isolated values?
13:57nickmbaileyrickmode: that sounds like a bug to me. according to the doc: "It is possible to convert a boxed number into a JVM primitive using one of the following coercion functions: byte, char, int, long, float or double. Be aware, however, that unless the value is an immediate argument to a Java interop call or a Clojure function hinted to match, it is likely to be immediately auto-converted back to a boxed type."
13:57technomancythe result of cons is a list, so it must be a seq
13:58nickmbaileyso either the doc is wrong or (Foo/bar (int 1)) should work
13:58technomancylists are special because they are their own seq
13:58hiredmantechnomancy: no, the result of cons is a seq
13:58hiredmanit is not a list
13:59technomancyhiredman: it's not an instance of clojure.lang.PersistentList, but thinking in terms of classes is not helpful.
13:59hiredmancons is only for adding items to the front of seqs
14:04TimMchiredman: In case you didn't see context: (list? (list* 1 ())) => false
14:04technomancyyeah, I understand that's how it works under the current implementation of the list? predicate; I just think it's a dumb predicate.
14:05technomancyit's not a helpful distinction to make
14:05TimMcI think *something* is wrong here, but I'm not sure what!
14:05TimMcI'd just like a consistent abstraction.
14:09TimMcI'm fine with seq? and list? both returning true for the same object.
14:12hiredmantechnomancy: have you looked at the implementation of the cons function?
14:12technomancyyou mean in RT.java?
14:13hiredmantechnomancy: sure
14:14TimMcPresumably you are highlighting the return type?
14:16technomancyok, what I'm saying is that a list is a thing with a head and a tail; a linked list. a clojure.lang.PersistentList is something more specific.
14:16hiredmantechnomancy: it is defined as being "add this thing to head of a seq"
14:17TimMctechnomancy: seqs and lists *do* have basically the same API, don't they.
14:17technomancyif you want to talk about whether something is a clojure.lang.PersistentList, you should be specific. if someone just says "I have a list", it's reasonable to think they aren't specifically talking about a clojure.lang.PersistentList but a linked list.
14:18pjstadigi've always found this part of clojure muddied IMO
14:21TimMcIt definitely increases the cognitive load.
14:21hiredmantechnomancy: coll? only deals ipcolls and I believe the rest of the predicates are restrictied similarly
14:22hiredmanshould list? return true for array lists?
14:22TimMcShould lists and seqs even be different things?
14:24technomancyI'm not convinced there should be a list? predicate, but the only two times I've heard of people wanting it, it was to determine if its argument was a piece of code in parens.
14:25dnolentechnomancy: there are only a few data structure that guarantee that the rest will be identical? across operations
14:25dnolencons and list
14:25dnolenthis is useful
14:25dnolenan seq doesn't make any such promise because the seq may come from a data structure that doesn't support it.
14:26Chousukeseqs cache the generated values though
14:26dnolenChousuke: that not the property I'm talking about
14:26dnolenidentical?, not =
14:27Chousukewell, I'm not sure why the rest portion couldn't be identical
14:27dnolenChousuke: it could of course.
14:27TimMc&(let [x [1 2 3]] (identical? (rest x) (rest x)))
14:27lazybot⇒ false
14:27technomancynot sure how that's useful; IMO the only time identical? is called for is in explanatory texts =)
14:27TimMchappens to not be
14:27dnolentechnomancy: just because you haven't used it doesn't mean it's not. core.logic benefits from the guarantee.
14:27ChousukeTimMc: that example is wrong
14:28ChousukeTimMc: you're calling rest on two different seqs
14:28technomancyisn't the whole point of egal to not have to think in terms of identical?
14:28Chousukeon the same vector.
14:28amalloy&(let [x [1 2 3], s (seq x)] (identical? (rest s) (rest s)))
14:28lazybot⇒ false
14:28dnolentechnomancy: performance, you don't want to traverse to determine equality - you know what you're doing.
14:28TimMcChousuke: Oops, you're right. The point dnolen was making was more subtle than I thought.
14:29technomancydnolen: ok, but I'd argue if you care about that level of perf you're well into breaking-through-abstractions territory and you're probably also concerned about the difference between array-map and hash-map, etc.
14:29Chousuke&(let [x [1 2 3], s (seq x)] (identical? (next s) (next s)))
14:29lazybot⇒ false
14:29technomancyyou can write your own predicates
14:31dnolentechnomancy: there's seems to be a bit functional literature out there that leverages the identical? guarantee offered by cons / list.
14:31dnolenso it's worth preserving in Clojure IMO.
14:40technomancyyeah, definitely makes sense to preserve that guarantee. not sure how that plays into what defines a list though.
14:41hiredman(defn cons [x y] (reify clojure.lang.ISeq (first [_] x) (next [_] y)))
15:20patchworkhey all, where did dissoc-in go in 1.3?
15:20patchworkcan't find any docs on it
15:20patchworkthey all say it is in clojure.contrib.core
15:21patchworkeven better, how could I discover this? Is there a handy migration list for 1.3?
15:23cemerickpatchwork: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
15:31TimMcpatchwork: I think dissoc-in was removed in favor of using update-in with dissoc.
15:32patchworkTimMc: that is what I needed to know, thank you!
16:00flazzi'm using clojure.tools.logger and my messages all contain sun.reflect.NativeMethodAccessorImpl as the namespace, how do i change this?
16:14TimMcflazz: The answer probably depends on which logger you are using.
16:14flazzjul
16:21TimMc?
16:21TimMcIs that j.u.logging or something?
16:23amalloyseventh month of the year
16:32amalloyhm. this makes sense but kinda makes me sad: if your function foo returns a function f as (comp g h), and f is later called and blows up, foo doesn't show up in the stacktrace at all. does anyone have advice for figuring this out? in this case i knew foo was the culprit but if i didn't i'm not sure how i would track down which instance of comp was causing the problem
16:34hiredmanamalloy: I dunno how you could change that in an acceptable way
16:35hiredmanthe functions a generated at compile time and their class names reflect lexical scope, but you want the stacktrace to reflect dynamic scope, which is not known and compile time
16:36hiredmanmaybe if comp was inline-able, but that is not a general solution
16:37amalloyyeah, i don't really see a viable solution either
16:38amalloyyou couldn't get it into the java stacktraces, but maybe you could put metadata on the returned function somehow, to get some crude diagnostics? even that seems pretty challenging
16:39hiredmanthe best solution to errors is always: know what you are doing and don't make errors
16:41technomancyI find that internally-named fns are pretty handy for debugging
16:41technomancy(fn does-a-thing [x] [...])
16:41flazzTimMc: yep java.utls.logging, sorry
16:43hiredmantechnomancy: but if you create the fn with comp you don't have that
16:43technomancyhiredman: yeah, I don't think there's a good point-free answer for that
16:45TimMcflazz: If that's anything like log4j, you'll put some sort of properties file into the classpath with the configuration details you need.
16:45TimMcamalloy: Solution: Make comp a macro. :-P
16:46TimMc(scratch that, it doesn't make enough sense to be funny)
16:46amalloyright, i wound up changing it to #(g (h %)) so that i could confirm it was inside foo
16:47TimMcamalloy: The generated classname includes foo?
16:47amalloyof course. foo$fn__2349 or something
16:48amalloy&((fn foo [] #(inc 1)))
16:48lazybot⇒ #<sandbox12996$eval16802$foo__16803$fn__16804 sandbox12996$eval16802$foo__16803$fn__16804@e3313a>
16:54TimMcThat is suprisingly useful and obvious.
16:56technomancyweavejester: heya
16:57weavejestertechnomancy: Hey there
16:58technomancyhow goes the hacking on ragtime?
16:58technomancydid that ordering trick work out?
16:58weavejesterPerfect :)
16:58technomancysweet
16:59weavejesterI also changed the functions from 0-arg to 1-arg.
16:59technomancythinking of trying out on clojars
16:59weavejesterWith the one argument being the database.
16:59jcromartiegood call
17:00weavejesterSo (migrate db [foo]) will run ((:up foo) db)
17:00technomancylooks like it still needs an adapter for sql; maybe that could just be yoinked from migratus?
17:00weavejesterYeah, I'm working on a ragtime.sql. I haven't got very far though, so grabbing one from migratus is probably a good idea.
17:01technomancycurious: are you using this for work?
17:01weavejesterI was also looking into maybe grabbing the one from Lobos, as I'm using that librart anyway.
17:01technomancyhttps://github.com/weavejester/ragtime/graphs/punch_card <= guessing not =)
17:01weavejesterNo, currently work is a Ruby shop
17:01weavejesterNo Clojure there yet.
17:01technomancybummer
17:02weavejesterYeah, but on the other hand, it gives me a window into what's happening in Rails webdev
17:02weavejesterMy current plan is to make the database connection map a record
17:03weavejesterSo then I can add the "Migratable" protocol to it that allows me to store migrations.
17:03weavejesterI'm not 100% sure about it, but it's the best solution I've come up with so far...
17:03technomancyhmm... I just refactored c.j.jdbc so that you can pass a database URL string instead of the connection map
17:04technomancyI guess you could extend it to string and URL and parse it there
17:04weavejestertechnomancy: I was thinking about writing a library for that :)
17:04technomancythat's your catch-phrase, innit?
17:04weavejesterHaha! I'm a fan of many small libraries
17:05weavejesterApparently the empirical evidence suggests bugs are closely related to the number of lines of code.
17:05weavejesterSo less code = less bugs on average
17:05technomancyyeah, as long as the abstractions are rock-solid
17:05weavejesterYeah.
17:05technomancybecause the other side of the coin is that more libraries means more integration points
17:06technomancybut in general I agree
17:06weavejesterSo I need the "Migratable" protocol so that I can store migrations without mandating a specific type of database.
17:06weavejesterI mean, that makes sense, right?
17:06technomancyyeah, I think so.
17:07weavejesterSo (migrate db migration-list)
17:07technomancyit would be nice if you could pass the exact same config to ragtime and c.j.jdbc, but that might just be unrealistic
17:07weavejesterOr (migrate-ns db & namespaces)
17:07technomancynice
17:07weavejesterOriginally I was going to have it execute migrations like ((:up migration))
17:07weavejesterBut now I've changed it to ((:up migration) db)
17:08weavejesterBecause it seems like a good idea to pass the database connection info through the migrate function
17:08weavejesterEssentially saying "migrate this database with these migrations"
17:09weavejesterI guess I could just use a wrapper.
17:09technomancyI think taking an arg makes sense
17:09weavejester(migrate #SqlDatabase{:url "..."} ...)
17:09technomancybut we'll probably have to flesh out a few adapters to really get a feel for what works
17:09weavejesterYeah
17:10weavejesterOr maybe: (migrate-ns (sql-database db-url) 'my.app.migrations)
17:12weavejesterOne of these days I'll run out of libraries to build, and then I'll actually be able to make an application
17:13technomancydo you want a hand with the sql adapter?
17:14weavejestertechnomancy: Sure
17:14weavejesterI rarely turn away a helping hand :)
17:15technomancycheck your /msgs
18:08accelis there a godo book / chapter of a book / tutorial on Swing + Clojure?
18:09accelWhat is a godo book / chapter of a book / tutorial on Swing + Clojure? (I don't want a yes/no answer, I want a reference :-) ).
18:20RaynesTutorials on swing + Clojure are fairly lacking, though I'll be covering it in my book. That doesn't help you much now.
18:23Wild_CatRaynes: when is said book supposed to come out?
18:23RaynesI wish I knew.
18:23Wild_Cat(also, I get the feeling that it'd be pretty interesting to model the UI as an agent)
18:24RaynesI'll be covering Seesaw in the book.
18:24Rayneshttp://github.com/daveray/seesaw
18:28gtrak`Wild_Cat, why agent over atom?
18:28gtrak`or ref, I guess
18:28Wild_Catgtrak`: because I'm envisioning every event as a message it could/should send to other agents (the actual program logic)
18:29Wild_Catalso, because I'm a Clojure noob and it's likely my understanding of its concurrency and synchronization primitives is sketchy.
18:30gtrak`hmm, well the downside of an agent is when you actually want stuff to happen synchronously
18:30gtrak`I guess if the queue is small, it's no big deal
18:31Wild_Catyeah, there's the potential issue of the UI lagging way behind the user's commands
18:31Wild_Catwhich tends to happen when you accept too many of those, usually as a side effect of event handlers returning immediately
18:32gtrak`there's really no downside of a single rendering thread, is there?
18:33gtrak`but I know that in swing it's easy to do the wrong thing, maybe seesaw makes that better?
18:34Wild_Catas long as rendering is fast or easy to break down in steps that are and return quickly, no downside. The problems start creeping in when rendering is neither fast nor broken down in small steps.
18:34gtrak`Wild_Cat, I've done programming in adobe flex, you only have a single thread there, and event queues, it's pretty flexible though unless you have long-running work and need to interleave it between frame-renderings
18:34Wild_Catat which point your UI hangs while your logic is processed, a very common issue in Swing programs
18:34amalloyswing tells you not to interact with gui elements in anything but the event dispatch thread
18:34Wild_Catgtrak`: yeah, it's pretty much exactly that problem ;)
18:34Wild_Cat(to be fair, you get it in most UI toolkits)
18:36gtrak`the data-binding was super-nice though, basically any time a property changes, an event bubbles up and updates everything that it needs to update
18:36Wild_Catah, nice.
18:36gtrak`like this: <mx:Binding source="source.text" destination="destination.text" />
18:36gtrak` or <mx:TextInput id="destination" text="{source.text}" />
18:37Wild_Catthat's another thing Swing sorely lacks: a declarative UI representation format.
18:38Wild_Cat...or anything that makes working with a WYSIWYG UI designer something other than a massive kludge that autogenerates megabytes of horrible Java code
19:16accelRaynes: perhaps I am asking the wrong question.
19:16accelWhat are the currently well used methods for doing GUI in Clojure?
19:17accelTo me, the important bits are: I need to code in Clojure. I need to have a GUI.
19:17accelSwing is replacable.
19:18accelAlso, did anyone ever port the GUI that common lisp systems had to clojure?
19:18cemerickSwing and SWT are the only games in town, really.
19:19cemerickplus using an embedded webkit view via SWT and using a web UI on the desktop :-P
19:19cemerickThere was a tasty Clojure swing wrapper that just came out that looked very promising…
19:20accelIIRC, common lisp had a very interesting GUI toolkit: clim, I thin it was called.
19:20accelIs there no port of it to clojure?
19:22cemerickSurely not.
19:22TimMccemerick: Yeah, the next time I can get away with it, I'm writing a web GUI.
19:22accelTimMc: why?
19:22cemerickIf clim is your benchmark, then the framework doesn't matter that much, it's the construction of the API you care about.
19:22accelWhy is Web GUI easier than Java GUI?
19:23cemerickDeclarative layout is nifty.
19:23accelcemerick: sure; I care more about the API than "framework"
19:23TimMcaccel: It's not that it's easier (although it often is), it's that you can meet more of the user's interface expectations.
19:24TimMcCross-platform GUIs are often awkward for the user.
19:24TimMcThey look wrong and feel wrong on *every* platform.
19:24accellol
19:24accelI believe this is called *fairness*
19:24TimMchaha
19:24TimMcSomething declarative that got compiled to each platform's widgets would *rock*.
19:25duck1123but they look wrong in different ways depending on the OS
19:25duck1123TimMc: you mean, HTML?
19:25cemerickaccel: try https://github.com/stathissideris/clarity or https://github.com/daveray/seesaw
19:26accelce
19:26accelcemerick: going to try clarity just because I like the name better
19:27TimMcduck1123: Just about.
19:27zerokarmalefttechnomancy: does emacs-starter-kit override settings in init.el for cc-mode somewhere?
19:27TimMcIt could totally be done.
19:27accelwhat if, we took HTML
19:27accelthen we made it scriptable
19:27accelwith a scripting language
19:27TimMcheh
19:27technomancyzerokarmaleft: version 1 or 2?
19:27accelthe scripting langauge would be cross platform, like Java
19:27duck1123hold the phone
19:28accelbut it would be for Scripting purposes
19:28zerokarmalefttechnomancy: 2
19:28technomancyzerokarmaleft: 2 doesn't add any bindings outside the starter-kit-bindings module, but I don't know if it overrides anything in cc-mode because I've never used it.
19:29accelSadly, I think the approach I want to take
19:29accelis to suffer and deal with Swing directly so I can build my own abstractions.
19:29accelWhat is the most hardcore way to learn Swing?
19:30duck1123accel: flagelate yourself for every bug
19:30accelNo no, I don't want a Darwin award.
19:30accelI'm looking for the K&R equivalent, i.e.
19:30accel"The Swing GUI Library"
19:30accel[2nd edition]
19:32zerokarmalefttechnomancy: ok...i hadn't installed bindings yet anyway
19:35zerokarmaleftmaybe cc-mode has changed in 24, i'll check that
19:53seancorfieldboy, i've had one of those days where i just love clojure!
19:54seancorfieldwe have a custom search engine that returns a block of results with metadata on each call and now, thru clojure, i have a single search call that returns three lazy sequences that call the search engine as needed to get results as we page thru results!
19:58Raynesseancorfield: I'm going to be doing something similar for paging in tentacles.
20:06yayitsweihow would I group items in a list based on a cumulative function? e.g. split when sum is greater than 10: (9 1 2 5 1 8) -> ((9 1) (2 5 1) (8))
20:09duck1123yayitswei: IIRC there's a reductions fn in combinatorics that returns each stage of a reduction, that might get you started
20:11yayitsweiah quite useful, ty
20:12duck1123not quite sure how you'll make it work, but it should help
20:13brehaut,#((map vector % (reductions + 0 %)) [1 2 5 3 4])
20:13clojurebot#<sandbox$eval28$fn__29 sandbox$eval28$fn__29@25dd02>
20:13brehautcrap
20:13brehaut,(#(map vector % (reductions + 0 %)) [1 2 5 3 4])
20:13clojurebot([1 0] [2 1] [5 3] [3 8] [4 11])
20:14brehautnah thats ugly
20:22amalloythis feels like something i wrote recently, but i can't remember what it actually was
20:24yayitsweihere's what i have so far: (reductions #(if (<= (+ %1 %2) 10) (+ %1 %2) %2) '(9 1 2 5 1 8))
20:26brehautoh. its not a foreclojure question is it?
20:27Raynesamalloy has returned?!?
20:27yayitsweinope, at least not afaik
20:28amalloynah, i though wrote it as a response to something on the google group. but i can't find it
20:28amalloymy basic premise was "it seems like you should be able to do this with reductions and split-with or something, but it was easier to just write with lazy-seq directly"
20:30rickmodeI'm doing a remote debugging via swank-clojure, but when I tried (swank.core/break) I get IllegalStateException: Attempting to call unbound fn: #'swank.core.connection/*current-connection*
20:32rickmodeI did a C-c c on my (ns ..) line that added :require swank.core and on the fn that has (swank.core/break). And oddly, if I require swank.core.connection, I can see *current-connection* in my remote REPL.
20:33drivera.exit
20:35amalloyyayitswei: https://github.com/flatland/useful/blob/develop/src/useful/seq.clj#L191 is maybe a little relevant/useful?
20:40yayitsweithanks amalloy, i'm finishing up my split-with version and i'll take a look in a sec
20:44amalloyVICTORY. it was http://groups.google.com/group/clojure/browse_thread/thread/fc08587280d2244e/c266706ed52c8d2?q=#0c266706ed52c8d2 - someone wanted to group a bunch of strings such that each partition had a maximum size <= N
20:58ihodesanyone hiring Clojure devs about to graduate from school? :)
21:21yayitsweinice.. thanks amalloy
21:53brweber2how do I make my protocol extend Map?
21:54brehaut(doc extend-protocol)
21:55clojurebot"([p & specs]); Useful when you want to provide several implementations of the same protocol all at once. Takes a single protocol and the implementation of that protocol for one or more types. Expands into calls to extend-type: (extend-protocol Protocol AType (foo [x] ...) (bar [x y] ...) BType (foo [x] ...) (bar [x y] ...) AClass (foo [x] ...) (bar [x y] ...) nil (foo [x] ...) (bar [x y] ...)) expands into: (do (clojure.c
21:55brehaut,(supers (class {}))
21:55clojurebot#{clojure.lang.IPersistentCollection clojure.lang.IPersistentMap clojure.lang.Counted clojure.lang.IMeta clojure.lang.AFn ...}
21:56brehautbrweber2: clojure.lang.IPersistentMap is the interface you want to implement the protocol for. you can either do it in the protocol definition, or with extend-protocol.
21:56brweber2brehaut: thanks
21:56brehautbrweber2: i am under the impression that if you define it in the protocol definition, then it will be a bit faster than if its done later
21:57brweber2brehaut: perfect. I forgot about supers for checking the hierarchy
22:05amalloybrehaut: you can't include any implementation in the definition of a protocol; you're probably thinking about inlining protocol implementations when defining a type, but your advice doesn't make sense in that context: you don't control the creation of the IPersistentMap class so there's nowhere to inline
22:05brehautamalloy: aha yes of course i am
22:22tmciverAnyone using CDT from a repl? I tried following http://georgejahad.com/clojure/cdt.html but when I (use 'com.georgejahad.cdt) I get they FileNotFoundException.
22:33seancorfieldtmciver: i think the namespaces have changed recently?
22:33seancorfieldi got this working: http://georgejahad.com/clojure/swank-cdt.html
22:35tmciverseancorfield: I was just looking at that. I wanted to see if I could get *pure* CDT working w/o swank. I guess I'll just move on to swank-cdt.
22:42jcrossley3why was clojure.java.io/delete-file-recursively removed from 1.3?
22:49erujolcusing the clojure 1.3 repl (clj) from a terminal emulator in linux it doesnt behave very natively e.g. if i type (def x 1) <Enter> and then on the next line the up arrow instead of showing last command shows the escape of up arrow
22:49amalloy$google rlwrap
22:49lazybot[rlwrap - utopia.knoware.nl] http://utopia.knoware.nl/~hlub/rlwrap/
22:49amalloyerujolc: ^
22:50RaynesLeiningen handles that for you.
22:50amalloythough really, don't use clj at all; install lein and it will make a repl with readline
22:50RaynesThat.
22:51Rayneshttps://github.com/technomancy/leiningen
22:51erujolcthanks
22:51erujolclein repl works perfectly
22:52Raynes'clj' is not an official Clojure thing. It's just a script that your package manager probably installed to start up a REPL. You still have to deal with handling the classpath once you've began a project and start having dependencies. Leiningen does that too.
22:52erujolcthanks. yes i believe clj was installed via pacman (archlinux)
23:02erujolcOT: techie podcasts worth subscribing to?
23:08devnWhat's the channel for chicken scheme?
23:15Raynesdevn: Wild guess, but I'd assume it to be #bawwwwwwwwk.