#clojure logs

2011-04-03

00:12HavvyIn lein, what would be the groupID/artifactID for http://clojars.org/repo/irclj/irclj/ ?
00:12amalloyHavvy: irclj
00:12amalloyor irclj/irclj if you want to be verbose
00:15technomancy"If you're not really into the whole brevity thing" as the Dude would say
00:22Havvy(inc amalloy)
00:22sexpbot⟹ 7
00:23amalloyHavvy: clojars will even tell you the answer to this question
00:24HavvyIt will?
00:24amalloyhttp://clojars.org/irclj/irclj
00:24HavvyOh, it will.
02:46Deranderwhat was that library released recently to handle classpaths on a persistent vm?
02:47Deranderjark
03:23thorwilgiven the code at https://github.com/gcv/appengine-magic/issues/14#issue/14/comment/949920
03:24thorwilusing (save-article-1) should work on the repl, after a (doto 'texst.core require in-ns), right?
03:25thorwilbut what i get is "java.lang.NoClassDefFoundError: texst/core/Eek (NO_SOURCE_FILE:0)"
03:26thorwileven after pasting (ds/defentity Eek [body]) to the repl
03:29amalloythorwil: it seems to me you will have a much larger pool of helper-people if you can narrow your questions down to involve less domain-specific stuff
03:30amalloyi'd love to help, but i don't know anything about GAE, which iirc is what you're using
03:31thorwilamalloy: i wish i could, but the problem *is* specific
03:31amalloydoes it work if you change defentity to a defrecord-like construct?
03:33thorwilamalloy: it works if i put the defentity within the function. but surely gvc (appengine-magic dev) knows what he does, and he placed it outside!?
03:34amalloynot seeing how that's relevant to my suggestion. i'm trying to find out whether you're having general classpath issues (which you'd see with defrecord) or something specific to defentity
03:39thorwilmaking sense of the (defmacro defentity ...) in https://github.com/gcv/appengine-magic/blob/master/src/appengine_magic/services/datastore.clj is beyond my level of understanding
03:40thorwilif it's a classpath issue, i wonder if Leiningen 1.4.2 is the culprit
03:43amalloyseems tremendously unlikely
03:44amalloythorwil: the defentity macro is pretty simple. he just defines a record with the name and properties you specify, which implements/extends/satisfies the EntityProtocol
03:46thorwili could just copy (defrecord ~name ~properties ... and fill in the gaps?
03:46amalloyindeed
03:46amalloythough get-entity-helper might be private
03:47thorwilwhat's this# ?
03:47amalloyhaving a protocol with multiple arities for the same function kinda smells bad. like he meant to use an interface
03:47amalloygensym for java's this object
03:47amalloy&`(fn [arg#] (inc arg#))
03:47sexpbot⟹ (clojure.core/fn [arg__10205__auto__] (clojure.core/inc arg__10205__auto__))
05:07fliebelTo map or not to map, that is the question: Whether 'tis nobler in the mind to suffer the slings and arrows of O(n) lookup, or to take arms agains the a sea of added complexity.
05:10fliebelOr, in normal language, will I store my game objects in a vector or a map. A vector makes things simple, but for a bat to tell the location of the ball, it'd have to go through all the 3 objects to look it up. On the other hand, a map makes this faster and simpler, but makes everything else more involved.
05:19fliebelCan a protocol extend another protocol or interface? Or do all implementations just need to implement both?
06:20nickikHas somebody used clojure with couchdb spezially the clojure view server?
06:23midshaving problems?
06:32nickikmids, i just doesn't work and I don't know how i could debug it. I have know idea whats wrong. If I start the server manually it starts and throws no errors or something but if I trie to send a query from the repl nothing happens.
07:10tomojnickik: you're saying you're trying to talk to the view server from the repl?
07:11tomojor just using a couchdb client from the repl?
07:11nickiknot direktly
07:11tomoj(which happens to be talking to a couch running the clojure view server)
07:11nickikthrew couchdb
07:11nickikyes
07:12tomojdo you get anything back?
07:12nickiklike discribed here: http://www.ibm.com/developerworks/java/library/j-couchdb-clojure/?ca=drs-
07:12tomojsomething besides querying a view
07:12nickikno
07:12nickikyes everything else works
07:12nickikcreating docs etc.
07:13tomojlooked at the couchdb logs?
07:13nickikno
07:13nickik(its my first time using cloud)
07:15nickiknot sure what i should be looking for in the logs
07:26fliebelnickik: Are you sure the query server is configured?
07:27fliebelThe link you gave does not mention starting it, and I do believe Clutch makes Clojure views.
07:28nickikyes i see the server in my couchdb config (in futon)
07:29nickiki did it accourding to the clutch github site
07:30fliebelnickik: Hm, I think you might be better helped asking the #couchdb channel. While they might not know Clutch, they do know how to debug malfunctioning query servers.
07:30nickiktrue I figured maybe somebody has had the same problem
07:31nickikI'm trieng to get some good logs of my problem atm
07:31fliebelnickik: What happens if you run the query server yourself? The protocol is really simpel.
07:32nickikit just starts it dosn't generate any output or anything
07:32nickikno errors or something
07:32fliebelOkay, now try manually running something… let me see
07:33fliebelhttp://wiki.apache.org/couchdb/View_server
07:35nickikah intressting stuff happening here while i was reading the view_server crashed. I never let it run manually more then 20s.
07:35nickik["fatal","fatal_error","java.lang.IllegalArgumentException: Value out of range for char: -1\n\tat clojure.lang.RT.charCast(RT.java:887)\n\tat clojure.contrib.json$read_json_reader.invoke(json.clj:116)\n\tat clojure.contrib.json$fn__1125.invoke(json.clj:178)\n\tat clojure.contrib.json$fn__1104$G__1099__1115.invoke(json.clj:167)\n\tat clojure.contrib.json$read_json.invoke(json.clj:197)\n\tat com.ashafa.clutch.view_server$run$fn__69.invoke(view_
07:35nickikserver.clj:129)\n\tat com.ashafa.clutch.view_server$run.invoke(view_server.clj:127)\n\tat com.ashafa.clutch.view_server$_main.doInvoke(view_server.clj:146)\n\tat clojure.lang.RestFn.invoke(RestFn.java:398)\n\tat clojure.lang.AFn.applyToHelper(AFn.java:159)\n\tat clojure.lang.RestFn.applyTo(RestFn.java:133)\n\tat com.ashafa.clutch.view_server.main(Unknown Source)\n"]
07:36fliebelnickik: I've seen this bug before… Try getting a newer version of JSON.
07:37nickikfliebel, my i have standard 1.2
07:37nickikcontrib
07:37fliebelI know, let me look it up.
07:39fliebelnickik: http://dev.clojure.org/jira/secure/QuickSearch.jspa
07:42fliebelSo, according to stuartsierra this has been fixed.
07:44nickikwitch bug do refere to?
07:44nickikcontrib-100?
07:45fliebeloh, right, post request
07:45fliebelhttp://dev.clojure.org/jira/browse/CONTRIB-101
07:45fliebelthere are quite a few of these.
07:47nickikcould it be that leiningen is chaching an old contrib?
08:06nickikfliebel, what should I do? Ask on the group?
08:07fliebelnickik: Hm, maybe. But did you try another version of contrib? Maybe there is one for 1.2.1?
08:08nickiki thought 1.2.1 should come with 1.3
08:11fliebelhm, okay, the 1.2.0 branch is not fixed, but I think the 1.3 version of json will run just fine.
08:15nickikah ok
08:15nickiklets hope everything else works with 1.3 too
08:15nickikthx fliebel
08:16fliebelnickik: I think you can just use 1.3 json with 1.2 Clojure if you want.
08:17nickikfliebel, but then i would have to change the source clutch view server. I can only change the jars I pass in
08:29raekyou could use [org.clojure/data.json "0.1.0"] too
08:54fliebelDoes anyone have experience with BufferStrategy? I found one example where they just get a graphic, render, and dispose, but in other examples, there is a lot of cruft about these volatile images. Do I need that?
09:12nickikwhat leiningen project.clj do i need if i want clojure alpha 6 and contrib alpha 6?
09:17raekalpha-6 seems to be [org.clojure/clojure "1.3.0-alpha6"]
09:17raekand contrib has been split up into separate modules
09:18raekyou can look around at http://build.clojure.org/releases/org/clojure/ http://build.clojure.org/snapshots/org/clojure/ and http://repo2.maven.org/maven2/org/clojure/
09:19raekalso, there's this: http://corfield.org/clj/index.cfm
09:19fliebelHow does alter-var-root work? I can use that to change earmuffs, right?
09:20raekfliebel: well, you can use that to change any var, dynamic or not
09:20raekto change the thread-local value, use set!
09:20fliebelah, okay.
09:24fliebelraek: I can;t get it to work: user=> (def ^:dynamic *frame-duration* 100) #'user/*frame-duration* user=> (set! *frame-duration* 50) IllegalStateException Can't change/establish root binding of: *frame-duration* with set clojure.lang.Var.set (Var.java:219)
09:24raekfliebel: you have to do that inside the dynamic scope of a (binding [...] ...)
09:25raekif you just want to configure the value once on startup, maybe redefining the root binding with alter-var-root is better
09:26fliebelraek: Okay, but then again, how does it work? It seems it takes a fn like swap!, but just passing it inc game an error that suggested that I need to return a var.
09:26raekyou need to pass it the var object
09:27raek(alter-var-root #'some-var inc)
09:27fliebelah, that way! I was thinking inc should return a var.
09:27fliebelokay, thanks
09:28fliebelSo, no need for ^:dynamic on this one?
09:28raeknot if you don't itend to use binding on it
09:28fliebelOkay, I'll leave that open than.
09:28raekor let the users of the namespace do that
09:32mrBlissexcerpt from 'On Lisp': "An ideal world is left as an exercise to the reader." :-)
09:32ejacksonmrBliss: genius !
10:38@rhickeyI'm thinking about making the default behavior of promise, when an Throwable has been delivered, to re-throw it on deref, with an optional arg to control that - (promise :rethrow bool), default true
10:41raekwhat used to happen / what happens when :rethrow is false?
10:44raekwhen was clojure.lang.IBlockingDeref added?
10:45@rhickeyraek: whatever is put in the promise is returned
10:45raekbut if the expression throws?
10:45@rhickeyraek: what expression?
10:46@rhickey(promise)
10:46raeksorry, mixed up this with delay/force
10:47@rhickeyhttps://github.com/clojure/clojure/commit/84710838d6996d9144d83c5b659bdeda4c656100
10:47@rhickey^added IBlockingDeref
10:47raekvery nice...
10:48raekwill read it and update my blog post about clojure and the executor framework
10:49kephale00I'll give this question one last shot: Is there a way to control the maximum number of cores a clojure program uses? The doesn't appear to be a JVM argument that will do it. The program uses agents heavily.
10:49@rhickeykephale00: no
10:50kephale00rhickey: a final answer! thank you
10:50kephale00I tried to use cpulimit to start java, and that worked to an extent, but it wasn't strict enough
10:51@rhickeykephale00: it would have to be on the JVM level, for sure
10:51kephale00The situation is I'm running experiments on a cluster with shared nodes, and getting 8 slots on an 8 core machine has near impossible statistics for actually getting the job scheduled.
10:52kephale00rhickey: thats what I figured… ah well, I guess i have to single thread-ify my program (never thought I would have to "devolve")
10:53raekrhickey: so this new change provides a way to get a Throwable to be thrown at the deref call? (by delivering a Throwable as the value)
10:54@rhickeyraek: right
10:54kephale00rhickey: Thank you though. Now I know I can stop banging my head against the wall
10:56raekseems like a useful and reasonable default, since Throwables as values are quite rare anyway (at least in my code)
11:00@rhickeybreaking change though
11:00@rhickeyopposite default would not be
11:04TimMcAlternatively, could you add a new method? As opposed to deliver, one would call (deliver-failure some-promise throwable)
11:05TimMcIn-band signalling always makes me twitchy.
11:06TimMcor even a new ariy of deliver: (deliver x :throw throwable)
11:06TimMc*arity
11:07fliebelHow, evil, a map that implements mapentry :)
11:08@rhickeyTimMc: that's not really out-of-band for the receiver anyway, and takes the policy decision away from him
11:08fliebelrhickey: How often do you update the contributing page? I sent you my agreement at the end of the last year, and I'm not yet on it.
11:09@rhickeyfliebel: If your not on it I haven't gotten it - updated several times this year, and recently as well
11:10@rhickeyyou're
11:10fliebelrhickey: ouch, okay, then I guess I'll have to send you a new one… Sometime… It's not one of my priorities now.
11:16TimMcrhickey: Would implementing both be out of the question? deliver could send an exception to be thrown, and promise could still specify whether exceptions are to be rethrown or simply returned.
11:18TimMcIn that scenario, promise would only throw if both ends had opted in.
11:18@rhickeyhaving played with it a bit, I'm not sure I like it better than (deref-and-rethrow anyref-that-might-have-a-throwable)
11:20@rhickeyI'm not sure how often people need this (communicate errors through a promise)
11:59fliebelWhen I produce a seq in one thread and consume it in another, where is the actual producing going to happen?
12:00fliebel(let [s (iterate heavy-task 42)] (future (do-heavy-stuff-with s)))
12:02opqdonutI'm guessing it's the consuming task
12:03opqdonutyou can probably verify that quickly with (.. Thread currentThread getId)
12:03fliebelopqdonut: I guess so to, but it's not what I was hoping for.
12:03opqdonutbut if you put futures into the seq...
12:03raekfliebel: in the consuming thread
12:04fliebelOkay, is there any way around that? Or does that just esentially limit my seq chain to one thred?
12:04raekfliebel: you could use a LinkedBlockingQueue do decouple them
12:04fliebelraek: What about ##(doc seque)
12:04sexpbot⟹ "([s] [n-or-q s]); Creates a queued seq on another (presumably lazy) seq s. The queued seq will produce a concrete seq in the background, and can get up to n items ahead of the consumer. n-or-q can be an integer n buffer size, or an instance of java.util.concurrent B... http://gist.github.com/900517
12:05raekah, it probably does something like that :)
12:06raekit seems to fit your problem description
12:06fliebelNow I seriously need to consider how much wiggling room I have. I's almost certainly going to fail if I have the producer get a ahead of the consumer to much. e.g. the producer is not completely functional.
12:06raekbut you can't control in which thread the processing gets done in...
12:07fliebelwhy not?
12:07raekseque will start the forcing of the seq in another thread for you
12:08raekyou can set set the size of the queue to limit how many elements the producer can get ahead of the consumer
12:10fliebelyea, so I need to carefully tweak that, if I happen to need it. I got myself in premature optimisation again :P
12:57TimMcCan anyone recommend an Emcas color scheme for working on a laptop in sunlight?
12:58kephale00I have no clue, but I'm happy to see that question
13:04Dantas1
13:20TimMc"Katester" is almost what I want.
13:49marko_hi, any enclojure users here?
13:50fliebelmarko_: Not me, but go ahead and ask what you want to know.
13:51marko_i started a new project on netbeans and id like to add external libraries like hiccup, but i just cant find how to add them easily to the new project
13:52marko_there is a preference to add libraries to netbeans, but not to the project itself
13:54marko_screenshots on web show a menu add library upon lib folder, but not on mine, i have only dependencies. i cant believe if I need to add every library manually setting up each dependencity on pom.xml, thats not cool job
13:54fliebelOh, right, so you need to add maven deps...
13:55marko_i have ten or so libraries i want on project. on eclipse its just a matter of click and select
14:14marko_ok, i think i got it now. there is an autocomplete box on dependencity window where you pick up right items OR go to the maven repository browser and pick up libraries for project from there
14:15marko_*dependency
14:22TimMcI have a map of keys to functions -- what's a good way to map the function values to their return values, each given the same arguments?
14:22TimMcWhat I have so far... given (def fs {:a + :b * :c /}), (zipmap (keys fs) ((apply juxt (vals fs)) 2 3)) seems to work.
14:23raekso you want a map as the result?
14:23TimMcyeah
14:24raek(zipmap (keys fs) (for [f (vals fs)] (f 2 3 4))) would be my approach
14:25TimMcSo you'd still use zipmap?
14:25jkkrameror (into {} (for [[k f] fs] [k (f 2 3 4)]))
14:26raekeither that or what jkkramer just wrote :)
14:26TimMcI keep forgetting about for. Thanks!
14:27jkkramerfor and maps are like pb & j
14:29fliebelpb & j??
14:29jkkramerpeanut butter and jelly
14:29fliebeljelly?
14:29jkkrameror vegemite & toast...whatever foreigners eat
14:30TimMcand juxt is like that tasty new cheese you bought that you try adding to everything even when it doesn't quite go together. :-)
14:31TimMcfliebel: jelly (US) is the juice from boiled-down fruit with pectin added.
14:33jkkramerfor and maps are like paste made from ground peanuts and juice from boiled-down fruit with pectin added
14:33fliebelClojure in a whole is like applesource in that respect, (young children) add it to everything, and it still tastes good.
14:33fliebel(or whatever you foreigners add to everything)
14:34jkkramerketchup
14:34jkkramerthis is making me hungry. time for lunch
14:35fliebeljkkramer: American huh? Ketchup…
14:41jhchabranon fait les porcs
14:41jhchabranon go macdo
14:47fliebelWhat is the difference between merge and into?
14:51ejacksonmerge is maps only
14:52ejacksonso its probably faster for them
14:56TakeVIs there a built in PriorityQueue, either in the core or contrib libraries?
14:56fliebelTakeV: Java.util.concurrent has them
14:57TakeVSure, thanks.
14:57fliebelejackson: Thanks
14:57TimMcTakeV: There's one coming into contrib
14:57fliebelTimMc: Why? Anything wrong with the Java one?
14:57TimMcI suspect the Java one is mutable.
14:58fliebeloh, true...
14:58TakeVA pure clojure version would be nice.
14:58TimMcTakeV: This appears to be in development: http://clojure.github.com/clojure-contrib/branch-master/priority-map-api.html
14:58pdkcouldn't you use a sorted map
14:59TimMcpdk: Those sort by keys.
14:59fliebelTimMc: Oh, I used that one just yesterday, it works fine.
15:06devnhmm, jark looks neat
15:12Raynesdevn: It's pretty shocking how easy it's been to ignore jark. I really should check it out.
15:30thorwil"Warning: :repl-init-script is deprecated; use :repl-init", but just renaming the key in the project file causes leiningen to fail with "java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Character"
15:31thorwilso what does leiningen expect for :repl-init in contrast to repl-init-script?
15:33jkkramerthorwil: https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L94
15:38thorwili take it :repl-init expects a namespace, not a path, but how do i translate "src/tlog/init_repl.clj" in this context?
15:40midsthorwil: tlog/init-repl
15:41raekI would expect tlog.init-repl
15:42thorwilmids, raek both fail: Exception in thread "main" java.lang.Exception: No such namespace: tlog (NO_SOURCE_FILE:1)
15:42midserr that raek
15:42midsthorwil: did you declare the ns in the init_repl.clj file itself?
15:46thorwilmids: the ns declared in init_reply.cly used to be user, but changing it doesn'thelp
15:49thorwiltechnomancy: hi! i'm trying to switch from :repl-init-script to :repl-init, as leiningen 1.5 tells me the former is deprecated
15:51thorwiltechnomancy: initially i thought i would just have to change from the path "src/tlog/init_repl.clj" to a namespace, maybe tlog.init-repl
15:51thorwilbut given the trouble above, i guess there's a conceptual change i'm yet unaware of?
15:56marko_how do you implement incrementing value on clojure? say you have a map of ({}{}{}), iterate over it and get the number of current loop index?
15:57marko_number or count
15:57raekmarko_: ##(map vector (range) [{:a 1} {:b 2} {:c 3}])
15:57sexpbot⟹ ([0 {:a 1}] [1 {:b 2}] [2 {:c 3}])
15:58raekinstead of vector, you can have a function that takes the index as the first arg and the value as the second
15:58amalloy&(doc map-indexed)
15:58sexpbot⟹ "([f coll]); Returns a lazy sequence consisting of the result of applying f to 0 and the first item of coll, followed by applying f to 1 and the second item in coll, etc, until coll is exhausted. Thus function f should accept 2 arguments, index and item."
16:00fliebelWhich chars have a literal like \newline?
16:02amalloyfliebel: you can see the list in LispReader.java
16:02amalloylooks like the ones with "long" escapes are newline, space, tab, backspace, formfeed, return
16:03amalloythen there's \uXXXX and \oXXX
16:03raekit's available in clojure too
16:03raek,char-name-string
16:03clojurebot{\newline "newline", \tab "tab", \space "space", \backspace "backspace", \formfeed "formfeed", \return "return"}
16:03fliebelOkay, thanks. How would I get to the arrow keys?
16:04raekarrow keys?
16:04fliebelyea, like \up
16:04TimMcfliebel: Those are keys, not chars.
16:04fliebelTimMc: But they are represented as chars, or not?
16:04TimMcAre you using Swing?
16:05fliebelyea
16:05raekthere are no unicode code points for most non-letter keyboard keys
16:05TimMcOK, those have keycodes.
16:05raekthere are some exceptions, though (enter, backspace, tab)
16:05marko_raek, thanks, let me see how it works on my end, seems exactly what I need
16:06fliebelraek: When I do .getKeyChar on my event, I sure get something for up...
16:06TimMcfliebel: Read the class docs for this carefully: http://download.oracle.com/javase/6/docs/api/java/awt/event/KeyEvent.html
16:07raekfliebel: interesting, do you know which one?
16:07TimMcfliebel: is it CHAR_UNDEFINED ?
16:07raekif you (int ...) it, what number do you get?
16:07TimMc"Virtual key codes are used to report which keyboard key has been pressed, rather than a character generated by the combination of one or more keystrokes (such as "A", which comes from shift and "a"). "
16:07fliebelI'll try… It displays as a questionmark, so that's not a good sing I think.
16:08fliebelyuk… I'll have to revisit this code :P
16:10fliebelAll arrows return 65535
16:11fliebelreally everything return 65535
16:11fliebelexcept… characters :P
16:12amalloyTimMc: i don't really work in sunlight much, but i'd expect high-constrast themes to be useful, no? i use color-theme-tty-dark
16:13TimMcamalloy: I used Katester for a bit. However, playing with themes messed up my fonts, so I had to restart Emacs.
16:15fliebelIs there some trick to mold these constants into a nice dict?
16:20raekfliebel: maybe you could use reflection to construct a map with prettier names
16:21raekfilter by fields starting with VK_, and turn VK_PAGE_UP into :page-up
16:22fliebelraek: Can I use ##(doc bean) for that?
16:22sexpbot⟹ "([x]); Takes a Java object and returns a read-only implementation of the map abstraction based upon its JavaBean properties."
16:23amalloyi don't see how
16:23raekno, you'd like to iterate over static fields
16:23fliebelHow do I get these?
16:24raekjava.lang.reflect
16:24fliebeloh, okay :)
16:29raekfliebel: (into {} (for [field (filter #(.startsWith (.getName %) "VK_") (.getFields java.awt.event.KeyEvent))] [(.getName field) (.getInt field nil)]))
16:30fliebel(inc raek)
16:30sexpbot⟹ 7
16:35raek,(-> "VK_CAPS_LOCK" (.substring 3) (.toLowerCase) (.replace \_ \-) (keyword))
16:35clojurebot:caps-lock
16:35fliebelneat :)
16:35raekclojure is such a wonderful language... :-)
16:56shelloxhi
16:58shelloxdo i need lisp programming experience to learn clojure? I just done a little bit ruby programming before
16:58pdkyou'll learn the basics of lisp that are applicable to clojure through introductory books
16:58pdkeg practical clojure, programming clojure etc
16:58amalloyshellox: no. it helps, of course
16:59pdka java background is helpful too for understanding performance considerations of code and handling java interop/using java libraries
16:59amalloypascal programming experience helps too :P (because any programming experience helps)
17:00shelloxok thanks, I'll read some tutorials
17:53sritchiehey all -- quick question on clojure.contrib.monads, if anyone's up for it -- https://gist.github.com/900855
17:54sritchie((build 1 2 3) (list)) produces [["First return." "Next return."] ("building 3" "a list of 12")], as expected. I had thought that (build-chain (list)) would produce the same result, but that turns out not to be the case
17:54amalloybrehaut: aren't you lucky to have been nominated as "that monad guy"?
17:54sritchieso, any comments on what I'm doing wrong with m-chain would be great
17:55brehauthaha
17:55sritchiehaha, that's the guy I'm looking for!
17:55brehautsritchie: give me a moment
17:55sritchiebrehaut: no problem, nothing urgent
17:57brehautsritchie: first up, why have you created phase1 and phase2 as bare functions rather than defining them in terms of the monadic combinators?
17:58sritchieI'm very new at this -- I wanted to define a closure that would generate a monadic value
17:59brehautsritchie: sure. lookin at your definitions i think its legit, but its quite an awkward way to write it
17:59sritchiebrehaut: I definitely agree, and I'm glad to hear that this isn't the way! let me give a quick description of my goal, in exploring this --
18:00amalloyoh no. now brehaut's going to see how i helped him make his awful macro awfuler
18:00sritchieamalloy: haha, he doesn't get to see the gist, don't worry
18:00brehautamalloy: wait, which awful macro
18:01amalloybrehaut: he did this as a macro before trying monads
18:01sritchiein https://github.com/pallet/pallet, phases are currently built up by threading a request map through a number of subphases, which modify it and pass it on the next phase
18:02sritchiesritchie: I wrote this macro-writing macro that builds up a phase, inserting a call to a checker-function in between every subphase, to make sure that everything's still well-formed in the request
18:02amalloyamalloy: sritchie is talking to himself. looks fun, you wanna give it a go?
18:02brehautok sure
18:03brehauthaha
18:03sritchiesorry, trying to pull up a gist -- probably should have had this ready!
18:03sritchieanyway, it seems that the state monad would be a better way to manage this business of incrementally modifying a request
18:03amalloysritchie: my fork of that gist is at https://gist.github.com/895897/
18:04marko_is it possible to create a task containing leiningen commands and shell based mv command all in same?
18:04brehautsritchie: brb
18:04marko_i have a shell script for it and possibly could use it on intelliJ when deploying google app for dev server
18:05sritchieamalloy: thanks, I was looking for this -- https://github.com/whizbangsystems/pallet/blob/feature%2F0.5.0-develop/src/pallet/phase.clj
18:10sritchieamalloy: the macro definitely feels clunky, but the resulting dsl for composing phases is really clean as a result -- I'm hoping that a clean way of defining phases as monadic values will beat it
18:14brehautsritchie: how familiar are you with monads?
18:14sritchienot very, this is my first excursion
18:15sritchiebut I've been through this whole thing -- http://onclojure.com/2009/03/05/a-monad-tutorial-for-clojure-programmers-part-1/
18:15brehautsritchie: then you are diving into the deep end with state-m :) no problem
18:15brehautok sure
18:16sritchie(not that that tells you anything about my comfort level, but it's the start of an answer!)
18:16brehautsritchie: so m-bind is a variation of apply; its a function application operator
18:17brehautin particular it applies the a function that takes a single non-monadic value and returns a new monadic value
18:18sritchiethat's m-result, right? the function that takes a single non-monadic value?
18:18brehautits a bit clearer in haskell because things like the Maybe type clearly wrap another type and so its easy to see how the two levels work
18:18brehautm-result is the identity for monads
18:19brehaut(m-bind monadic-val m-result) ;=> monadic-val
18:19sritchiegot it
18:20brehautsritchie: its important to understand that it unpacks the value from the monad.
18:20brehautsritchie: this means your computation exists on different levels
18:21brehautso the monadic type in state-m is a function from a value to a pair of state and value
18:22brehautthe implementation of m-bind is a bit of a trip
18:22brehauti like to think of it as taking a state machine and function that generates a state machine and the binding is creating a new state machine that connects the two
18:23sritchiethis is all certainly a bit of a trip -- I'm listening, and scanning the beginning of http://intensivesystems.net/tutorials/monads_101.html
18:24brehautsritchie: the best way to grasp all these things is to implement them yourself
18:24brehautstart with identiy-m, then maybe-m, then list-m and state-m
18:24sritchieokay, that makes sense
18:25brehautthe other thing is that domonad is really useful but its sugar over m-bind
18:25brehautand it is going to add to your confusion
18:25sritchieyes, I was doing expansions of domonad by hand yesterday
18:25brehautthats good
18:26sritchieI think it may have been a mistake to try and go directly from the sugar, domonad, to other sugar, m-chain
18:27sritchieI'll take your advice of implementing these, and working with m-bind
18:27brehautsritchie: your problem is that phase1 in particular is not bindable
18:27brehaut(it takes two arguments!)
18:27brehautbut it does return a valid monadic value for state-m
18:27amalloysritchie: have you watched brian marick's recent series of monad videos?
18:28sritchieoh, no, I haven't
18:28sritchieI do remember seeing a comment about those on the clojure list, I'll look those up now
18:28sritchieamalloy: thanks, that'll be really helpful
18:30sritchiebrehaut: I had thought that (phase1 1 2) would evaluate to the monadic value, which would be bindable
18:30brehautsritchie: the result of phase1 it is bindable only as value side of the bind, not the function side
18:30brehautsorry thats imprevise
18:31brehaut(phase1 x y) is only bindable as the value of a bind
18:31brehautphase1 is not in any way bindable
18:31sritchieokay
18:32sritchiewhat would be the proper way to define a computation, here? for a computation that incremented state by 1
18:32sritchieyou had mentioned that I should have used the monadic combinators
18:33brehauthere is how i would do it
18:33brehaut(with-monad state-m (defn phase1 [x y] (domonad [_ (update-state (fn [s] (cons (str "a list of " x y) s)))] "First")))
18:34sritchieah, I see
18:35brehautim going to try to desugar that for you too
18:35brehautsritchie: the expression after the comprehension is implicitly wrapped in m-result btw
18:36sritchieokay, sure
18:36brehautheres the desugared form
18:36brehaut
18:36brehaut(with-monad state-m
18:36brehaut (defn phase1 [x y] (m-bind (update-state (fn [s] (cons (str "a list of " x y) s))) (fn [_] (m-result "First")))))
18:37sritchiethat's certainly clearer -- m-result takes a value, and returns the monadic value, then
18:37sritchieand update state takes a monadic value and returns a monadic function?
18:38sritchieand then m-bind applies that function to the value
18:38brehautheres the confusing part
18:38brehautstate-m's monadic values are functions
18:38brehautupdate-state takes a state updating function but returns a monad value
18:39brehautthat value _happens to be a function_
18:39brehautbut we are using it here as a value
18:39brehautnote that there is an anon function on the RHS of bind?
18:39sritchieso update state is taking a monadic value, which for state-m is a state-updating function
18:39sritchiealways a state updating function, right, for state-m?
18:41brehautnot quite. update-state's argument is not monadic. jsut a normal function.
18:41brehautthat function is provided the old state and returns a new state
18:41brehautupdate state wraps that all up in a state machine function
18:42sritchieoh, I see -- so (with-monad state-m (m-result (fn [s] (inc s)))) would convert (fn [s] (inc s)) into a monadic value
18:43brehautyes but not in the way you imagine
18:43brehautm-result takes a non monadic value and wraps it in the monadic context type needed for the monad
18:44brehautin state-m that means it returns a function that takes the existing state machine state and returns a new state machine state (thats a pair of value and state) where the state is whatever it always was a the value is (fn [s] (inc s))
18:46sritchieone quick question (and really, thanks for taking the time go through this with me) -- in your phase1 example, with m-bind --
18:46sritchiewith m-bind, the first parameter is a monadic value, and the second is the function to apply to that value, right?
18:46brehautcorrect
18:49sritchieso our monadic function here -- (fn [_] (m-result "First")) -- returns a monadic value that doesn't modify the state, but returns "First" -- so it's going to be really helpful for me to work out exactly how m-bind applies that function to (update-state .. etc in this case
18:49brehautyeah :D
18:49brehautthats the head trip ;)
18:50brehautalso, i cant get m-chain to work at all ;)
18:50sritchiethat's the real head trip
18:51sritchieokay, so, my homework is to go off and implement these
18:51brehautyup
18:51brehautsritchie: ive got a full expansion of a state-m on my site
18:52sritchiesimpler question -- in an application like pallet's, where we modify state but don't really care about return values -- that's still a good use for the state monad, right?
18:52brehautsritchie: http://brehaut.net/blog/2010/welcome_to_the_machine
18:52sritchiehey, great
18:52brehautif you are just creating a log of events then the writer monad is probably more appropriate, but i dont know if there is an imp in c.c.m
18:53sritchiewell, eventually the map is converted into a big ssh command for the nodes
18:54sritchiethe goal of that macro-writing macro was to allow for the state, the request, to thread through a function that checked whether or not the state was well formed, which would either act as identity or throw an exception
18:54clojurebotyou're doing it wrong!
18:54brehauthaha
18:54sritchiehaha, what was it responding to?
18:54brehautthrow an exception
18:55sritchiebut it would be very advantageous to, rather than throw an exception, keep passing the request along and add the error as a result
18:55brehautsritchie: i think state is a reasonable tool in this case. in combination with a variation of maybe-m you could get error handling too
18:58TimMcclojurebot: throw an exception
18:58clojurebothttp://paste.lisp.org/display/74305
19:27hirak8i'm trying to setup clojure within emacs, and get this error "rlwrap: Oops, crashed (caught SIGFPE)"
19:28hirak8when i run C-c C-z
19:28hirak8on a .clj file
19:28hirak8has anyone seen this before?
19:28hirak8i can't find anything online
19:39hirak8anyone?
19:39clojurebotPlease do not ask if anyone uses, knows, is good with, can help you with <some program or library>. Instead, ask your real question and someone will answer if they can help.
19:40devnclojurebot: bad form.
19:40clojurebothttp://clojure.org/java_interop#toc46
19:40devnclojurebot just pulled a watson
19:40devnhirak8: i have not seen that personally, what platform?
19:41hirak8OSX 10.6
19:41devnhirak8: let me see if i can reproduce
19:41hirak8i'm using a custom script that launches rlwrap to get a nice REPL
19:42hirak8however inferior-mode still doesn't work even when i use the default script that comes with homebrew
19:42hirak8perhaps i should try a straight java command line
19:42devnhirak8: whoa whoa -- why not use slime?
19:42hirak8i am trying to use slime
19:42devni have rlwrap installed, but that's really not part of my slime setup
19:42hirak8i have to set 'inferior-lisp-program' to use slime, no?
19:42devnhirak8: ill gist my setup for you
19:42hirak8that's where i'm stuck
19:42hirak8ok
19:43hirak8are you on osx?
19:43devnhirak8: indeed
19:43hirak8k
19:43hirak8are you using emacs starter kit?
19:43devni built my setup out of that sort of, yes
19:44devnhirak8: https://gist.github.com/900931
19:44devnit's kind of messy because i've been adding to it here and there
19:44devnbut that should be enough to show you how to get your slime setup working
19:44Derandermy experience with slime & clojure has been to install lein, type lein swank at the command line and then run m-x slime-connect
19:45devnhirak8: I do what Derander is saying
19:45DeranderI've never heard of rlwrap though
19:45devnrlwrap is good if you want a better cmd line repl
19:45devnbut not necessary for slime
19:46devnhirak8: my setup might just confuse you more
19:46devnthere are much smaller setups out there
19:47devnhirak8: http://riddell.us/ClojureSwankLeiningenWithEmacsOnLinux.html
19:47devnscroll down to "Configure Emacs"
19:47devnthat's really all you need
19:48devnactually, you dont even need that if you're using elpa
19:49devnM-x package-list-packages, get slime, slime-repl, clojure-mode by typing 'i' at the beginning of the lines in the package dialog where you want to install, then type 'x' to execute the installation
19:49hirak8why do you say that?
19:49hirak8yes, i've been using ELPA
19:49hirak8i thought i had to configure the 'inferior-lisp-program' variable in order to get it all to work
19:50hirak8without using lein+swank
19:50devnyou really just need a (require 'slime), (eval-after-load "slime" '(progn (slime-setup '(slime-repl)))), (require 'clojure-mode), and a (slime-setup)
19:51hirak8hmm
19:51hirak8this is what i have installed via ELPA:
19:51hirak8let me make a gist
19:52hirak8https://gist.github.com/900937
19:52hirak8alot of that came pre-installed due to emacs starter kit
19:54hirak8was hoping to not have to use lein/swank right away, oh well
19:54hirak8how do you evaluate code that's not part of a lein project?
19:55TimMcTo get custom printing for my defrecords, all I should have to do is override print-method, yeah?
19:55not-timmcTo get custom printing for my defrecords, all I should have to do is override print-method, yeah?
19:55not-timmcstupid netsplit
19:56devnnot necessarily in that order
19:56devnhirak8: sorry im not as much help as I had anticipated -- i havent mucked with my slime setup in a long time
19:56devnd'oh
19:57hirak8devn: do you only edit code that lives in a lein project?
19:57devnhirak8: uninstall swank-clojure
19:57devnthat is deprecated IIRC
19:57hirak8good to know
19:58TimMcdevn: I wish they would remove deprecated stuff.
19:58devni use marmalade
19:58TimMcOr at least release a modification that warns you.
19:58devnit's not in my list anymore
19:58hirak8marmalade = different package repo?
19:59devnyes
19:59devnyou need a diff version of package.el
20:04devnhirak8: sorry you're having so much trouble
20:04hirak8me too!
20:04hirak8even setting inferior-lisp-program to a raw command line instead of a shell script (java -cp /usr/local/Cellar/clojure-contrib/1.2.0/clojure-contrib.jar:/usr/local/Cellar/clojure/1.2.0/clojure.jar clojure.main) didn't cut it
20:04hirak8when i run C-c C-z it loads the repl file
20:05hirak8but when I run C-c C-e on an sexp, i get some error message
20:05hirak8it's bizarre
20:05hirak8i'm just following the instructions on the clojure wiki
20:05hirak8http://dev.clojure.org/display/doc/Getting+Started+with+Emacs
20:07devnhirak8: http://marmalade-repo.org
20:07mreynoldsNewb question : I'm trying to write a server that communicates using DataOutput/InputStream. I got tired of writing (doto OutputStream (.writeInt 1) (....)), so I figured I'd use multimethods. I (defmutli write (fn [stream item] (class item)) and then impl'd the underlying types. Works great till I get to collections, which I tried to switch on "ISeq", but that didn't work. Is this dumb? Are there better ways to do this?
20:07mreynoldsOtherwise, what class should I use for Seqs so I can (doseq...) them
20:07mreynoldshttp://pastebin.com/wfLD82f2
20:08hirak8devn: thanks. so is this for packages that don't exist at all on ELPA?
20:08devnhirak8: it's a better maintained package repo
20:08hirak8devn: or for updates to existing packages that aren't on ELPA yet
20:08hirak8ok
20:08devnboth
20:08hirak8k
20:09hirak8cool
20:09hirak8well, after reading the help docs again i think i may have figured it out
20:09devnhirak8: dont set inferior lisp program -- clojure-mode with slime-repl should be enough
20:09hirak8hmm
20:09devnhirak8: cool
20:09hirak8well, it looks like you have to launch a lisp process with C-c C-z.
20:10hirak8then you can send commands to it using C-x C-e
20:10hirak8but you have to switch to the *inferior-lisp* buffer to see results
20:10hirak8which is kind of odd
20:10devnthat's kind of a non-standard setup hirak8
20:10hirak8it's the setup that's listed here: http://dev.clojure.org/display/doc/Getting+Started+with+Emacs
20:10hirak8which you would think would be *the* standard setup
20:11hirak8i'll setup lein+swank eventually
20:11hirak8if you just use clojure-mode+slime-repl, how does emacs know how to execute clojure?
20:11hirak8like, how does it know what command to run?
20:11hirak8do you need to add the clojure.jar to CLASSPATH and it takes care of everythign else?
20:12devnlein swank takes care of the classpath
20:12devnyou just need to connect to that instance by having [swank-clojure "1.3.0-SNAPSHOT"] in your :dev-dependencies
20:12hirak8yes
20:12devnlein deps, lein swank
20:12hirak8not using lein yet
20:12hirak8will be
20:12devnM-x slime-connect
20:34hirak8devn: have lein+swank+slime working now tooo
20:36hirak8err, i thought i did
20:36hirak8C-x C-e is broken again :\
20:41hirak8fixed
20:41hirak8god that was a lot of work :)
20:41hirak8but now i can hack clojure!
22:49MiggyXhi
22:49brehautMiggyX: hello
22:50MiggyXbrehaut: do people answer programming related questions here or is it just general clojure discussion? :)
22:50brehautboth
22:51MiggyXbrehaut: Well I've just started using closure, so I'm still getting up to speed. I have a CSV file that I need to process. Each line is self contained and can be processed individually. I'm trying to have each line processed in parallel to make good use of the number of cores on this both (16)
22:52brehautMiggyX: clojure or closure?
22:52MiggyXbut not having a great deal of luck. I've tried a few things with the latest (just seeing if it would work) - (fmap println (read-lines "foo"))
22:53brehautMiggyX: fmap is a bunch slower than map
22:53MiggyXbrehaut: apologies I meant clojure, hands are on auto pilot :)
22:53brehautno worries, just making sure we are on the same page
22:53MiggyXbrehaut: I've tried map and pmap - pmap was what I thought i needed
22:54brehautpmap is the obvious first choice, your snippet above has fmap though, which is different again
22:54brehautthe effectiveness of pmap in speeding things up is directly proportional to the cost of each mapping operation though
22:54MiggyXthis particular file just has two lines of text in it. It prints those out, sits there for a minute and then quits. When I try it on a large file, nothing gets printed, cpu usage is minimal and again after a minute or so it quits
22:54MiggyXso I figure I'm doing something obviously wrong
22:55brehautcan you paste your program up in a gist or something
22:56MiggyXhttp://www.pastie.org/1752839
22:56MiggyXall i wanted it to do was print each line :)
22:56brehautMiggyX: first up, lazy seqs and side effecting code are a fun mix
22:57brehautyou need to force the realization and evaluation of the whole sequence
22:57brehaut(doc doall)
22:57clojurebot"([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. doall can be used to force any effects. Walks through the successive nexts of the seq, retains the head and returns it, thus causing the entire seq to reside in memory at one time."
22:57brehaut(doc dorun)
22:57clojurebot"([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. dorun can be used to force any effects. Walks through the successive nexts of the seq, does not retain the head and returns nil."
22:58brehautwhat version of clojure are you using BTW?
22:58MiggyX1.2.0
23:08MiggyXhmm, doseq looks more like what I need. The CSV file is massive, I can't load it all into ram at once
23:08MiggyXseems processing each line in parallel is a lot harder than I thought it would be
23:09brehautMiggyX: so pmap runs the mapped operation on seperate threads, and by default those threads dont have their std outs bound to the repl console
23:09brehautMiggyX: i use cljr for my messing about repl and when i pmap println over something it all spews out in the console that i opened cljr from
23:09brehautMiggyX: but approximately the snippet you provided runs fine for me over /usr/share/dict/words
23:11malkomalkoanybody know any good clojure/emacs/slime/swank posts? I'm having some problems getting up and running
23:11malkomalkokeeps complaining about undefined namespace when I try running some code after a slime-connect
23:12brehautmalkomalko:have you followed the readme in swank-clojure; most of the blog posts and articles in teh wild are out of date
23:14amalloymalkomalko: slime-connect doesn't automatically load any code
23:14malkomalkoI have, but I'm having problems when trying to excecute code
23:14malkomalkoahh
23:14amalloythe first step after connecting, for me, is usually C-c C-k in the file i want to load
23:14amalloythat spews the whole file and all its dependencies into the repl
23:15amalloyafter that, you can use C-x C-e or C-c C-c to load individual forms, or C-c C-k for another wholesale import
23:16malkomalkook cool, that helps a lot
23:16amalloyother handy ones to know are C-c M-p (set repl to namespace of active buffer) and C-c C-d C-d (documentation for symbol at point)
23:17MiggyXbrehaut, hmm that might well be it. I would have still expected to see CPU usage though even if it wasn't printing anything, maybe it's too small to be picked up.
23:17MiggyXbrehaut, now to find out how to bind stdout for each threa
23:17MiggyXthread
23:17brehautMiggyX: until you start doing heavy computation on that, i would expect it to be IO bound
23:18MiggyXbrehaut: would explain why it justs there for a bit
23:19malkomalkothanks amalloy... any other useful emacs plugins or tips/workflows?
23:20amalloymalkomalko: emacs in general, or slime/swank in particular?
23:21malkomalkojust specifically for clojure development with emacs
23:21malkomalkobeen doing a lot of research, but there seems to be a lot of out of date information
23:21amalloymalkomalko: install paredit mode if you haven't already, and then learn some of the most-common commands
23:23amalloymy favorites are M-<UP>, C-<RIGHT>, M-(, and occasionally C-}
23:24malkomalkoare those paredit specific shortcuts?
23:24amalloyyes
23:24malkomalkoalright cool, I'll go dig into that, thanks for the heads up again, been very helpful
23:24amalloyenjoy
23:24malkomalkoand then so after you make changes to a file, you'll want to reload that correct?
23:26amalloyyeah
23:33MiggyXcan anyone provide an example of how to bind *out* in a thread? i.e. each thread needs to be able to write to stdout
23:34brehautMiggyX: i question the sanity of doing that
23:36MiggyXbrehaut: I agree, I'm just trying to see whether or not the reason the calculation etc aren't taking any cpu time is because I'm not actually doing anything with them