#clojure logs

2014-03-23

00:18devnIs it normal to get this: :test/expected (identical? first-result (try-call)), from clojure.test-clojure.delays?
00:19devnI rebased RC2. Is this exception ignored by the CI and its failure is actually a sign things are working?
00:21devnnevermind, looks like an ant build fied it
00:21devnfixed it*
00:43bufferlosshow can I convert a LazySeq to a regular javascript array in clojurescript?
00:46noonian(clj->js my-seq)
00:55amalloyprobably also (apply array some-seq)
01:02bufferloss,(reduce + [1 2 3 4 5])
01:02clojurebot15
01:03bufferlosshow do I get that to give me back an array such as [1 3 6 10 15]
01:03bufferlossnoonian, amalloy, thanks that does the trick re: the conversion from lazyseq thing, any idea how I should go about doing the above type of reduce?
01:03TEttingerbufferloss: reductions
01:03bufferlosswhich, in a way, is not really a reduce or a map
01:03TEttinger,(reductions + [1 2 3 4 5])
01:03clojurebot(1 3 6 10 15)
01:04bufferlossawesome thanks
01:04amalloy$findfn + [1 2 3 4 5] [1 3 6 10 15]
01:04lazybot[]
01:04amalloyreally, lazybot? shouldn't that be reductions?
01:04TEttingerI'd be surprised if it could find it...
01:04TEttingerbesides it returns a seq not a []
01:04amalloyit compares with =, of course
01:05bufferloss,(reductions + [[:foo 1] [:bar 2] [:baz 3] [:qux 4] [:noop 5]]
01:05clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
01:05bufferlossso what if I need to do that to just the second item of each sub item / sub array
01:05amalloy&(doc map)
01:05lazybot⇒ "([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]); Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. An... https://www.refheap.com/63825
01:06amalloy(reductions + (map second ...)), depending on what you want
01:07bufferlossamaloy I want to turn [[:foo 1] [:bar 2] [:baz 3] [:qux 4] [:noop 5]] into [[:foo 1] [:bar 3] [:baz 6] [:qux 10] [:noop 15]]
01:08TEttinger,(reductions (fn [[k1 v1] [k2 v2]] [k2 (+ v1 v2)]) [[:foo 1] [:bar 2] [:baz 3] [:qux 4] [:noop 5]])
01:08clojurebot([:foo 1] [:bar 3] [:baz 6] [:qux 10] [:noop 15])
01:09bufferlossawesome thanks
01:10TEttingerusing the [[]] argument destructuring to get the pairs as separate elements
01:22amalloybufferloss: most irc clients let you tab-complete other users' nicks. when you spell mine wrong, my client doesn't notify me, which is why i didn't notice your question
01:24bufferlossamalloy, true, I usually use tab complete, just... didn't... that time
01:25amalloyi can't imagine not using it. sometimes i try to tab-complete ordinary words mid-sentence if my brain decides they're so obvious my client should figure out what goes next
01:25bufferlossanyway, next question is, is there a common way to deal with js "history" in clojurescript? the modern-cljs tutorial has each endpoint be static HTML files
01:26bufferlossI'd like to do something more "backbone router" ish, so the app changes when the hash tag in the address bar changes
01:28blakeAnyone here able to help me connect to sqlite3? I keep getting "missing required parameter".
01:30nopromptbufferloss: https://github.com/gf3/secretary/
01:31bufferlossnoprompt, awesome thanks
01:32nopromptbufferloss: i'm not completely sure if that's what you're looking for but we've put a lot of work into it and more features are on the way.
01:34bufferlossnoprompt, looks almost exactly like what I want
01:35nopromptbufferloss: awesome. let us know if you have any ideas on how we can improve it.
01:36bufferlossnoprompt, can I (defroute "/users/:id" {:as params} foo-namespace/render-view-function) ?
01:36bufferlossor must I define/run the thing inline?
01:36bufferlossas in can I pass in a handler instead of defining the handler right there?
01:36nopromptbufferloss: yeah, but i think you mean (foo-namespace/render-view-function))
01:37bufferlossnope, I mean what I pasted actually
01:37bufferlossso I can define the function, with params etc that handles the route entirely in another file
01:37bufferlossthough now that I'm thinking of it, I guess it's not a lot different to actually invoke that handler right there
01:37nopromptwell you can pass the function the params
01:38bufferlossright
01:39bufferlossnoprompt, is dommy any better than e.g. domina or enfocus?
01:39bufferlossdoes hiccup run in clojurescript?
01:39bufferlossI don't see much difference between them right now
01:40nopromptbufferloss: that really depends on what you're doing and how you want to manipulate the DOM. a lot of folks are using Om/Reagent/etc. to build frontend applications w/o directly manipulating the DOM.
01:41_eric,(= '(#"cat.*") '(#"cat.*"))
01:41clojurebotfalse
01:41_ericwhy don't those match?
01:41_ericis there a different sort of equality I can do?
01:42nopromptbufferloss: dommy doesn't render to a string, it creates DOM nodes so there's a big difference there already. it's fairly transparent though.
01:42bufferlossnoprompt, yeah I intend to investigate Om pretty soon, still starting slow/basic for now
01:42_ericah, just found this: http://dev.clojure.org/jira/browse/CLJ-1182
01:42nopromptdommy is also *very* fast.
01:43bufferlosswas wondering if there is something more akin to underscore.js' _.template() function for clojurescript
01:43bufferlosssuch that my designers can still work with "html"
01:43bufferloss(le sigh, yes it's a thing)
01:43nopromptbufferloss: i might go with the enlive flavor of templating then.
01:44nopromptbufferloss: working with html and designers is fine. i'm a designer and a programmer. both are hard. both groups need to be happy. :)
01:45bufferlosscool, yeah enfocus looks like it'll work, thanks
01:45nopromptenlive is fun btw too. you can do a lot of cool stuff with it.
01:45bufferlossenlive enfocuse? I did a google for 'clojurescript enlive' and all I got was enfocus
01:45nopromptyeah sorry, enfocus seems to be for the client. my mistake.
01:46noprompti wish that guy cgrande thought about clojurescript when he puts his libs together. they guy does great stuff.
01:50muhooi'm pretty sure that when most of his more popular libs were written, clojurescript wasn't yet a thing
01:56nopromptmuhoo: true, but enliven is newer.
01:57nopromptmuhoo: to be fair though he does make judicious use of java libraries instead of reinventing the wheel.
01:57nopromptwhich is a good thing.
02:22bufferlossso I'm getting "nothing" when trying to use (ef/at "body" (ef/content "Home Page Enfocus!"))
02:22bufferlossdommy works at the exact same line, but enfocus seems to "do nothing"
02:37bufferlossnoprompt, I can't get my non home page route to trigger :/
03:40muhoois there any reason why a clojure heroku push would just hang at compiling and never do anything?
03:41muhooit compiles all the namespaces, then just hangs
04:22muhooduplicable with just plain lein uberjar. aot problem somewhere :-/
06:11Pate_has anyone seen Pallet? https://github.com/pallet/pallet-docker
06:11Pate_*or is using it.
06:18AeroNotixin emacs, are there switchable indentation modes for Clojure?
06:18AeroNotixas in clojure-mode.el -> choose indentation style
06:18AeroNotixor w/e
06:43AeroNotix(setq clojure-defun-style-default-indent t)
06:43clojurebotPardon?
06:43AeroNotixdone
06:43AeroNotixclojurebot: you heard me
06:43clojurebotAeroNotix: I'm just giving you a second chance
06:43AeroNotixclojurebot: NO U
06:43clojurebotPardon?
06:48unsymbol:3
07:05Pate_I'm running my Clojure REPL inside a Docker container. Problem is, without repackaging a new Docker image with the latest dependencies, Leiningen re-downloads the project's dependencies every time I run the container. An obvious solution would be to mount a volume in the Docker container where all the dependencies are cached. Is there a way to override Leiningen's jar cache location?
07:10mr-foobarin cljs lib secretary, I can currently get client side routes like localhost/ and localhost/#/foo can I have routes for localhost/foo ?
07:13mercwithamouthdoes anyone here use datomic? i'm still trying to wrap my head around what it's about...what use cases does it solve over a traditional relational database?
07:18dnolen_mercwithamouth: it's immutable
07:29mercwithamouthdnolen_: hrmm, ok. i guess i have to reach the point of dealing with concurrency more before it's of value to me. biting on more than i should chew a the moment. just curious
08:08l3dxis it possible to fetch lein plugins directly from github?
08:20john2xwhy is this throwing ClassCastException (-> "bar" #(str "foo" %))?
08:20john2x,(-> "bar" #(str "foo" %))
08:20clojurebot#<CompilerException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.ISeq, compiling:(NO_SOURCE_PATH:0:0)>
08:21pyrtsa,(-> "bar" (#(str "foo" %)))
08:21clojurebot"foobar"
08:21john2xpyrtsa: thanks
08:22pyrtsaThe expression #(str "foo" %) converts into somethign like (fn [x] (str "foo" x)) which would be turned into (fn "bar" [x] (str "foo" x)) by ->.
08:22dnolen_,(macroexpand '(-> "bar" #(str "foo" %)))
08:22clojurebot(fn* "bar" [p1__77#] (str "foo" p1__77#))
08:23pyrtsaIt's a shame that that happens, but macros aren't perfect.
08:48ptcek_Anyone working on bumping clojuredocs.org to 1.6 or so?
09:37Bbarrettquestion, I was reading the clj discussion group, specifically a discussion with Steve Yegge, and someone mentioned that Clojure might have problems with the (read-line) function in certain contexts (like reading user input), anyone ever experience this
09:37BbarrettI had to create a channel and have my app read from the channel, rather than just a simple (read-line), couldn't figure out why
09:38Bbarrettit just kind of skipped over the whole user input part in any function i included it in
09:55Curious_,(+ 2 3 4)
09:55clojurebot9
09:56s0x_hey guys, is it possible to use a stored vector for let, e.g. like this: (def x `[a 42 b :some]) (let [x] (println b) a)
09:58elephantTechnoThat would be (let x ...
09:58elephantTechnoAnd I guess you can't do that without a macro
09:59s0x_elephantTechno: let x ... doesnt work ... i would have guessed so :-/
09:59elephantTechnoEg `(let ~x ...
10:05s0x_elephantTechno: well macro works fine ... thx anyways :)
10:05ptcek_,(.getDate #inst "2014-03-14T23:00:00")
10:05clojurebot#<SecurityException java.lang.SecurityException: denied>
10:06AeroNotixs0x_: https://gist.github.com/AeroNotix/3dc016ad70e351bb2a02
10:07AeroNotixs0x_: but you have to ask yourself, "what am I doing this for"
10:07AeroNotixperhaps there's a better way to do what you want. I doubt very much that this is what you want
10:07Pate_in project.clj, under :aliaser, why do some string values have trailing commas, e.g. "run-client" ["do" "bower," "cljsbuild" "once" "dev," "less-debug," "resource," "httpd" "8000"] ?
10:07Pate_*:aliases
10:22hyPiRionPate_: it's to run multiple commands
10:23hyPiRionit's like `lein bower; lein cljsbuild once dev; lein less-debug; lein resource; lein httpd 8000`, just more efficient
10:23Pate_why not: "run-client" ["do" "bower" "cljsbuild once dev" "less-debug" "resource" "httpd 8000"] ?
10:27hyPiRionPate_: Would hard to do varargs, like ["do" "httpd" ~PORT]
10:29hyPiRionbut it's possible to do ["do" "bower" ["cljsbuild" "once" "dev"] "less-debug" "resource" ["httpd" "8000"]] I think
10:29hyPiRionIf not, you'd wrap the no-arity tasks with []
10:29Pate_yeah, that makes sense.
10:29Pate_what does "do" mean?
10:33Pate_I'm having a hard time doing live dev. How do I live update compojure routes by connecting to an nREPL?
10:34Pate_I have a simple om/compojure app. I can run "lein dev", which starts a headless ring server, but how do I connect to that running instance and modify it live?
10:35Pate_"dev" alias defined as follows: :aliases {"dev" ["pdo" "cljsbuild" "auto" "dev," "ring" "server-headless"]}
10:37Pate_do I need to add drawbridge as a ring handler to connect to a running ring server?
10:43hyPiRionPate_: `lein help do`
10:43Pate_is pdo like do but in parallel?
10:44Pate_it's not obvious to me how the alias chaining works
10:44Pate_e.g. ["do" "bower," "cljsbuild" "once" "dev," ... -- how does "do" fit into things here?
10:45Pate_sorry, I'm not sure if I'm asking theis lein-specific questions in the right place.
10:45Pate_*these.
10:46hyPiRionPate_: It's just like running several tasks in succession from the command line
10:46hyPiRionjust a bit faster
10:46Pate_because it shares the same JVM?
10:47hyPiRionyeah, no need to setup Clojure and leiningen again
10:47Pate_ermagerd, *discovers :auto-reload? true and :auto-refresh? true*
10:51Pate_is anyone using Light Table as their main editor?
10:5223LAA142J<table></table>
10:5223LAA142J^^ That's a light table right there
10:52unsymbolhaha
11:06Pate_What's the difference between ring-server and ring-serve ?
11:09Pate_As a non-Emacs user, I'm really struggling with Clojure's development story :(. I have an nREPL started, and I'm requiring ring-serve in my core.clj file, but when I connect to the nREPL with Light Table and try to evaluate ring.util.serve/serve, it complains with a ClassNotFoundException
11:17Pate_How do I run "lein ring server-headless" inside a REPL that I can connect to from Light Table?
11:21technomancyPate_: you need a dependency on ring-jetty-adapter; call run-jetty inside the repl
11:21Pate_I think I got it working with ring-server
11:21Pate_(use 'ring.server.standalone)
11:22technomancyI usually do something like this: https://github.com/technomancy/syme/blob/master/src/syme/web.clj#L146
11:22Pate_(serve my-handler)
11:23Pate_technomancy, what's the difference/similarities between jetty and ring? As a I undertand it, ring is middleware for HTTP stuff and Jetty is a web server. But ring can also serve web things.
11:24technomancyPate_: ring can't serve things on its own
11:24technomancyit probably brings jetty in anyway
11:24Pate_ah, I see. What happens when you run "lein ring server-headless"? Does it run jetty under the cover?
11:25technomancyprobably. I don't run lein ring myself; I don't see the point.
11:25Pate_I'm still noob. I'm trying to get a smooth dev env going.
11:25Pate_All of this knowledge is pretty spare on the interwebs.
11:25technomancyIMO it's simpler if you run everything from the repl instead of launching some stuff from the CLI
11:26Pate_yeah! I want to do that.
11:26technomancyif it's just a function call then you know exactly what's going on
11:26Pate_I'm trying to get a basic Om/Datomic thing going
11:27technomancythe getting started situation for clojurescript is still pretty rocky afaict
11:27Pate_yeah, lots of dependencies. But it's getting better.
11:32Pate_If I want Om to do things when something changes on the server, in realtime, what should I be looking at? http-kit?
11:36DomKMPate_: I'd recommend taking a look at Sente https://github.com/ptaoussanis/sente
11:36DomKMPate_: It depends on http-kit. I've found it very easy to use.
11:37Pate_awesome, thanks DomKM.
11:38Pate_ah, so Ring server is Jetty and http-kit is almost a drop-in replacement
11:42Pate_how do I get the source of a function from the repl? (:source (meta #'+)) doesn't work.
11:44sveriPate_: (source +) does the trick
11:44Pate_hmmm. works now, but was getting source method not found a while back
11:44Pate_ah, have to do (use 'clojure.repl)
11:45sveriPate_: hm, I started "lein repl" from a leiningen project and (source +) worked without loading a namespace
11:46kirasdoes lein repl clojure.repl implicitly?
11:46kirasuse
11:46kirasseems like it must
12:00michaniskinclojure.repl is refer'd into the user namespace
12:00kirasok, thought it must be something like that
12:01michaniskinwhen you evaluate things in other namespaces you need to do (use 'clojure.repl)
12:33whodidthiscan i set up functions in clojurescript i can call from javascript after they get closure compiled
12:35malynwhodidthis: Yes, you just need to mark them as ^:public.
12:49whodidthisdoesnt seem to do anything but solved with ^:export meta
12:50malynOh, right, it's ^:export, not ^:public. I always get that backwards. Sorry about that!
12:51whodidthisnoprobs at least u told me where to look from
12:56teslanickHow would I combine something like Carmine's wcar* macro (https://github.com/ptaoussanis/carmine#connections) with pulling the redis host name from a command line argument?
12:56teslanickCould I just set! the global var and have that work?
13:43AeroNotixIs there a mocking library which will allow me to do stuff like "Mock this function after it was called n times."
13:44AeroNotix?
14:22jjl`you can always write such a thing
14:49patrickodis there an easy way to make light table use a leiningen profile when evaluating things?
15:20teslanickAre there examples/docs for core.async outside of put, take, and alts?
15:30technomancypatrickod: lein profiles are activated when the project starts
15:30technomancyyou can't apply them inside a repl session
15:31patrickodis there a way to specify one in particular though? i.e. test?
15:31technomancypatrickod: you would have to change the command used to launch lein; I only know how that works for emacs
15:32patrickodokies. I'm not too pushed on Light Table at the moment. Just trying it out as I'm writing this test suite.
15:32technomancyI would recommend putting anything you need for tests to pass into the dev profile though
15:32patrickodI'm guessing I could look to replicate the same inline evaluation with vim
15:34patrickodthe main issue was w/ the ring-mock dependency. I added that in and it seems to be ok now
15:35patrickodcoming from other languages where I'd keep the dev / test dependencies separate I didn't think to do that initially
15:36technomancyyeah, that definitely goes in dev dependencies
15:36technomancythe test profile is honestly not very useful
15:37s0x_hey guys, i was asking earlier how to build a let which takes a vector (known at runtime only). Im still struggling with it unfortunately
15:38patrickodhuh good to know.
15:38s0x_(defmacro mylet [v & body] `(let ~v ~@body)) results in an illegal argument exception
15:38s0x_"let requires a vector for its binding ...
15:39brehauts0x: using a macro at runtime? smells like a mistake
15:40brehaut~xy
15:40clojurebotxy is http://mywiki.wooledge.org/XyProblem
15:40s0x_um ... the macro should just extend the vector v to [a 1 b 2]
15:40brehauts0x_: how about you explain the real problem you are trying to solve
15:43s0x_well im trying to build a mini dsl which knows a few keywords which are provided by a structure ...
15:44brehauta good guideline for DSLs (if you must write them) is to write them as functions first, and only then add macro layers if they are still difficult to work with
15:45s0x_thats exactly why i need a macro here (as far as i do get them right :D)
15:45s0x_i dont know a way to expand my vector to use it by let
15:45s0x_like (let v (println a)) doesnt work at all
15:45brehauts0x_: thats because macros are a compile time facility (unless you are doing some deeply esoteric stuff. *handwaving*)
15:46pyrtsas0x_: So you get that vector v dynamically (at runtime)? Is it user input? Is it always of the shape [the-symbol-a value-for-a the-symbol-b value-for-b]?
15:46s0x_pyrtsa: yes it is
15:46brehauts0x_: if you want to pass an environment around you sure look at maps of keywords to things
15:46s0x_the vector is a record actualy
15:47pyrtsaThen, if you know that the block always uses the variables a and b, why don't you just capture the user input as a map and do something like (let [{:keys [a b]} the-input-map] ...)?
15:48pyrtsaAnd a record with keys a and b will also work in my example.
15:48s0x_just because i was wondering if there is a way to catch even the additional fields of the record
15:49pyrtsaSure you can capture those as well.
15:49s0x_btw, i would have to replace the key by symbols obviously :)
15:49s0x_pyrtsa: how?
15:50pyrtsaFor example:
15:50pyrtsa,(defrecord Foo [a b])
15:50clojurebotsandbox.Foo
15:50pyrtsa,(let [{:keys [a b c]} (assoc (Foo. 1 2) :c 3)] [a b c])
15:50clojurebot[1 2 3]
15:50pyrtsa,(let [{:keys [a b] :as m} (assoc (Foo. 1 2) :c 3)] [a b m])
15:50brehaut,(let [{:keys [a b] :as m} {:a 1 :b 2 :c 3}] [a b m])
15:50clojurebot[1 2 #sandbox.Foo{:a 1, :b 2, :c 3}]
15:50clojurebot[1 2 {:a 1, :c 3, :b 2}]
15:50s0x_um thats not what i wanna do :(
15:50pyrtsaHeh, high 5.
15:51pyrtsas0x_: Then I don't understand and you should probably write a better example of it online.
15:55s0x_fair enough ... just a sec
15:59s0x_http://pastebin.com/MAEQqSDL
15:59s0x_whats what i have so far
16:00pyrtsaSo, only v is user input?
16:00s0x_yes
16:01pyrtsaOh, should :c somehow refer to the values of keys :a and :b?
16:01pyrtsaAre you expecting c to be {1 [1 2]} and not {:a :b}?
16:01s0x_um ... not really
16:02s0x_sry ... a bit confussing maybe ...
16:02pyrtsaOkay, so just {:a :b}.
16:02s0x_yes :)
16:02pyrtsaAnd also ignored by the block of code you've got there.
16:02s0x_so the result i wanna get is (let [a 1 b [1 2] c {:a :b} (println a) b)
16:03pyrtsaJust do what I and brehaut adviced above.
16:03pyrtsa,(let [{:keys [a b]} {:a 1 :b [1 2] :c {:a :b}}] (println a) b)
16:03clojurebot1\n[1 2]
16:04s0x_how should i do that if v is the user input and i dont know if the symbol is a,b,c or even x y z
16:05pyrtsaThen you should dig out the keys dynamically anyway. By asking what you asked, you were kind of implying that :a and :b are special.
16:05brehautit seems like you are trying to bring a lot of magic into play just to operate on structured data
16:07s0x_i know ... and i know that this is exactly what i wanna do
16:07s0x_and i think it should be possible somehow
16:08pyrtsas0x_: Okay then, what should a and b be if v doesn't include values for :a and :b?
16:09s0x_like in this example a should be 1 and b [1 2]
16:09s0x_but only for this example
16:09s0x_i wanna do something like (let v some-val-of-sym-from-v)
16:10pyrtsaI'm afraid there's little people can do to help you.
16:10s0x_i just wanna provide the vector which is used for let not explicit but from a variable
16:11pyrtsaThat you can do only at the compile time. (Of course, you can compile new code with (eval ...) and such in the runtime as well, but that's a different story.)
16:11s0x_hmm ... well :_/
16:13AeroNotixs0x_: do you have a use-case where you absolutely cannot proceed without dynamic let binding forms?
16:14s0x_AeroNotix: Yes i've
16:14s0x_pyrtsa: thanks for the hint ...
16:14s0x_using eval will solve the issue :p
16:14AeroNotixs0x_: what's the use-case?
16:16s0x_there has to be a small dsl controlling robots. you can access any value of the state using a symbol like (= state :landed)
16:16s0x_while state may be any key stored in the state of the robot
16:16s0x_args ... (= control-state :landed) is the one :)
16:17AeroNotixso (= state :landed) sets the state to landed?
16:18s0x_(= control-state :landed) checks if the robot has landed yet
16:18AeroNotixs0x_: there's already a DSL for that
16:18AeroNotixit's called (if ...)
16:18AeroNotixit's pretty cool
16:18s0x_lol
16:19AeroNotixI still don't see why you need the dynamic let vector, though
16:19s0x_"you can access any value of the state using a symbol"
16:19AeroNotixchanging (= state :landed) to an if form is child'
16:19AeroNotixchild's play
16:20shaungilchristI get the feeling the use case has not been fully stated?
16:20AeroNotixprobably
16:20s0x_well ... it is ... nevermind
16:20AeroNotixI just think you're trying to overcomplicate something
16:20shaungilchristbut yeah in general any time you start reaching for dynamic/runtime destructuring you've made a wrong turn a few moves back
16:23s0x_is it that hard to understand?
16:23s0x_well i hope it's not the language barier :p
16:23AeroNotixs0x_: nope. It just sounds like extremely poor design.
16:26s0x_http://pastebin.com/eppGkfrs
16:26s0x_well ... an example of the thing
16:26AeroNotixs0x_: looks like you want an FSM
16:27brehautits not really a surprise that the idea of DSLs become popular with both lots of runtime dynamism and a lack of first class functions. it seems a pity to repeat the mistakes when thats not the case
16:27brehauts/with both/with a language with both/
16:27AeroNotixs0x_: this looks good: https://github.com/cdorrat/reduce-fsm
16:28AeroNotixand (set happy true) is just ridiculous
16:28AeroNotixThere's plenty of built-in state management niceties in Clojure, what's wrong with those s0x_ ?
16:29s0x_i will use them ... thats just a mapping to make things easy to the controller ...
16:30AeroNotixs0x_: what's "the controller" ?
16:30s0x_the guy how controls the robot
16:32AeroNotixs0x_: so this example code here, I'm *still* not even close to understanding why you need that dynamic let binding?
16:32AeroNotixthe example you gave here is a tiny macro which takes a single form and a body and turns it into an if/else expression
16:32AeroNotixs/is a/could be a/
16:33s0x_well ... only an if ...
16:33s0x_anyways ... control-state is a symbol
16:33AeroNotixand?
16:34s0x_and this should be mapped to a value you can find inside the robot using the keyword :control-state
16:34AeroNotix,(keyword 'omfg-a-keyword)
16:34clojurebot:omfg-a-keyword
16:34AeroNotixso if there is some state associated with the robot, turn the symbol The Controller provides into some accessor on that state
16:35AeroNotixusually it's going to be a map
16:35s0x_im not sure if i got you right but i think yes
16:36AeroNotix~xy
16:36clojurebotxy is http://mywiki.wooledge.org/XyProblem
16:40s0x_http://pastebin.com/a8kBszwZ
16:40s0x_thats what might result from the commands
16:41s0x_is not a blockage if its part of my research
16:41s0x_s/blockage/blockade/
16:51shaungilchristand the potential symbols in robot are unknown at read time?
16:54shaungilchristcrazy talk or not one more involved approach would be to come up with a prefix for symbols you want to get from robot e.g. (= ?control-state :idle)
16:54shaungilchristwalk your exprs to build up vector of symbols and put that into your expanded let form
16:59jasonjcknjust booked my ticket for clojure/west
17:00AeroNotixI'm going to EuroClojuer
17:00AeroNotixEuroClojure*
17:00jasonjcknnice!
17:01s0x_shaungilchrist: thats sounds indeed not bad ... even if i think i didnt get the whole thing
17:02s0x_but actually the expanded let form is the problem here :)
17:04shaungilchristwell in this case you would expand to (let [{?control-state :control-state} robot] ....) negating the need for eval or runtime left-hand destructuring
17:11s0x_shaungilchrist: great idea ...
17:11s0x_thanks ... that should work even better :)
17:12shaungilchristif you are going down this route - flatten and filter with a predicate that finds your special prefixed symbols (as you don't need to replace them this is fine)
17:14shaungilchristbut I still have to say if I saw this "in the wild" I'd definitely want to see why such an approach was necessary. The good and bad thing about lisp is that there is an infinite amount of "how" - explaining the "why" is still your job.
17:19ToBeReplacedif i have channels ch and #{x y z}, how do i say (alt! ch true [x y z] false) by referencing #{x y z} as a group like "channels"... (alt! ch true (vec channels) false) doesn't work
17:33shaungilchristuse alts! and check for the port being in #{x y z}
18:43irctcI cloned a library in git, then did maven install. It appears alongside the clojar'd version of the lib in my ~/.m2, which is what I expected. I updated my project.clj to depend on "FOO-SNAPSHOT" which is the subdir name in ~/.m2... I did lein reps, which returned (ok) with no output. But when I try to run the project, it cannot find the core__init.class or core.clj on classpath. What did I do wrong / forget to do? I am a newbie
18:43irctc"lein deps" above stupid spell corrector
20:09guest23432if anyone knows anything about yesql, I'm trying to load basic example, and getting "No namespace: yesql types" ... I'm copying directly from the readme on https://github.com/krisajenkins/yesql
20:10guest23432sort of new to clojure; guesses as to what's going on? HUGE thanks to anyone.
20:11noonianif you shared your failing code on refheap it'd be easier to help
20:11noonianyou will need to restart your repl if you added the dependency after you started it originally
20:11guest23432will do, one moment. thanks!
20:14guest23432https://www.refheap.com/64420
20:15guest23432that's copy-pasted from two files:
20:15guest23432 [yesql "0.4.0"] is in project.clj dependencies
20:16guest23432using lighttable..
20:16noonianthe first one looks fine, for the second one, you don't need to quote anything inside the ns form in your source code, just in the repl
20:16noonianif you're using light table as your repl make sure to evaluate each form including the ns fomr
20:17guest23432that's what I thought. first one spits 'No namespace: yesql.types though
20:19noonianand you included the dependency before connecting to your project in light table
20:19noonian?
20:20guest23432like it knows to go over and get yesql, bring it in, and can find the other parts...
20:20guest23432yes. included dependency. have disconnected-> re- "Add connection"; restarted LT; ...
20:21nooniandefinitely strange, it would need to evaluate yesql.core to even know to try to pull in yesql.types so it must be on the classpath
20:22guest23432doesn't complain about parser or util : https://github.com/krisajenkins/yesql/blob/master/src/yesql/core.clj
20:22noonianare you trying to use a function from yesql.types somewhere further down in your program?
20:22guest23432that's all there is in the file..
20:22guest23432haven't even gotten to an actual function, ha!
20:24noonianhmm, have you tried requiring it from a normal repl?
20:24boreHello guys - a (stupid) question. If I have a keyword :foo and a var with the same name (def foo :bar). Can I access the war knowing the keyword. Something like... (symbol :foo)
20:25boreAs you might have guessed from the question I am still finding my way around clojure
20:25guest23432have not tried normal repl
20:25guest23432* yet. stand by ;)
20:26noonianyou could use (resolve (name :foo)), but if you are new to clojure, this isn't a very common thing to need to do
20:26noonianer, (resolve (symbol (name :foo)))
20:27noonian,(resolve (symbol (name :identity)))
20:27clojurebot#'clojure.core/identity
20:27guest23432ah, lighttable is now spitting: "no such var: jdbc/execute!"
20:27borethanks I'll try it out
20:27guest23432...and re-evaluate and its 'no namespace yesql.types'
20:28noonianimo you probably shouldn't try to resolve classpath and require issues from within light table, it's hard to tell when your code has already been loaded or not
20:28noonian,(doc resolve)
20:28clojurebot"([sym] [env sym]); same as (ns-resolve *ns* symbol) or (ns-resolve *ns* &env symbol)"
20:28guest23432ok. good to know. thanks.
20:28noonian,(doc ns-resolve)
20:28clojurebot"([ns sym] [ns env sym]); Returns the var or Class to which a symbol will be resolved in the namespace (unless found in the environment), else nil. Note that if the symbol is fully qualified, the var/Class to which it resolves need not be present in the namespace."
20:29boreThis way I get the var itself and not the value it holds
20:29bore,(doc deref)
20:29clojurebot"([ref] [ref timeout-ms timeout-val]); Also reader macro: @ref/@agent/@var/@atom/@delay/@future/@promise. Within a transaction, returns the in-transaction-value of ref, else returns the most-recently-committed value of ref. When applied to a var, agent or atom, returns its current state. When applied to a delay, forces it if not already forced. When applied to a future, will block if computation n...
20:29noonianif you just want the value you can defef the var
20:30noonian,(dereg (resolve (symbol (name :identity))))
20:30clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: dereg in this context, compiling:(NO_SOURCE_PATH:0:0)>
20:30noonian,(deref (resolve (symbol (name :identity))))
20:30clojurebot#<core$identity clojure.core$identity@18e7ed>
20:30borethis is getting quite funky now - you are probably right that it is non idiomatic to access data like this
20:30boreit doesn't look particulary nice
20:31borethank for widening my horizons
20:31noonian,(-> :identity name symbol resolve deref)
20:31clojurebot#<core$identity clojure.core$identity@18e7ed>
20:31nooniana little cleaner, but if you want to look this stuff up at runtime, just but your functions in a map
20:32noonian{:foo (fn [x] (println x))}
20:33borethanks for the tip
20:36nooniannp
20:44guest23432noonian: I'm an idiot. good to include [org.clojure/java.jdbc "0.3.3"] higher in dependencies. all appears to be well. can find yesql.types
20:45guest23432don't some libraries call other libraries... goes and grabs what they need... I was assuming yesql was pulling in whatever "DB" stuff it needed. (not a very sound assumption)
20:47bjaguest23432, you can always check that with "leon deps :tree"
20:47bjaerr, "leon reps :tree"
20:47bjafucking autocorrect
20:47guest23432lein
20:48guest23432I gotcha
20:48bjayeah, that thing
20:48guest23432leon is useless anyway
20:48arkhI'm so making that a new project
20:48guest23432good for nothing bum. never knows what you're talking about in CLI
20:49guest23432leon should be a project to make sure shit ain't misspelled;
20:50guest23432or whatever you want to make. you know. you're the one who said you wanted to make it something.
20:50guest23432good luck and god speed. send my regards to leon.
21:06upwardindexMust I really have the whole goog javascript library in my uberjar?
21:21aphyrHas anyone seen wildly unpredictable performance from reducers?
21:22aphyrhttps://gist.github.com/aphyr/9732470
21:23aphyrfoldcat can consume 68% of 48 cores for 16 seconds... or maybe it'll complete in 600ms
21:23aphyrOr anywhere in between, really
21:23jcromartiemy first instinct says GC
21:24jcromartieoh wait
21:24jcromartiefirst time, you are realizing a massive lazy seq?
21:24aphyrvec
21:24aphyrIt's realized.
21:24aphyrIt varies thereafter basically at random
21:24aphyrsometimes really fast, sometimes slow.
21:26jaccarmacHello all!
21:27jcromartieaphyr: I'd guess you are near the memory limit of your process and you are ending up GC'ing something
21:27jcromartiebut just a hunch
21:27hiredmanaphyr: I've not seen it, but I don't have any 48 core machines, maybe replace the reducers forkjoin pool with one with a smaller parallelism factor to see if there is some threshold for the weirdness
21:29aphyrkk lemme retry with 100g heap
21:29jcromartiewhat the bloody hell are you running on?
21:29aphyrmy desktop
21:29jcromartieseriously
21:29jcromartiehow
21:29aphyryes
21:29jcromartie:)
21:30aphyrI got tired of waiting for slow Clojure programs haha
21:30aphyrand analyzing 32gb heap dumps is a lot easier with 128gb of ram
21:31jcromartiebut the 48 core thing… I am not even aware of how to buy or build a machine like that
21:31aphyr2x xeon e5-2697s
21:31aphyr12 physical, 24 virtual cores/socket
21:32aphyroh intriguing
21:32aphyrthis is indeed a GC issue
21:32aphyrit wasn't showing up in the instrumentation because the instrumentation hung during the GC
21:32aphyrthat's a new trick, haha
21:33aphyrRaising the heap gets it to be reliably fast
21:34aphyr15 seconds GC pause in the REPL: it's fiiiiine
21:34jcromartieaphyr <-- 0th world problems
21:34aphyr[Full GC [PSYoungGen: 2228064K->0K(7456768K)] [ParOldGen: 18404882K->17010297K(22369792K)] 20632946K->17010297K(29826560K) [PSPermGen: 16295K->16280K(32768K)], 5.7822210 secs] [Times: user=171.45 sys=2.29, real=5.79 secs]
21:40aphyr[GC[ParNew: 619968K->68864K(619968K), 1.3309380 secs] 10448396K->10220077K(10773416K), 1.3310350 secs] [Times: user=6.36 sys=0.41, real=1.33 secs]
21:40aphyr1.3 second parnews repeated 15 times in a row: its' FIIIIINE
21:47aphyrWeirdly enough, despite running 48 fj threads, it only eats ~6% CPU
21:54jcromartieyou know, this whole "multicore future" thing seems a bit far away to me, when I realize that basic parallelism on a quad-core machine will never buy me the 10X speed improvements that result in perceptible differences to the average user
21:54jcromartiebut on a 48 core machine
21:54jcromartieI'd imagine that it's actually really, really, noticeable
21:55jcromartieone day that will be fairly normal, no?
22:13aphyrYeah, Clojure literally gets me a 40x speedup on this box if I do it right
22:13aphyrbut this reduction problem I'm working on... getting nowhere near that kind of speedup out of reducers
22:13aphyrmay go back to explicit threads
22:59vermais there a way for me to be notified when an atom's value is changed? either through reset! or swap! so that I can trigger a callback, I looked at reflex, but that climbs up the dependency tree on deref
23:00Bronsaverma: add-watch
23:00vermanice!
23:00vermalet me check
23:31vermaBronsa, its working great, thanks