#clojure logs

2013-12-01

01:19logic_progfor swap!, is there something that does "swap and return old value" ?
01:19logic_progso update-in returns the new value of the atom
01:20logic_proghowever, instead of doing update-in, I'd like to update the value ... but also get the old value
01:49nightflyI'm not sure that that's possible since swap! isn't guaranteed to be called only once
01:49nightflyyou could probably build what you want using refs instead though
01:56amalloyi mean, you can do it with an atom if you don't mind making it a bit of a hassle to use the atom for other stuff
01:58amalloy(defn historical-atom [x] (atom [x nil])) (defn swap-returning-old! [hatom f & args] (second (swap! hatom #(apply f (first %) args)))) (defn current-value [hatom] (first @hatom))
01:59amalloyor...well, i got the swap! wrong. but i think the idea is clear enough
02:27mysamdogHow would I do var folded = new OriDomi(document.getElementsByClassName('responsee.1')[0]); in clojurescript?
02:34seangrovemysamdog: (OriDomi. (first (.getElementsByClassName js/document "responseee.1)))
02:34seangroveBut of course you'd have to make sure all the deps were loaded properly, etc.
02:35seangroveYou just asked for a simple mechanical transformation.
02:36seangrovemysamdog: (-> (.getElementsByClassName js/document "responseee.1) first (OriDomi.)) might be more clear, depending on your background
02:36mysamdogThank you so much
04:31amalloyfwiw, seangrove, the way i think reads most nicely is (OriDomi. (first (-> js/document (.getElementsByClassName "responseee.1"))))
04:32amalloybut i dunno. that puts the classname last, whereas i'd like it to be more prominent
05:46xificurCHi, reading about 'Mocking and Stubbing' in 'Clojure in Action' I notice that the author is dynamically rebinding a function, i.e. he has a (defn log-call ...) and somewhere else does (binding [log-call something-else] ...). I understand that this is not possible since then unless you declare (defn ^:dynamic log-call ...)?
05:48xificurCso that means you cannot shadow a var unless it's declared as ^:dynamic, right?
05:53arcatanxificurC: yeah
05:53arcatanxificurC: but in earlier versions of Clojure all variables used to be dynamic
05:54arcatan(earlier versions = 1.2 and earlier)
05:54xificurCarcatan: thanks
05:54xificurCso that part of the book is practically deprecated
05:56arcatanthere's still with-redefs, which can be used all variables and which mutates the binding globally (binding does it thread-locally)
05:56arcatanso it's kinda dangerous if you're multithreading, but it can be useful when writing tests
05:57arcatani recently asked on stackoverflow about it: http://stackoverflow.com/q/20139463/297366
06:01arcatani wonder if mocking by rebinding variables is popular, or good style.
06:02xificurCarcatan: I wonder too. thanks for the tip
06:05xificurCarcatan: cool I only had to change binding to with-redefs in the functions and the tests work as expected. Thanks!
06:37d11wtqI notice map returns a lazy-seq. However, when I map over a vector, it doesn't seem to be lazy like it is using a list. What am I doing wrong here?
06:37d11wtq(first (map (fn [x] (println (str "Called with " x)) x) [1 2 3 4 5]))
06:37d11wtqSee the side-effects even when just asking for first. If you switch that vector to a list, the side-effects go away for the rest of the list.
06:48eigenlichtclojure's macro system is not hygienic, is that correct? but it avoids the problem of unhygienic macros by not allowing name bindings that hide others
06:49hiredmaneigenlicht: no, if it did that, that is pretty much the definition of macro hygene
06:50hiredmaneigenlicht: clojure has some facilities for automatically generate symbol names for use in macro created bindings that have names that are unlikely to shadow anything
06:51eigenlichthiredman: so even though I use a name that is likely to shadow some other, it internally gets replaced by something else?
06:51eigenlichtinstead of me doing it manually like in CL with gensymbol?
06:51hiredmaneigenlicht: no, it would get replaced unless you as for it
06:51eigenlichtpardon?
06:53hiredmaneigenlicht: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L794-L804 is what it looks like
06:53hiredmanwhen using syntax quote (which is sort of like the quasi quote other lisps have) a symbol name that ends with # is auto gensymed
06:54hiredmanall symbols that do not end with # are assumed to be globals and get namespace qualified
06:54eigenlichthiredman: got it, thanks
06:54hiredmanso if you want to have a local name inside syntax quote that is not a gensym you have to work at it
06:55hiredman`a
06:55hiredman,`a
06:55clojurebotsandbox/a
06:55hiredman,`a#
06:55clojurebota__57__auto__
06:55hiredman,`(let [a 1] a)
06:55clojurebot(clojure.core/let [sandbox/a 1] sandbox/a)
06:55hiredmanand clojure won't let you bind a namespace qualified name as a local
06:55eigenlicht,`(let [a# 1] a)
06:55clojurebot(clojure.core/let [a__114__auto__ 1] sandbox/a)
06:56hiredman,`(let [a# 1] a#)
06:56clojurebot(clojure.core/let [a__143__auto__ 1] a__143__auto__)
06:56eigenlichtseems reasonable
06:56hiredmanit has worked ok so far :)
07:04d11wtqNoob question, but what should I be looking at if I know (map ..) is not being lazy when it should be? I've tried wrapping the seq with (lazy-seq s) but it's still executing the function for every element in the seq.
07:08hiredmand11wtq: http://blog.fogus.me/2010/01/22/de-chunkifying-sequences-in-clojure/
07:08d11wtqAh never mind, it wasn't anything to do with laziness. I was going down the wrong rabbit hole.
07:08d11wtqhiredman: thanks. I'll have a look at that in a tick. I definitely need to better understand seqs.
07:09WWWest1Hi all
07:10WWWest1Has anyone managed to get source maps working on node?
07:13danenaniahola clojurians, could use a little guidance on compojure/friend if anyone has a minute: http://stackoverflow.com/q/20311952/238751
07:31Bronsahiredman: what I was trying to fix with the current behaviour of validate-loop locals is this: http://sprunge.us/RfMe
09:05ziltiI have a problem with core.async in clojurescript. >! and <! both block forever, while put! and take! work as intended.
09:25ziltiI have a problem with core.async in clojurescript. >! and <! both block forever, while put! and take! work as intended.
09:58jph-anyone know offhand if there's a pretty printing / output formatter for console apps?
09:58jph-ie formatting data into tables
09:58jph-ascii tables
10:05ziltijph-: Look into the clojure.pprint namespace.
10:07jph-zilti: cheers, wasnt sure if that would include table-level formatting or just json-type formatting
10:08ziltijph-: You can format things into tables as well, yes
10:08jph-zilti: lovely
11:19danneuHas anyone hapened to roll their own function that walks arbitrary structures/values and converts values in some way? Ideally I'd just borrow someone's since my attempt sorta sucks https://www.refheap.com/21390
11:22danneunvm, the dispatch on map? coll? etc needs to be moved outside the `walk` as well
11:28rovaris there a way to explore the classes that are loaded in the classpath from the repl?
11:28rovarI'm having a hard time finding the correct name to use to load modules
11:30rovari run lein repl, and and when I try to require or use, it says it can't find that class.
11:31rovarspecifically: (use 'jiraph.graph) or (use 'org.flatland/jiraph.graph)
11:31justin_smithdanneu: does clojure.walk2 not do what you want?
11:31justin_smithrovar what is the artifact you added to your dependencies?
11:32rovar[org.flatland/jiraph "0.12.3-alpha1"]
11:32seangrove Looking at picking up JoC, but I don't want any more physical books. Is the ebook reasonably well formatted and enjoyable to read?
11:32rovarlein cp indicates that it is referencing it
11:32rovarseangrove, so far so good. I just picked it up last night
11:32rovarthe 2nd edition from manning
11:32justin_smithrovar: flatland.jiraph.graph https://github.com/flatland/jiraph/blob/develop/src/flatland/jiraph/graph.clj#L1
11:32rovarthey give you a [mobi ebook pdf] file
11:33justin_smithalso, avoid use, require with an alias helps a lot
11:33justin_smithrovar: basically what you want to require is the ns name declared in the file you are using
11:34rovarwhat would be the best approach for a repl?
11:34justin_smithusually I do: (require '[flatland.jiraph.graph :as g])
11:35justin_smithnot too much hassle to type, makes me rembember where the functions came from if I put them in my code
11:37rovarthat works
11:38justin_smiththe problem with use, in my experience, is I come back to something later, and need to reorganize, and have no idea where any of these functions came from
11:38justin_smithit makes extending or splitting my code very annoying
11:39rovarerg
11:41seangroverovar: Did you try it on the Kindle?
11:41rovarthe good news is there has been significant development work since that documentation was written. The bad news is <<<
11:41justin_smithlol
11:41justin_smithdocumentation skew!
11:42rovareverything has been moved into new namespaces..
11:42rovarbut the tests are current
11:43rovarseangrove, uploading the .mobi now
11:43rovarI have a crappy kindle, so most programming books are not good
11:44hyPiRionAh dang, wish there were some way to couple documentation indirectly with "tests". Although I have a feeling that it's harder than it seems
11:44justin_smithusing the doc strings in function bodies help - at least they are right there when you edit or move the function
11:44hyPiRionIt's "hard" to trace down "outdated" documentation.
11:45hyPiRionyeah, I am more thinking of documentation living outside the source code
11:46justin_smithI think for that, you really need a preamble : this documentation is current as of "version"
11:46justin_smithsomeone was having some trouble the other day, some nrepl docs had been s/nrepl/cider/g edited, and were inaccurate because some of the stuff isn't actually working in cider
11:48hyPiRionhmm, yeah, that's doable
11:48justin_smithit is fairly simple, and you know as soon as you start reading whether it is guaranteed to apply to your version (and how many versions old it is)
11:49rovarseangrove, looking at it now on my 7" black and white kindle.. looks good. no tables are mangled, code examples look right.
11:49justin_smithspeaking of, there are some old caribou docs that should really just be taken down and pointed at the new docs
12:00jtoywhere is a log function in clojure? its not in math contrib anymore it seems
12:01justin_smith,(Math/log 0.1)
12:01clojurebot-2.3025850929940455
12:01justin_smiththough you may want something with proper numeric tower support
12:02justin_smithdunno where you would find that
12:02jtoythat should work for now, thanks
12:02jtoyhard to tell from the docs
12:08justin_smithjtoy: fyi clojure.contrib.math is not clojure.math.numeric-tower
12:09justin_smithhttps://github.com/clojure/math.numeric-tower
12:18jtoyjustin_smith: it says Formerly clojure.contrib.math ?
12:20justin_smithI meant now, typed not
12:20justin_smithoops!
12:32rubber-duckif I have a macro (defmacro foo [x]) how do I get (foo y) to return symbol y ?
12:33rubber-duck''x will return x, 'x will return y that gets evaluated to y in local ns
12:35rubber-ducknvm figured it out (defmacro foo [x] `(quote ~x))
12:35bbloomrubber-duck: you can write `'~x
12:36rubber-duckbbloom, nice
12:40jtoycan I add metadata to a defn and then from inside the method access that data?
12:41hyPiRionI guess
12:41hyPiRion(defn foo [] (meta #'foo)) ...
12:42hyPiRionjtoy: ^ works fine
12:49exuperocan anyone tell me why when I run `lein trampoline cljsbuild repp-listen` it seems to hang?
12:49exupero*repl-listen
12:59holohi
13:00holojust created a new library template with lein, test file is suffixed with _test instead of a directory named test. what is the rationale behind for this decision?
15:53solidus_how do i use clojure async? i did (require 'clojure.core.async) and added the deps in lein project.clj but i can't use any of the macros
15:54dnolenbellkev: https://github.com/clojure/clojurescript/blob/master/src/clj/cljs/compiler.clj#L355, the entire CLJS AST is represented as maps, and multimethods over them
15:54dnolenbellkev: you'll see similar things if you look at the modern CLJ analyzer and emitter that Bronsa is working on
15:55coventryI did run into a problem with using a dispatch map: <http://dev.clojure.org/jira/browse/CLJ-1276&gt;. I they're considered bad style, that's a drawback because it's a largely untested usage.
15:56coventry*If
15:57coventryPerhaps if I used a multimethod, I could reunify the code I had to split out because of that bug. https://github.com/coventry/troncle/blob/master/src/troncle/wrap/wrappers.clj
15:59coventrysolidus_: Can you post some code and the error you're getting on refheap.com
16:00solidus_coventry : turn out i needed to eval (require '[clojure.core.async :as async :refer :all]) ...
16:01bellkevJust briefly looking at defmulti, it looks like it's primarily a way to do something like method overloading by type in Java?
16:01coventrybellkev: It's much more general than that.
16:01justin_smithbellkev: you can use an arbitrary function for dispatch
16:01justin_smithbellkev: so you can have a key declaring the "type" of map it is
16:01justin_smithfor example
16:02bellkevOkay, I'll keep checking it out. In my case, I need between 1 and 4 different methods (named "default", "create", "update" and "delete"), each of which will basically take maps as input/output
16:03si14how can I debug random "ClassNotFound" exceptions about one of my records?
16:04justin_smithsi14: is a record you have redefined at some point in the repl?
16:04si14the weird thing is that it's really random. It works in 80% cases, and in 20% exception is thrown
16:04si14justin_smith: nope
16:05justin_smithare you getting complaints that a class could not be loaded?
16:05si14justin_smith: here is the trace: https://gist.github.com/si14/187a43845e3d1eea4544
16:06justin_smithand is this a class you can normally access?
16:06si14yes
16:06si14moreover, it was accessed by previous request
16:08si14and it breaks core.async in somewhat funny way that I can't even locate, it just stops to deliver WS messages through the "bridge" I've made
16:08justin_smiththreads + exceptions can lead to unexpected behavior combinations in my experience
16:09coventryjustin_smith: Can you give an example?
16:09tbaldridgesi14: are you using record literals?
16:09si14tbaldridge: нуы
16:09si14tbaldridge: yes
16:09si14(sorry)
16:09si14tbaldridge: I'm using cljson that use them
16:10tbaldridgesi14: yeah, until recently, record literals are a bit buggy with core.async
16:11si14tbaldridge: I'm using the last tagged version ("0.1.242.0-44b1e3-alpha"). Does it mean that I should better switch to snapshot?
16:12tbaldridgesi14: try using 0.1.256.0-1bf8cf-alpha
16:13tbaldridgeor you can also move the record literals outside of go blocks (call them in other functions or something) that might help
16:14tbaldridgeand this is only for record literals. Normal record creation like (->Foo 1 a) works just fine
16:15gunsWas (def ^{:private true} foo …) legal back in Clojure 1.2?
16:16si14tbaldridge: tried the newer version and it didn't help. I don't use record literals directly, they are used by a library
16:17si14the thing that is the most painful is that it really happens in 20-30%
16:17tbaldridgesi14: that should be fine then. The problem is only when you use reducers directly inside the body of a go
16:17tbaldridgesi14: it's probably a race condition. A class gets called before it is loaded.
16:18andyftbaldridge: This question might be nonsense, but is there some sense in which core.async is x% of a Clojure compiler, for some non-0 number x?
16:19tbaldridgeyes, it is a CLJ->CLJ compiler :-)
16:20coventryI call my compiler #'identity.
16:20gunsAnd to answer myself, yes ^{:key value} metadata is fine in 1.2, but not ^:key
16:20andyftbaldridge: I ask not from deep knowledge of core.async, but just the vague impression that the kinds of bugs experienced in core.async seem to be in some fairly deep corners of the language.
16:24si14tbaldridge: how this can be given that the code that uses that class was already run?
16:27tbaldridgeandyf: yeah, that's very much the case. Most of the bugs in the go macro have come from use cases that 0.01% of Clojure code uses.
16:27tbaldridgesi14: I'm not sure, I haven't seen the code. That's just a guess
16:28si14tbaldridge: I mean that I can be wrong in my assumptions about how classes are resolved in JVM.
16:30ProfpatschI finally got the Clojurescript brepl working on top of nrepl in Emacs.
16:31ProfpatschNow I’m experimenting with coding a little on canvas.
16:31ProfpatschI’ve got a brepl running on 9000 and cider connected to that.
16:32ProfpatschThen I wanted to pull in dommy, edited the project.clj, edited the require and restarted cljsbuild auto.
16:34ProfpatschBut somehow the repl didn’t quite follow. I can type stuff in the file, save it and reload the page, works just fine, but when I try to eval dommy functions from the repl I get evaluation TypeErrors.
16:34Profpatsch“Cannot call method ‘call’ of undefined.”
16:35ProfpatschIs this normal with repls?
16:41justin_smithsounds like you are trying to use a function that is declared as a var but not yet bound
16:41ProfpatschWoah there.
16:41ProfpatschI just imported a library. ;)
16:42ProfpatschThe one thing I stumble over a lot in clj is the namespace system.
16:43si14finally fixed (or I hope so) the problem with AOT.
16:49Profpatschjustin_smith How could that be. When I refresh the browser, the repl should be completely fresh, shouldn’t it?
16:57justin_smithProfpatsch: it could be the error has to do with trying to call something that does not even exist
16:58bellkevjustin_smith: Well, I think I found a more Clojurey way around my whole multi method question...
16:58Profpatschjustin_smith: https://www.refheap.com/21393
16:58justin_smithbellkev: cool, what is it?
16:59bellkevThe whole reason I needed methods in the first place was to respond to create/update/delete calls from the AWS CloudFormation custom resource API
16:59Profpatschjustin_smith: That’s after reloading the browser.
16:59bellkevHowever, those actually come as a "event" object kind of like an HTTP request, with the "method" as one of the fields in the event
16:59justin_smithahh
16:59bellkevSo I can make it so that you just have to implement a handler, like a ring handler, that gets the whole request as input
17:00justin_smithso you can use the format that comes in
17:00bellkevDoes that make sense?
17:00justin_smithindeed
17:00bellkevYeah, and then handler-developers can do whatever they want with the map that comes in
17:00coventryProfpatsch: It looks like sel1 is a macro, meaning it's clojure code, but your repl is trying to execute it as cljs.
17:00coventry...unless cljs has been moving so fast it now has native macros, and I didn't notice.
17:01ProfpatschHuh. So I can’t use dommy in-browser?
17:01coventryProfpatsch: I would be googling for things like "using macros in brepl".
17:03ProfpatschOh, I should use Austin, that seems to support interactive macroexpansion.
17:04ProfpatschBut you are right, in brepl I need to first explicitly evaluate the namespace to make the reader expand the macro.
17:18jtoyhow can this be true: (println (= "integer" (column-map (first x)))) but this prints false: (println (or (= "bigint" (column-map (first x)) (= "integer" (column-map (first x))))))
17:18jtoyim sure its some silly mistake, but I dont see it
17:20coventryjtoy: Try (println (or (= "bigint" (column-map (first x))) (= "integer" (column-map (first x)))))
17:20coventry(Your paren positions look wrong.)
17:20jtoyyes, thats it :(
17:20jtoythx
17:21jtoyis there a simpler way to write that same expression?
17:21coventry(let [r (column-map (first x))] (println (or (= "bigint" r) (= "integer" r))))
17:21hyPiRion(boolean (some #{"bigint" "integer"} (column-map (first x))))
17:22hyPiRionwait er
17:22coventryBut you might also want to look into an tree-editing mode, like paredit.
17:22hyPiRion(contains? #{"bigint" "integer"} (column-map (first x)))
17:22jtoycoventry: I do use paraedit, how would htat help me in that situation?
17:23coventryjtoy: It should have inserted balanced parens as you built the expression.
17:23jtoycoventry: probably from me doing too much editing
17:30diogenes_where can i see the clojure conj 13 videos? are they up yet?
17:44mercwithamouthquestion...say i used enlive opposed to enfocus....would the created markup code stress the backend or would it function just the same as all of the code were client side?
17:51justin_smitha good templating / rendering engine should not be too much of a load
17:52justin_smithI have not used enlive much in production though, except to destructure 3rd party data and render it, and there I was using a cache with a ttl to avoid mainly the overhead of fetching
17:53justin_smithbut also having the side effect of not calling the rendering function for most requests
18:08mercwithamouthjustin_smith: i see....i think i'm just going to use hiccup for the basics and enfocus or dommy. i'm toying with dommy at the moment but something tells me i'm going to go the enfocus route
18:15noncom|2justin_smith: so, regarding timbre, sorted it out, mthanks, looking at the config contents. the file problem was due to wrong path. did not give an exception though
18:15justin_smithnoncom|2: cool, so otherwise that config to turn off stdout and turn on file logging was correct?
18:15noncom|2yeah
18:33wafis there some sort of 'interceptor' function in clojure, where i can apply input/output transformations based on some condition?
18:33wafi'm not happy with this code: https://www.refheap.com/21394 and trying to find a more idiomatic way to write it
18:39justin_smithwaf: the middleware pattern as used with ring is a nice way to do that stuff
18:39justin_smitha bunch of small functions that each do some action or transformation on the input, and you define your features / behaviors by how you line them all up
18:40bellkevIs there some way to use "require" on namespaces that have been dynamically created?
18:40bellkevOr, put another way, is there a more dynamic way to do something like what the amazonica AWS wrapper does here: https://github.com/mcohen01/amazonica/tree/master/src/amazonica/aws
18:40justin_smith(require '[some.ns :as alias]) will work for that
18:40justin_smithin a repl for example
18:41chouserbellkev: require calls various public functions such as alias and refer
18:41justin_smithbellkev: what file are you trying to point to there?
18:41bellkevI'm pointing to the collection of files
18:41bellkevEach one is just a tiny wrapper, that dynamically interns a bunch of functions into its namespace
18:41justin_smiththat looks like a bunch of small namespaces that only exist to create side effects
18:42wafjustin_smith: ah, interesting. this is a ring app, i'll lookin into pulling it out into middleware
18:42wafthanks!
18:42bellkevI was wondering if I could do a similar thing programatically with "create-ns" called on a big array of strings basically
18:43bellkevIt seems to work, and I can call "use" on the generated namespaces, but if I try to "require" them, I get "file not found" exceptions...
18:43chouserbellkev: I'm not sure amazonica is the right approach, but you can absolutely create namespaces dynamically and manipulate them with functions.
18:44justin_smithyeah, I haven't looked at this in detail, but they are making some really weird design decisions here
18:44justin_smiththe whole "namespace that only exists to configure some object as a side effect" thing has me skeptical
18:45chouserbellkev: oh, you want your *users* to be able to call require and bring in namespaces that may not actually exist as files on disk?
18:45bellkevWell, the motivation (and I have the same motivation) is to wrap a bunch of things that are "namespacey" with corresponding clojure namespaces
18:45bellkevchouser: that's right
18:46bellkevI mean, say what you will about the way amazonica is made, but using it is a joy compared to the Java api and feels very clojurey
18:46zerokarmaleftis it possible to "unmap" an imported java class via ns-unmap?
18:47bellkevJust do: (require '[amazonica.aws.ec2 :as ec2]) and then (ec2/create-instance {params})
18:47bellkevWhich feels pretty nice
18:48bellkevAs far as dynamically generating the namespaces though, if you do this: (create-ns 'foo.bar) then (require '[foo.bar :as bar]) you get a filenotfound exception
18:49bellkevBecause it seems "require" needs a clj or .class file to be there...
18:50justin_smithbellkev: may help to look at the source of require, then the source of load-libs (which is what it calls) etc. until you find the sequence of calls that can map and load an ns without looking for a file
18:51zerokarmaleftmy motivation is to recompile and re-intern a java class in a repl
18:51justin_smithbellkev: probably what you want is clojure.core/alias if you want the :as feature of require
18:52justin_smithzerokarmaleft: so you want the opposite of import, basically
18:52amalloyzerokarmaleft: why not just skip the import step altogether, and just use the class's full name?
18:52amalloythen you can get your recompile working, which is the hard part, and get back to import if you decide it matters
18:52bellkevYeah, maybe... Except it would be nice if the users of the namespaces I'm making could treat them as normal namespaces, pick their own aliases with ":as", etc...
18:53justin_smiththe other option is to give them a version of clojure.core/require that is not the real one
18:54justin_smithand potentially cause really weird bugs for people who do not realize you have replaced it
18:54bellkevjustin_smith: you mentioned the questionable design choices of amazonica... can you think of an alternative approach to all this stuff?
18:54bellkevhaha, yeah I have no qualms with causing weird bugs for people :P
18:54coventryRemind me never to run your stuff. :-)
18:55justin_smithbellkev: I'll have to consider it. Creating an object of the top level of a namespace is a bad idea.
18:55zerokarmaleftjustin_smith: essentially, yes, though as amalloy points out, it's ancillary to the problem of recompiling and reloading
18:55bellkevI mean, another way to go about things would be to treat these namespaces as some kind of string constants or keys that get passed into generic functions that process them
18:56justin_smithbellkev: a namespace is a hash map where the keys are vars and the values are their definitions
18:56bellkevrather than dynamically generating a bunch of similar but differently named functions
18:56justin_smithbellkev: if you want weird behaviors that are not quite right for a namespace, then make those maps as regular maps
18:57bellkevYou mean use regular maps if I *don't* want weird behaviors, right?
18:57justin_smithno, maps are open ended, you can do all sorts of stuff with them
18:57justin_smithnamespaces are more restricted in terms of proper usage
18:57amalloyuse regular maps if you want behaviors that are weird for namespaces
18:58bellkevoh, I see what you mean
18:58coventryI used a programmatically created namespace and vars in it for internal communication between invocations of a macro. But I wouldn't use it for an API.
18:58justin_smithyeah, that's what I meant
18:59coventryAt least, not an API want people to program to. A short namespace can be useful for interactive repl work.
19:00bellkevOnce created, these namespaces will be pretty normal namespaces (maps of vars/values)
19:00bellkevIt's just the question of how to make them, or to use something besides namespaces
19:01bellkevAre there any good examples out there of libraries that use a whole bunch of (possibly nested) string constants? Because that's another way to think of this I suppose...
19:01coventryThey're easy enough to make. The functions at the bottom of http://clojure.org/namespaces suffice. But it's too much magic.
19:01justin_smithhaving namespaces without files breaks a bunch of pretty reasonable assumptions about clojure code. At the very least make an empty namespace file with a comment that it is filled in programmatically in such and such way.
19:02justin_smithbut even then I would be skeptical
19:02bellkevMaybe just a big map of keywords would be better?
19:03bellkevThat could be used like (create-aws-resource (-> resources :ec2 :instance)?
19:03justin_smithI think so. It is idiomatic.
19:04justin_smithpeople will be less likely to hate you forever, because I totally expect a map to be built dynamically and not be represented literally in a file. But if I find a bug in using a namespace and I cannot even find a file defining it...
19:05coventryWhere is amazonica making these namespaces It looks like it creates big maps.
19:05bellkevThey do have a file per namespace
19:06bellkevBut each file is just a little stub with a function in it that interns a bunch of functions into that namespace
19:06justin_smithwell, no, a bunch of them just run some code on some other object
19:06justin_smiththey just exist to make a side effect happen if you require them
19:06justin_smithwhich is awful
19:08coventryOh, I see. Yeah, why would a simple function be inadequate to that purpose?
19:08justin_smithseriously
19:08bellkevWell, I think the stuff it's doing with other objects is using reflection to pull all the method names out of the Java API objects
19:09bellkevYou guys mean use a simple function that can take some keyword/name or something and invoke the appropriate java method based on it? Rather than dynamically generate all the Clojure functions like amazonica does?
19:10justin_smithis that what amazonica is doing? I didn't get far enough in the inter-file spaghetti to even figure out that much
19:11coventryI suggest at least implementing it that way first, then maybe going back and making the convenience namespaces if it really seems to simplify the usage dramatically for some reason.
19:11bellkevHaha, if you think THAT'S inter-file spaghetti than you must not have to look at enterprise Java apps very much... :P
19:11justin_smithI strive to have higher standards
19:12bellkevDon't you see? MORE files means MORE robust software!
19:14justin_smithso amazonica.core has the functions which will take the various amazon classes and generate the functions in the apropriate namespaces which interop with that class?
19:15bellkevYeah, that's right
19:15justin_smithso where would I go to figure out what functions actually exist - dynamically query the ns-exports in a repl?
19:16bellkeveeh, that or look at the Amazon Java API documentation and convert everything from CamelCase to hyphen-case
19:17justin_smithwouldn't it be less work to just use the interop forms on the original java objects?
19:19bellkevThat AWS Java API makes you set up a request object for everything before calling one of the methods on the "client" object
19:19bellkevI haven't done too much Java interop in Clojure yet... Is there some easy way to call "new" on a class and map a Clojure hash map onto all its setters?
19:20bellkevBecause if so, then it would be pretty easy to use the AWS Java API directly...
19:20justin_smith,(Date.)
19:20clojurebot#<CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: Date, compiling:(NO_SOURCE_PATH:0:0)>
19:20justin_smith,(java.util.Date.)
19:20clojurebot#inst "2013-12-02T00:20:34.944-00:00"
19:20justin_smithcalling new is easy
19:20bellkevand setting a bunch of crap?
19:21bellkevjust use standard Clojure map manipulation for that?
19:22amalloyhttps://github.com/flatland/uncle/blob/master/src/uncle/core.clj has some examples of using java's bean inspector to convert hashmaps into objects with setters, but it's kinda ant-focused so you can't just use it by hand
19:22amalloyer, can't just use it directly
19:25justin_smith,(doto (java.util.HashMap.) (.put 1 "hello") (.put 2 "world"))
19:25clojurebot{1 "hello", 2 "world"}
19:26justin_smithif you want automatic finding of the methods available and conversion to a map, there are things like bean and clojure.reflect. Amazonica uses the clojure.lang.Reflector class directly
19:29amalloyactually it looks like https://github.com/flatland/uncle/blob/master/src/uncle/core.clj#L25 sets properties according to a hashmap, in a way that is not dependent on ant at all, so you could try that if you want
19:29bellkevWell, I think keep using amazonica for now to interact with the AWS API, but for my own stuff (which is just manipulating a bunch of JSON) I'll try to keep things data-oriented and avoid too much namespace fiddling :)
19:29TEttinger,(java.util.HashMap. {"a" 1 "b" 2})
19:29clojurebot{"b" 2, "a" 1}
19:30coventrybellkev: Good call.
19:30bellkevOh, thanks though amalloy that does look cool...
19:40akhudekis it possible to lazily parse a file with gloss? (e.g. if the file is bigger than available memory)
19:40ztellmanakhudek: yes
19:41akhudekztellman: do I need to use channels for that to work?
19:41ztellmansee gloss.io/lazy-decode-all
19:41ztellmanand no
19:44akhudekztellman: ok, thanks, I'll play around with it.
20:20rubber-duckif I put clj file in the same folder as my cljs files and use :require-macros it should get used by cljsbuild right ?
20:21akhudekztellman: what does lazy-decode-all take as input? A bytebuffer?
20:35rubber-duckwhy would cljs compiler not load my clj macro file even when it's finding it on the path ?
20:36rubber-duckI intentionally put a error inside the file it's not complaining, all it's saying is "WARNING: No such namespace: at line 1 client/prodtr/app.cljs" and complains about use of undeclared vars from that ns
20:36clojurebot'Sea, mhuise.
20:51seangroveAlright, now for the other horrible half: given a datastructure, sync the UI state.
20:52amalloyrubber-duck: your ns form is probably broken
20:54Bronsaandyf: fixed #TANAL-15, I had to rewrite the uniquify pass but now is *much* simpler and works as expected, thanks for finding that bug
20:56rubber-duckamalloy, I just moved the clj file in to a different folder and it worked :\
20:57rubber-duckamalloy, it was in top level folder with cljs files, I created a subfolder "macro" and referenced foo.macro.myns and it worked where foo.myns wouldn't work - looks like a cljs bug to me
21:06akhudekhmm, what's a good strategy for lazily (and quickly) loading a stream of variable sized binary data frames?
21:06bitemyappakhudek: lazy-seq?
21:06akhudekthat doesn't really address the file buffering problems
21:07akhudekI've managed to use gloss to write this sort of data quickly.
21:07akhudekbut reading it back lazily requires managing the buffering
21:07akhudekwhich isn't that easy because each data frame can be a different length
21:07bitemyappyour kingdom for Data.Conduit? :P
21:07bitemyappthe data frame length is a non-issue so far as I know.
21:09akhudekswitching to haskell might be a bit of work :-)
21:09bitemyappexplain to me how lazy-seq is a problem with buffering?
21:10akhudeklazy-seq just allows you to construct lazy sequences
21:10bitemyappright, and programming languages allow you to construct programs.
21:10bitemyapphow is lazy-seq not empowering you to solve this problem?
21:11bitemyappif you need read-ahead buffering slap a seque on top of the lazy-seq.
21:12bitemyappakhudek: http://clojuredocs.org/clojure_core/clojure.core/seque
21:12akhudekif you have variable length frames, you can query each for it's length and read in exactly that length
21:12akhudekbut that's probably not a good buffering strategy if the lengths are smallish
21:12bitemyappkeep it simple stupid.
21:27amalloyakhudek: you're worrying about a non-issue. generations of computer scientists have made buffered file i/o easy for you. just read from the file using a handle that buffers, and then it doesn't matter if your reads are large or small
21:32akhudekamalloy: that's a good point. I'm going to blame my not seeing the obvious on a lack of sleep.
21:33kylevjust call it a premature optimization and call it good :)
21:33kylevread stuff, worry about efficient reading later
21:33kylev(and then discover you didn't need to worry later)
21:35akhudekI think gloss not being able to read from a stream is throwing me off. It can handle reading variable sized frames, but it appears to require me to provide it a bytebuffer of exactly the right size to decode a frame, which means I have to write my own decoding code anyways. Confusing.
21:37hiredmanakhudek: I would guess it can take of a seq of bytebuffers
21:37andyfBronsa: It was a lucky accident. Thanks for the quick fix.
21:45alsoanyone here use counterclockwise?
21:45alsotrying to figure out how to debug into leiningen dependencies
21:46justin_smithlein deps :tree helps with debugging your dependencies
21:46alsoi mean, i want to use the eclipse debugger
21:47alsoto step into a java class
21:47justin_smithso wait, this sounds like it has nothing to do with leiningen
21:48alsoit has to do with the treatment of leiningen dependencies by counterclockwise
21:49also"The JAR of this class file belongs to container 'Leiningen dependencies' which does not allow modifications to source attachments on its entries"
21:49also"Leiningen dependencies" here being something provided by counterclockwise
21:50justin_smithOK, I thought I could help, but that is clearly very counterclockwise specific
21:50justin_smithgood luck
21:53also:) thanks anyway
21:54alsowhat's the current state of the art in debugging clojure applications?
21:54alsoI tried counterclockwise simply because i used to use eclipse
21:54seangrovealso: It's not very sophisticated, tooling wise
21:55dnolenalso: in CCW it supposedly "just works"?
21:55seangroveMost people just work in a repl with interactive development. There is ritz if you can get it to work.
21:55alsodnolen: it seemed to work pretty well in my local clojure source
21:55justin_smithI heard good things about cursive, I think you need to sign up for the beta to get that
21:55alsobut not so well with the java dependencies
21:56justin_smithI have seen hlship demonstrate debugging his java deps with cursive
21:56justin_smithcursive is also an eclipse plugin iirc
21:58alsojustin_smith: intellij, looks like
21:58alsobut i'm not picky
21:58justin_smithahh ok
22:00alsoi think the easiest path for me is going to be starting the repl with -Xdebug and connecting from a java ide
22:04justin_smithwith schmetterling we have been able to view both clojure and java stackframes, and view locals in each
22:04justin_smithit doesn't do source browsing per se though
22:08alsojustin_smith: i hadn't seen that, thanks!. it looks interesting, even if it doesn't help right now
22:09justin_smithit is still a young project, so it should be acquiring new features shortly. But it still has some good use cases already
22:12akhudekhiredman: think you are right, but it still seems to require each bytebuffer to represent a complete seq of frames
22:16bitemyappoh we're still discussing this?
22:17bitemyappakhudek: can I give you some drugs so you relax and get back to coding?
22:19akhudekbitemyapp: suspect you are the only one worked up here
22:20technomancy~gentlemen
22:20clojurebotYou can't fight in here. This is the war room.
22:23indigobitemyapp: Drugs?!?!?
22:25technomancyalso: factoids are triggered with ~ and eval is triggered with ,
22:25technomancybut you kind of have to know the factoids up front
22:26technomancyunless you trigger them by accident
22:26technomancyhow?
22:26clojurebotwith style and grace
22:26seangrovehah
22:26seangrove~technomancy
22:26clojurebottechnomancy is to blame for all failures
22:27bitemyappakhudek: I'm perfectly chill, I'm just trying to get you to where I am.
22:27seangroveclojurebot: technomancy is a god amongst men.
22:27clojurebotYou don't have to tell me twice.
22:27technomancy~hiredman
22:27clojurebothiredman <3 XeLaTeX
22:27bitemyappakhudek: you are way too hung up on bits that don't particularly matter. Just write something that works.
22:27bitemyapp~technomancy
22:27clojurebottechnomancy is a god amongst men.
22:27technomancyoh you
22:28brehauthe just wants a free copy of lein
22:28alsosomeday, clojurebot will know my name
22:28amalloyclojurebot: also is this real life?
22:28clojurebotExcuse me?
22:28amalloyoh, i forgot, he can't learn factoids ending with ?
22:29amalloythat's lame
22:29technomancyalso: there's like a 1% chance that any random line will be interpreted as being addressed to clojurebot, so that leads to some crazy stuff too
22:29technomancyplus the wacky inference engine
22:29technomancy~inventory
22:29clojurebotI am carrying 0) a poorly-calibrated inference engine, currently leaking 1) a well-worn copy of clojure 1.2 tucked deep away inside a classloader 2) the last shreds of what was once my sanity
22:29indigo~bitemyapp
22:29clojurebotGabh mo leithscéal?
22:30bitemyappI don't have a factoid.
22:30brehautclojurebot: drop sanity
22:30clojurebotexcusez-moi
22:30brehautclojure: drop shreds
22:30brehautclojurebot: drop shreds
22:30clojurebotHuh?
22:31brehautthese text adventures are all the same. i can never get the right verbs and nouns
22:31bitemyapp~APL is a comonad
22:31clojurebotIk begrijp
22:31seangrovehahaha
22:31bitemyapp~APL
22:31clojurebotAPL is a comonad
22:31seangroveclojurebot: brehaut is eaten by a grue
22:31clojurebot'Sea, mhuise.
22:32bitemyapp~APL is the language of choice of octopodes
22:32clojurebotIk begrijp
22:32bitemyappeggscellent.
22:32akhudekbitemyapp: I know how to write this myself, just though that gloss would do it with less hassle, but it doesn't seem to address this use case. Not a big deal.
22:38bitemyapp~also is enlightened
22:38clojurebotIk begrijp
22:38bitemyappding ding ding, we have a winner.
22:58justin_smith so how long until you can get "micro-drone" instances via aws?
23:20xpeI'm following the steps on http://pedestal.io/documentation/service-war-deployment/
23:21xpeI've got the jetty dependencies in a leiningen :dev profile
23:21xpewhen I examine the generated WAR, they are in the libs directory, which I think may be a problem
23:21justin_smithxpe: why would you have a jetty dependency if you are deploying a war?
23:21xpejustin_smith: I don't want one
23:22xpebut I want to keep it in the project.clj so I can still run the repl and run-dev command
23:22justin_smiththe url you posted says "service war deployment"
23:22xpejustin_smith: yes, I know that :) I'm leading up to my point, you were too fast
23:22justin_smithoh, sorry
23:22xpeit looks like mvn dependency:copy-dependencies is paying no heed to the :dev profile -- it seems to be copying everything
23:22xpeI need to confirm that
23:23xpeside note: lein deps :tree doesn't distinguish between profiles either
23:23nopromptin tbaldridge's macro videos i noticed that when he evaluates a form in a buffer it is copied into the repl as well; does anyone know how that's configured?
23:25coventrynoprompt: He gave code for doing that in the github repository for his core.async talk at the recent conj.
23:25xpejustin_smith you see that I would want to be able to run in the REPL and still deploy, right?
23:25justin_smithxpe: looking at that, I wonder why lein ring uberwar wouldn't work with a pedastal project? it is much simpler than those steps
23:25justin_smithxpe: right
23:25coventrynoprompt: https://github.com/halgari/clojure-conj-2013-core.async-examples#usage
23:25justin_smithxpe: I have used lein ring uberwar and had no container conflicts
23:25nopromptcoventry: thanks!
23:26xpejustin_smith: thanks I will give it a look. I'm glad I did the steps, though, because now I see what is happening in extreme detail
23:28xpejustin_smith: you've used it with pedestal, am I understanding you right? with Jetty? Tomcat? something else?
23:29justin_smithnot with pedastel
23:29justin_smiththat's why I was asking why it wouldn't work with it
23:30justin_smithI doubt they are so different from what I have deployed that the ring uberwar task would break
23:30justin_smithspecifically various versions of caribou, deployed to tomcat containers
23:34xpejustin_smith: I'm skeptical about `lein ring uberwar`. It is yelling at me: for not having `:ring {:handler your.app/handler}`
23:34justin_smithyou have a handler right?
23:34xpeI'm sure it works great for ring, but I don't think it is meant for pedestal
23:34justin_smiththat key is used during war generation
23:34justin_smithOK
23:35justin_smithoh wait, I thought pedastal used ring
23:35justin_smithshows you how much I know
23:35justin_smithoh wait
23:35justin_smithyes it does use ring
23:35justin_smithjust tell it where the handler is
23:38xpejustin_smith: I'm no expert, but I remember the pedestal team modifying some parts of ring to work with interceptors
23:38justin_smithoh, ok
23:38xpethe other catch is that I don't have the "standard" ring handler lying around in my app
23:38justin_smithif there isn't a ring handler (or the equivalent), then yeah lein ring uberwar won't work
23:38xpein any case, I have no fear of doing this "by hand" for now
23:39justin_smithwhat do you mean by standard ring handler?
23:39justin_smithlike there is no one function that puts requests into the middlewares?
23:39xpejustin_smith: I'm not really sure what I meant by that :) just referring to what the lein ring plugin wanted me to point to
23:39xpejustin_smith: I'll put a gist up
23:40justin_smiththe handler is the function that would take a request, pump it through the middleware, and return the response
23:40justin_smithI see that pedastal splits this up into two stages, but there should still be one entery point
23:42xpejustin_smith: maybe so. https://gist.github.com/xpe/d8644065ada8e5ffdc6f
23:43justin_smithbased on the service-war-deployment page you linked above, it looks like YOUR_APP_SERVER_NAMESPACE/servlet-service would be the analog
23:43justin_smithand I could have come to the same conclusion from seing your gist
23:43justin_smithheh
23:44xpejustin_smith: so, I don't mind doing the steps by hand per the pedestal page
23:44xpei'm really close, I have scripts
23:44justin_smithOK
23:44xpethe problem is my :dev profile is getting included in the libs
23:44xpei'd like to find a way to tweak the maven command, if possible, to only copy over my main deps
23:44justin_smithyou can prune things you don't want it to have from the jar, right?
23:45xpejustin_smith: i mean, sure, by hand, but I'm sure maven can figure it out? or maybe I can borrow some leiningen code
23:45xpeif the lein ring plugin can do it, the information is there somewhere
23:46xpejustin_smith: thanks for taking a look
23:46justin_smiththere must be an argument to tell it to use the production / deployment profile
23:46justin_smithwhich would not include dev
23:46justin_smithnp
23:46justin_smiththought it would be simpler
23:46xpere: argument: exactly
23:47justin_smithpedestal looks interesting, but since it is made for end-to-end clojure it didn't really work for our own use case
23:47justin_smithour front end guys are not all excited about switching over from html/js to edn templates and clojurescript
23:47bitemyappjustin_smith: pedestal offers the most advantage when you're doing a lot of data chucking back and forth between server and the smart web-client.
23:47justin_smithmakes sense
23:48bitemyappif you don't have a relatively small number of complex views, it's not going to make a lot of sense.
23:48xpeFWIW, lein profiles are really powerful: https://github.com/technomancy/leiningen/blob/stable/doc/PROFILES.md
23:48justin_smithbut as I said, the people we have writing the web client stuff aren't clojure people, so it would be a hard sell for us
23:48seangrovetechnomancy: Go get 'em! https://twitter.com/ericpallen/status/407356656113045504
23:49xpehmm "In order to prevent profile settings from being propagated to other projects that depend upon yours, the :default profiles are removed from your project when generating the pom, jar, and uberjar"
23:50xpealso "By default the :dev, :provided, :user, :system, and :base profiles are activated for each task, but their settings are not propagated downstream to projects that depend upon yours."
23:50alsointeresting promotion on twitter from t-mobile ceo: http://files.ryanberdeen.com/Sjb7
23:52xpejustin_smith: I learned a nice command: lein with-profile base deps :tree
23:53justin_smithwell that's a chain of two
23:53justin_smithwith-profile
23:53justin_smithand deps :tree
23:55xpejustin_smith: I had to chain them to get the particular deps tree I wanted
23:56justin_smithyeah, just saying
23:56xpeit is not entirely obvious (to me) about which profile is active for which lein task. I think they vary.
23:57xpestrike that. I just had to re-read what I wrote above