2013-03-17
| 00:00 | lynaghk | Rich_Morin: I don't think those directions are correct |
| 00:00 | lynaghk | Rich_Morin: Clojure/West is happening downtown, in NW Portland. Your directions point to a hotel on the East side of the river. |
| 00:02 | Rich_Morin | Yow - good catch! |
| 00:03 | lynaghk | Rich_Morin: taking the train is a good idea, though--just make sure you take it over the river =) |
| 00:13 | Rich_Morin | http://pastie.org/6578249 - this looks better... |
| 00:26 | bbloom | lynaghk: https://www.refheap.com/paste/12649 |
| 00:26 | bbloom | lynaghk: that's just one tiny example of some working rewrite combinators |
| 00:27 | bbloom | lynaghk: basically, any function that returns nil "fails" and then any other function that returns a map "succeeds" and then there is a big library of combinators made out of composing those pieces. things like rewrite until a fixed point, rewrite from the bottom up, rewrite from the top down, stop rewriting when some condition is met, etc |
| 00:42 | bbloom | lynaghk: decided to publish progress so far: https://github.com/brandonbloom/retree |
| 00:46 | tomoj | should be easy to write something that makes analyzer output less insanely huge? |
| 00:46 | technomancy | tomoj: smaller defns? =) |
| 00:46 | tomoj | (rewrite &env (everywhere #(when (:env %) (dissoc % :env)))) |
| 00:46 | bbloom | tomoj: :-) |
| 00:46 | tomoj | except that's too naive.. |
| 00:47 | bbloom | #(when (:op %) (dissoc % :env)) |
| 00:47 | technomancy | if |
| 00:47 | technomancy | http://p.hagelb.org/9grin.gif |
| 00:47 | bbloom | technomancy: nah, it should be very clear that nil is being returned otherwise :-) |
| 00:48 | bbloom | anyway, there are conditional combinators too |
| 00:48 | Raynes | technomancy: Psh. |
| 00:48 | Raynes | Linking to Christopher Eccleston. |
| 00:48 | Raynes | That's Doctor Who heresy. |
| 00:49 | bbloom | something like: (everywhere (choice (contains? :env) #(dissoc % :env))) |
| 00:49 | bbloom | ignoring the fact that clojure.core has contains? |
| 00:49 | Raynes | technomancy: http://24.media.tumblr.com/829ff0fe4c6edff85f3371f409a87f4a/tumblr_mguw0yxEaS1s3s9i1o1_500.gif |
| 00:50 | bbloom | tomoj: i'm still learning how to work w/ these combinators, but i think there is one that is like everywhere top-down but stops when it does a rewrite, but continues for all siblings |
| 00:51 | bbloom | so it would eliminate :env from any AST form, but it wouldn't eliminate it from :info sub forms or anything like that |
| 00:51 | bbloom | haven't wrapped my brain around all this yet :-P |
| 00:51 | tomoj | looks pretty cool |
| 00:52 | bbloom | tomoj: thanks :-) |
| 00:52 | bbloom | notice the phase 2 of the master plan: https://github.com/brandonbloom/retree/blob/master/src/retree/core.clj#L6 |
| 00:52 | bbloom | instead of returning functional combinators, i want all the non-primitives to return AST nodes |
| 00:52 | bbloom | and then i want an older version of retree to optimize the ASTs of newer versions of retree ;-) |
| 00:52 | bbloom | mwahaha |
| 00:53 | tomoj | I understood phases 1 and 3 |
| 00:54 | ambrosebs | bbloom: looks cool! Where does this fit with the ASTs? Would a consumer use this to generate :children etc, like you suggested previously? |
| 00:54 | john2x | how do I test ring sessions? I'm using lib-noir's noir.session with memory-store, and I can put!/get! in the handler, but I'm lost on how to get! the session atom in the test function. |
| 00:54 | tomoj | the AST would be your own invented AST? |
| 00:54 | bbloom | tomoj: basically: phase two produces an AST, which is just a tree of maps and then the "compile" function just produces a tree of function combinators. phase 3 would actually produce and compile code |
| 00:54 | tomoj | or jvm.tools.analyzer-like? |
| 00:55 | bbloom | ambrosebs: this is for any type of tree rewriting, especially ASTs :-) some examples include dead code elimination, deforestation, etc |
| 00:55 | bbloom | ambrosebs: the kiama code base has some examples |
| 00:56 | ambrosebs | bbloom: Ahk sweet! |
| 00:57 | bbloom | ambrosebs: would be awesome if we could do deforestation of (->> coll (map ...) (map ...) (reduce ...)) :-) |
| 00:57 | bbloom | inlining, etc too! |
| 00:58 | ambrosebs | *looks up deforestation* |
| 00:59 | bbloom | ambrosebs: short version: (-> (range 5) (map inc) (map dec)) is the same as (-> (range 5) (map (comp dec inc))) |
| 00:59 | bbloom | can even go further and eliminate known pure functions like (comp dec inc) to identity |
| 00:59 | bbloom | and then (map identity) to identity |
| 01:00 | ambrosebs | bbloom: ah. I remember reading a Haskell paper on something like this. |
| 01:00 | bbloom | or to `seq i guess |
| 01:00 | bbloom | :-P |
| 01:01 | callenbot | anyone here work on message-passing stuff before? |
| 01:01 | bbloom | i was addressing lynaghk with this though b/c i think it will also be useful for his grammar of graphics |
| 01:02 | bbloom | and i have top secret evil schemes too ;-) |
| 01:02 | tomoj | I see some semantic editor combinators in there, but not many paths |
| 01:02 | bbloom | huh? |
| 01:04 | bbloom | (btw, clojure is sooo much less verbose than scala... ::hug::) |
| 01:08 | tomoj | I mean, the (*-in [...]) style is only there in the leaf editors |
| 01:10 | bbloom | tomoj: still not 100% sure what you're saying... trying to say that there are some assoc, update-in, assoc-in, etc type functions that are missing? yes :-) phase ZERO is to reach feature parity with the kiama library... then i'll clojure-ize it more fully |
| 01:11 | tomoj | no, I mean it just looks like a completely different manner of composition |
| 01:16 | bbloom | tomoj: you mean how it uses the #() syntax for the actual changes? yeah. that's sorta the point: clean interop with normal clojure code. shouldn't need to have a totally different standard library for transformations. although, there will be the most common stuff in there to simplify common patterns |
| 01:17 | bbloom | could for example do (:require [retree :as rt]) then (rt/everywhere (rt/dissoc :env)) |
| 01:17 | tomoj | I just mean.. operations with semantic editor combinators tend to look like (op-in [lots of composition] #(some simple f %)) |
| 01:18 | tomoj | er, with SECs the op is always update |
| 01:18 | tomoj | but rewrite just takes a function |
| 01:18 | tomoj | maybe the application order is just different |
| 01:19 | tomoj | (I mean (op-in t ...) of course) |
| 01:21 | bbloom | tomoj: ooooh, you're talking about your lib... |
| 01:21 | bbloom | haha dude, we were totally talking past each other |
| 01:21 | bbloom | what's the link to your lib again? |
| 01:22 | tomoj | I think I refheap'd something once, I don't actually have a lib |
| 01:24 | tomoj | I think I like building up a single rewrite strategy like you do better |
| 01:28 | bbloom | tomoj: not my idea :-P stollen shamelessly from the fine folks who work on kiama |
| 01:30 | bbloom | entertainingly enough, i stumbled across kiama when i was working on fipp, since they implement the same pretty pritner algorithm. however, they went with a lazy implementation, which is very awkward in an eager language like scala. i presume that kiama implemented the algo before the paper on the strict/generators approach was published |
| 01:30 | bbloom | re-stumbled upon it again this weekend while i was looking for a better way to do some rewriting |
| 01:31 | bbloom | and, even more entertainingly, they have attribute grammars too! which i was just talking about in here... but i didn't study their implementation yet: https://code.google.com/p/kiama/wiki/Attribution |
| 01:32 | tomoj | hmm, #(rewrite (all (all inc)) %) == (update-in* % [all all] inc) |
| 01:32 | tomoj | (all (all inc)) solves one problem I posed today |
| 01:34 | bbloom | him so what does (all (all f)) do ? |
| 01:34 | bbloom | hmm* |
| 01:34 | bbloom | i guess it does all children of all children? |
| 01:34 | bbloom | so rewrites down skipping a level? |
| 01:34 | tomoj | (= [[2 3 4] [5 6 7]] (rewrite (all (all inc)) [[1 2 3] [4 5 6]])) |
| 01:34 | tomoj | (if you add a vector? clause) |
| 01:35 | bbloom | yeah, the vector? clause is planned :-P haha |
| 01:35 | tomoj | https://www.refheap.com/paste/5cec0e559e2d3519f5b7160ef |
| 01:35 | tomoj | some other problems I wrote down so far |
| 01:36 | bbloom | hmm, wanna think through them? |
| 01:36 | bbloom | by line number: |
| 01:36 | bbloom | #10 is just pass |
| 01:36 | tomoj | does zipping have any place in retree? |
| 01:36 | bbloom | #13 is (all #(inc 3)) |
| 01:36 | tomoj | if not most of those will be irrelevant |
| 01:36 | bbloom | zipping as in zippers or as in (map x y) ? |
| 01:37 | tomoj | (map x y) |
| 01:37 | bbloom | you could use down-up to zip and unzip |
| 01:37 | muhoo | is there some way in clojurescript to introspect objects to find their methods/etc ? |
| 01:38 | tomoj | OH, down-up?! |
| 01:38 | bbloom | https://github.com/brandonbloom/retree/blob/master/src/retree/core.clj#L191 |
| 01:38 | muhoo | it's really handy in clojure to be able to look in the repl to see wtf a java object actually is and what methods it has. it'd be great to have it in clojurescript for javascript |
| 01:38 | tomoj | I was reading something about down/up recently |
| 01:38 | tomoj | didn't recognize it when I saw down-up |
| 01:38 | bbloom | tomoj: ? |
| 01:38 | bbloom | lol i have no idea that down/up was a thing, lol |
| 01:38 | bbloom | down-up is basically pre AND post fix |
| 01:39 | bbloom | er pre and post traversal |
| 01:39 | tomoj | "continuations and transducer composition" |
| 01:39 | tomoj | maybe it's just a coincidence |
| 01:40 | bbloom | *gulp* heady title right there, haha |
| 01:40 | bbloom | WHAT HAVE I GOTTEN MYSELF INTO!? |
| 01:40 | bbloom | :-P |
| 01:40 | tomoj | probably not the same thing |
| 01:40 | tomoj | well shit everything is the same thing |
| 01:40 | bbloom | haha |
| 01:40 | bbloom | well, transducers are like reducers with state |
| 01:41 | bbloom | in theory, you can store state in the tree via down/up |
| 01:41 | bbloom | ie you add a state accumulator and then remove it when you're done |
| 01:41 | bbloom | but i'm sure there is a better/different way |
| 01:42 | bbloom | i also want to have every combinator automatically record rewrites into metadata |
| 01:42 | bbloom | maybe optionally |
| 01:43 | bbloom | this way, you could have an after-the-fact debugger |
| 01:43 | bbloom | you could step-backwards through the rewrites :-) |
| 01:43 | bbloom | could have an undo combinator too! |
| 01:44 | tomoj | hmm |
| 01:45 | bbloom | i'm also thinking about how to handle dynamic restarts of rewrites. ie if something external changes the tree, can you cause the rewrites to restart from wherever they depended on the data that changed |
| 01:45 | bbloom | no idea if that is feasible or not |
| 01:46 | tomoj | if that works, almost fully compiled down to raw DOM, with this thing optimizing itself.. |
| 01:46 | tomoj | :) |
| 01:47 | bbloom | tomoj: hahaha shhhh you're extrapolating from my other projects |
| 01:48 | bbloom | my secret evil master plans must stay secret for a bit longer! |
| 01:49 | tomoj | I wouldn't be surprised if we wind up faster than some popular bare-metal-optimized js libs |
| 01:52 | bbloom | yeah, it's actually quite amazing how much persistent data structures buys you |
| 01:52 | bbloom | kiama does an absurd amount of copying to do it's rewriting |
| 01:53 | bbloom | and then it has this weird "same" function that attempts to do reasonable equality, but without immutability, there is no reasonable equality |
| 01:53 | tomoj | have you read any of the generic programming literature around folds/traversals? |
| 01:54 | bbloom | no |
| 01:54 | tomoj | oh, well, it passed before my eyes, not sure I can say I read it. feels very related to kiama though |
| 01:57 | tomoj | which protocol will be the basis for all/one? |
| 01:57 | bbloom | huh? |
| 01:57 | bbloom | oh, you mean for identifying "children"? |
| 01:57 | tomoj | I mean, will it just be a closed dispatch like clojure.walk? or will there be a protocol? |
| 01:57 | tomoj | yeah |
| 01:58 | bbloom | i dunno yet |
| 01:58 | tomoj | and rebuilding |
| 01:58 | tomoj | ? |
| 01:58 | tomoj | I think that might be the same protocol I've been trying to think of lately |
| 01:59 | bbloom | here's the kiama Rewritable trait: https://code.google.com/p/kiama/source/browse/src/org/kiama/rewriting/Rewritable.scala |
| 01:59 | bbloom | it basically is closed dispatch for standard case classes, tuples, maps, seqs, etc |
| 01:59 | bbloom | and then if you have a custom type & want it to be rewritable, you inherit that trait |
| 02:00 | bbloom | it's basically count/seq/into |
| 02:00 | tomoj | IReduce and IEmptyableCollection aren't enough? |
| 02:00 | bbloom | dunno yet, i punted on even the vector case for tonight |
| 02:01 | bbloom | will revisit after clojure/west |
| 02:02 | bbloom | one other thing to consider is that you may have a tree of maps where each map has a :children key and you might want to somehow override (ie dynamic var) the tree navigation |
| 02:02 | bbloom | for example, consider Raynes' laser |
| 02:02 | bbloom | it operates on XML nodes which have attrs and content |
| 02:03 | bbloom | but i think it might be sufficient to say "OK, just don't use the everywhere combinator inappropriately" and not allow customization of children relationships |
| 02:03 | bbloom | dunno yet |
| 02:04 | tomoj | (partial fixed-point (comp all (at :content))) ? |
| 02:04 | bbloom | something like that |
| 02:04 | bbloom | i'm past the point of thinking though, so i'm gonna go to bed. you gonna be at the conference? |
| 02:05 | tomoj | no :( |
| 02:05 | tomoj | next year |
| 02:05 | bbloom | bummer :-/ oh well, then we'll chat about this next week sometime when i get back to it |
| 02:05 | bbloom | gnight all |
| 02:09 | tomoj | thanks for releasing retree |
| 02:10 | tomoj | not bblöom: is the rate at which a dynamic value (!) will be sampled a reasonable use of metadata? |
| 02:10 | tomoj | I hardly use metadata except for vars and type-hints since I usually decide that it should really just be data |
| 02:44 | hiredman | bbloom: kiama looks a lot like zippers |
| 02:47 | hiredman | at least the traversal and tree rewriting bits, the main thing lacking when using zippers for rewriting is the sort of repeated pattern matching |
| 03:43 | drorbemet | |
| 03:49 | Raynes | |
| 05:18 | holo | hi |
| 05:20 | mzelinka | hello |
| 05:21 | holo | how do i find which lib uses x dependency? i know x, but i can't use lein deps :tree, because x artifact cannot be downloaded |
| 06:08 | carlocci | should I use openjdk or oracle? |
| 06:09 | carlocci | I don't care for the license, but I actively dislike the prince of darkness |
| 06:33 | NeedMoreDesu | Can I get future's thread? |
| 06:34 | Hali_303 | hi! is there a function similar to eclipse's "organize imports" in emacs? |
| 06:36 | scottj | Hali_303: I don't think so, but maybe checkout slamhound |
| 06:37 | scottj | carlocci: most things work fine on both |
| 06:38 | Hali_303 | scottj: looks interesting,t hx! |
| 06:40 | NeedMoreDesu | I want a way to check if some future is current thread. |
| 07:15 | pdmct | Hi, can someone help me understand what is happening with the following? |
| 07:15 | a_run | hi, a newbie to clojure |
| 07:15 | a_run | do i need JDK to use clojure or is JRE enough ? |
| 07:16 | pdmct | I am trying to map a map into a function but I can't understand what is happening to my data structures' |
| 07:17 | pdmct | Here is the code: (let [data (get @events (first (keys @events)))] (log/info "draw1" (apply str (concat "events:" @events))) (log/info "draw1" (apply str (concat "key: " (first (keys @events))))) (log/info "draw1" (apply str (concat "data: " data))) (unify data (fn [{:keys [host service metric ranges measures markers]}] (log/info "draw2" (apply str (concat "host: " host "service: " service " |
| 07:17 | xeqi | pdmct: can you use refheap.com or make a gist? |
| 07:17 | pdmct | hmm, sorry that doens't look do good |
| 07:17 | pdmct | ok |
| 07:18 | xeqi | a_run: I believe you only need a jre for clojure itself |
| 07:18 | a_run | xeqi: thanks |
| 07:19 | pdmct | ok, here is the code and the output https://www.refheap.com/paste/12654 |
| 07:20 | pdmct | I don't understand why data is the way that it is -- it looks like a list of vectors |
| 07:22 | pdmct | I should add this is actually clojurescript |
| 07:23 | xeqi | &(concat "data: " {:x 1 :y 2}) |
| 07:23 | lazybot | ⇒ (\d \a \t \a \: \space [:y 2] [:x 1]) |
| 07:23 | xeqi | &(apply str (concat "data: " {:x 1 :y 2})) |
| 07:23 | lazybot | ⇒ "data: [:y 2][:x 1]" |
| 07:23 | xeqi | when you do the concat to print it out it converts from a map to a seq of key value pairs |
| 07:24 | xeqi | &(apply str "data: " {:x 1 :y 2}) |
| 07:24 | lazybot | ⇒ "data: [:y 2][:x 1]" |
| 07:24 | xeqi | &(str "data: " {:x 1 :y 2}) |
| 07:24 | lazybot | ⇒ "data: {:y 2, :x 1}" |
| 07:24 | xeqi | there we go |
| 07:24 | xeqi | pdmct: ^ |
| 07:25 | pdmct | xeqi: ok, thanks ... this has sidetracked me -- I'm not getting any value for host and service -- which is why I have the logs -- and I am not sure why |
| 07:26 | pdmct | xeqi: I don't really understand what (fn [{:keys [host service ...]}]) is doing -- and it doesn't seem to work |
| 07:27 | xeqi | where does `unify` come from? |
| 07:27 | xeqi | core.logic? |
| 07:27 | clojurebot | idiomatic clojure uses dashes to separate words |
| 07:27 | xeqi | clojurebot: thanks, you're awesome |
| 07:27 | clojurebot | I'm no man, and she's no lady! |
| 07:27 | pdmct | xeqi: no a visualisation framework C2 (clojurescript) -- I think it is basically does (unify data f) -> (map f data) |
| 07:29 | pdmct | xeqi: I don't fully grok how the functions arguments are extract from the map (data) |
| 07:30 | xeqi | you don't need unify/map here |
| 07:30 | xeqi | you could just call the function directly |
| 07:31 | xeqi | &((fn [{keys [x y]}] [x y]) {:x 1 :y 2}) |
| 07:31 | lazybot | java.lang.RuntimeException: Unable to resolve symbol: x in this context |
| 07:31 | pdmct | xeqi: I know it only has one element in the map -- once I get it working the map will have many |
| 07:31 | xeqi | &((fn [{:keys [x y]}] [x y]) {:x 1 :y 2}) |
| 07:31 | lazybot | ⇒ [1 2] |
| 07:33 | xeqi | the :keys destructuring looks at the keys in the map argument and binds the symbol of those keys to the corresponding value in the map |
| 07:33 | pdmct | xeqi: I don't undertstand how that works, is it positonal or does :x map to x ? |
| 07:33 | xeqi | :x maps to the x symbol |
| 07:33 | xeqi | .. the value of :x in the map get bound to the x symbol |
| 07:33 | pdmct | ok, thanks |
| 07:34 | pdmct | so looking at the code -- if (unify data d) is actually (map f data) -- can you see why the values for host and service are nil? |
| 07:35 | xeqi | but right now with the (unify data ...) it tries to (map ... data), which converts the data map datastructure into a seq of k/v pairs |
| 07:35 | pdmct | *d f |
| 07:36 | xeqi | .. simplified examples of whats its doing: |
| 07:36 | xeqi | (map (fn [x] x) {:x 1 :y 2}) |
| 07:36 | xeqi | &(map (fn [x] x) {:x 1 :y 2}) |
| 07:36 | lazybot | ⇒ ([:y 2] [:x 1]) |
| 07:36 | xeqi | vs |
| 07:36 | xeqi | &((fn [x] x) {:x 1 :y 2}) |
| 07:36 | lazybot | ⇒ {:y 2, :x 1} |
| 07:38 | xeqi | pdmct: you could either remove the unify/map and call it directly, or make (get @events (first (keys @events))) return a vector of maps |
| 07:38 | pdmct | ok, got it ... map applies the fn to each element of the map |
| 07:38 | Glenjamin | hi everyone, i'm using a lib that uses clj-http for oauth, and it's not quite working - is there a way to get debug output from a library i'm calling? |
| 07:38 | xeqi | pdmct: each key value pair |
| 07:38 | pdmct | so I could just wrap it in vec? |
| 07:38 | pdmct | xeqi: yes, thats what I mean by element a K,v pair |
| 07:39 | xeqi | I'd do what makes sense for the data model, does an event have multiple data points? |
| 07:40 | pdmct | yes @events will be a map of "name" : {event data} pairs |
| 07:43 | xeqi | I'd prolly do something like https://www.refheap.com/paste/12655 |
| 07:44 | xeqi | Glenjamin: thats going to be specific to the library |
| 07:45 | Glenjamin | it doesn't look like it's got anything built-in |
| 07:45 | Glenjamin | in other dynamic languages i'd probably usually open it up and hack in a debug output line |
| 07:45 | Glenjamin | or monkey-patch something |
| 07:45 | Glenjamin | or use a stepping debugger |
| 07:46 | Glenjamin | any of those doable in clojure? |
| 07:47 | xeqi | hacking debug output difficulty will depend on your setup, not too difficult using nrepl.el and a repl, but would be harder for others |
| 07:47 | pdmct | xeqi: k thanks ... will give it a try |
| 07:47 | xeqi | monkey-patching is doable with &(doc with-redefs) |
| 07:48 | xeqi | or the robert.hooke library |
| 07:48 | xeqi | &(doc with-redefs) |
| 07:48 | lazybot | ⇒ "Macro ([bindings & body]); binding => var-symbol temp-value-expr Temporarily redefines Vars while executing the body. The temp-value-exprs will be evaluated and each resulting value will replace in parallel the root value of its Var. After the body is executed... https://www.refheap.com/paste/12656 |
| 07:48 | xeqi | ritz or eclipse has a stepping debugger, but I've not used them yet |
| 07:51 | Glenjamin | could you give me some pointers on hacking debug output in with the repo? |
| 07:51 | Glenjamin | repl even |
| 07:53 | xeqi | Glenjamin: with nrepl.el you can M-. into the source of what you're calling, edit it, and C-c C-k to compile that file and use the debug version. In a pure repl I think you'd have to manually (in-ns ...) and then you should be able to (defn ..) the function you want to change, though could require a lot of copy paste |
| 07:54 | Glenjamin | ah, i see |
| 08:04 | Glenjamin | xeqi: managed to get somewhere with in-ns and def on the repo, cheers! |
| 08:04 | Glenjamin | damn autocorrect s/repo/repl/ |
| 08:06 | ticking | any thoughts on how to idiomatically update multiple subpaths of a nested datastructure at once? say (update-in {:a [{:b 1}, {:b 2}]} [:a n :b] inc) -> {:a [{:b 2}, {:b 3}]}, problem is zippers don't work with maps, update-in only works on one path, tree walkers don't have the appropriate information at walk time, and deconstructing an entirely new datastructure while updating at the same time is tedious and error prone ^^ |
| 08:08 | ambrosebs | ticking: you mean update them simultaneously with the same function? |
| 08:08 | ticking | ambrosebs yeah |
| 08:09 | ambrosebs | ticking: I often use the (-> map (update-in [:a] fn1) (update-in [:b] fn2)) idiom, but it's not "simultaneous". |
| 08:11 | ticking | ambrosebs, the above would also only work on a flat non nested map if I see this correctly |
| 08:12 | ambrosebs | ticking: not sure what you mean. |
| 08:14 | ticking | ambrosebs the code updates two elements of the map on the top level, say on a structure like {:a 1:b 2}, while the above data structure is nested {:a [{:b 1}, {:b 2}]} |
| 08:16 | mpenet | you can use for + reduce with an update in fn |
| 08:16 | mpenet | ex: (reduce (fn [path] (update-in map path) )(for [x xs y x ...] [x y]) map) |
| 08:17 | mpenet | not quite, my example is a bit wrong (the trailing map), but you get the idea |
| 08:17 | mpenet | cgrand wrote something about that a couple of years ago |
| 08:21 | banisterfiend | hi, does anyone here know about lighttable? i know it's written in js/html5 but it's in a webview, what's the framework? cocoa? qt? |
| 08:23 | mpenet | ambrosebs: I managed to get check-ns to hang for a very long time (minutes, with jumps to 100% cpu), I tried to quickly annotate a very small project with few deps to isolate the issue, but same result. Could you have a look? https://github.com/mpenet/knit/tree/typed |
| 08:24 | ticking | mpenet, so you're basically iterating all paths at once? |
| 08:25 | mpenet | you construct a vector of path with for, then use it with reduce to apply update-in to your original map |
| 08:26 | ticking | mpenet, I see thanks, sounds like an interresting approach |
| 08:26 | mpenet | well my example work with assoc-in, not update in, you would need to construct vectors or args to update-in, but same thing |
| 08:26 | mpenet | [[:foo :bar :baz] inc 1] etc |
| 08:26 | carlocci | scottj: thanks |
| 08:27 | mpenet | cgrand post was "flattening reduce", same approach for a different problem |
| 08:27 | mpenet | http://clj-me.cgrand.net/2010/01/19/clojure-refactoring-flattening-reduces/ |
| 08:30 | ambrosebs | mpenet: are you on master? |
| 08:30 | mpenet | ambrosebs: "0.1.7" |
| 08:30 | ambrosebs | I've probably fixed this, try 0.1.8-SNAPSHOT. |
| 08:31 | mpenet | I'll give it a try |
| 08:31 | ambrosebs | You'll need to lein install it. |
| 08:31 | mpenet | np, I have a local copy for greping around :) |
| 08:31 | ambrosebs | mpenet: It's a bit unsatisfying. What's actually happening is that jvm.tools.analyzer evals each form after analysing it, and it evals check-ns infinitely. |
| 08:32 | mpenet | quite funny |
| 08:32 | ambrosebs | mpenet: It sucks, but that's the only way I can figure out to make sure require's and use's are actually run at the right time during analysis. |
| 08:33 | mpenet | right |
| 08:33 | ambrosebs | mpenet: I've added a flag that tracks which namespaces are currently being checked, and to just return if already in progress. |
| 08:33 | mpenet | it seems to work now, thank |
| 08:33 | mpenet | s |
| 08:33 | ambrosebs | mpenet: great |
| 08:34 | ambrosebs | mpenet: I'll release 0.1.8, that's a pretty critical fix. |
| 08:34 | mpenet | yep, good idea |
| 08:34 | ambrosebs | mpenet: I'm in the middle of adding fn keyword argument support :) |
| 08:34 | ticking | mpenet, ah I see, thanks that should do the trick ^^, I wonder why noone has wraped that in a macro |
| 08:36 | ticking | banisterfiend, what do you wanna do? It doesn't seem written in qt the dylibs normally associated with qt are missing |
| 08:36 | ambrosebs | mpenet: does core.typed noticeably increase startup time for your app? |
| 08:36 | mpenet | ambrosebs: I noticed about kw args, I am waiting for it. |
| 08:37 | mpenet | about startup time, mostly the reflection warnings slow things a little, but no big deal |
| 08:37 | ticking | banisterfiend, it looks like they use https://github.com/rogerwang/node-webkit |
| 08:37 | mpenet | ambrosebs: other than that, I don't really care since this happens at compile time anyway. As long as it is not incredibely slow |
| 08:38 | ambrosebs | mpenet: I'm really not too sure how slow it is. I don't know how to AOT compile core.typed either. |
| 08:38 | ambrosebs | mpenet: good to hear anyway. |
| 08:39 | mpenet | ambrosebs: on knit, it's barely noticable, on hayt or alia it could be different, but I havent managed to successfully run check-ns on them yet, I am just using the repl and dummy fns until recently |
| 08:39 | carlocci | I would like to try out clojure: what is a web framework I can dabble in? |
| 08:41 | carlocci | I was reading about noir, only to discover it as somehow deprecated |
| 08:42 | jonasac | carlocci: there is something called http://www.luminusweb.net/ |
| 08:42 | jonasac | it uses lib-noir i think |
| 08:43 | jonasac | but just mixing and matching the libraries you need is pretty straightforward compared to other languages :) |
| 08:45 | carlocci | thanks, I'll check it out |
| 08:45 | mpenet | ambrosebs: I just realized I made a tons of error with HMap, and should use APersistentMap instead most of the time, again ann.clj is really helpfull to understand how things work. |
| 08:45 | carlocci | jonasac: what do you mean, compared with other languages? |
| 08:46 | carlocci | the problem is that I would like to learn the language as I go, so I think a little bit more constriction would be helpful in the beginning |
| 08:51 | ambrosebs | mpenet: There's also a common misunderstanding with Seq*, Vector* vs. ISeq and IPersistentVector. You almost always want the latter. |
| 08:51 | mpenet | ambrosebs: yup, took me a while to get that too |
| 08:52 | ambrosebs | It's not really documented anywhere unfortunately. |
| 08:53 | clojure-new | Hello, i have to files: proj.core and proj.util, how can i use proj.util from proj.core? |
| 08:53 | clojure-new | proj.util defined like that (ns proj.util) (defn...) |
| 08:54 | thm_prover | is there a language, embedded inside of clojure, that (1) does not have access to Java, (2) is similar to Clojure, and (3) has lightweight coroutines? (i.e. does not require an entire java thread)? |
| 08:54 | clojure-new | When i trying to (ns proj.core (:use proj.util)) i'm getting file not found exception. |
| 08:56 | markmcconachie | Hey, any recommendations for learning materials for clojure? |
| 08:57 | mpenet | ambrosebs: am I missing the obvious here? https://gist.github.com/mpenet/854ebc2a644fd68f77a7 |
| 08:58 | ambrosebs | mpenet: that's core.typed being a bit too strict. |
| 08:58 | clojure-new | It's a leiningen genrated project. |
| 08:58 | ambrosebs | mpenet: Perhaps casing :a to a Keyword might help? |
| 08:58 | mpenet | ambrosebs: but even if I use an union of values, it seems to fail |
| 08:58 | mpenet | keyword returns the same error |
| 08:58 | ambrosebs | ok I'll have a look. |
| 08:59 | mpenet | ambrosebs: I was trying it here: https://github.com/mpenet/knit/blob/typed/src/qbits/knit.clj#L18 |
| 09:00 | mpenet | ahhh, maybe I need to namespace qualify it? since it's declared in another ns? |
| 09:00 | mpenet | well, no it would work on my short example :/ |
| 09:01 | ambrosebs | mpenet: is it important to know that looking up :ns gives you a NANOSECOND, rather than a TimeUnit? |
| 09:01 | mpenet | ambrosebs: I want to restrict the possible values, and I would have to reuse this on kw args later |
| 09:01 | ambrosebs | restrict which values? |
| 09:01 | mpenet | that's why I didn't go for HMap (if I understand) |
| 09:01 | mpenet | keywords |
| 09:02 | mpenet | no I don't want to check that :ns = TimeUnit/NS, just that the user doesnt use nanosec |
| 09:02 | mpenet | :nanosec |
| 09:03 | ambrosebs | Right, you probably want '{:ns TimeUnit, :us TimeUnit, ...} |
| 09:03 | mpenet | ambrosebs: that's what I tried to say earlier, I will need this alias on kw args in another function later |
| 09:04 | mpenet | that is why it is not a HMap |
| 09:04 | clojure-new | Oh, i see. I can't use '-' in filenames. (ns bla-bla) => bla_bla.clj |
| 09:04 | mpenet | in the schedule fn |
| 09:05 | clojure-new | Is there workaround for that? Sinc it's ugly to have underscores in anything. |
| 09:05 | ambrosebs | mpenet: you've lost me. :/ |
| 09:07 | corecode | clojure-new: i think that is related to the jvm |
| 09:08 | clojure-new | corecode: Yeah, i think so too, but i don't know how to fix it. |
| 09:08 | corecode | don't |
| 09:08 | corecode | accept it |
| 09:08 | corecode | move on |
| 09:09 | john2x | how do I test a Ring handler that requires authentication? |
| 09:10 | gfredericks | authenticate with it? or use (with-redefs ...) to stub your auth function if you don't want to test that. |
| 09:10 | gfredericks | (with-redefs [authentic? (constantly true)] ...test the other stuff...) |
| 09:11 | Glenjamin | does anyone know of an easy way to generate an absolute url from a ring request map? |
| 09:14 | Glenjamin | aha, full url is in ring.util.request-url |
| 09:15 | ticking | mpenet, looks like this approach only works properly with statically known indices, not when they are calculated from the size of a vector for example |
| 09:26 | jimkcar | where does the contrib zip-filter library now live? |
| 09:30 | ticking | jimkcar, clojure.data.zip? |
| 09:32 | ticking | jimkcar, https://github.com/clojure/data.zip/ and in case of doupbt http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go it contains a list of what migrated where ^^ |
| 09:56 | _torn | hi - question about sequential destructuring |
| 09:56 | _torn | why would you want to use ":as foo" when you can just refer to the thing you're destructuring from? |
| 09:57 | _torn | I mean, :as creates a local binding -- but why is that useful? |
| 09:57 | jjttjj | if the thing you're binding is a longish expression? |
| 09:58 | _torn | ah right |
| 09:59 | jjttjj | and to not repeat yourself in general i guess. Like, the same reasons you would be binding the thing in the first place, but not you can do that and more in one compact line |
| 09:59 | xeqi | john2x: it sounds like you might want a cookie jar, I'd recommend looking at https://github.com/xeqi/peridot or https://github.com/xeqi/kerodon |
| 10:00 | _torn | does :as always grab the whole thing? |
| 10:00 | jjttjj | yup |
| 10:01 | jjttjj | _torn: this always was extremely useful for me getting used to destructuring: http://blog.jayfields.com/2010/07/clojure-destructuring.html |
| 10:02 | _torn | thanks for the link |
| 10:03 | john2x | xeqi: cool, thanks! curious, why make the 2 of them? at a quick glance, they seem to be very similar. (I think I'll go with peridot) |
| 10:04 | xeqi | john2x: peridot adds a cookie jar and a couple other nicities on top of ring-mock |
| 10:04 | xeqi | kerodon adds html parsing and interaction like a human |
| 10:04 | xeqi | peridot is better for api level stuff, like a edn or json api |
| 10:04 | xeqi | since its not html based |
| 10:06 | john2x | ah got it. it seems peridot is exactly what I'm looking for. |
| 10:06 | Glenjamin | is there a guide to "idiomatic" indentation for clojure somewhere? |
| 10:07 | borkdude | Glenjamin yes: https://github.com/bbatsov/clojure-style-guide |
| 10:07 | Glenjamin | excellent, thanks |
| 10:07 | borkdude | how do you add an entry like ~style ? |
| 10:08 | borkdude | ~anyone |
| 10:08 | clojurebot | anyone is anybody |
| 10:08 | borkdude | ~anybody |
| 10:08 | clojurebot | anybody is anyone |
| 10:08 | borkdude | lol |
| 10:08 | borkdude | :) |
| 10:08 | xeqi | clojurebot: style is https://github.com/bbatsov/clojure-style-guide |
| 10:08 | clojurebot | In Ordnung |
| 10:08 | xeqi | ~style |
| 10:08 | clojurebot | style is https://github.com/bbatsov/clojure-style-guide |
| 10:09 | borkdude | xeqi tnx |
| 10:09 | xeqi | hmm... not sure if thats the right way, but it seemed to do something |
| 10:10 | jonasen | dnolen: ping |
| 10:17 | jimkcar | @ticking thanks. that was it. |
| 10:21 | ticking | jimkcar, np ^^ |
| 10:21 | Scorchin | What's the recommended way to create functions that take optional parameters? e.g. (get-users) and (get-users 12) |
| 10:23 | skelternet | (get-users [] (blah blah ) [numusers] (blah blah blah)) ? |
| 10:23 | ticking | Scorchin I'd probably go with a multibody function (fn ([] 0) ([n] n)) |
| 10:24 | Scorchin | thanks |
| 10:24 | dnolen | jonasen: pong |
| 10:25 | jonasen | dnolen: anything that I need to do to get the core.logic.unifier patches applied? |
| 10:26 | jonasen | or have you not had time to look at them yet? |
| 10:26 | dnolen | jonasen: nope, they look good. Just want to cut 0.8.0 first |
| 10:27 | dnolen | then I'll apply it, and see if there are other similar fixes that should go into 0.8.1 |
| 10:27 | jonasen | dnolen: ok. I tought you released that already |
| 10:27 | dnolen | jonasen: no not yet. |
| 10:28 | Glenjamin | could someone help me out with laying out this macro? I can't figure out how to make it readable! https://gist.github.com/glenjamin/548670fe5855c7943d81 |
| 10:28 | jonasen | dnolen: I'd like to release my new lib to clojars but I'll wait for 0.8.1 as it depends heavily on the unifier |
| 10:31 | dnolen | jonasen: new lib looks cool |
| 10:33 | skelternet | Glenjamin: I got nuttin' for the formatting. |
| 10:33 | jonasen | dnolen: I'm very happy with how it turned out. It'll replace the kibit rules as it is much more powerful. No more need to write monstrosities like https://github.com/jonase/kibit/blob/master/src/kibit/rules/misc.clj#L65 |
| 10:33 | skelternet | Glenjamin: I think it is as readable as is |
| 10:34 | skelternet | Glenjamin: unless we can break that function out some how. |
| 10:36 | Glenjamin | skelternet: that's what i'm wondering, it feels like i'm doing too much in the let binding |
| 10:38 | edw | Glenjamin: I just commented. It seems like the code that is supposed to simplifies things just makes things more complicated. |
| 10:39 | Glenjamin | does the binding resolve to the original function? |
| 10:39 | Glenjamin | i just assumed doing that would recurse and break >.< |
| 10:40 | edw | The value is evaluated beforehand. |
| 10:42 | edw | I just commented again. In general you should do as little work in the macro proper. |
| 10:42 | dnolen | jonasen: hehe, that's good to hear :) |
| 10:43 | edw | Glenjamin: You could even put the LET over the LAMBDA, er, DEFMACRO. |
| 10:44 | Glenjamin | thats much clearer! |
| 10:45 | edw | Glenjamin, thanks, but you should also make sure it works. |
| 10:46 | Glenjamin | i can follow what's going on nwow - so should be able to sort it |
| 10:46 | Glenjamin | will probably pull the map out as its going to get more complex when i change insecure to a custom truststore |
| 10:48 | Glenjamin | hrm, thats infinitely recursing |
| 10:52 | edw | Glenjamin: One more try in your comments. |
| 10:59 | Glenjamin | edw: getting issues when using the macro now, i've updated the gist to something that'll run the the repl |
| 10:59 | Scorchin | Anyone used betamax to mock clj-http requests? If so, do you know how you're supposed to handle 'accept' headers? e.g. my clj-http request looks like this: (client/get url {:accept :json}) |
| 10:59 | Glenjamin | it says this: IllegalArgumentException No matching ctor found for class http$eval332$f__333 clojure.lang.Reflector.invokeConstructor (Reflector.java:163) |
| 11:00 | Scorchin | My betamax mock works fine without the {:accept :json}, but I'd like to provide the accept header |
| 11:02 | edw | Glenjamin: your original post function takes zero arguments. |
| 11:03 | edw | Also, with your http-extras, the ^:private is annotating the value and not the var. |
| 11:21 | Glenjamin | edw: sorry to keep bugging you, but i don't really understand what the No matching ctor error is trying to say - i've fixed the things you mentioned, but still getting that error when calling the macro |
| 11:22 | Glenjamin | are the vars in the let binding available in the scope of the expanded macro when used this way? |
| 11:23 | edw | Let me check something out… |
| 11:27 | Glenjamin | yeah, seems to work when i move the let back inside the macro expansion |
| 11:32 | edw | Glenjamin: please consult my latest comment. |
| 11:33 | Glenjamin | edw: awesome, makes sense |
| 11:34 | Glenjamin | any idea why it can capture orig-http, but not f? |
| 11:36 | edw | Glenjamin: I updated it yet again, just to show it in action. |
| 11:40 | jjido | jjttjj: I saw this link you sent earlier about destructuring |
| 11:40 | jjido | (let [{the-x :x the-y :y} point] |
| 11:40 | jjido | (println "x:" the-x "y:" the-y)) |
| 11:43 | jjido | I like how it reads. Makes me think the syntax I use in my language may not be as readable. Are there downsides to the syntax? |
| 11:54 | Glenjamin | edw: weirdly, when i tried that latest version, it didn't work with the real http/post - works with the let inside the macro and is still pretty readable, so going to stick with that |
| 11:55 | Glenjamin | cheers for all the help! |
| 12:08 | bbloom | hiredman: kiama relies on scala's pattern matching by type. my plan with retree is to omit pattern matching entirely from the base library, so that a pluggable pattern matching system can be used |
| 12:09 | bbloom | hence my questions about the nth exceptions with destructuring.... i kinda wish it didn't do that, so that there was a cheap free when-let style pattern matching baked in... *shrug* oh well |
| 12:10 | bbloom | my thought is that there are other useful syntaxes for patterns, such as CSS selectors or XPath queries that can be encoded as EDN and plugged into retree |
| 12:10 | bbloom | depending on the type of tree you're rewriting |
| 12:12 | ravster | hello all |
| 12:32 | clojure-new | Does clojure.jdbc provide sql injections protection? |
| 12:33 | clojure-new | with-query-results results ["select * from bla where ?" evil-code] |
| 12:33 | clojure-new | Is it secure? |
| 12:37 | tomoj | clojure-mode's indentation of hiccup bugs me |
| 12:48 | augustl | anyone got a favorite "getting started with Clojure repls in emacs" article? :) |
| 12:51 | ticking | augustl, the nrepl.el github page has a list of all the commands^^https://github.com/kingtim/nrepl.el |
| 12:51 | ticking | augustl, also if you are a newcomer to emacs I highly recommend emacs-live it's a pretty good emacs starter kit |
| 12:52 | ticking | https://github.com/overtone/emacs-live all you do then is go to your project do an M-x nrepl-jack-in |
| 12:54 | ticking | and then you get your regular repl, like your used to know, or you can evaluate forms in files via C-M-x and other various commands ^^ |
| 13:03 | augustl | ticking: thanks :) |
| 13:04 | augustl | swank is the old one, and nrepl is new and shiny, right? |
| 13:07 | tomoj | bbloom: it occurs to me that the parts of the one/all protocol I was thinking about are basically the children/make-node arguments to zipper |
| 13:09 | tomoj | I wonder if it's a coincidence that both things are called "zipping" -- given zippers a b you can implement (map f a b)-style zipping? |
| 13:12 | ticking | augustl, yes, nrepl.el uses clojures nrepl facility directly |
| 13:17 | augustl | inside a -main function invoked via "lein run", is it possible to read out the leiningen environment somehow? |
| 13:17 | augustl | what I really want to do: start a nrepl server in that main function when I'm starting with "lein run" and the development profile, but not when running it with java -jar |
| 13:18 | ticking | augustl you could simply run it by lein repl |
| 13:18 | ticking | and then M-x connect-nrepl |
| 13:20 | tomoj | another workaround would be to have two -mains in two namespaces and set :main to the repl one in the dev profile? |
| 13:22 | ticking | yeah right repl won't start the main |
| 13:22 | ticking | sorry, wait a sec |
| 13:23 | augustl | ticking: I want to connect to a repl that lives inside an existing process, not a "lein repl" process |
| 13:23 | augustl | tomoj: trying to figure out how to call a -main from another -main :) |
| 13:23 | ticking | augustl yeah right |
| 13:24 | augustl | I guess it's easier to put the actual call to a separate function and call that from both -main functions |
| 13:24 | tomoj | :injections [(require 'com.example.foo)] :repl-options {:init (com.example.foo/-main)} ? |
| 13:25 | tomoj | why care whether it's a "repl" or "run" process, as long as it's running your -main? |
| 13:25 | augustl | yay, epheremal ports works |
| 13:26 | augustl | tomoj: the problem was that my current -main contains lots of logic, that I would need to invoke from the other -main for dev. But putting the logic elsewhere makes more sense |
| 13:26 | ticking | you could also use clojure.main with the --repl flag and a --main provided |
| 13:27 | ticking | http://clojure.org/repl_and_main |
| 13:27 | tomoj | hmm, is that how you use :injections? |
| 13:27 | tomoj | or would you just do {:repl-options {:init-ns com.example.foo :init (-main)}} |
| 13:27 | ticking | *but I don't know how that would work out ^^ |
| 13:29 | augustl | I think it's better to just have two different mains with no logic other than dispatch |
| 13:29 | augustl | where the "main" main only starts the system, and my dev main starts a repl, the system, and whatever |
| 13:35 | augustl | is it possible to have nrepl in emacs automatically reconnect? |
| 13:38 | ticking | augustl, as in disconnect then reconnect? |
| 13:38 | ticking | for your case I don't think so |
| 13:38 | ticking | you could though write an elisp function that polls that for you ^^ |
| 13:39 | ticking | https://github.com/kingtim/nrepl.el/pull/56 |
| 13:39 | ticking | hrm |
| 13:49 | augustl | I guess I'll rarely stop the repl process when doing actual dev |
| 14:01 | augustl | how can it be that simply importing something causes side effects? Importing org.lwjgl.opengl.Display causes a box to appear in the OS X dock, even if I don't call anything. |
| 14:03 | augustl | and no, I don't have any (def foo 123) that could cause side effects when compiling :) All my calls are inside a function |
| 14:25 | bpr | augustl: i don't know what's necessarily going on in your particular case, but I've found that importing anything that depends on java.awt.* will cause the dock (app switcher) to show a generic application icon |
| 14:28 | bpr | augustl: for cli apps (or libraries) i've found that putting ["-Djava.awt.headless=true"] into your :jvm-opts in your project file can fix that |
| 14:28 | bpr | augustl: if your app does need a GUI, i'm not sure if that will work. I've nvr tried it |
| 14:32 | augustl | bpr: ah, that's probably it then. I guess lwjgl uses awt to draw the window |
| 14:32 | augustl | bpr: the gui will load even if I just start a "lein repl" :) |
| 14:32 | augustl | so it's a bit annoying.. |
| 14:32 | bpr | yup |
| 14:33 | bpr | i've had it pop up during a build (ie. lein uberjar). |
| 14:38 | augustl | on a slightly related note, anyone got a opengl library for the JVM to recommend? lwjgl is good enough, but much larger than what I need (I only need OpenGL itself) |
| 14:50 | augustl | refs lets you do coordinated writes to multiple refs. Is there also a way to do coordinated reads from refs? If I sequentially read @foo, @bar, @baz, I might values from different transactions/writes, right? |
| 14:50 | augustl | s/sequentially read/sequentially deref |
| 14:51 | jjjddd0 | Hi all, what is the recommended session middleware for a luminus app? There are lots of middlewares avail. out there but I don't really understand what is different about them ? |
| 14:53 | jjjddd0 | Eg. ring/wrap-session, noir.session, sandbar/wrap-stateful-session... etc |
| 14:53 | augustl | what's a luminus app? |
| 14:54 | ravster | what do they mean by "post-order traversal of form" in the docs for a post-walk? |
| 14:55 | augustl | jjjddd0: I use the build-in session stuff in ring, if that helps ;) |
| 14:56 | jjjddd0 | augustl: thanks! http://www.luminusweb.net/ |
| 14:59 | augustl | jjjddd0: I use cookies for session storage, too |
| 15:09 | edtsech | jjjddd0: luminus uses lib-noir internally, you can use noir.session http://yogthos.github.com/lib-noir/noir.session.html#var-get-in |
| 15:10 | jjjddd0 | edtsech: thanks! I just realized that the luminus site had a lot more documentation that I though |
| 15:14 | tyler__ | i just had the realization that url query string are a lot like logic programming e.g. http://example.com/some/resource/where?a=1&b=2 |
| 15:14 | tyler__ | looks a lot like [:find ?a ?b :where [1 ?a] [2 ?b]] |
| 15:14 | tyler__ | wonder if i can take that somewhere |
| 15:18 | tomoj | how do you represent [?a :foo ?b]? |
| 15:26 | smnirven | anybody out there use crypto-password? |
| 15:28 | dnolen | jonasen: ping |
| 15:30 | smnirven | anybody else trying to get crypto-password 0.1.0, and finding that there's only a snapshot version on clojars? |
| 15:33 | jonasen | dnolen: hi |
| 15:37 | dnolen | jonasen: patch applied! as far as LOGIC-118 I think prep* should be fixed. |
| 15:40 | jonasen | dnolen: I thought prep* should only handle ?x and (foo bar . ?y) and relying on walk-term to do the actual tree walking |
| 15:51 | dnolen | jonasen: prep* takes any expression, so I think it should handle it |
| 15:51 | Glenjamin | hi guys, i'm trying to figure out a nice way of handling errors in a compojure app without cluttering my routes - are there any good examples of open source sites I can look at? |
| 15:52 | smnirven | Glenjamin: do you mean exceptions or errors? |
| 15:52 | Glenjamin | any error conditions i guess, but specifically exceptions at the moment |
| 15:53 | Glenjamin | for example, i'm making an http request inside a let binding, if it fails i'd want to show a friendly page specific to that route - but putting a try..catch inside the binding is ugly, and putting one around the whole route seems a bit heavy handed |
| 15:53 | smnirven | I use a wrap-exceptions middleware |
| 15:53 | smnirven | in my "controller" code, I validate parameters, for example |
| 15:54 | smnirven | and if there's a problem, throw an ex-info with a specific response code and message |
| 15:54 | Glenjamin | and have the middleware decode that into a specific method? |
| 15:55 | Glenjamin | my exact example is calling request-token in an oath workflow - if it fails I'd rather show a "sorry, we can't connect" than the generic "unexpected error" page |
| 15:55 | smnirven | have the middleware catch any exception, and check for any ex-data that was specified when the exception was thrown |
| 15:55 | jonasen | dnolen: I'll take a second look |
| 15:56 | jtoy_ | hi all! |
| 15:56 | smnirven | Glenjamin: https://github.com/clojure/clojure/blob/master/changes.md#24-clojurecoreex-info-and-clojurecoreex-data |
| 15:58 | Glenjamin | so i'd have my oauth/authorise function catch the raw http error and turn it into something my app can handle, but doesn't that lead to binding the app to the various exception types? |
| 15:58 | Glenjamin | binding in the coupling sense, i mean |
| 16:01 | smnirven | Glenjamin: you mean binding the app to the specific kinds of exceptions that could get thrown by the http client? |
| 16:02 | Glenjamin | yeah, it might just be the way i'm looking at it |
| 16:02 | smnirven | I would have the code that calls oauth/authorize wrapped in try catch (make sure you catch Throwable, not Exception) |
| 16:02 | smnirven | in the catch throw a ex-info |
| 16:03 | smnirven | with specific instructions for the middleware |
| 16:04 | Glenjamin | smnirven: ok, cool - that makes sense |
| 16:04 | Glenjamin | the other case that comes to mind is if on a "save" action, theres a database connection failure |
| 16:05 | Glenjamin | you'd usually want to preserve the context, and redisplay the form to try again - i guess in that case just wrap the route in try..catch? |
| 16:06 | Glenjamin | i suppose i could do some sort of let-catch macro if i run into that |
| 16:07 | smnirven | Glenjamin: https://gist.github.com/smnirven/5183366 |
| 16:07 | smnirven | Glenjamin: that's akin to what I do |
| 16:11 | amalloy | Glenjamin: if you're using a reasonable http client, you can tell it to return an error-map instead of throwing an exception |
| 16:12 | Raynes | clj-http can make this happen. |
| 16:12 | Glenjamin | clj-http is what i'm using |
| 16:12 | Glenjamin | it's the translation of http code -> application error with context that i'm trying to piece together |
| 16:13 | Glenjamin | i'll gist an example, it's quite plausible i'm over-thinking it |
| 16:14 | Glenjamin | https://gist.github.com/glenjamin/81983d5a18a96e022196 |
| 16:15 | Glenjamin | multiple bindings in let with complex failure conditions, in general i've always tried to keep try..catch scoped as tightly as possible |
| 16:16 | Glenjamin | so an exception on the DB call would want to be handled differently to failures on external http calls, but still specific to the route |
| 16:17 | Glenjamin | i guess the idea is to wrap up those calls behind something that captures the domain, and turn them into exceptions with context for the domain that the controller can decide what to deal with? |
| 16:23 | smnirven | Glenjamin: here's what I would do, combined with that middleware thing I showed you earlier https://gist.github.com/smnirven/986ffd6ef66010df9d79 |
| 16:24 | Glenjamin | right, that makes a lot of sense |
| 16:24 | Glenjamin | thanks! |
| 16:24 | smnirven | no prob |
| 16:25 | Frozenlock | Is there an 'official' tool to make logs with ring/compojure? |
| 16:25 | smnirven | clojure.tools.logging |
| 16:25 | smnirven | Frozenlock: https://github.com/clojure/tools.logging |
| 16:26 | Frozenlock | smnirven: Thanks! |
| 16:46 | clojure-new | Hello. |
| 16:47 | brehaut | clojure-new: hi |
| 16:47 | Frozenlock | Welcome. |
| 16:48 | clojure-new | Guys, can you try to guess why this happening? I have string, and i'm trying to insert it in h2 db, rowtype is varchar, println prints string just ok but when it inserts string in db, string becames like this: |
| 16:48 | tyler__ | can you add tagged literals after cloure has already started? |
| 16:48 | clojure-new | aced000573720020636c6f6a7572652e6c616e672e50657273697374656e745374727563744d6170da82a8a2fdf1ac2f0200044c00055f6d65746174001d4c6 |
| 16:48 | clojure-new | I'm just don't know how to debug it... |
| 16:49 | clojure-new | When i'm switch type from varchar to carchar(1024) i'm getting this: |
| 16:50 | clojure-new | Exception in thread "main" org.h2.jdbc.JdbcSQLException: Value too long for column "DESCRIPTION VARCHAR(1024)": "'aced000573720020636c6f6a7572652e6c616e672e50657273697374656e745374727563744d6170da82a8a2fdf1ac2f0200044c00055f6d65746174001d4c6... (10060)"; |
| 16:50 | brehaut | ~helpme |
| 16:50 | clojurebot | A bug report (or other request for help) has three parts: What you did; what you expected to happen; what happened instead. If any of those three are missing, it's awfully hard to help you. |
| 16:50 | brehaut | clojure-new: guessing doesnt help anyone |
| 16:50 | brehaut | clojure-new: your best bet is to put a snippet on refheap or gist and link to that. |
| 16:51 | brehaut | clojure-new: however, it is nearly clojure west so a lot of people who might be able to answer your question may not be here atm |
| 16:53 | tyler__ | why would i use a tagged literal instead of just calling a function and passing in args? |
| 16:53 | tyler__ | im not grokking their utility |
| 16:53 | dnolen | tyler__: tagged literals are about data exchange |
| 16:53 | tyler__ | .... |
| 16:54 | tyler__ | like over the wire data exchange? |
| 16:54 | brehaut | tyler__: say i send you a blob of edn data, and i ahve tagged something as an #inst. your code might use java.util.Date etc, but mine uses jodatime. tagged literals mean that you dont have to worry about my implementation decisions, and we can still agree on a format for a specific datatype that wasnt originally in the transfer format specification |
| 16:55 | tyler__ | brehaut: ah brilliant |
| 16:55 | tyler__ | so its for people using my data who aren't me |
| 16:55 | brehaut | alternatively future you in a different project |
| 16:56 | tyler__ | brehaut: future me is not me ;) |
| 16:56 | brehaut | or the same project when you internal implementation changes |
| 16:56 | hyPiRion | Essentially it means that it's "boxing" and "unboxing" for you, so that you don't have to handle it yourself. |
| 16:56 | ivaraasen | tagged literals is the best thing since smoked bacon |
| 16:56 | clojure-new | Oh, i've figured it out, my string wasn't string at all, sorry for desturbance. :) |
| 16:56 | tyler__ | everytime someone says "box" now i think of monads heh |
| 16:56 | brehaut | clojure-new: lol. not a problem |
| 16:57 | brehaut | tyler__: shake that!! monads are not boxes |
| 16:57 | tyler__ | brehaut: i know i never said it was voluntary |
| 16:57 | brehaut | lol fair |
| 16:57 | ivaraasen | brehaut: yeah, they're burritos |
| 16:57 | brehaut | in this community they are writing desks |
| 16:59 | tyler__ | speaking of joda time, why doesn't #inst natively use joda it seems everyone uses it. maybe its complecting rather than composing |
| 16:59 | tyler__ | but you could just add it to clojure.core and that fixes that ;) |
| 17:00 | brehaut | tyler__: big long mailing list thread about exactly the that exists :P |
| 17:01 | tomoj | add a dependency on joda time to clojure.core?? |
| 17:01 | lazybot | tomoj: Definitely not. |
| 17:01 | tomoj | (inc lazybot) |
| 17:01 | lazybot | ⇒ 15 |
| 17:02 | tomoj | heh, lazybot always has your back on incredulous stares |
| 17:03 | hyPiRion | really?? |
| 17:03 | lazybot | hyPiRion: Definitely not. |
| 17:03 | tyler__ | is this a predicate function? |
| 17:04 | tyler__ | doh |
| 17:04 | tyler__ | is this a predicate function?? |
| 17:04 | lazybot | tyler__: Uh, no. Why would you even ask? |
| 17:04 | clojurebot | I don't understand. |
| 17:05 | tyler__ | do the bots use core.logic to do the nlp? |
| 17:05 | brehaut | no |
| 17:05 | hyPiRion | no |
| 17:05 | Bodil | tyler__: Nothing but core.logic would be powerful enough to match #"\?\?$" |
| 17:06 | tyler__ | heh |
| 17:06 | brehaut | #"\?{2,}$" ;) |
| 17:06 | brehaut | question??? |
| 17:06 | clojurebot | tufflax: there was a question somewhere in there, the answer is no |
| 17:06 | lazybot | brehaut: Oh, absolutely. |
| 17:06 | Bodil | brehaut: Whatever, showoff. :) |
| 17:06 | brehaut | Bodil: im pretty sure it has different answers for different numbers of questionmarks |
| 17:07 | brehaut | (negative and positive) |
| 17:07 | tyler__ | does it???? |
| 17:07 | brehaut | foo!! |
| 17:07 | brehaut | huh, maybe its only 2 and 3 now |
| 17:07 | tyler__ | are you sure??? |
| 17:07 | lazybot | tyler__: Yes, 100% for sure. |
| 17:07 | tyler__ | ok |
| 17:08 | Bodil | who is best pony??? |
| 17:08 | lazybot | Bodil: Oh, absolutely. |
| 17:08 | brehaut | a?? |
| 17:08 | lazybot | brehaut: Definitely not. |
| 17:08 | Bodil | That wasn't very exciting. :) |
| 17:08 | amalloy | Bodil, brehaut: just 2 or 3 |
| 17:08 | brehaut | sorry |
| 17:19 | technomancy | tyler__: #inst not using joda was a horrible mistake IMO |
| 17:21 | ivaraasen | Bodil: loving Catnip btw |
| 17:23 | Bodil | ivaraasen: Thanks! |
| 17:23 | brehaut | technomancy: an extension of java.util.Date being a horrible mistake? |
| 17:33 | ravster | what does "No acceptable resource available" mean when trying to use liberator? I have my route as " (GET "/" [] (l/resource :handle-ok {:body "hello world"}))" |
| 17:33 | manud | #sml |
| 17:35 | ravster | I'm trying to move my project to using liberator, and I don't understand why in the docs it says to use resource at some points and defresource at others. |
| 17:45 | tieTYT2 | i'm just getting started with clojure. Sometimes in my repl the prompt becomes " #_=>" and seems to stop responding. How do I get rid of this? |
| 17:46 | hiredman | that is a feature of the repl library lein uses, not of clojure proper |
| 17:46 | brehaut | tieTYT2: that means that you have an incomplete s experession |
| 17:46 | brehaut | eg if you open a list, vector, map, set or string and dont close it |
| 17:46 | hiredman | basically it means you hit enter on a incomplete expression |
| 17:47 | tieTYT2 | how do I get back to the user prompt? |
| 17:47 | tieTYT2 | i don't care if this errors |
| 17:47 | brehaut | close the expresssion |
| 17:47 | hiredman | most likely a missing quote or missing bracket |
| 17:47 | brehaut | ^C may also get you back in reply |
| 17:47 | tieTYT2 | i typed ) like 5 times and ' a few times |
| 17:47 | metellus | there's also ] and } and " |
| 17:47 | hiredman | it will never be ' |
| 17:47 | brehaut | and } |
| 17:47 | tieTYT2 | ^C exits out and it take a few seconds to startup again which is kind of annoying |
| 17:48 | hiredman | clojure does use ' in matched pairs for anything |
| 17:48 | hiredman | doesn't |
| 17:48 | smnirven | anybody use rotary for dynamodb? |
| 17:50 | tieTYT2 | this seems to happen when I paste multi-line code into the repl |
| 17:50 | tieTYT2 | even if it's valid |
| 17:50 | tieTYT2 | i'm following this example: http://java.ociweb.com/mark/clojure/article.html#Vars |
| 17:50 | tieTYT2 | the first defn is causing it |
| 17:51 | hiredman | I doubt it |
| 17:52 | tieTYT2 | i can paste it in at any time and get it to change my prompt |
| 17:53 | hiredman | tieTYT2: do you hit enter after that? |
| 17:53 | tieTYT2 | no |
| 17:53 | hiredman | well do that |
| 17:53 | tieTYT2 | ah ok that fixes it |
| 17:53 | hiredman | because it is mutliline input |
| 17:53 | hiredman | the first line is not a complete expression |
| 17:53 | tieTYT2 | i guess it needs a blank line |
| 17:53 | tieTYT2 | oh i get it |
| 17:53 | tieTYT2 | the weird thing is that it gives me the prompt before I hit enter |
| 17:54 | tieTYT2 | so it made me think that it processed that line |
| 17:55 | ravster | gah, even the most basic hello world isn't working with liberator for me. I'm doing "(GET "/" [] (l/resource :handle-ok "hello world"))", which is basically what the example is. Any ideas? |
| 17:58 | thm_prover | does ":when" in domonad (in contrib.moands) require a monad that supports m-zero and m-plus? |
| 17:59 | brehaut | thm_prover: im pretty sure it required m-zero |
| 18:00 | brehaut | thm_prover: m-zero represents the failure state / implicit else branch of the :when |
| 18:01 | thm_prover | brehaut: awesome! that explains alot, I was wondering wtf happened when ":when (...)" failed |
| 18:01 | brehaut | ha yes |
| 18:02 | thm_prover | brehaut: "When he heard this, he left very sad, because he was a man of great wealth." <-- is this because in clojure, it's not clear who owns what? |
| 18:02 | brehaut | thm_prover: thats a quote from the bible |
| 18:03 | thm_prover | yes, but I was trying to make sense of it in the context of concurrency |
| 18:03 | thm_prover | and didn't realize there were two followsup lines |
| 18:04 | brehaut | the wealth is mutable state in technomancy's version |
| 18:04 | tyler__ | i was playing with a bot and my buddy who knows about edn but didn't realize it was as subset of clojure. he was like "how do you get your output to convert to edn" and i suddenly had pity for everyone who's code isn't data |
| 18:06 | thm_prover | is m-seq just "(reduce >>= ...) " ? |
| 18:07 | brehaut | its been a long time since i used it but yes i think so |
| 18:08 | brehaut | thm_prover: (source m-seq) ;) |
| 18:08 | brehaut | thats clojure.repl/source |
| 18:10 | thm_prover | brehaut: nice, thanks! |
| 18:12 | tyler__ | im 4clojure i think we should rename the diffculty from easy-hard to simple-difficult because this one is supposedly "easy" but i have no clue how to do it |
| 18:12 | tyler__ | s/im/on/ |
| 18:12 | tyler__ | s/simple-difficult/simple-complicated/ |
| 18:24 | tgoossens | paredit sometimes really screws up (probably me) |
| 18:27 | tieTYT2 | i don't know what I'm doing yet, but if I type "lein classpath", it includes clojure-1.4.0 instead of 1.5.1 which I just downloaded. Is this something to be concerned about? |
| 18:28 | tieTYT2 | it's using a clojure-1.4.0 from my local maven repository. I assume it downloaded that on its own |
| 18:31 | tomoj | suppose you have a bunch of integers in some known bounds, but the distribution of the integers within the bounds is not known. you have a function which takes an integer k and returns a seq of the integers greater than or equal to k. can you draw approximately uniform samples (with and/or without replacement)? |
| 18:31 | ryanf | does emacs paredit have a command for "move the current form to the left/right in its containing list"? |
| 18:31 | ryanf | vim paredit doesn't seem to, and that's like the main thing I was expecting it to do |
| 18:31 | tomoj | uh, without just going and counting everywhere |
| 18:31 | brehaut | tieTYT2: you dont download clojure versions yourself, you specify them in your dependancies. if an older version is being used its because a lib you depend on is forcing it |
| 18:31 | tomoj | ..or pulling in the whole seq into a vec and using rand-nth |
| 18:33 | tieTYT2 | brehaut: i see. So the project.clj is using 1.4.0. Why does it do that by default? Shouldn't it use the latest by default? |
| 18:33 | brehaut | because the default is based on a template that ships with lein; a newer lein will use a newer template, but 1.5 is only a couple of weeks old |
| 18:34 | brehaut | tieTYT2: its a fairly safe assumption that if you dont know how to change the project.clj dependancies to a newer version of clojure, you probably dont know enough clojure to need the newer version |
| 18:35 | tieTYT2 | brehaut: i see. Well i've been learning clojure for 2 hours now. Should I concern myself with this? I created a clj script that puts a manually downloaded clojure-1.5.1.jar file in the classpath when it runs. But lein seems to be using 1.4.0. I don't knwo what trouble i could get myself into by doing this |
| 18:35 | st3fan | i'm having problems with println .. when i run code from the nrepl, println works fine, *except* when I println from a map or for .. not sure what is happening |
| 18:36 | brehaut | tieTYT2: well thats wrong. lein manages it for you |
| 18:36 | brehaut | it being the classpath |
| 18:36 | tieTYT2 | brehaut: I'm just following this tutorial: http://java.ociweb.com/mark/clojure/article.html#Vars |
| 18:37 | tieTYT2 | it told me to use the clj script, but it didn't tell me how to make the clj script. I googled separately and found a version on the web but it asks for the path to the clojure.jar |
| 18:37 | st3fan | maybe i should use a real logging framework |
| 18:37 | brehaut | tieTYT2: a clj script is a very old way of using clojure. use lein as the front end and stop using the script |
| 18:38 | tieTYT2 | ok i'll delete that, thanks |
| 18:38 | amalloy | ryanf: sorta, although "the current form" is too vague to act on. in (foo (bar (|baz) (blah)) (bam)), what is the current form? baz, (baz), (bar (baz (blah))), and (foo (bar (baz) (blah)) (bam)) are all "current" |
| 18:39 | xeqi | tieTYT2: theres some more current attempts at guides to clojure at http://clojure-doc.org/articles/content.html |
| 18:39 | amalloy | the command you probably want to look at is transpose-sexps |
| 18:40 | tieTYT2 | xeqi: should I read this instead? |
| 18:41 | tieTYT2 | this does seem to be a better tutorial |
| 18:41 | thm_prover_ | is there a way to get lightweight clojure threads / coroutines via algo.monads in clojure? |
| 18:42 | ryanf | amalloy: I guess that's true. I wouldn't mind having to have the cursor on the outermost paren though |
| 18:42 | ryanf | but yeah that sounds promising, I'll look into it, thanks |
| 18:42 | brehaut | thm_prover: im suspicious that monadic coroutines would not be what you want in clojure; the lack of tail call removal impedes that kind of thing |
| 18:43 | tgoossens | can someone think of useful clojure constructs / libraries for what i'm trying to do: simulator for robot. It must be able to execute a command which must be interruptable at any point. |
| 18:43 | thm_prover_ | is there no way to combine it with trampolines ? :-) |
| 18:43 | companion_cube | thm_prover_: in which logic do you prove theorems? :] |
| 18:43 | thm_prover_ | Coq |
| 18:43 | companion_cube | I see |
| 18:46 | thm_prover_ | brehaut: how about http://www.intensivesystems.net/tutorials/cont_m.html ? |
| 18:46 | brehaut | thm_prover_: you'd want to ask jimduey or pehaps hiredman whether they blow stack or not |
| 18:47 | thm_prover_ | hiredman: ^ |
| 18:50 | thm_prover_ | brehaut: holy sh** the article I was reading is by jim duey |
| 18:50 | brehaut | yes |
| 18:51 | brehaut | thats why i said to ask him :P |
| 18:51 | brehaut | he's also the single most enthused about monads person in the clojure community |
| 18:52 | xeqi | tieTYT2: I haven't kept up with the documentation project, but I'm sure antares_ would enjoy hearing any feedback since you're in the target demographic (new to clojure) |
| 18:53 | st3fan | grr i now switched to logging .. when i simply (myfunction) then I see my info logging go to *nrepl-server* but when i (def foo (myfunction)) nothing is logged |
| 18:53 | st3fan | what. is. going. on. |
| 18:54 | thm_prover_ | brehaut: I think the only thing I can do to make my work mmore black magic, is to use continuation monad together with minikaren |
| 18:59 | tyler__ | how do i make a for unlazy? |
| 18:59 | tyler__ | or eval all results |
| 18:59 | brehaut | tyler__: use doseq |
| 18:59 | Glenjamin | does anyone know of a library that provides a macro for catching exceptions based on matched ex-data? |
| 19:00 | tyler__ | ah looks like i have to wrap it in a vector |
| 19:01 | ryanf | using midje, is there an idiomatic way to store intermediate results so I don't have to include all of the setup in each fact? |
| 19:01 | xeqi | Glenjamin: slingshot ? |
| 19:01 | xeqi | https://github.com/scgilardi/slingshot |
| 19:02 | Glenjamin | i'm using clj-http, which throws an (ex-info), afaict slingshot needs me to be using try+/throw+ |
| 19:02 | brehaut | thm_prover_: fwiw, i recall that algo.monads' state-m has a couple of things that would be functions in haskell implemented as macros to get around the stack frame limits |
| 19:03 | ryanf | oh, I can use def inside the (fact) call. that helps. |
| 19:03 | tyler__ | brehaut: my function returns a value though, it looks like doseq is ignoring return value |
| 19:03 | brehaut | tyler__: is the value a sequence? |
| 19:03 | xeqi | I though try+ worked with normal throw |
| 19:04 | tyler__ | brehaut: yes |
| 19:04 | xeqi | also, clj-http mentions compatibility with slingshot https://github.com/dakrone/clj-http#exceptions |
| 19:04 | brehaut | tyler__: doall then |
| 19:04 | Glenjamin | xeqi: ah, you're right |
| 19:05 | thm_prover_ | brehaut: does continuation passing style transforms give me co-routines? |
| 19:05 | thm_prover_ | if so, this soudns like the type of thing that should already be available as a mcro |
| 19:05 | thm_prover_ | *macro* |
| 19:05 | brehaut | thm_prover_: CPS gives you everything ever |
| 19:05 | brehaut | thm_prover_: as coroutines are a subset of everything ever, yes they can |
| 19:05 | thm_prover_ | I heard it solves the halting problem in O(1) time |
| 19:06 | brehaut | everythign ever was implicitly within the scope of computable things |
| 19:07 | Glenjamin | xeqi: in fact, i was completely wrong - it's using throw+ |
| 19:10 | benedikt | i'm missing "clojure-jack-in" from emacs |
| 19:10 | benedikt | i have clojure-mode |
| 19:11 | thm_prover_ | brehaut: have you played with https://github.com/swannodette/delimc ? |
| 19:12 | scottj | benedikt: deprecated I believe in favor of nrepl-jack-in |
| 19:12 | benedikt | scottj: i dont have that either :P how do i get it? |
| 19:12 | scottj | benedikt: gogole nrepl.el |
| 19:13 | hyPiRion | $google nrepl.el |
| 19:13 | lazybot | [kingtim/nrepl.el · GitHub] https://github.com/kingtim/nrepl.el |
| 19:13 | hyPiRion | ^ |
| 19:13 | brehaut | thm_prover_: not in a very long time |
| 19:13 | benedikt | scottj: pulling it from the marmelade repo |
| 19:15 | ryanf | if I have a structure like (def foo {:a [{:b 1} {:b 2}]}), is there a function s.t. (____ foo [:a :b]) returns [1 2] |
| 19:15 | ryanf | or similar |
| 19:18 | benedikt | scottj: thanks |
| 19:19 | thm_prover_ | https://github.com/swannodette/delimc <-- why is (@cont3 10) 15 rather than 13 ? |
| 19:25 | dnolen | thm_prover_: I should probably just get rid of delimc, mostly was an experiment porting Common Lisp to Clojure |
| 19:26 | thm_prover_ | dnolen: what would you recommend? |
| 19:26 | thm_prover_ | I just want lightweight threads / coroutines in Clojure :-) |
| 19:31 | dnolen | thm_prover_: probably not going to happen. I think most of the coroutine stuff built on top of delimited continuations in Lisp ended up performing terribly. |
| 19:31 | dnolen | thm_prover_: I looked into that stuff quite a bit when I was writing delimc |
| 19:32 | thm_prover_ | so I want to simulate lots of micro threads |
| 19:32 | thm_prover_ | and for agents, I end up writing "state machines" |
| 19:32 | thm_prover_ | when I'd really prefer to write litle threads that block |
| 19:32 | thm_prover_ | does Clojure basicaly not suppor the actor model? |
| 19:32 | scottj | ryanf: not built-in afaik, for that specific case (((fn [m [a b]] (map b (a m))) foo [:a :b]) |
| 19:32 | thm_prover_ | dnolen: ^ |
| 19:33 | SegFaultAX | dnolen: Don't get rid of it. Just make sure the documentation (README, wiki, whatever) reflects what it is accurately. |
| 19:33 | Bodil | thm_prover_: You can use Akka from Clojure. |
| 19:33 | Bodil | thm_prover_: Just saying. :) |
| 19:33 | ryanf | scottj: oh, ok, thanks. I ended up just doing (map :b (foo :a)) and not worrying about generalizing it |
| 19:33 | dnolen | SegFaultAX: sure |
| 19:34 | SegFaultAX | dnolen: I say this as someone who has dumpster dived through quite a lot of your code. :) Currently working through core.match |
| 19:35 | dnolen | SegFaultAX: heh, cool! |
| 19:35 | thm_prover_ | Bodil: please excuse my ignorance: how does Akka work with Clojure? how does Akka avoid clojure code from being full java threads? |
| 19:35 | SegFaultAX | Dumpster dived had the wrong connotation there. I just mean reading deeply through lots of your projects. |
| 19:35 | SegFaultAX | No offense meant :) |
| 19:35 | Bodil | thm_prover_: I don't know much about Akka, only that it's got Clojure bindings. :) |
| 19:40 | thm_prover_ | dnolen: what was your final conclusion on clojure / coroutines? |
| 19:40 | dnolen | thm_prover_: sounds like a fun experiment, I don't see how it could really be practical or usable |
| 19:41 | dnolen | thm_prover_: I could be wrong tho, I didn't really pursue, I kind of stopped after I read the results of various papers. |
| 19:48 | egghead | hey clj/west guys -- do we need to do anything special for the ground kontrol stuff tonight or just show up? |
| 19:48 | Raynes | Given the word 'kontrol' in the name I assume you need to be using KDE. |
| 19:49 | Bodil | Raynes: http://25.media.tumblr.com/tumblr_m9xw9cYPmK1rbg79no1_500.gif |
| 19:49 | dnolen | egghead: I imagine just show up |
| 19:50 | Bodil | Raynes: You coming, btw? |
| 19:50 | egghead | cool :) |
| 19:51 | Raynes | No. |
| 19:51 | Bodil | Raynes: :( |
| 19:51 | egghead | alright, headed to the st paddys day stuff over at kells then ground kontrol, cya around #clojure |
| 19:51 | hyPiRion | Raynes: Oh, good! We can make some Clojure app or library while everyone else is attending ClojureWest |
| 19:52 | hyPiRion | Because, you know, I suspect we may be the only ones not attending =| |
| 19:53 | Raynes | hyPiRion: Sure. I was thinking of doing a Space Alert mission generator. amalloy can consult. |
| 19:53 | Raynes | You start, I'll hop in with bug fixes. |
| 19:55 | seancljwest | see some of you in portland tonight i expect... just heading out to the airport... |
| 19:56 | hyPiRion | Bug #1: Implement the Space Alert mission generator. |
| 19:56 | hyPiRion | (Enhancement) |
| 19:56 | Raynes | You've won this battle hyPiRion, but you shall not win my war. |
| 19:56 | clojurebot | hyPiRion: Probably because it is using the IRC protocol directly -- the equivalent of you putting /say in front of your messages. |
| 19:57 | hyPiRion | heh |
| 19:57 | hyPiRion | Thank you clojurebot, that cleared everything up. |
| 20:02 | xeqi | <- also missing c/w |
| 20:04 | Raynes | It's interesting how the people missing c/w are coincidentally the coolest in the community. |
| 20:04 | SegFaultAX | It's also interesting that the organizers would decide to schedule it concurrently with an even bigger conference. |
| 20:05 | seancljwest | what conference is that SegFaultAX ? |
| 20:05 | SegFaultAX | seancljwest: PyCon |
| 20:05 | Raynes | I don't think we have much overlap there. |
| 20:05 | seancljwest | well, the conference proper ended today |
| 20:05 | seancljwest | what's left are the sprints |
| 20:06 | xeqi | .. is pycon really a whole week? |
| 20:06 | seancljwest | and i bumped into a couple of clojurians at pycon |
| 20:06 | seancljwest | 13-21 are the official dates xeqi |
| 20:06 | SegFaultAX | xeqi: It's a huge community. Lots of stuff going on. |
| 20:06 | seancljwest | but that includes tutorials, workshops, sprints |
| 20:06 | seancljwest | the conference itself was friday-sunday |
| 20:06 | seancljwest | and today was mostly "poster sessions" rather than a full day of sessions |
| 20:07 | seancljwest | tavis rudd gave an awesome talk today - and he'll be speaking at c/w too |
| 20:08 | seancljwest | pycon was awesome :) |
| 20:08 | seancljwest | 2,500 people - it sold out |
| 20:09 | seancljwest | ok, airport bound... laters :) |
| 20:10 | SegFaultAX | Raynes: In what way do you mean? |
| 20:10 | Raynes | In the way I said. |
| 20:10 | Raynes | :p |
| 20:11 | Raynes | I doubt there is a huge amount of overlap of people going to pycon who want to go to clojure/west and vice versa. |
| 20:12 | SegFaultAX | Perhaps. |
| 20:20 | TimMc | Is there a way I can mock or intercept System/getenv for testing purposes? |
| 20:21 | SegFaultAX | TimMc: Is wrapping System/getenv an option? |
| 20:21 | TimMc | I suppose. |
| 20:22 | jonasac | hmm no matter what i put into (javadoc) i just get the api for String, strange |
| 20:22 | scottj | jonasac: maybe you're passing a string, and it takes a class? |
| 20:23 | scottj | jonasac: yeah http://clojuredocs.org/clojure_core/clojure.java.javadoc/javadoc |
| 20:25 | jonasac | oh right :p |
| 20:32 | jonasac | should have figured |
| 20:32 | jonasac | probably an indication that i should take a break :p |
| 20:49 | dnolen | recursive featurec http://github.com/clojure/core.logic/commit/d5eda7d7f89443b449d7955a76e72828561082f6, re: hiredman |
| 20:54 | TimMc | dnolen: Because there's no internet? |
| 20:56 | dnolen | TimMc: heh no, just few distractions (for me) |
| 21:14 | technomancy | erlang factory is this week too |
| 21:14 | hiredman | dnolen: exciting |
| 21:16 | scottj | no distractions like glare from other passengers open windows, announcements by pilot/flight crew, electronic turn-off mandates, getting up for someone else to go to the restroom, drink/food/snack service, skymall offers, babies, turbulence, ? :) |
| 21:19 | scottj | for me its more a matter of few options than no distractions. |
| 21:20 | hyPiRion | yeah, I should've been at erlang factory, because I need it to learn it within the next 5 days |
| 21:21 | dnolen | scottj: heh, well put |
| 21:25 | ambrosebs | dnolen: massive congrats on 0.8.0! Really exciting :) |
| 21:26 | dnolen | ambrosebs: thanks! |
| 21:27 | ambrosebs | dnolen: what's on the menu for for 0.9.0? |
| 21:28 | dnolen | ambrosebs: hrm, figuring out how to do polymorphic constraints. Bunch of performance stuff, and hopefully another constraint domain(s) CLP(Set|HashMap) |
| 21:29 | ambrosebs | dnolen: nice |
| 21:33 | dnolen | ambrosebs: yeah I don't think I'd be happy nearing 1.0 w/o a polymorphic constraint story. it's seems pretty tricky to me at the moment. |
| 21:34 | dpwright | Hello.. I'm a bit confused about clojure and Java booleans |
| 21:35 | brehaut | dpwright: how so? |
| 21:35 | dpwright | I am getting a java.lang.Boolean back from korma, and I'm given to understand that they always evaluate to true in if statements and that I should use "boolean" to coerce it to a clojure boolean |
| 21:36 | dpwright | but (type (boolean (java.lang.Boolean. true))) returns java.lang.Boolean |
| 21:37 | ambrosebs | dnolen: what is a polymorphic constraint? |
| 21:37 | dpwright | (I think it was a stack overflow thread on "common mistakes for clojure programmers to avoid" or something where I read that java booleans evaluate to true) |
| 21:38 | dnolen | ambrosebs: we don't want to get into a situation where we have things like (fd/!= ...) and (!= ...) etc. |
| 21:39 | dnolen | ambrosebs: it would be nice to dispatch to the right constraint implementations once a parameter becomes instantiated. |
| 21:40 | dnolen | ambrosebs: but because we might "run" backwards it kind of complicates things. It's no longer the case that just dispatching on the type of the first argument is all that useful. |
| 21:41 | ambrosebs | I don't understand what you mean by trying to avoid fd/!= and !=? |
| 21:41 | dnolen | ambrosebs: if (!= x 1) where x is assigned to some interval should dispatch to fd/!= instead of inefficient disequality |
| 21:42 | ambrosebs | dnolen: ah makes sense. So it's multiple dispatch on a volatile runtime type :/ |
| 21:43 | dnolen | ambrosebs: this is something I toyed around with when I started cKanren work but it just seemed like too much work at the time. |
| 21:43 | dpwright | ...actually, there's a comment on that stackoverflow thread saying that it's working in clojure 1.4, so maybe it's just an old version thing. Turns out the problem that led me to wondering about bools was caused by something unrelated |
| 21:43 | dnolen | ambrosebs: it kinds of seems like you would need predicate dispatch for it to work ... |
| 21:44 | dnolen | ambrosebs: since you would want the system to be open, but very efficient based on type of and the level of instantiation of the constraint parameters. |
| 21:44 | dpwright | since (type true) returns java.lang.Boolean, I guess there's no such thing as a "clojure boolean", and they are just java.lang.Booleans? |
| 21:44 | ambrosebs | dnolen: yea... |
| 21:47 | amalloy | dpwright: indeed |
| 21:47 | hyPiRion | Oh, the booleans |
| 21:47 | hyPiRion | ,(false? (Boolean. false)) |
| 21:47 | clojurebot | false |
| 21:49 | dpwright | right, and yet |
| 21:49 | dpwright | ,(false? (boolean (Boolean. false))) |
| 21:49 | clojurebot | true |
| 21:50 | hyPiRion | I think it's because |
| 21:50 | hyPiRion | ,(identical? false (Boolean. false)) |
| 21:50 | clojurebot | false |
| 21:50 | hyPiRion | ,(identical? false (boolean (Boolean. false))) |
| 21:50 | clojurebot | true |
| 21:50 | dnolen | ambrosebs: we may be able to get away with a much lighter version of core.match in core.logic since it really doesn't need to be general - just types and level of instantiation - this only about constraint parameters. |
| 21:51 | ambrosebs | dnolen: interesting. |
| 21:51 | dpwright | so the type is the same, but the value representing false is different |
| 21:52 | dnolen | ambrosebs: the core.match algo really isn't that much code, most of that code is crazy stuff like extending the matcher and optimized matching for all the different datatypes. I don't think we need to do that at all here. |
| 21:52 | dpwright | is there a reason for that? pretty sure this conversation has been had many times before, but maybe I just haven't found the right blog post for it or something |
| 21:54 | ambrosebs | dnolen: are you implying building a more specific predicate dispatch system on top of a stripped down core.match? |
| 21:54 | dnolen | ambrosebs: yeah |
| 21:55 | ambrosebs | dnolen: is the core.match algorithm still relevant for pred disp? |
| 21:55 | dnolen | ambrosebs: oh, should be clear we don't need full pred dispatch here. |
| 21:55 | dnolen | ambrosebs: it's really just optimized pattern matching that allows future extension. |
| 21:55 | ambrosebs | ok |
| 21:55 | muhoo | U+1F4A9 pile of poo: https://www.refheap.com/paste/12674 |
| 21:56 | dpwright | oh wait, clojure "false" represents the java constant java.lang.Boolean/FALSE, whereas (Boolean. false) is just the value false of type boolean |
| 21:56 | dnolen | ambrosebs: I think for core.logic we just assume the matches are disjoint - I think we can get away with that ... |
| 21:56 | dpwright | ,(identical? false java.lang.Boolean/FALSE) |
| 21:56 | clojurebot | true |
| 21:57 | dpwright | think I get it now -- thanks hyPiRion for pointing me in the right direction |
| 21:57 | hyPiRion | dpwright: That's essentially what it boils down to. |
| 21:57 | dnolen | ambrosebs: heh good discussion, this has clarified how I think I might want to tackle this ... |
| 21:58 | ambrosebs | dnolen: haha nice |
| 21:58 | tomoj | lattice-kanren looks intriguing |
| 21:59 | dnolen | tomoj: it does ... don't really understand it yet though :) |
| 22:01 | tomoj | it looks like the time type in conal's reactive is an example of a domain in their sense |
| 22:02 | tomoj | I guess any sensible time type would look like that |
| 22:19 | muhoo | any idea how i can turn a BufferedImage into something that i can feed to a ring response :body? |
| 22:20 | antares_ | muhoo: converting it to bytes or a stream should work, not sure what's the best way, though |
| 22:21 | muhoo | antares_: sounds reasonable, but i don't see any way to do that. alas, my java-fu is lacking |
| 22:22 | antares_ | muhoo: http://stackoverflow.com/questions/649186/how-to-get-an-inputstream-from-a-bufferedimage |
| 22:22 | muhoo | disco, thanks! |
| 22:22 | antares_ | muhoo: so, ByteArrayOutputStream sounds like what you need |
| 22:22 | muhoo | OkThankYouForThat |
| 22:55 | muhoo | done https://www.refheap.com/paste/12675 |
| 23:09 | mye | Since handling bytes in clojurescript doesn't seem to be directly supported, the best alternative is probably a vector with ints, right? |
| 23:10 | brehaut | mye: how do you mean? primative bytes are handled fine. its only unsigned bytes that are problematic |
| 23:11 | brehaut | ,(byte 100) |
| 23:11 | clojurebot | 100 |
| 23:11 | brehaut | ,(map byte [127 128 129]) |
| 23:11 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Value out of range for byte: 128> |
| 23:12 | mye | brehaut: trying that in my clojure*script* repl: is tells me (byte) isn't defined |
| 23:12 | brehaut | oh, clojurescript is different |
| 23:12 | brehaut | theres only numbers |
| 23:12 | brehaut | (in javascript) |
| 23:12 | brehaut | except where there arent |
| 23:12 | brehaut | depending on the browser you are targetting you can get typed arrays |
| 23:12 | brehaut | and i think you can get real bytes there |
| 23:13 | mye | hm, yeah, for portability of code that runs in clojure and cljs having a fallback for bytes would be nice, if that's possible |
| 23:14 | mye | the clojure code could be more efficient probably, but I'll have to do with whats in cljs then. (I want that code to generate URLs in both the browser and server side) |
| 23:15 | muhoo | iirc in javascript all numbers are floats (!) |
| 23:15 | brehaut | muhoo, not exactly |
| 23:16 | brehaut | muhoo: modern runtimes treat them as ints if you perform certain operations on them, converting to float only when necessary |
| 23:16 | brehaut | and you can convert them back with some bitwise ops |
| 23:17 | brehaut | (this is the premise of emscripten and asm.js i believe) |