2014-03-23
| 00:18 | devn | Is it normal to get this: :test/expected (identical? first-result (try-call)), from clojure.test-clojure.delays? |
| 00:19 | devn | I rebased RC2. Is this exception ignored by the CI and its failure is actually a sign things are working? |
| 00:21 | devn | nevermind, looks like an ant build fied it |
| 00:21 | devn | fixed it* |
| 00:43 | bufferloss | how can I convert a LazySeq to a regular javascript array in clojurescript? |
| 00:46 | noonian | (clj->js my-seq) |
| 00:55 | amalloy | probably also (apply array some-seq) |
| 01:02 | bufferloss | ,(reduce + [1 2 3 4 5]) |
| 01:02 | clojurebot | 15 |
| 01:03 | bufferloss | how do I get that to give me back an array such as [1 3 6 10 15] |
| 01:03 | bufferloss | noonian, 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:03 | TEttinger | bufferloss: reductions |
| 01:03 | bufferloss | which, in a way, is not really a reduce or a map |
| 01:03 | TEttinger | ,(reductions + [1 2 3 4 5]) |
| 01:03 | clojurebot | (1 3 6 10 15) |
| 01:04 | bufferloss | awesome thanks |
| 01:04 | amalloy | $findfn + [1 2 3 4 5] [1 3 6 10 15] |
| 01:04 | lazybot | [] |
| 01:04 | amalloy | really, lazybot? shouldn't that be reductions? |
| 01:04 | TEttinger | I'd be surprised if it could find it... |
| 01:04 | TEttinger | besides it returns a seq not a [] |
| 01:04 | amalloy | it compares with =, of course |
| 01:05 | bufferloss | ,(reductions + [[:foo 1] [:bar 2] [:baz 3] [:qux 4] [:noop 5]] |
| 01:05 | clojurebot | #<RuntimeException java.lang.RuntimeException: EOF while reading> |
| 01:05 | bufferloss | so what if I need to do that to just the second item of each sub item / sub array |
| 01:05 | amalloy | &(doc map) |
| 01:05 | lazybot | ⇒ "([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:06 | amalloy | (reductions + (map second ...)), depending on what you want |
| 01:07 | bufferloss | amaloy 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:08 | TEttinger | ,(reductions (fn [[k1 v1] [k2 v2]] [k2 (+ v1 v2)]) [[:foo 1] [:bar 2] [:baz 3] [:qux 4] [:noop 5]]) |
| 01:08 | clojurebot | ([:foo 1] [:bar 3] [:baz 6] [:qux 10] [:noop 15]) |
| 01:09 | bufferloss | awesome thanks |
| 01:10 | TEttinger | using the [[]] argument destructuring to get the pairs as separate elements |
| 01:22 | amalloy | bufferloss: 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:24 | bufferloss | amalloy, true, I usually use tab complete, just... didn't... that time |
| 01:25 | amalloy | i 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:25 | bufferloss | anyway, 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:26 | bufferloss | I'd like to do something more "backbone router" ish, so the app changes when the hash tag in the address bar changes |
| 01:28 | blake | Anyone here able to help me connect to sqlite3? I keep getting "missing required parameter". |
| 01:30 | noprompt | bufferloss: https://github.com/gf3/secretary/ |
| 01:31 | bufferloss | noprompt, awesome thanks |
| 01:32 | noprompt | bufferloss: 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:34 | bufferloss | noprompt, looks almost exactly like what I want |
| 01:35 | noprompt | bufferloss: awesome. let us know if you have any ideas on how we can improve it. |
| 01:36 | bufferloss | noprompt, can I (defroute "/users/:id" {:as params} foo-namespace/render-view-function) ? |
| 01:36 | bufferloss | or must I define/run the thing inline? |
| 01:36 | bufferloss | as in can I pass in a handler instead of defining the handler right there? |
| 01:36 | noprompt | bufferloss: yeah, but i think you mean (foo-namespace/render-view-function)) |
| 01:37 | bufferloss | nope, I mean what I pasted actually |
| 01:37 | bufferloss | so I can define the function, with params etc that handles the route entirely in another file |
| 01:37 | bufferloss | though now that I'm thinking of it, I guess it's not a lot different to actually invoke that handler right there |
| 01:37 | noprompt | well you can pass the function the params |
| 01:38 | bufferloss | right |
| 01:39 | bufferloss | noprompt, is dommy any better than e.g. domina or enfocus? |
| 01:39 | bufferloss | does hiccup run in clojurescript? |
| 01:39 | bufferloss | I don't see much difference between them right now |
| 01:40 | noprompt | bufferloss: 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:41 | clojurebot | false |
| 01:41 | _eric | why don't those match? |
| 01:41 | _eric | is there a different sort of equality I can do? |
| 01:42 | noprompt | bufferloss: 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:42 | bufferloss | noprompt, yeah I intend to investigate Om pretty soon, still starting slow/basic for now |
| 01:42 | _eric | ah, just found this: http://dev.clojure.org/jira/browse/CLJ-1182 |
| 01:42 | noprompt | dommy is also *very* fast. |
| 01:43 | bufferloss | was wondering if there is something more akin to underscore.js' _.template() function for clojurescript |
| 01:43 | bufferloss | such that my designers can still work with "html" |
| 01:43 | bufferloss | (le sigh, yes it's a thing) |
| 01:43 | noprompt | bufferloss: i might go with the enlive flavor of templating then. |
| 01:44 | noprompt | bufferloss: working with html and designers is fine. i'm a designer and a programmer. both are hard. both groups need to be happy. :) |
| 01:45 | bufferloss | cool, yeah enfocus looks like it'll work, thanks |
| 01:45 | noprompt | enlive is fun btw too. you can do a lot of cool stuff with it. |
| 01:45 | bufferloss | enlive enfocuse? I did a google for 'clojurescript enlive' and all I got was enfocus |
| 01:45 | noprompt | yeah sorry, enfocus seems to be for the client. my mistake. |
| 01:46 | noprompt | i wish that guy cgrande thought about clojurescript when he puts his libs together. they guy does great stuff. |
| 01:50 | muhoo | i'm pretty sure that when most of his more popular libs were written, clojurescript wasn't yet a thing |
| 01:56 | noprompt | muhoo: true, but enliven is newer. |
| 01:57 | noprompt | muhoo: to be fair though he does make judicious use of java libraries instead of reinventing the wheel. |
| 01:57 | noprompt | which is a good thing. |
| 02:22 | bufferloss | so I'm getting "nothing" when trying to use (ef/at "body" (ef/content "Home Page Enfocus!")) |
| 02:22 | bufferloss | dommy works at the exact same line, but enfocus seems to "do nothing" |
| 02:37 | bufferloss | noprompt, I can't get my non home page route to trigger :/ |
| 03:40 | muhoo | is there any reason why a clojure heroku push would just hang at compiling and never do anything? |
| 03:41 | muhoo | it compiles all the namespaces, then just hangs |
| 04:22 | muhoo | duplicable with just plain lein uberjar. aot problem somewhere :-/ |
| 06:11 | Pate_ | has anyone seen Pallet? https://github.com/pallet/pallet-docker |
| 06:11 | Pate_ | *or is using it. |
| 06:18 | AeroNotix | in emacs, are there switchable indentation modes for Clojure? |
| 06:18 | AeroNotix | as in clojure-mode.el -> choose indentation style |
| 06:18 | AeroNotix | or w/e |
| 06:43 | AeroNotix | (setq clojure-defun-style-default-indent t) |
| 06:43 | clojurebot | Pardon? |
| 06:43 | AeroNotix | done |
| 06:43 | AeroNotix | clojurebot: you heard me |
| 06:43 | clojurebot | AeroNotix: I'm just giving you a second chance |
| 06:43 | AeroNotix | clojurebot: NO U |
| 06:43 | clojurebot | Pardon? |
| 06:48 | unsymbol | :3 |
| 07:05 | Pate_ | 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:10 | mr-foobar | in cljs lib secretary, I can currently get client side routes like localhost/ and localhost/#/foo can I have routes for localhost/foo ? |
| 07:13 | mercwithamouth | does 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:18 | dnolen_ | mercwithamouth: it's immutable |
| 07:29 | mercwithamouth | dnolen_: 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:08 | l3dx | is it possible to fetch lein plugins directly from github? |
| 08:20 | john2x | why is this throwing ClassCastException (-> "bar" #(str "foo" %))? |
| 08:20 | john2x | ,(-> "bar" #(str "foo" %)) |
| 08:20 | clojurebot | #<CompilerException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.ISeq, compiling:(NO_SOURCE_PATH:0:0)> |
| 08:21 | pyrtsa | ,(-> "bar" (#(str "foo" %))) |
| 08:21 | clojurebot | "foobar" |
| 08:21 | john2x | pyrtsa: thanks |
| 08:22 | pyrtsa | The 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:22 | dnolen_ | ,(macroexpand '(-> "bar" #(str "foo" %))) |
| 08:22 | clojurebot | (fn* "bar" [p1__77#] (str "foo" p1__77#)) |
| 08:23 | pyrtsa | It's a shame that that happens, but macros aren't perfect. |
| 08:48 | ptcek_ | Anyone working on bumping clojuredocs.org to 1.6 or so? |
| 09:37 | Bbarrett | question, 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:37 | Bbarrett | I 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:38 | Bbarrett | it just kind of skipped over the whole user input part in any function i included it in |
| 09:55 | Curious_ | ,(+ 2 3 4) |
| 09:55 | clojurebot | 9 |
| 09:56 | s0x_ | 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:58 | elephantTechno | That would be (let x ... |
| 09:58 | elephantTechno | And I guess you can't do that without a macro |
| 09:59 | s0x_ | elephantTechno: let x ... doesnt work ... i would have guessed so :-/ |
| 09:59 | elephantTechno | Eg `(let ~x ... |
| 10:05 | s0x_ | elephantTechno: well macro works fine ... thx anyways :) |
| 10:05 | ptcek_ | ,(.getDate #inst "2014-03-14T23:00:00") |
| 10:05 | clojurebot | #<SecurityException java.lang.SecurityException: denied> |
| 10:06 | AeroNotix | s0x_: https://gist.github.com/AeroNotix/3dc016ad70e351bb2a02 |
| 10:07 | AeroNotix | s0x_: but you have to ask yourself, "what am I doing this for" |
| 10:07 | AeroNotix | perhaps there's a better way to do what you want. I doubt very much that this is what you want |
| 10:07 | Pate_ | 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:07 | Pate_ | *:aliases |
| 10:22 | hyPiRion | Pate_: it's to run multiple commands |
| 10:23 | hyPiRion | it's like `lein bower; lein cljsbuild once dev; lein less-debug; lein resource; lein httpd 8000`, just more efficient |
| 10:23 | Pate_ | why not: "run-client" ["do" "bower" "cljsbuild once dev" "less-debug" "resource" "httpd 8000"] ? |
| 10:27 | hyPiRion | Pate_: Would hard to do varargs, like ["do" "httpd" ~PORT] |
| 10:29 | hyPiRion | but it's possible to do ["do" "bower" ["cljsbuild" "once" "dev"] "less-debug" "resource" ["httpd" "8000"]] I think |
| 10:29 | hyPiRion | If not, you'd wrap the no-arity tasks with [] |
| 10:29 | Pate_ | yeah, that makes sense. |
| 10:29 | Pate_ | what does "do" mean? |
| 10:33 | Pate_ | I'm having a hard time doing live dev. How do I live update compojure routes by connecting to an nREPL? |
| 10:34 | Pate_ | 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:35 | Pate_ | "dev" alias defined as follows: :aliases {"dev" ["pdo" "cljsbuild" "auto" "dev," "ring" "server-headless"]} |
| 10:37 | Pate_ | do I need to add drawbridge as a ring handler to connect to a running ring server? |
| 10:43 | hyPiRion | Pate_: `lein help do` |
| 10:43 | Pate_ | is pdo like do but in parallel? |
| 10:44 | Pate_ | it's not obvious to me how the alias chaining works |
| 10:44 | Pate_ | e.g. ["do" "bower," "cljsbuild" "once" "dev," ... -- how does "do" fit into things here? |
| 10:45 | Pate_ | sorry, I'm not sure if I'm asking theis lein-specific questions in the right place. |
| 10:45 | Pate_ | *these. |
| 10:46 | hyPiRion | Pate_: It's just like running several tasks in succession from the command line |
| 10:46 | hyPiRion | just a bit faster |
| 10:46 | Pate_ | because it shares the same JVM? |
| 10:47 | hyPiRion | yeah, no need to setup Clojure and leiningen again |
| 10:47 | Pate_ | ermagerd, *discovers :auto-reload? true and :auto-refresh? true* |
| 10:51 | Pate_ | is anyone using Light Table as their main editor? |
| 10:52 | 23LAA142J | <table></table> |
| 10:52 | 23LAA142J | ^^ That's a light table right there |
| 10:52 | unsymbol | haha |
| 11:06 | Pate_ | What's the difference between ring-server and ring-serve ? |
| 11:09 | Pate_ | 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:17 | Pate_ | How do I run "lein ring server-headless" inside a REPL that I can connect to from Light Table? |
| 11:21 | technomancy | Pate_: you need a dependency on ring-jetty-adapter; call run-jetty inside the repl |
| 11:21 | Pate_ | I think I got it working with ring-server |
| 11:21 | Pate_ | (use 'ring.server.standalone) |
| 11:22 | technomancy | I usually do something like this: https://github.com/technomancy/syme/blob/master/src/syme/web.clj#L146 |
| 11:22 | Pate_ | (serve my-handler) |
| 11:23 | Pate_ | 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:24 | technomancy | Pate_: ring can't serve things on its own |
| 11:24 | technomancy | it probably brings jetty in anyway |
| 11:24 | Pate_ | ah, I see. What happens when you run "lein ring server-headless"? Does it run jetty under the cover? |
| 11:25 | technomancy | probably. I don't run lein ring myself; I don't see the point. |
| 11:25 | Pate_ | I'm still noob. I'm trying to get a smooth dev env going. |
| 11:25 | Pate_ | All of this knowledge is pretty spare on the interwebs. |
| 11:25 | technomancy | IMO it's simpler if you run everything from the repl instead of launching some stuff from the CLI |
| 11:26 | Pate_ | yeah! I want to do that. |
| 11:26 | technomancy | if it's just a function call then you know exactly what's going on |
| 11:26 | Pate_ | I'm trying to get a basic Om/Datomic thing going |
| 11:27 | technomancy | the getting started situation for clojurescript is still pretty rocky afaict |
| 11:27 | Pate_ | yeah, lots of dependencies. But it's getting better. |
| 11:32 | Pate_ | If I want Om to do things when something changes on the server, in realtime, what should I be looking at? http-kit? |
| 11:36 | DomKM | Pate_: I'd recommend taking a look at Sente https://github.com/ptaoussanis/sente |
| 11:36 | DomKM | Pate_: It depends on http-kit. I've found it very easy to use. |
| 11:37 | Pate_ | awesome, thanks DomKM. |
| 11:38 | Pate_ | ah, so Ring server is Jetty and http-kit is almost a drop-in replacement |
| 11:42 | Pate_ | how do I get the source of a function from the repl? (:source (meta #'+)) doesn't work. |
| 11:44 | sveri | Pate_: (source +) does the trick |
| 11:44 | Pate_ | hmmm. works now, but was getting source method not found a while back |
| 11:44 | Pate_ | ah, have to do (use 'clojure.repl) |
| 11:45 | sveri | Pate_: hm, I started "lein repl" from a leiningen project and (source +) worked without loading a namespace |
| 11:46 | kiras | does lein repl clojure.repl implicitly? |
| 11:46 | kiras | use |
| 11:46 | kiras | seems like it must |
| 12:00 | michaniskin | clojure.repl is refer'd into the user namespace |
| 12:00 | kiras | ok, thought it must be something like that |
| 12:01 | michaniskin | when you evaluate things in other namespaces you need to do (use 'clojure.repl) |
| 12:33 | whodidthis | can i set up functions in clojurescript i can call from javascript after they get closure compiled |
| 12:35 | malyn | whodidthis: Yes, you just need to mark them as ^:public. |
| 12:49 | whodidthis | doesnt seem to do anything but solved with ^:export meta |
| 12:50 | malyn | Oh, right, it's ^:export, not ^:public. I always get that backwards. Sorry about that! |
| 12:51 | whodidthis | noprobs at least u told me where to look from |
| 12:56 | teslanick | How 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:56 | teslanick | Could I just set! the global var and have that work? |
| 13:43 | AeroNotix | Is there a mocking library which will allow me to do stuff like "Mock this function after it was called n times." |
| 13:44 | AeroNotix | ? |
| 14:22 | jjl` | you can always write such a thing |
| 14:49 | patrickod | is there an easy way to make light table use a leiningen profile when evaluating things? |
| 15:20 | teslanick | Are there examples/docs for core.async outside of put, take, and alts? |
| 15:30 | technomancy | patrickod: lein profiles are activated when the project starts |
| 15:30 | technomancy | you can't apply them inside a repl session |
| 15:31 | patrickod | is there a way to specify one in particular though? i.e. test? |
| 15:31 | technomancy | patrickod: you would have to change the command used to launch lein; I only know how that works for emacs |
| 15:32 | patrickod | okies. I'm not too pushed on Light Table at the moment. Just trying it out as I'm writing this test suite. |
| 15:32 | technomancy | I would recommend putting anything you need for tests to pass into the dev profile though |
| 15:32 | patrickod | I'm guessing I could look to replicate the same inline evaluation with vim |
| 15:34 | patrickod | the main issue was w/ the ring-mock dependency. I added that in and it seems to be ok now |
| 15:35 | patrickod | coming from other languages where I'd keep the dev / test dependencies separate I didn't think to do that initially |
| 15:36 | technomancy | yeah, that definitely goes in dev dependencies |
| 15:36 | technomancy | the test profile is honestly not very useful |
| 15:37 | s0x_ | 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:38 | patrickod | huh good to know. |
| 15:38 | s0x_ | (defmacro mylet [v & body] `(let ~v ~@body)) results in an illegal argument exception |
| 15:38 | s0x_ | "let requires a vector for its binding ... |
| 15:39 | brehaut | s0x: using a macro at runtime? smells like a mistake |
| 15:40 | brehaut | ~xy |
| 15:40 | clojurebot | xy is http://mywiki.wooledge.org/XyProblem |
| 15:40 | s0x_ | um ... the macro should just extend the vector v to [a 1 b 2] |
| 15:40 | brehaut | s0x_: how about you explain the real problem you are trying to solve |
| 15:43 | s0x_ | well im trying to build a mini dsl which knows a few keywords which are provided by a structure ... |
| 15:44 | brehaut | a 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:45 | s0x_ | thats exactly why i need a macro here (as far as i do get them right :D) |
| 15:45 | s0x_ | i dont know a way to expand my vector to use it by let |
| 15:45 | s0x_ | like (let v (println a)) doesnt work at all |
| 15:45 | brehaut | s0x_: thats because macros are a compile time facility (unless you are doing some deeply esoteric stuff. *handwaving*) |
| 15:46 | pyrtsa | s0x_: 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:46 | s0x_ | pyrtsa: yes it is |
| 15:46 | brehaut | s0x_: if you want to pass an environment around you sure look at maps of keywords to things |
| 15:46 | s0x_ | the vector is a record actualy |
| 15:47 | pyrtsa | Then, 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:48 | pyrtsa | And a record with keys a and b will also work in my example. |
| 15:48 | s0x_ | just because i was wondering if there is a way to catch even the additional fields of the record |
| 15:49 | pyrtsa | Sure you can capture those as well. |
| 15:49 | s0x_ | btw, i would have to replace the key by symbols obviously :) |
| 15:49 | s0x_ | pyrtsa: how? |
| 15:50 | pyrtsa | For example: |
| 15:50 | pyrtsa | ,(defrecord Foo [a b]) |
| 15:50 | clojurebot | sandbox.Foo |
| 15:50 | pyrtsa | ,(let [{:keys [a b c]} (assoc (Foo. 1 2) :c 3)] [a b c]) |
| 15:50 | clojurebot | [1 2 3] |
| 15:50 | pyrtsa | ,(let [{:keys [a b] :as m} (assoc (Foo. 1 2) :c 3)] [a b m]) |
| 15:50 | brehaut | ,(let [{:keys [a b] :as m} {:a 1 :b 2 :c 3}] [a b m]) |
| 15:50 | clojurebot | [1 2 #sandbox.Foo{:a 1, :b 2, :c 3}] |
| 15:50 | clojurebot | [1 2 {:a 1, :c 3, :b 2}] |
| 15:50 | s0x_ | um thats not what i wanna do :( |
| 15:50 | pyrtsa | Heh, high 5. |
| 15:51 | pyrtsa | s0x_: Then I don't understand and you should probably write a better example of it online. |
| 15:55 | s0x_ | fair enough ... just a sec |
| 15:59 | s0x_ | http://pastebin.com/MAEQqSDL |
| 15:59 | s0x_ | whats what i have so far |
| 16:00 | pyrtsa | So, only v is user input? |
| 16:00 | s0x_ | yes |
| 16:01 | pyrtsa | Oh, should :c somehow refer to the values of keys :a and :b? |
| 16:01 | pyrtsa | Are you expecting c to be {1 [1 2]} and not {:a :b}? |
| 16:01 | s0x_ | um ... not really |
| 16:02 | s0x_ | sry ... a bit confussing maybe ... |
| 16:02 | pyrtsa | Okay, so just {:a :b}. |
| 16:02 | s0x_ | yes :) |
| 16:02 | pyrtsa | And also ignored by the block of code you've got there. |
| 16:02 | s0x_ | so the result i wanna get is (let [a 1 b [1 2] c {:a :b} (println a) b) |
| 16:03 | pyrtsa | Just do what I and brehaut adviced above. |
| 16:03 | pyrtsa | ,(let [{:keys [a b]} {:a 1 :b [1 2] :c {:a :b}}] (println a) b) |
| 16:03 | clojurebot | 1\n[1 2] |
| 16:04 | s0x_ | 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:05 | pyrtsa | Then 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:05 | brehaut | it seems like you are trying to bring a lot of magic into play just to operate on structured data |
| 16:07 | s0x_ | i know ... and i know that this is exactly what i wanna do |
| 16:07 | s0x_ | and i think it should be possible somehow |
| 16:08 | pyrtsa | s0x_: Okay then, what should a and b be if v doesn't include values for :a and :b? |
| 16:09 | s0x_ | like in this example a should be 1 and b [1 2] |
| 16:09 | s0x_ | but only for this example |
| 16:09 | s0x_ | i wanna do something like (let v some-val-of-sym-from-v) |
| 16:10 | pyrtsa | I'm afraid there's little people can do to help you. |
| 16:10 | s0x_ | i just wanna provide the vector which is used for let not explicit but from a variable |
| 16:11 | pyrtsa | That 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:11 | s0x_ | hmm ... well :_/ |
| 16:13 | AeroNotix | s0x_: do you have a use-case where you absolutely cannot proceed without dynamic let binding forms? |
| 16:14 | s0x_ | AeroNotix: Yes i've |
| 16:14 | s0x_ | pyrtsa: thanks for the hint ... |
| 16:14 | s0x_ | using eval will solve the issue :p |
| 16:14 | AeroNotix | s0x_: what's the use-case? |
| 16:16 | s0x_ | there has to be a small dsl controlling robots. you can access any value of the state using a symbol like (= state :landed) |
| 16:16 | s0x_ | while state may be any key stored in the state of the robot |
| 16:16 | s0x_ | args ... (= control-state :landed) is the one :) |
| 16:17 | AeroNotix | so (= state :landed) sets the state to landed? |
| 16:18 | s0x_ | (= control-state :landed) checks if the robot has landed yet |
| 16:18 | AeroNotix | s0x_: there's already a DSL for that |
| 16:18 | AeroNotix | it's called (if ...) |
| 16:18 | AeroNotix | it's pretty cool |
| 16:18 | s0x_ | lol |
| 16:19 | AeroNotix | I still don't see why you need the dynamic let vector, though |
| 16:19 | s0x_ | "you can access any value of the state using a symbol" |
| 16:19 | AeroNotix | changing (= state :landed) to an if form is child' |
| 16:19 | AeroNotix | child's play |
| 16:20 | shaungilchrist | I get the feeling the use case has not been fully stated? |
| 16:20 | AeroNotix | probably |
| 16:20 | s0x_ | well ... it is ... nevermind |
| 16:20 | AeroNotix | I just think you're trying to overcomplicate something |
| 16:20 | shaungilchrist | but yeah in general any time you start reaching for dynamic/runtime destructuring you've made a wrong turn a few moves back |
| 16:23 | s0x_ | is it that hard to understand? |
| 16:23 | s0x_ | well i hope it's not the language barier :p |
| 16:23 | AeroNotix | s0x_: nope. It just sounds like extremely poor design. |
| 16:26 | s0x_ | http://pastebin.com/eppGkfrs |
| 16:26 | s0x_ | well ... an example of the thing |
| 16:26 | AeroNotix | s0x_: looks like you want an FSM |
| 16:27 | brehaut | its 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:27 | brehaut | s/with both/with a language with both/ |
| 16:27 | AeroNotix | s0x_: this looks good: https://github.com/cdorrat/reduce-fsm |
| 16:28 | AeroNotix | and (set happy true) is just ridiculous |
| 16:28 | AeroNotix | There's plenty of built-in state management niceties in Clojure, what's wrong with those s0x_ ? |
| 16:29 | s0x_ | i will use them ... thats just a mapping to make things easy to the controller ... |
| 16:30 | AeroNotix | s0x_: what's "the controller" ? |
| 16:30 | s0x_ | the guy how controls the robot |
| 16:32 | AeroNotix | s0x_: so this example code here, I'm *still* not even close to understanding why you need that dynamic let binding? |
| 16:32 | AeroNotix | the 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:32 | AeroNotix | s/is a/could be a/ |
| 16:33 | s0x_ | well ... only an if ... |
| 16:33 | s0x_ | anyways ... control-state is a symbol |
| 16:33 | AeroNotix | and? |
| 16:34 | s0x_ | and this should be mapped to a value you can find inside the robot using the keyword :control-state |
| 16:34 | AeroNotix | ,(keyword 'omfg-a-keyword) |
| 16:34 | clojurebot | :omfg-a-keyword |
| 16:34 | AeroNotix | so if there is some state associated with the robot, turn the symbol The Controller provides into some accessor on that state |
| 16:35 | AeroNotix | usually it's going to be a map |
| 16:35 | s0x_ | im not sure if i got you right but i think yes |
| 16:36 | AeroNotix | ~xy |
| 16:36 | clojurebot | xy is http://mywiki.wooledge.org/XyProblem |
| 16:40 | s0x_ | http://pastebin.com/a8kBszwZ |
| 16:40 | s0x_ | thats what might result from the commands |
| 16:41 | s0x_ | is not a blockage if its part of my research |
| 16:41 | s0x_ | s/blockage/blockade/ |
| 16:51 | shaungilchrist | and the potential symbols in robot are unknown at read time? |
| 16:54 | shaungilchrist | crazy 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:54 | shaungilchrist | walk your exprs to build up vector of symbols and put that into your expanded let form |
| 16:59 | jasonjckn | just booked my ticket for clojure/west |
| 17:00 | AeroNotix | I'm going to EuroClojuer |
| 17:00 | AeroNotix | EuroClojure* |
| 17:00 | jasonjckn | nice! |
| 17:01 | s0x_ | shaungilchrist: thats sounds indeed not bad ... even if i think i didnt get the whole thing |
| 17:02 | s0x_ | but actually the expanded let form is the problem here :) |
| 17:04 | shaungilchrist | well in this case you would expand to (let [{?control-state :control-state} robot] ....) negating the need for eval or runtime left-hand destructuring |
| 17:11 | s0x_ | shaungilchrist: great idea ... |
| 17:11 | s0x_ | thanks ... that should work even better :) |
| 17:12 | shaungilchrist | if 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:14 | shaungilchrist | but 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:19 | ToBeReplaced | if 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:33 | shaungilchrist | use alts! and check for the port being in #{x y z} |
| 18:43 | irctc | I 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:43 | irctc | "lein deps" above stupid spell corrector |
| 20:09 | guest23432 | if 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:10 | guest23432 | sort of new to clojure; guesses as to what's going on? HUGE thanks to anyone. |
| 20:11 | noonian | if you shared your failing code on refheap it'd be easier to help |
| 20:11 | noonian | you will need to restart your repl if you added the dependency after you started it originally |
| 20:11 | guest23432 | will do, one moment. thanks! |
| 20:14 | guest23432 | https://www.refheap.com/64420 |
| 20:15 | guest23432 | that's copy-pasted from two files: |
| 20:15 | guest23432 | [yesql "0.4.0"] is in project.clj dependencies |
| 20:16 | guest23432 | using lighttable.. |
| 20:16 | noonian | the 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:16 | noonian | if you're using light table as your repl make sure to evaluate each form including the ns fomr |
| 20:17 | guest23432 | that's what I thought. first one spits 'No namespace: yesql.types though |
| 20:19 | noonian | and you included the dependency before connecting to your project in light table |
| 20:19 | noonian | ? |
| 20:20 | guest23432 | like it knows to go over and get yesql, bring it in, and can find the other parts... |
| 20:20 | guest23432 | yes. included dependency. have disconnected-> re- "Add connection"; restarted LT; ... |
| 20:21 | noonian | definitely 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:22 | guest23432 | doesn't complain about parser or util : https://github.com/krisajenkins/yesql/blob/master/src/yesql/core.clj |
| 20:22 | noonian | are you trying to use a function from yesql.types somewhere further down in your program? |
| 20:22 | guest23432 | that's all there is in the file.. |
| 20:22 | guest23432 | haven't even gotten to an actual function, ha! |
| 20:24 | noonian | hmm, have you tried requiring it from a normal repl? |
| 20:24 | bore | Hello 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:25 | bore | As you might have guessed from the question I am still finding my way around clojure |
| 20:25 | guest23432 | have not tried normal repl |
| 20:25 | guest23432 | * yet. stand by ;) |
| 20:26 | noonian | you could use (resolve (name :foo)), but if you are new to clojure, this isn't a very common thing to need to do |
| 20:26 | noonian | er, (resolve (symbol (name :foo))) |
| 20:27 | noonian | ,(resolve (symbol (name :identity))) |
| 20:27 | clojurebot | #'clojure.core/identity |
| 20:27 | guest23432 | ah, lighttable is now spitting: "no such var: jdbc/execute!" |
| 20:27 | bore | thanks I'll try it out |
| 20:27 | guest23432 | ...and re-evaluate and its 'no namespace yesql.types' |
| 20:28 | noonian | imo 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:28 | noonian | ,(doc resolve) |
| 20:28 | clojurebot | "([sym] [env sym]); same as (ns-resolve *ns* symbol) or (ns-resolve *ns* &env symbol)" |
| 20:28 | guest23432 | ok. good to know. thanks. |
| 20:28 | noonian | ,(doc ns-resolve) |
| 20:28 | clojurebot | "([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:29 | bore | This way I get the var itself and not the value it holds |
| 20:29 | bore | ,(doc deref) |
| 20:29 | clojurebot | "([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:29 | noonian | if you just want the value you can defef the var |
| 20:30 | noonian | ,(dereg (resolve (symbol (name :identity)))) |
| 20:30 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: dereg in this context, compiling:(NO_SOURCE_PATH:0:0)> |
| 20:30 | noonian | ,(deref (resolve (symbol (name :identity)))) |
| 20:30 | clojurebot | #<core$identity clojure.core$identity@18e7ed> |
| 20:30 | bore | this is getting quite funky now - you are probably right that it is non idiomatic to access data like this |
| 20:30 | bore | it doesn't look particulary nice |
| 20:31 | bore | thank for widening my horizons |
| 20:31 | noonian | ,(-> :identity name symbol resolve deref) |
| 20:31 | clojurebot | #<core$identity clojure.core$identity@18e7ed> |
| 20:31 | noonian | a little cleaner, but if you want to look this stuff up at runtime, just but your functions in a map |
| 20:32 | noonian | {:foo (fn [x] (println x))} |
| 20:33 | bore | thanks for the tip |
| 20:36 | noonian | np |
| 20:44 | guest23432 | noonian: 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:45 | guest23432 | don'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:47 | bja | guest23432, you can always check that with "leon deps :tree" |
| 20:47 | bja | err, "leon reps :tree" |
| 20:47 | bja | fucking autocorrect |
| 20:47 | guest23432 | lein |
| 20:48 | guest23432 | I gotcha |
| 20:48 | bja | yeah, that thing |
| 20:48 | guest23432 | leon is useless anyway |
| 20:48 | arkh | I'm so making that a new project |
| 20:48 | guest23432 | good for nothing bum. never knows what you're talking about in CLI |
| 20:49 | guest23432 | leon should be a project to make sure shit ain't misspelled; |
| 20:50 | guest23432 | or whatever you want to make. you know. you're the one who said you wanted to make it something. |
| 20:50 | guest23432 | good luck and god speed. send my regards to leon. |
| 21:06 | upwardindex | Must I really have the whole goog javascript library in my uberjar? |
| 21:21 | aphyr | Has anyone seen wildly unpredictable performance from reducers? |
| 21:22 | aphyr | https://gist.github.com/aphyr/9732470 |
| 21:23 | aphyr | foldcat can consume 68% of 48 cores for 16 seconds... or maybe it'll complete in 600ms |
| 21:23 | aphyr | Or anywhere in between, really |
| 21:23 | jcromartie | my first instinct says GC |
| 21:24 | jcromartie | oh wait |
| 21:24 | jcromartie | first time, you are realizing a massive lazy seq? |
| 21:24 | aphyr | vec |
| 21:24 | aphyr | It's realized. |
| 21:24 | aphyr | It varies thereafter basically at random |
| 21:24 | aphyr | sometimes really fast, sometimes slow. |
| 21:26 | jaccarmac | Hello all! |
| 21:27 | jcromartie | aphyr: I'd guess you are near the memory limit of your process and you are ending up GC'ing something |
| 21:27 | jcromartie | but just a hunch |
| 21:27 | hiredman | aphyr: 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:29 | aphyr | kk lemme retry with 100g heap |
| 21:29 | jcromartie | what the bloody hell are you running on? |
| 21:29 | aphyr | my desktop |
| 21:29 | jcromartie | seriously |
| 21:29 | jcromartie | how |
| 21:29 | aphyr | yes |
| 21:29 | jcromartie | :) |
| 21:30 | aphyr | I got tired of waiting for slow Clojure programs haha |
| 21:30 | aphyr | and analyzing 32gb heap dumps is a lot easier with 128gb of ram |
| 21:31 | jcromartie | but the 48 core thing… I am not even aware of how to buy or build a machine like that |
| 21:31 | aphyr | 2x xeon e5-2697s |
| 21:31 | aphyr | 12 physical, 24 virtual cores/socket |
| 21:32 | aphyr | oh intriguing |
| 21:32 | aphyr | this is indeed a GC issue |
| 21:32 | aphyr | it wasn't showing up in the instrumentation because the instrumentation hung during the GC |
| 21:32 | aphyr | that's a new trick, haha |
| 21:33 | aphyr | Raising the heap gets it to be reliably fast |
| 21:34 | aphyr | 15 seconds GC pause in the REPL: it's fiiiiine |
| 21:34 | jcromartie | aphyr <-- 0th world problems |
| 21:34 | aphyr | [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:40 | aphyr | [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:40 | aphyr | 1.3 second parnews repeated 15 times in a row: its' FIIIIINE |
| 21:47 | aphyr | Weirdly enough, despite running 48 fj threads, it only eats ~6% CPU |
| 21:54 | jcromartie | you 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:54 | jcromartie | but on a 48 core machine |
| 21:54 | jcromartie | I'd imagine that it's actually really, really, noticeable |
| 21:55 | jcromartie | one day that will be fairly normal, no? |
| 22:13 | aphyr | Yeah, Clojure literally gets me a 40x speedup on this box if I do it right |
| 22:13 | aphyr | but this reduction problem I'm working on... getting nowhere near that kind of speedup out of reducers |
| 22:13 | aphyr | may go back to explicit threads |
| 22:59 | verma | is 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:00 | Bronsa | verma: add-watch |
| 23:00 | verma | nice! |
| 23:00 | verma | let me check |
| 23:31 | verma | Bronsa, its working great, thanks |