#clojure logs

2014-06-16

00:03mdeboard,(fn [s] (let [sep #"," foo (clojure.string/split s sep)] (if (= (str (last s)) (str sep)) true false)))
00:03clojurebot#<sandbox$eval73$fn__74 sandbox$eval73$fn__74@15c2817>
00:03mdeboardWhoops, well yeah that
00:03mdeboard,((fn [s] (let [sep #"," foo (clojure.string/split s sep)]
00:03mdeboard (if (= (str (last s)) (str sep)) true false))) "a,b,c,d,")
00:03clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
00:04mdeboard,((fn [s] (let [sep #"," foo (clojure.string/split s sep)] (if (= (str (last s)) (str sep)) true false))) "a,b,c,d,")
00:04clojurebottrue
00:04mdeboard,((fn [s] (let [sep #"," foo (clojure.string/split s sep)] (if (= (str (last s)) (str sep)) true false))) "a,b,c,d")
00:04clojurebotfalse
00:04mdeboardkelseygi: ^ ?
00:04kelseygiyeah, that’s where i was going—check the last char, treat the array differently in each one
00:05kelseygii guess i was secretly hoping for something like a split-with on string with regex?
00:05andyf,(clojure.string/split "a,b,c,d" #"," -1)
00:05clojurebot["a" "b" "c" "d"]
00:05andyf,(clojure.string/split "a,b,c,d," #"," -1)
00:05clojurebot["a" "b" "c" "d" ""]
00:05andyfkelseygi: ^^^
00:06mdeboardnoice
00:06kelseygiooooh!
00:06mdeboardstil have to treat the array differently :P
00:06kelseygii totally missed that in the clojuredocs example, thank you!
00:07kelseygithat works for this particular case, the thing i was going to do if it *doesn’t* end in the separator was store an empty string
00:08dbaschthat should be in the doc string, because it’s not obvious behavior for the limit parameter
00:08mdeboardNow, what about comparing vectors? like how would I "diff" [1 1 3 5] and [1 1 2 3 4 5 5], such that it would return [2 4 5]
00:09kelseygidbasch: much agreed
00:09mdeboardthere are dupes so sets wouldn't work
00:10andyfdbasch: You can create a ticket requesting such a change. It may or may not be accepted. Not easy to tell until one tries.
00:10andyfdoc strings tend to be terse
00:10andyfby choice
00:10mdeboardfar too terse in many cases
00:11dbaschandyf: true, but they do try to document the expected behavior of a function with expected parameters
00:11andyfOne can make their own doc strings that expand on the originals, e.g. https://github.com/jafingerhut/thalia
00:12andyfThat project only scratches the surface, and I haven't added to it in a while, but if people are interested in longer doc strings and have the time to write them, send a pull request.
00:12johnwalkerthanks for lein 2.4.2
00:12dbasche.g.
00:12dbasch,(reduce 1 1 [])
00:12clojurebot1
00:12dbasch^^ that works according to the doc string of reduce
00:13johnwalker,(reduce 'foobar 1 [])
00:13clojurebot1
00:13andyfmdeboard: If you want to write 600 expanded doc strings, or even 10, go for it. I don't mean that sarcastically -- it only takes time.
00:13johnwalkerhahaha
00:13johnwalkerthats cute
00:14mdeboardandyf: I mean, it's not a philosophical point... many doc strings are close to useless as documentation, i.e. helping people understand what a function does.
00:14andyfone can complain, or one can do something useful about it
00:15mdeboardI mean, I literally can't do something useful about it because I don't know what the function does because their documentation doesn't explain it well
00:16andyfthere is the source code, and docs on the Java API's
00:16andyfI am not demanding that you do something -- I am pointing out an alternative to complaining. That's all.
00:16mdeboardeyeroll
00:16mdeboardat the passive aggressiveness
00:17andyfThere is no aggressiveness in my mind at all.
00:18hellofunkAnyone know how to route an abitrary URI like /whatever to show the contents of a specific HTML file? route/files seems to require the URI *is* the HTML file
00:18hellofunkUsing Compojure, of course
00:18johnwalkerdid you see what hyPiRion did with deliver dbasch?
00:18brehauthellofunk: just make a route and return that specific html file
00:19brehautfiles are a vald response :body
00:19dbaschjohnwalker: no
00:19hellofunkbrehaut: when you say "return" it, how exactly?
00:19johnwalker,(map deliver [inc dec] [10 11])
00:19clojurebot(11 10)
00:20hellofunkbrehaut: you mean [:body "something.html"] ?
00:20umpa,(defmacro forever [& body]`(while true ~@body))
00:20clojurebot#'sandbox/forever
00:20johnwalkerhe also did a good one with with clojure.string/replace
00:20brehauthellofunk: return {:body (clojure.java.io/file path-to-filename) ...}
00:21brehauthellofunk: you need to go learn about ring right away
00:21brehauthellofunk: https://github.com/ring-clojure/ring/
00:21dbaschjohnwalker: that’s a bit unexpected :)
00:22hellofunkbrehaut ah doing it at the ring layer, not the compojure layer
00:22hellofunkbrehaut or rather the hiccup layer
00:22brehauthellofunk: compojure is just a small layer on top of ring, you cant use compojure without also using ring
00:22johnwalkerhis replace was better, but it was something like this
00:22johnwalker,(clojure.string/replace "$1000$5000" #"\d{4}" (fn [s] (apply str (reverse s))))
00:22clojurebot"$0001$0005"
00:23johnwalkerwell, he actually did a parseint and exchanged those for unicode characters
00:23johnwalkerbut the idea is that you can pass functions to clojure.string/replace when the second arg is a regex
00:23johnwalkerit doesn't work for strings, which is slightly irregular
00:24brehauthellofunk: hiccup is just an html rendering layer
00:31hellofunkwhenever I change my compojure routes function, i notice I must stop the webserver, compile the entire source file, then start the server again (connecting localhost). does this seem right?
00:31johnwalkerhave you tried using a var
00:31johnwalkerfor your routes?
00:31johnwalkerwith #'
00:32hellofunklooks like it is a var: (jetty/run-jetty (wrap-app #'app) {:port port :join? false}
00:33hellofunkah, perhaps because my #'app refers to a def that in turn then refers to my routes, since #' is wrapping the routes inside cemerick's friend
00:34johnwalkeri don't actually know if thats related
00:34johnwalkerseems like it should work
00:35hellofunkjohnwalker: good catch. I had one reference as a var, but what it referred to then did not reference my routes as var. changed that, workign nicely.
00:35hellofunkthe Friend example doesn't use vars so I hadn't either.
00:35johnwalkeroh, gotcha
00:35johnwalkerglad i could help
00:39hellofunkjohnwalker so am i!
00:40johnwalker:)
00:57hellofunkdo i understand correctly that clojure.java.io/resource will look directly and implicitly in the leinengen resources/ directory?
01:00amalloytoday's reminder of little-used clojure features: an alternate to the standard single-line comment character ";" is available in #!, in case you hate semicolons
01:01hellofunkamalloy curious are ; and #! both reader-level comment symbols?
01:01amalloyyes
01:01amalloyhellofunk: it seems completely bizarre and pointless - who would use #! instead of a semicolon? but then you remember that that's a shebang
01:01hellofunkas opposed to (comment ...) which is actually compiled
01:01hellofunka shemale, what?
01:01hellofunkin clojure??
01:02lazybothellofunk: Uh, no. Why would you even ask?
01:02hellofunkoh, misread...
01:02amalloygood answer, lazybot
01:02amalloyas always
01:02hellofunkindeed that was impressive. what triggered that response? the double question mark?
01:03hellofunkquestions ending in clojure??
01:03hellofunkguess not
01:03lazybothellofunk: Uh, no. Why would you even ask?
01:03hellofunklazybot likes shemales?
01:03hellofunkguess not
01:03hellofunkyou like this, what?
01:05TEttinger??
01:05lazybotTEttinger: What are you, crazy? Of course not!
01:05clojurebot? is suddenly
01:05ecfuser59999Does anyone know if the limit of 4 primitive arguments will be removed ?
01:06amalloyi wouldn't bet on it, ecfuser59999
01:06amalloyit's pretty rare to need more than four distinct primitive args, and if you really do you can shove them into an array
01:07ecfuser59999I do math modelling and could easily use 10 or primitive arguments. Yes I could use an array but not a very nice way to pass parameters!
01:09ecfuser59999thanks anyways
01:25mdeboardHow would I "diff" [1 1 3 5] and [1 1 2 3 4 5 5], such that it would return [2 4 5]
01:25mdeboardi feel like i'm missing something
01:39amalloymdeboard: well, diff is a vaguely-defined problem. if it's guaranteed that all elements of the first list are present in the second, in the same order (or if those are the only answers you care about), then it's not too hard
01:40mdeboardamalloy: I think I got a solution with `frequencies`
01:40amalloythat's fine too, if you don't care about order
01:42amalloyif you wanted to diff them in order, by which i basically mean "which elements from b would you have to remove in order to get a", you can do something like https://www.refheap.com/86669
01:43amalloybehavior is undefined if there's no way to remove elements from b and wind up with a
01:53amalloymdeboard: ^
02:00mdeboardamalloy: interesting, thanks
02:14mdeboardI mean the "funny" part of this purely functional approach is that I'm managing exactly as much state as I was before
02:27hellofunkmdeboard you are using atoms, refs a lot?
02:38ayiaHi guys. I need a collection in clojure with specific rule for adding new elements. What is the best way to do this in clojure? I tried to ask google, but did not find much... It was even hard to build a proper query because I don't know the correct direction to go...
02:38hellofunkayia what kind of rule?
02:40pyrtsaamalloy: Diff in general is a vaguely-defined problem but what mdeboard seemed to be talking about and what you came up with a good answer for in https://www.refheap.com/86669 is the well-defined problem of difference of sorted sequences, or essentially, bags.
02:40ayiahellofunk: My collection should be (most a probably a set) a collection of "path" vectors like [1 0 0 0], [1 0 1 0]... The rule should be: the new vector is "ok" to be conj-ed if it has at least one "peek/node/element" with bigger number at correspondent location... hm... hard to explain... will think more now:)
02:43ayiaE.g. if I have [[1 0 2 0][2 0 1 0]] then I can't conj-ed [1 0 1 0], because no one from its peeks is "higher" than any other peek in correspondent place at available "paths"
02:44ayiaOK paths are: [3 0 1 0], [1 0 3 0], [1 1 2 0], [2 0 1 1], [2 1 1 0], etc...
02:47mdeboardi'm doing this wrong, right? https://github.com/mattdeboard/ticket-to-ride/blob/functional-refactor/src/ttr/board.clj#L326-L347 All the swap! calls seems weird as hell to me
02:49mdeboardI guess I'm just not thinking with recursion hard enough
03:04amalloyyes, mdeboard, that's madness. all those swap! calls are just describing one pure function that acts on state, composed of five shorter ones
03:05amalloy(swap! state (fn [state] (-> state (update-in [:players pname :routes :claimed] concat route) ...)))
03:07amalloyreally all of claim! can probably be a single swap! call, which takes in an old state and returns a new state
03:07amalloyonce you've done that, it becomes clear that you can drop the swap! and the atom from claim! entirely, and just call the function claim instead. then you can write (swap! state claim pname route)
03:08amalloydoes that make sense, mdeboard?
03:29dhklWhen creating a map using the map literal {} in 1.6.0, (class {:a 1 :b 2}) says that it is a PersistentArrayMap, but when evaluating the form {:a 1 :b 2}, the insertion order is not perserved like an array-map should. What causes the inconsistency?
03:36amalloymap ordering should be regarded as entirely coincidental, unless you are specifically using a sorted-map
03:48dhklThanks amalloy
04:31yocapybarawonder if anyone can help a noob - I've got a sequence (2 4 6 8), and I've got a sequence of maps ( {a: 1} {a: 5 b: 2} {a: 4} {a: 5}) - I'm trying to get a sequence of maps but with items from that sequence in it as values, like ( {a: 1 new:2} {a: 5 b: 2 new: 4} {a: 4 new: 6} {a: 5 new: 8} ). I've been thinking of something like mapping assoc-in over the sequence of maps but my brain isn't working.
04:35amalloyyocapybara: you want to map a function over the two sequences at once: (map (fn [a b] (assoc b :new a)) as bs)
04:36ddellacosta,(map #(assoc %1 :new %2) '({:a 1} {:a 5} {:a 4} {:a 5}) '(2 4 6 8))
04:36clojureboteval service is offline
04:36ddellacostad'oh
04:36ddellacostayocapybara: anyways, that's basically the same as what amalloy just said ^
04:37amalloyddellacosta: lazybot's eval service is never offline, for what it's worth. as long as lazybot himself isn't offline, anyway
04:37ddellacostaamalloy: oh, didn't realize that, thanks
04:37ddellacosta&(map #(assoc %1 :new %2) '({:a 1} {:a 5} {:a 4} {:a 5}) '(2 4 6 8))
04:37lazybot⇒ ({:new 2, :a 1} {:new 4, :a 5} {:new 6, :a 4} {:new 8, :a 5})
04:37yocapybaraamalloy, ddellacosta: thanks guys - that's where I started off but I couldn't quite figure it out. Hopefully it'll get easier as I get more used to thinking in clojure
04:38ddellacostayocapybara: np, speaking from experience it does seem to. :-)
04:39yocapybaraddellacosta: :)
04:41ayiaI have added my question at https://stackoverflow.com/questions/24239606/how-to-validate-filter-new-elements-to-be-conj-added-to-collection-in-clojure. I will appreciate any help... Thanks...
04:45clgvayia: if [1 0 1 0] and [0 0 1 0] was acceptable, you are looking for incomparable/non-dominating in the sense of pareto-optimality
04:46clgvayia: btw why is [2 0 1 1] [2 1 1 0] valid when the above example is not?
04:46ddellacostaayia: here's one solution I think
04:46ddellacosta&(defn add-peak [peak peaks] (if (>= (reduce + peak) (reduce + (first peaks))) (conj peaks peak) peaks))
04:46lazybotjava.lang.SecurityException: You tripped the alarm! def is bad!
04:47clgvayia: or is insertion order important? such that [0 0 1 0], [1 0 1 0] would be valid
04:47ddellacosta&(add-peak [1 0 1 0] #{[1 0 2 0][2 0 1 0]})
04:47lazybotjava.lang.RuntimeException: Unable to resolve symbol: add-peak in this context
04:47ddellacostawhoops
04:47clgvdeevus: you want clojurebot since he allows `def`
04:47ddellacostaayia: anyways, try that ^
04:47ddellacostaclgv: clojurebot is offline now I believe
04:48clgvstill? is he still rolling dice?
04:48ddellacosta,(defn add-peak [peak peaks] (if (>= (reduce + peak) (reduce + (first peaks))) (conj peaks peak) peaks))
04:48clojureboteval service is offline
04:48ddellacostad'oh
04:49ddellacostaayia: my solution doesn't have particularly good efficiency but it works according to your constraints I believe
04:49ddellacostaayia: oh actually, I guess it's not bad
04:49ddellacostaayia: but it's not right...d'oh
04:50clgvddellacosta: did you understand clearly what he wants?
04:50ayiaclgv: since we have #{[1 0 2 0][2 0 1 0]}, then [1 0 1 0] is not acceptable because its 0th element is not "higher" than 0th element of both already existed in a set...
04:50ddellacostaclgv: I thought I did
04:50ddellacostaclgv: but I realized my solution was making the wrong assumption
04:51clgvayia: to validate a single state strictly speaking a set would be wrong since you are interested in a time-order?
04:51ayia[2 0 1 1] is acceptable because its 3rd element is higher than 3rd element of both vectors in a set
04:51clgvayia: how can that be ok? [1 0 3 0] [1 1 2 0]
04:51ddellacostayeah, the only thing I'm coming up with is O(n^2) I think
04:51clgvit shrank on index 2
04:53ayiaclgv: i did not mention "time"... because I though it was a separate problem. And solution for it, I know:) I think so at least:)
04:53ddellacostaayia: so, would this work? (defn add-peak [peak peaks] (if (>= (reduce + peak) (apply max (map #(reduce + %) peaks))) (conj peaks peak) peaks))
04:54ddellacostathat's assuming no ordering though
04:54clgvayia: can you formulate mathmatically what a new vector must fulfill with respect to a vector of the set to be added?
04:54ayiaactually my collection entries will be like: #{ {:peeks [1 0 2 0] :time 2000} {:peeks [2 0 1 0] :time 1000} }. And I want to sort it by :time
04:55clgvayia: so peeks can vanish but somtimes they are not allowed to?
04:57clgvayia: well if it some easy predicate that only one position must be bigger just use every?+some
04:58ayiahm... first of all... don't think much of this case like real emulation... The task I am solving is "mathematical"... It has no any sens about mountains:) I decided to use "mountains" terms just because it was easier for me to explain...
04:59clgvwell if it is math better describe it with text+formulas next time ;)
04:59ayiaSo... My case... Is the case of some "virtual" mountains ridges... That can appear on the earth (let it be a sorted set) but only if they a "cooler" at least in something that any other ridge on earh
04:59ayiaThe "coolness" is the hight of at least some peak
05:00ayiaclgv: sorry:) next time i will try with formulas... I have no formulas though....
05:01ayiaI have only description:) in words:) but in terms of "vectors and their elements" not ridges...
05:03ddellacostaayia: I'm not sure what your goals are with this; if you want a solution in clojure then I would use something like the function I posted above and sort the set after the fact.
05:03clgvayia: yeah, if you want the one vector position must be higher you can just check that by using `every?` on the set and `some` on the positions to compare the given element with one of the set elements
05:14ayiaclgv: yeah... that seems to be straightforward solution... I just thought may be there is any more "elegant" solution... In this task I can do like this... But if for example I will use often different implementations of "sets" with custom "element uniqueness definition"... Is there a way to implement this in clojure in a convenient way?
05:15ayia"like any way to add rule of uniqueness to the set"... like you add a custom "comparator" to the sorted-set
05:17clgvayia: no your actually not changing the uniqueness property of the set. you just write a custom conj-like function that decides whether to add or not a given element
05:18clgvayia: if you want something generic it would just boil down to (defn cond-conj [s pred x] (cond-> s pred (conj x)))
05:18clgvoops
05:18ddellacostais it something I said
05:19clgvayia: I meant it like that (defn cond-conj [s pred x] (cond-> s (pred s x) (conj x))) where pred is the "uniqueness" predicate in your words
05:20ayiaclgv: I see... Good note! Thanks!
05:21rurumatewhat's a quick way to do a wget style download in clojure?
05:21clgvrurumate: `slurp` ?
05:21rurumateoh right, slurp takes an url I forgot thanks
05:22clgvrurumate: (slurp "http://www.google.de&quot;) ^^
05:22rurumatebut that will load the thing to memory right? I want it written to a file
05:22rurumatebecause it's 28 mb binary
05:22clgvso?
05:22clojurebotso is (add-to-list 'erc-keywords '("\\bso\\b" erc-default-face))
05:22clgvI'd have believed you if it was 5GB ;)
05:23rurumateno, we have not achieved that level of bloat yet. but we're working on it
05:23clgvrurumate: well the solution gets more complex when you require directly writing it to a file
05:24clgvyou got to setup an inputstream for the URL and an outputstream for the file and there should by clojure.java.io/copy*
05:25rurumateoh, so I so (with-open [in (bla) out (bla)] (copy in out))?
05:26rurumatewhy the starred version of copy though?
05:27clgvrurumate: didnt know if it was called copy-stream maybe ;)
05:27rurumateI'll try and post result when it's done
05:32fenrockclojure.java.io/copy "does not close any streams except those it opens itself (on a File)", which i take to meaning you only need the with-open if you're using streams, otherwise you should be able to do (io/copy (io/file src) (io/file dst)) and all streams will be closed for you, and it's buffered
05:32rurumateok so the input will be a stream, but not the output
05:33fenrockbut i think you mentioned a stream, so former will probably be right
05:33fenrockyarp
05:56rurumateseems workey: https://www.refheap.com/86675
05:57clgvrurumate: looks good
05:57clgvrurumate:
05:57clgvrurumate: you probably can omit the `file` expression since it coercing anyway, a string or url would be coerced as well
05:58rurumateclgv: would anything but a file make sense here?
05:58rurumatewhat if dest is url?
05:59rurumateif we know it would fail, I think it's better to coerce explicitly
06:30clgvrurumate: well coercing url to a file wont change that it might file if it is not writable ;)
06:30clgv*fail
06:54silasdavisis there a nice way to
06:55silasdavis,((juxt (partial map first) (partial map second)) [[1 2][3 4][5 6]])
06:55clojurebot[(1 3 5) (2 4 6)]
06:55silasdavisnicer*
06:56philandstuff,(map vector [1 2] [3 4] [5 6])
06:56clojurebot([1 3 5] [2 4 6])
06:56bob2darn, too slow
06:56silasdavisgreat
06:57silasdavis,(apply map vector [[1 2][3 4][5 6]])
06:57clojurebot([1 3 5] [2 4 6])
06:57philandstuffalso works for more than two entries in the inputs
06:58pyrtsa,(apply mapv vector [[1 2][3 4][5 6]]) ;; if you want to keep the structure
06:58clojurebot[[1 3 5] [2 4 6]]
06:58silasdavisyep, I forget map works that way
06:58philandstuff,(map vector [1 2 3] [4 5 6] [7 8 9])
06:58clojurebot([1 4 7] [2 5 8] [3 6 9])
06:58silasdavispyrtsa, also handy
07:00clgvyou can call that `transpose` ;)
07:00pyrtsa,(def transpose (partial mapv vector))
07:00clojurebot#'sandbox/transpose
07:00pyrtsa,(transpose [[1 2][3 4][5 6]])
07:00clojurebot[[[1 2]] [[3 4]] [[5 6]]]
07:01pyrtsaDuh.
07:01clgvapply ;)
07:01pyrtsaYep.
07:01clgv,(def transpose (partial apply mapv vector))
07:01clojurebot#'sandbox/transpose
07:01pyrtsaThanks.
07:01clgv,(transpose [[1 2][3 4][5 6]])
07:01clojurebot[[1 3 5] [2 4 6]]
07:02silasdavisah very nice, that is how to think of it
07:08clgvtranspose for list of maps is harder to do correctly ;)
07:14silasdavisclgv, not sure how you'd define that
07:15silasdavisusing the keys as column/row indices
07:15silasdavisor treating the map as a sequence of k-v pairs?
07:15clgvsilasdavis: list of map transposed to map of lists per key
07:15silasdavisah
07:15clgvsilasdavis: it is not exactly the same
07:15agarmanthat's more a pivot than a transpose
07:16clgvbut also some kind of transpose and pretty handy for plotting or analyzing attributes ;)
07:16silasdaviscomes up in exactly the same place though
07:16silasdavisif you're returning multiple values
07:16clgvagarman: I dont know that meaning of "pivot"
07:16agarmanin Scalaz that is generalized to a function called sequence
07:17agarmanclgv: pivot is a rotation of tabular data...
07:18clgvagarman: ah ok. might make sense then
07:18agarmanclgv: not to be confused with a pivot as in quicksort
07:33clgvagarman: but transpose is the common principle, I'd say. consider that in the vector case the keywords are the positions ;)
07:43agarmanclgv: anyhow, if you google with the term pivot, you get fairly relevant results like http://stackoverflow.com/questions/11438918/pivoting-data-via-clojure
07:44clgvagarman: yeah, I didnt want to deny that ;)
07:45agarmanclgv: I'm happy to call it transpose or pivot or yarble, as long as folks know what I'm talking about :-)
07:45clgvthough that example is doing something different than I meant
07:45clgvplease not "yarble" ;)
07:47agarmanclgv: is it that you have a List of Maps and want a Map of Lists...that's https://hackage.haskell.org/package/base-4.7.0.0/docs/Data-Traversable.html
07:47agarman:-)
07:49clgvyeah that was my initial description. it's getting more complex if you allow non-present keys in some of the maps ;)
07:49agarmanah, well good luck :-)
07:49clgvalready done it some weeks ago ;)
08:06Morgawris there a way to specify the size of the threadpool used by pmap?
08:07clgvno
08:07clgvMorgawr: if I were you I would not use pmap except for quick and dirty parallelization
08:08clgvwe need a "pmap considered harmful" blog post
08:08Morgawryeah I know, I'm just working on a study comparing various threading utilities/libraries (Among both java and clojure) and I'm now tackling pmap
08:08MorgawrI normally wouldn't use pmap :)
08:08clgvjust note it as downside ;)
08:08Morgawryeah
08:08Morgawrwill do
08:09clgvit is using one of the threadpools eigther agent or future
08:09clgvah no future^^
08:10clgvMorgawr: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L6465
08:10Morgawryeah, I'm looking at it now, thanks :)
08:10clgvbut as far as I added you need to add +1 to that number
08:10MorgawrI was kind of hoping it would use the internal threadpool like agents do
08:10clgvso in principle it could have a param for that ^^
08:11Morgawrbut instead it just does its own thing
08:11Morgawryeah
08:11clgvit uses the one of futures so it does what you were hoping. but the limit is through the lazy construction there
08:12Morgawrclgv: I see
08:12clgvMorgawr: just recommend reducers over pmap
08:13Morgawrclgv: yeah, definitely
08:40silasdavisfrom time to time I keep restarting lighttable to get a fresh repl and make sure I'm not using any old definitions
08:40silasdaviscan anyone suggest a good way of getting a fresh environment, either lighttable specific or not
08:40agarmanfresh
08:41agarmanand component
08:45silasdavisagarman, doesn't sound like it remove existing bindings
08:45Glenjaminsilasdavis: i tend to just disconnect from repl, and then add a new connection
08:45silasdavisI'm also not sure how it would integrate with lighttable which seems to run an nrepl session per file
08:45silasdavisor per project
08:45agarmanGlenjamin: everything is still in the namespace's if you just disconnect
08:46Glenjaminright, i mean i kill the repl session without quitting LT
08:47Glenjamini mostly use tools.namespace & a component-style setup, but you don't need to exit LT for a fresh session
08:47agarmansilasdavis: I tend to leave my various project REPLs running until I reboot my dev box
08:47_oggyanybody using instaparse here? any idea how to specify a grammar for "character 'a' followed by exactly one other character (any other)"?
08:47silasdavisGlenjamin, what command do you use?
08:48Glenjaminsilasdavis: "Editor: Disconnect clients attached to editor"
08:50silasdavisah
08:50silasdavisok so when you re-evaluate the namespace it will reconnect
08:50silasdavisI think that's pretty decent
08:52agarman(inc hyPiRion) ; just discovered cowsay thanks to lein-shell
08:52lazybot⇒ 38
08:54silasdavisagarman, you might find this useful: https://github.com/erkin/ponysay in an enterprise setting
08:54agarmanlol
09:03agarman(inc silasdavis)
09:03lazybot⇒ 1
09:05hyPiRionagarman: haha
09:06agarmanhyPiRion: silasdavis: these are the most amazing utility that I've brew installed this month!
09:42stompyjHave there been any good articles on clojure adoption recently?
09:56johnnyblazeWhen using a (map func col) is there a way to know that you are on the last item in the collection?
09:56toastnot with map
09:56toastmaybe map-indexed?
09:57johnnyblazeK need to look at that haven't used it before. Thanks.
09:57clgvjohnnyblaze: it's (map f (range) coll)
09:57toastIt passes the index along with the item
09:58drbobbeatystompyj: What are you looking for - specifically?
09:58clgvstompyj: 1 year ago counts?
09:59stompyjI don’t even need hard numbers, I’m just trying to convince people here in NYC that clojure is a viable language, and should be in the conversation as people are moving from ruby/python to go/scala
10:00clgvstompyj: so you are interested in numbers and not success stories?
10:01drbobbeatystompyj: Well... I've been writing production clojure code for more than a year at Groupon. It's in use in several projects here, including real-time processing of our web and mobile event streams in Storm.
10:01stompyjnumbers or recent success stories. there was a ton of momentum around core.async and cljs
10:01clgvstompyj: http://www.colinsteele.org/post/27929539434/60-000-growth-in-7-months-using-clojure-and-aws
10:01stompyjyeah, we’ve been writing clojure here @ indaba for a good 5 months now
10:01stompyjand it’s been amazing
10:01stompyjclgv: thanks!
10:02stompyjand I know movable ink has a big clojure codebase now
10:02justin_smithstompyj: we used a lot of clojure when I worked with Instrument, a few of the sites running Caribou (our open source web framework we made for Instrument) are linked on the bottom of the official Caribou site http://let-caribou.in/
10:03stompyjHow is Instrument? They seem pretty awesome
10:03justin_smithnow that I mention it, there are more sites that should be added to that list
10:03justin_smithstompyj: very hip, very Portland
10:04justin_smithsadly, they've gotten big enough that the bigger clients they get now get to dictate the backend stack (or have a legacy backend they have to adapt), so they divested on Clojure (including Clojure devs like me)
10:05justin_smithI think they will find long term that was a poor choice, but it wasn't a bad layoff (they gave some severance etc.)
10:06arrdemjustin_smith: sorry to hear that
10:06_alejandrostompyj: We're using it in NYC at Adaptly for a lot of our backend stack too
10:07_alejandrostompyj: we switched from mostly ruby; core.async has been great for us in production
10:07stompyjjustin_smith: wow, that’s sad/ interesting
10:08stompyj_alejandro: on the front-end? or back-end?
10:10_alejandrostompyj: back-end so far
10:10_alejandrostompyj: although I'm pushing for cljs :-)
10:11stompyjare you using core.async structures in the req/resp cycle?
10:11stompyjor calling out to a persistent service
10:12_alejandrostompyj: both
10:15NikenticHey, I am looking for some learning resources. I've been doing some project euler but I don't really learn any "best practices" or such. Coming from a Python/C++ background.
10:15NikenticAny books maybe? Online courses?
10:15justin_smithhere's another Instrument site, with clj backend, cljs frontend http://onenorthpdx.com/
10:15_alejandroNikentic: I like braveclojure and joy of clojure
10:15arrdemNikentic: 4clojure comes well commended, but is like Project Euler in that it's just a bunch of exercises
10:15_alejandroNikentic: in that order
10:16stompyj_alejandro: wow, I’d love to hear about the in-req-resp cycle stuff at some point
10:16Nikentic_alejandro: ok, thank you! arrdem, I'll check that one out!
10:18_alejandrostompyj: I'm not sure we're doing it the best way :-), but the request basically triggers a message to be put on a channel, and then the response waits for the output message from an output channel
10:18_alejandrostompyj: so there's basically a message 'processor' that is always running, and waiting for input messages
10:21_alejandrostompyj: definitely happy to answer specific questions too
10:22Nikentic_alejandro: have you got any open source project which source code is useful to read & learn?
10:24_alejandroNikentic: Leinengen, Enlive, and Hiccup are all good, and seem to be recommended by others too
10:25Nikentic_alejandro: Leinengen & Enlive for sure. Been looking at some network based code too, pretty interesting
10:25_alejandroNikentic: do you have any other recommendations? I should do more code reading
10:26Nikentic_alejandro: No, sorry. I started coding Clojure last week so haven't looked into much
10:26stompyj_alejandro: thanks.
10:26NikenticThe only code I've read into detail is https://github.com/Raynes/irclj
10:27Nikenticriemann is pretty cool too
10:43mdallastellacaribou has just a couple of dependencies... :D
10:43benzapWas wondering, what does the carot simple mean?, like (def ^{:doc "something"} init? true)
10:43_alejandrobenzap: it's used for metadata
10:44_alejandrobenzap: http://clojure.org/reader (ctrl+f metadata)
10:44benzap_alejandro: ah thanks
10:47benzapI was more interested in the form of ^String x, and this seems to explain it
10:48ddellacostabenzap: that is type hinting
10:48TimMc^String is ^{:tag String}
10:49ddellacostabenzap: more here on that specifically: http://clojure.org/java_interop#Java%20Interop-Type%20Hints
10:50benzapthank you, i'll give that a read
10:50clgv,(.getCanonicalName (Class/forName "[D"))
10:50clojurebot"double[]"
10:56mdallastellaanyway, caribou is quite impressive!
10:59arohnerwhat is the best tool for configuring a server these days? pallet, or is there some new hotness?
10:59mpenetarohner: ansible is nice to work with
10:59stompyjarohner: I’ve been using ansible, to great success
10:59stompyjwith*
10:59stompyjmoved from chef
10:59seubertanother + for ansible
11:00_alejandrostompyj: do you use ansible for deployment too? or just config mgmt?
11:00apetrescWhat's the advantage of ansible over chef?
11:00seubertapetresc: simplicity
11:00stompyj_alejandro: thats why I switched
11:00apetrescAh, okay
11:00apetrescBut for someone who's already versed in chef, any compelling reason?
11:00seubertprobably not
11:01stompyjapetresc: simplicity also, but writing a script that can both deploy, provision and create an instance was the deal sealer for me
11:01wkellyapetresc: ansible is better at orchestrating tasks across multiple servers (do something on server A, then B, then A)
11:01stompyjapetresc: if you want to be able to deploy
11:01wkellybut if you don't need to do that, then no
11:01seubertstompyj: why can't you do that with chef
11:01seubert(my chef is rusty at best, honest question)
11:01stompyjseubert: early versions of chef had a janky capistrano kind of thing built in, but it never worked, and it seems they’ve deprecated it
11:02seubertah, gotcha
11:02stompyjseubert: I always had to do chef + capistrano
11:02seubertinteresting, i don't recall ever running into that
11:02seuberti haven't touched chef in about a year though
11:02wkellyI think they are focusing on orchestration for the next release of chef
11:02mpenetansible runs without agents too
11:02stompyjseubert: they’re changing it very rapidly, thats another reason why I switched. It broke too often
11:03mpenetlike pallet too, unlike chef I think
11:03stompyjansible is like a super thin layer over bash scripts
11:03seubertthis is the biggest reason i never wanted to touch chef again: http://docs.opscode.com/essentials_cookbook_attribute_files.html#attribute-precedence
11:03seubert15 levels of precedence and good luck debugging that without stellar internal docs
11:03seubert(it's hell)
11:03stompyjyeah
11:04stompyjthe only thing I miss from chef are the detailed recipes, but that’s just a matter of time, until galaxy catches up
11:04wkellyno server infrastructure on ansible either, which is nice
11:05stompyjyeah, thats another big win
11:05seubertchef is faster than ansible if you're touching a lot of boxes since it isn't raw ssh
11:05seubertwhich is both good and bad
11:05whaleystompyj: galaxy?
11:05seubertwhaley: https://galaxy.ansible.com/
11:06seubertbasically sharing ansible playbooks
11:06r4vidoesn't ansible have a 0mq transport- you don'thave to ssh
11:06stompyjwhaley: its their online repo of recipes. the goal being ansible-galaxy install clojure
11:06whaley*nod* thanks
11:06stompyjr4vi: it does. they’re ramping that up going forward
11:06seubertooo i've never used the 0mq part of it
11:06seubertthat sounds promising
11:06wkellyit does have a 0mq transport, but ansible breaks up work into tasks which execute in parallel on all of the nodes and then block until every node compeles the task
11:06wkellyI do not think the transport is usually the bottleneck there
11:07seubertah
11:07seubertmy ignorance is showing
11:07stompyjwkelly: yeah, and another tip, this is a huge problem when trying to spin up multiple instances
11:07stompyjits actually faster to spin up 1 instance in 4 different shells, then telling the ansible script to bring up 4 boxes at once
11:07wkellyhm!
11:08wkellywe haven't seen that on rackspace
11:08stompyjwkelly: interesting. then maybe it’s just something goofy with ec2, but a single box comes up in 3-5 mins here, but all 4 took about 25-30
11:08wkelly(which, disclosure, is the company who I work for, so bias filter appropriately)
11:08wkellythat is interesting
11:09stompyjya, its because it was blocking at every step, for some reason
11:09wkellywe do a separate provisioning and configuration playbook
11:09stompyjto be fair. I didn’t dig into the whys, it may be something I’m (not) doing on my end
11:10wkellythis is really the only ansible I have messed with: https://github.com/ludditry/ansible-zwift
11:10stompyjyeah, we have a “build ec2 + provision + deploy” script, but then separate scripts for provision and deploying
11:10wkellyit spins stuff up on cloud servers for our testing but is generally meant to run on physical machines (deploying openstack swift)
11:10stompyjactually, its all the same scripts, we just use tagging to split things out
11:10stompyjahhh very cool
11:10wkellyyeah, that makes sense
11:11wkellybut in any case, it seems to make networks in parallel, then spin the instances up in parallel, then make/attach block storage in parallel
11:12wkellywhich does mean that if for some reason one instance doesn't come up, the step fails, and configuration halts
11:13wkellynot sure if the ec2 plugins work the same way
11:13mdallastellawhat about fabric?
11:13stompyjfrom what I understand, fabric is more like capistrano, just a deployment tool
11:14wkellyI haven't done much with fabric
11:14mdallastellastompyj: yeah, right
11:14wkellyI am a big fan of dsh or gnu parallel for distribution my sshes :)
11:15wkellyer, distributing
11:15stompyjnice
11:36stompyjDoes anyone have any good reference / sites for tweaking the JVM for clojure production deployments?
11:48erlishi guys, quick question. How can I preserve the type of the collection after some operations, for example "map". So if I have a vector I can keep a vector, same for set, hash...
11:48erlisany trick ?
11:48Glenjaminerlis: you can get a vector with mapv, but in general you'd need (into (empty coll) ...) i think
11:49erlisthe point is that I don't know the type I have
11:49erlis(f coll) -> another_coll same time of coll
11:52Glenjaminyeah, (into (empty coll))
11:53Glenjamin,(doc empty)
11:53clojurebot"([coll]); Returns an empty collection of the same category as coll, or nil"
11:53erlisempty!!!
11:53erlisgreat! glenjamin
11:53erlisthanks!
11:53erlisthose little functions that makes your life easier :)
11:54arrdemmap-into should be a thing..
12:06johnwalkerarrdem: ehh. in principle i guess, since there are a lot of other strange combinations
12:06johnwalkerif-not when-not mapv mapcat some?
12:07arrdemjohnwalker: I mean, not something I'd inflict on the core, but I agree that the core has some strange composed utility functions.
12:08arrdemnot that I object to the core packaging utility stuff, it's just that the core's in the halfway house of having some utility stuff, not wanting to take more and not having all of the utilities you'd want as amalloy's useful is proof.
12:08johnwalkeragreed
12:14kzarAnyone use Linode here? Recommended? (Sorry very offtopic)
12:15arrdemthere are a couple of people here who are Linode based and have had good things to say in the past
12:15arrdemcheck the logs
12:16zaphroGetting an error with luminus new .... "Could not locate clojure/data/priority_map__init.class or clojure/data/priority_map.clj"
12:16kzararrdem: Oh yea good idea thanks
12:16arrdemzaphro: either something has fsck'd dependencies or you forgot to add an explicit dependency.
12:17zaphroI haven't reached the deps stage yet. It won't install.
12:18dbaschzaphro: what’s the full command?
12:18zaphrolein new luminus proj1 +postgres +cljs +site
12:19dbaschzaphro: version of leiningen?
12:20zaphro(OS X Mountain Lion) Leiningen 2.4.0 on Java 1.8.0_05 Java HotSpot(TM) 64-Bit Server VM
12:20zaphroClojure 1.6.0
12:20technomancyzaphro: did you install via homebrew or a manual install?
12:21toasterlis, Glenjamin: I used fluokitten to do a map that maintains the collection type, but empty is probably better if it's all you need, since it's there in core
12:21zaphroManual. I've even had luminus install fine before now, ie. before Lein 2.4.0
12:21kzarIs there a way to host multiple Clojure web apps on a server with only one instance of Java running, but that at the same time allows you to deploy new versions of each app separately?
12:22fenrockimmutant is doing work in that area
12:22kzar(my VPS is quite RAM limited ATM)
12:22technomancyzaphro: very strange; I can't reproduce. can you try with an empty user profile?
12:23Glenjamintoast: ah, neat - there's also an fmap in algo.generic
12:23kzarfenrock: Is immutant any good?
12:23zaphrotechnomancy Not sure how I do that.
12:23technomancyzaphro: mv ~/.lein/profiles.clj ~
12:24zaphrotechnomancy Ah, yes. Will try.
12:24toastGlenjamin: yeah, that was it - fmap was the function; next time I'll reach for empty: great suggestion. I'll have a look at algo.generic, too
12:24fenrockkzar: only just started using it, 1.x version is JBoss 7 AS based, and i was easily able to deploy and undeploy separate apps. 2.x is alpha and allows you to deploy to non JBoss instances. it works, but i've not used it in anger. they have a channel they are very helpful on if you want to know more
12:25arrdemGlenjamin: I love that (fmap IFn IFn) is comp :P
12:25kzarAnyone want me to put in their Linode referral code? (Giving it a try)
12:25kzarfenrock: cool OK, good to know
12:28zaphrotechnomancy That worked.
12:28zaphro:user
12:28zaphro {:plugins
12:28zaphro [[lein-ritz "0.7.0"]
12:28zaphro [cider/cider-nrepl "0.7.0-SNAPSHOT"]
12:28zaphro [lein-ancient "0.5.5"]
12:28zaphro [lein-immutant "1.2.1"]
12:28zaphro [org.bodil/lein-nashorn "0.1.2"]
12:28zaphro [com.jakemccrary/lein-test-refresh "0.5.0"]]
12:28zaphro :dependencies
12:28zaphro [[org.clojure/clojure "1.6.0"]
12:28zaphro [org.clojure/core.typed "0.2.52"]
12:28zaphro [org.clojure/core.match "0.2.1"]
12:28zaphro [nrepl-inspect "0.4.1"]
12:28zaphro [org.clojure/tools.trace "0.7.8"]
12:28TimMczaphro: D-:
12:29TimMcPlease use a pastebin in the future (such as refheap.com)
12:29zaphroSorry. Slip of keyboard :)
12:30arrdemshift-insert is such a cruel mistress :P
12:30zaphrotechnomancy Wondering which one might be the culprit?
12:30technomancyzaphro: maybe try bisecting?
12:30joegalloyour apology is not enough! prepare the brazen bull.
12:35ayiathis works &(sort-by (juxt :foo :bar) #{{:foo 2 :bar 11} {:bar 99 :foo 1} {:bar 55 :foo 2} {:foo 1 :bar 77}})
12:36ayiawhy does the following not work?
12:36ayia&(sort-by (juxt :foo :bar) > #{{:foo 2 :bar 11} {:bar 99 :foo 1} {:bar 55 :foo 2} {:foo 1 :bar 77}})
12:36lazybotjava.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number
12:37ayia&(sort-by (juxt :foo :bar) #{{:foo 2 :bar 11} {:bar 99 :foo 1} {:bar 55 :foo 2} {:foo 1 :bar 77}})
12:37lazybot⇒ ({:foo 1, :bar 77} {:foo 1, :bar 99} {:foo 2, :bar 11} {:foo 2, :bar 55})
12:37rasmusto,(< [1 2] [3 4])
12:37clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number>
12:38rasmustoayia: hm, I guess the default comp fn isn't < or >
12:38ayiaah... I see... seems like in this case yes...
12:38ayiaso I need to find proper comparator for me:)
12:39rasmustoayia: ah, default is ##(compare [1 2] [3 4])
12:39lazybot⇒ -1
12:41rasmusto&(sort #(compare %2 %1) [[1 2] [3 4]])
12:41lazybot⇒ ([3 4] [1 2])
12:44ayiarasmusto: thanks! makes sense so far:)
12:45gfredericksDoes anybody have any idea how this compojure defroutes expression works? https://github.com/JonyEpsilon/gorilla-repl/blob/develop/src/gorilla_repl/core.clj#L71
12:46mdeboardgfredericks: I'm sure someone does
12:46mdeboardgfredericks: But, seriously, what do you mean? Like how the defroutes macro works?
12:46gfredericksit looks like it just returns a ring handler instead of a response
12:46mdeboardin general
12:46ayiarasmuto: but seems like I will need my own comparator reimplemented... Because actually I need normal order for the first key, and reversed order for the second key...
12:47gfredericksmdeboard: no, I mean that specific usage that I linked to
12:47Glenjamingfredericks: compile-route expands the body with ~@
12:47Glenjaminhrm, that shouldn't make a difference
12:47Glenjaminhttps://github.com/weavejester/compojure/blob/1.1.8/src/compojure/core.clj#L101
12:48gfredericksI'm not 100% sure this code works; haven't checked out the diff between the version I'm running and the master in this repo
12:48gfrederickslooking into that now
12:49Glenjaminfrom how i follow this, i agree - there should be another function invocation to make this work
12:50Glenjamin,`(~@(fn [a] a))
12:50clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: sandbox$eval25$fn__26>
12:50Glenjamin,(quote `(~@(fn [a] a)))
12:50clojurebot(clojure.core/seq (clojure.core/concat (fn [a] a)))
12:51Glenjamin,(quote `(let [a b] ~@(fn [a] a))))
12:51clojurebot(clojure.core/seq (clojure.core/concat (clojure.core/list (quote clojure.core/let)) (clojure.core/list (clojure.core/apply clojure.core/vector (clojure.core/seq (clojure.core/concat (clojure.core/list (quote sandbox/a)) (clojure.core/list (quote sandbox/b)))))) (fn [a] a)))
12:51Glenjaminoh wow
12:51gfredericksno I do think this code is working; I just can't figure out how on earth
12:52mdeboardthat's not good
12:52CookedGryphonDoes anyone know of a nice efficient immutable (I don't even want to conj) tuple2 thing I could use?
12:53GlenjaminCookedGryphon: clj-tuple has that i think
12:53CookedGryphonI was using clj-tuple which was great, but won't aot compile, or at least something is exploding in my release build
12:53Glenjaminoh, then i dunno
12:53CookedGryphonand yeah, even that does too much really
12:54CookedGryphonI don't care about doing any manipulations, as soon as it changes I'd want it to just become a straight forward persistentvector
12:54CookedGryphonI'm using a simple float[ but that doesn't serialise nicely
12:55CookedGryphonotherwise it works perfectly for my needs
12:55Glenjamingfredericks: do you have a running repl for that project? would be good to see what it macroexpands to
13:03Glenjamingfredericks: this seems to work (do (defn func [req] {:status 418}) ((GET "/" [] func) {:request-method :get :uri "/"}))
13:04Glenjaminaha, found it
13:04Glenjaminthere's a call to (render) on https://github.com/weavejester/compojure/blob/1.1.6/src/compojure/core.clj#L94
13:04gfredericksGlenjamin: I do
13:04Glenjaminhttps://github.com/weavejester/compojure/blob/1.1.8/src/compojure/response.clj#L30
13:05Glenjamincompojure calls (render) on every route, and (render IFn) calls it with req
13:05gfredericksGlenjamin: so this is just some weird feature nobody uses that allows you to return a handler?
13:05Glenjaminpretty much, although i think i might start using it now
13:05gfrederickshaha
13:05Glenjamini was trying to figure out how to compose my app the other day
13:06Glenjaminended up using (context) a bit
13:06gfredericksGlenjamin: well thanks for investigating
13:06Glenjaminyou can also return an IDeref according to this
13:08umpaHow do I get the second value from each vector ? {0 [[0 1 2] [0 3 6] [0 4 8]], 6 [[6 7 8] [0 3 6] [2 4 6]]}
13:09umpain a form of {0 [2 3 4], etc..
13:09umpa{0 [1 3 4], etc.. *
13:10skratl0x1CHow can I create a macro that concats/join/w'ever 2 seqs, one created internally in the macro, the other provided by caller
13:11skratl0x1CI tried these https://gist.github.com/skrat/731f2e8e4bfa4e252c67 both fail
13:12skratl0x1Cthe 1st one works when I create the 'headers' vector in the macro calling list, but fails when I give it a var instead
13:13joegallowhy a macro?
13:15skratl0x1Cjoegallo: because it reads a file and joins its content with the args
13:15skratl0x1Cit's meant for ClojureScript as a way of embedding assets (GLSL shaders) in the source
13:17joegalloumpa: (into {} (for [[k vs] your-thingy] [k (map second vs)]))) is a bit brute-force, but should do the job.
13:22joegalloumpa: or for that matter, https://github.com/amalloy/useful/blob/develop/src/flatland/useful/map.clj#L47 would simplify my version nicely
13:22technomancy#=(alter-var-root #'clojure.core/*loading-verbosely* (constantly true)) ; <- clojure.lang.PersistentList cannot be cast to clojure.lang.Var
13:22technomancywhy is read-eval so weird?
13:23umpajoegallo: nice im going to try it both ways.
13:23technomancyI get that the reader hasn't been invoked yet, but this breaks too: #=(alter-var-root (resolve clojure.core/*loading-verbosely*) (constantly true))
13:23hiredmantechnomancy: arguments are not evaluated
13:31technomancyyeah... weird stuff
13:37arrdemhiredman: ping
13:37llasramSo it's more like "read–macro-eval"
13:46Raynesdevn: Holy new clojars.
13:46Raynesgg
13:46arrdemwp no re
13:48justin_smithmdallastella: re caribou, thanks for the feedback, and re "only a couple of dependencies" its a trick, because those deps are just modularized parts of caribou, and in total the deps are actually quite extensive
13:53dbaschclojars looks MUCH better
13:55justin_smithgfredericks: defroutes is meant to return a handler, that way you can wrap the handler in middleware etc.
13:55justin_smithI thought that was like the normal thing to do with compojure
13:56arrdemyay even has the markdown badge snip!
13:57daGrevisyelp! http://clojuredocs.org/clojure_core/clojure.core/_dot_dot
13:57daGreviswhat does .. do?
13:57cbp(doc ..)
13:57clojurebot"([x form] [x form & more]); form => fieldName-symbol or (instanceMethodName-symbol args*) Expands into a member access (.) of the first member on the first argument, followed by the next member on the result, etc. For instance: (.. System (getProperties) (get \"os.name\")) expands to: (. (. System (getProperties)) (get \"os.name\")) but is easier to write, read, and understand."
13:58pyrtsadaGrevis: (.. foo bar (baz quux)) is the same as (-> foo (.bar) (.baz quux))
13:58sorenmacbethcccccccc
13:58justin_smithpyrtsa: and that is the same as (-> foo .bar .baz quux)
13:58pyrtsajustin_smith: Careful!
13:58justin_smith?
13:58justin_smiththat's how the macro works
13:59pyrtsaYou're right with (.bar) === .bar in there, but quux was an argument.
13:59justin_smithahh, missed that
13:59justin_smithbecause of how the line wrapped
14:00justin_smith,(-> "hello" .length .getClass)
14:00clojurebotjava.lang.Integer
14:00gfredericksjustin_smith: no it's not that defroutes itself returned the handler, it's that it had: (GET "" [] (return some handler))
14:00daGrevispyrtsa, thanks mate
14:00justin_smithahh
14:01pyrtsadaGrevis: I prefer to stick to -> only, but some like .. more.
14:02daGrevispyrtsa, i'm going through om tut for clojurescript and other used ..
14:02daGrevisliterally i have no idea about whatever :) much magic to me
14:02daGreviss/other/author/ wtf me
14:02justin_smith.. is only for method chaining, -> can chain methods and functions
14:02technomancyiirc .. is vestigial
14:03Glenjaminhah, i like that idea
14:06kzarRaynes: cheers dude :)
14:06Rayneskzar: ohi there
14:08kzar:p
14:14benzapwas wondering, what's the clojure equivalent of Foo.class, for the class foo?
14:15hyPiRionbenzap: Foo
14:15justin_smith,(= (class "hello") 'java.lang.String)
14:15clojurebotfalse
14:15justin_smith,(= (class "hello") java.lang.String)
14:15clojurebottrue
14:15hyPiRionjustin_smith: no need to quote it
14:15justin_smithright
14:15hyPiRion,(= (class "f") String)
14:15clojurebottrue
14:15benzapah ok
14:16justin_smithclasses are first class in clojure
14:18benzapso (class Foo) and Foo are equivalent?
14:18hyPiRionNo, (class Foo) is Class
14:18hyPiRion,(class String)
14:18clojurebotjava.lang.Class
14:19hyPiRion(class x) means "I want the class of x". If x is a class, then its class is Class.
14:20benzapso would (class Foo) mimmick the functionality of Foo.class?
14:20hyPiRionTalk about going complete meta there, btw.
14:20hiredmanbenzap: no
14:20AimHere,(class class)
14:20clojurebotclojure.core$class
14:20hiredmanString in clojure is String.class in java
14:20TimMc,(class nil)
14:20clojurebotnil
14:21hiredmanclojure resolves String to the class object
14:21benzapah, so I just want to call Foo
14:21benzapFoo --> Foo.class
14:21hiredmanno
14:21TimMcbenzap: Well, you cna't call classes.
14:21hiredmanclasses doesn't implement IFn
14:21TimMcbenzap: Whatcha trying to do?
14:21benzapTimMc: Intent mainServiceIntent = new Intent(context, MainService.class);
14:22TimMcbenzap: (Intent. context MainService)
14:22benzapI have this http://pastebin.com/26rAtQ0E
14:22benzaphmm
14:22TimMc(class MainService) should be just MainService
14:23justin_smithTimMc: it should be java.lang.Class
14:23justin_smithoh wait, misunderstood you, n/m
14:23benzapso MainService is MainService.class in java, or am I going crazy
14:23TimMcbenzap: That's right.
14:23TimMcjustin_smith: I kind of wish (class nil) yielded java.lang.Void
14:24benzapso like this http://pastebin.com/WN3rk8xW
14:24TimMcIt's sooorta what that's for.
14:24TimMcbenzap: Yep.
14:26hyPiRion,(alter-var-root #'class (fn [f] (fn [x] (if x (f x) Void))))
14:26clojurebot#<sandbox$eval25$fn__26$fn__27 sandbox$eval25$fn__26$fn__27@7a4593>
14:26hyPiRion,(class nil)
14:26clojurebotjava.lang.Void
14:26hyPiRionTimMc: I fixed it for you
14:27justin_smith,(class false)
14:27clojurebotjava.lang.Void
14:27justin_smith:P
14:27hyPiRionhurray, the return of the nullpointerexception bug
14:28TimMcSee, shoulda used if-some
14:29hyPiRionyeah.
14:29TimMc,*clojure-version*
14:29clojurebot{:major 1, :minor 6, :incremental 0, :qualifier #<Void >}
14:29TimMchaha
14:29TimMc,nil
14:29clojurebot#<Void >
14:29justin_smithlol
14:29arrdemoh dear
14:29justin_smith,false
14:29clojurebot#<Void false>
14:30justin_smith,true
14:30clojurebottrue
14:30arrdem,(+ 3 4)
14:30clojureboteval service is offline
14:30TimMc>_<
14:30hyPiRionHey was that my fault
14:30TimMcOh, I was going to fix it.
14:30arrdemTimMc: I may just be banned, see if you can eval something
14:30hyPiRion,(+ 3 4)
14:30umpa,(into {} (for [[k v] {0 [1 3 4], 6 [7 3 4], 2 [1 5 4], 8 [7 5 4]}] [(set/intersection #{0 1 2} (set v))])) this is not working
14:30clojurebot7
14:30clojurebot#<CompilerException java.lang.RuntimeException: No such namespace: set, compiling:(NO_SOURCE_PATH:0:0)>
14:31arrdem~source
14:31TimMc,(alter-var-root #'class (fn [x] (if (nil? x) x (.getClass x))))
14:31clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.IFn>
14:31Glenjamin,(into {} (for [[k v] {0 [1 3 4], 6 [7 3 4], 2 [1 5 4], 8 [7 5 4]}] [(clojure.core/set/intersection #{0 1 2} (set v))])) this is not working
14:31clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.IFn>
14:32Glenjamin,(into {} (for [[k v] {0 [1 3 4], 6 [7 3 4], 2 [1 5 4], 8 [7 5 4]}] [(clojure.set/intersection #{0 1 2} (set v))])) this is not working
14:32clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.IFn>
14:32Glenjamin,(into {} (for [[k v] {0 [1 3 4], 6 [7 3 4], 2 [1 5 4], 8 [7 5 4]}] [(clojure.set/intersection #{0 1 2} (set v))]))
14:32clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.IFn>
14:32Glenjaminhrm, one sec
14:32hyPiRionGlenjamin: what are you trying to do?
14:32Glenjamintrying to see what's up with umpa's thing
14:33TimMc,(alter-var-root #'class (constantly (fn [x] (if (nil? x) x (.getClass x)))))
14:33umpaI am trying to get all the val and do intersection
14:33clojurebot#<sandbox$eval363$fn__364 sandbox$eval363$fn__364@101812b>
14:33hyPiRionThat is probably because the vector contains a single element only, not two elements
14:33TimMc,(map class [nil 1 false])
14:33clojurebot(nil java.lang.Long java.lang.Boolean)
14:34Glenjaminoh right, umpa you need a "k" in that vector
14:34justin_smithumpa: that fails at the into {} stage, you are feeding it with a one arg vector
14:34justin_smithbuild up from the inside out
14:35benzapi'm extending a class into clojure using (gen-class), if I overload a particular method, and return the wrong type, would you suppose it would return a null pointer?
14:39justin_smithbenzap: I wonder if it would maybe not be recognized as the method you mean to overload, but a new overload of the method with a different return type. Or maybe trying to do that would be erroneous.
14:39justin_smithbut unless someone else has a better idea, I'd say try it and see
14:39benzapfrom what I can tell, it doesn't appear to be my problem anyways
14:40umpa,(for [v [[1 3 4] [7 3 4] [1 5 4] [7 5 4]]] [(set/intersection #{0 1 2 3} (set v))]) kinda works
14:40clojurebot#<CompilerException java.lang.RuntimeException: No such namespace: set, compiling:(NO_SOURCE_PATH:0:0)>
14:40umpa,(for [v [[1 3 4] [7 3 4] [1 5 4] [7 5 4]]] [(clojure.set/intersection #{0 1 2 3} (set v))]) kinda works
14:40clojurebot#<CompilerException java.lang.ClassNotFoundException: clojure.set, compiling:(NO_SOURCE_PATH:0:0)>
14:40justin_smithfor javac, "The compiler does not consider return type when differentiating methods, so you cannot declare two methods with the same signature even if they have a different return type." - dunno how this applies to the clojure bytecode compiler though
14:41umpa,(include 'clojure.set)
14:41clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: include in this context, compiling:(NO_SOURCE_PATH:0:0)>
14:42justin_smiththat's require
14:42umpa,(require 'clojure.set)
14:42clojurebotnil
14:42umpa,(for [v [[1 3 4] [7 3 4] [1 5 4] [7 5 4]]] [(clojure.set/intersection #{0 1 2 3} (set v))]) kinda works
14:42clojurebot([#{1 3}] [#{3}] [#{1}] [#{}])
14:42justin_smiththe issue here is that you can't put that in a map, because there are no keys provided, just the vals
14:43umpajustin_smith: you mean as set/intersection args /
14:43justin_smithumm, no, set/intersection worked just fine there
14:44justin_smithI mean the previous thing, where you tried to turn that into a map
14:44umpagotcha
14:45umpa,(for [v [[1 3 4] [7 3 4] [1 5 4] [7 5 4]]] [(count (core.set/intersection #{0 1 2 3} (set v)))]) is what I actually need
14:45clojurebot#<CompilerException java.lang.ClassNotFoundException: core.set, compiling:(NO_SOURCE_PATH:0:0)>
14:45umpa,(require 'clojure.set)
14:45clojurebotnil
14:45umpa,(for [v [[1 3 4] [7 3 4] [1 5 4] [7 5 4]]] [(count (core.set/intersection #{0 1 2 3} (set v)))]) is what I actually need
14:45clojurebot#<CompilerException java.lang.ClassNotFoundException: core.set, compiling:(NO_SOURCE_PATH:0:0)>
14:45umpa,(for [v [[1 3 4] [7 3 4] [1 5 4] [7 5 4]]] [(count (clojure.set/intersection #{0 1 2 3} (set v)))])
14:45clojurebot([2] [1] [1] [0])
14:53arrdemBronsa: ping
14:54Bronsaarrdem: pong
14:54justin_smith,(clojure.set/intersection #{0 1 2 3} [0 1]) umpa: btw this works
14:54clojurebot#<ClassNotFoundException java.lang.ClassNotFoundException: clojure.set>
14:55justin_smith,(require 'clojure.set)
14:55clojurebotnil
14:55justin_smith,(clojure.set/intersection #{0 1 2 3} [0 1]) umpa: btw this works
14:55clojurebot[0 1]
14:55amalloyTimMc: i don't understand. were you saying that java.lang.Void is "for" the class of null?
14:56arrdemBronsa: I'm considering patching tanal to add :context types for invoke targets rather than expression forms. Also kinda considering a :binding context. Thoughts?
14:56arrdemBronsa: the problem I'm trying to solve is determining when a {:op :var} is bound to something that's invoked or directly invoked as opposed to taken as a value.
14:57arrdemthe former probably being a special case that constant propagation would reveal.
14:57TimMcamalloy: I was, but I'm not now. I got confused because Clojure treats the value of a void method call as nil.
14:58amalloyaww. can't you go back to being wrong? i like educating people
14:58TimMcand so many languages do use a nil response instead of having *no* return value.
14:59TimMcamalloy: I can pretend to still hold that opinion if it would make you happy.
14:59Bronsaarrdem: interesting
15:01Bronsaarrdem: personally, I wouldn't object to that, I can see why that would be helpful
15:01arrdemBronsa: I can trivially collect all {:op :invoke}s and their targets, and I think that if I just treat all vars in binding forms to be taken as values then I would get a _correct_ abet suboptimal analysis.
15:01arrdemwithout patching tanal.
15:01umpajustin_smith: something like this should work too right (into {} (for [[k v] {0 [1 3 4], 6 [7 3 4], 2 [1 5 4], 8 [7 5 4]}] [(count (clojure.set/intersection (set comb) v))]))
15:01umpajustin_smith: something like this should work too right (into {} (for [[k v] {0 [1 3 4], 6 [7 3 4], 2 [1 5 4], 8 [7 5 4]}] [(count (clojure.set/intersection (set comb) v))]))
15:02Bronsaarrdem: it would probably be better to move to namespace qualified contexts at that point, so that we could have :ctx/invoke derive from :ctx/expr
15:02umpa,(into {} (for [[k v] {0 [1 3 4], 6 [7 3 4], 2 [1 5 4], 8 [7 5 4]}] [(count (clojure.set/intersection (set comb) v))]))
15:02clojurebot#<CompilerException java.lang.ClassNotFoundException: clojure.set, compiling:(NO_SOURCE_PATH:0:0)>
15:02arrdemBronsa: a legitimate use for higherarchies! at last!
15:02arrdem:P
15:03justin_smithumpa: no, because you still only have one element in that vector
15:03justin_smithumpa: maybe you want ((juxt count identity) (clojure.set/intersection ...))
15:04justin_smithbut then, you would have identical counts clobbering one another, which is why I used reduce instead of for or map in previous examples
15:04Glenjamin,(do (require 'clojure.set) (into {} (for [[k v] {0 [1 3 4], 6 [7 3 4], 2 [1 5 4], 8 [7 5 4]}] [k (clojure.set/intersection #{0 1} (set v))])))
15:04clojurebot{0 #{1}, 6 #{}, 2 #{1}, 8 #{}}
15:05umpajustin_smith: would I need "for" if i used that
15:05justin_smithno, reduce and for are two different ways to walk a collection
15:05Glenjaminumpa: what is it you're actually trying to do, in terms of data in -> data out
15:08umpaGlenjamin: your code gives what I want, maybe vector for the val instead of hash
15:08umpaGlenjamin: data in would be a map with key val
15:12Bronsaarrdem: as I've said, I'm not against the idea; probably worth discussing with tbaldridge though, I remember him telling me a while ago that Rich was not really happy about the :expression/:statement dichotomy, he might have some valuable opinion on this
15:14arrdemBronsa: willco. Doing this "target rather than value" analysis is a pretty trivial post-walk now that I think about it so I'll just do it in Oxcart and whenever Oxcart get taken apart into contribs we can sort that out if I haven't been able to remove it due to folding.
15:15Bronsaarrdem: fine with me
15:15Rayneskzar: Turns out there were also breaking changes in that patch release. Oops.
15:16umpaGlenjamin: how would I get count of the output vals
15:16bbloomBronsa: i'm not sure i follow your comment about the expression/statement dichotomy as it relates to :context
15:16dkinzerfg
15:16bbloomBronsa: are you saying that rich wasn't happy that the analyzer behaves differently with respect to :context ?
15:16Glenjamin,(do (require 'clojure.set) (into {} (for [[k v] {0 [1 3 4], 6 [7 3 4], 2 [1 5 4], 8 [7 5 4]}] [k (count (clojure.set/intersection #{0 1} (set v)))])))
15:16clojurebot{0 1, 6 0, 2 1, 8 0}
15:16Glenjaminlike that?
15:17umpaGlenjamin: nice
15:17Glenjaminif you extract the input into a var with (def), then play around in the repl it should be easier to follow what's going on
15:18bbloomBronsa: looking at tools.analyzer & tools.analyzer.jvm, it seems it only generates :context, never really consuming it except in one place to clear locals... of course the generators are going to care about return position quite a bit
15:19Bronsabbloom: there might be some information loss here since I'm reporting what tbaldridge told me Rich told him, but from what I understood Rich didn't like the fact that ta had an explicit :statement context since Lisps don't really have any statement construct
15:20arrdemmeh... model != implementation
15:20bbloomBronsa: gotcha. but :statement is really just shorthand for :expr who's value is ignored
15:20bbloom:-)
15:20Bronsabbloom: tej uses :statement to understand when/where it needs to pop a value from the stack
15:21bbloomBronsa: yeah, that of course makes sense
15:21bbloominstead of :context => :expr :return :statement
15:21Bronsaso having it is actually useful
15:21bbloomyou could have :tail? and :used?
15:21bbloombut :tail? true and :used? false wouldn't ever make sense
15:22arrdembbloom: potentially it would if you're inlining or something and the tail value of a subexpression is ignored, ala (do (do .. ) )
15:22bbloomhm, that's true
15:22arrdembut that's already covered by :ret as opposed to :expr
15:23Bronsabbloom: I don't really see how that would be an improvement over :context :)
15:23bbloomyeah, i don't know the precise keywords, just conceptually... what are they precisely? :stmt :ret and :expr ?
15:23bbloomthis is IMO, the case for making _ a special variable
15:24bbloom,(let [_ 1] _)
15:24bbloom&(let [_ 1] _)
15:24clojurebot1
15:24lazybot⇒ 1
15:24umpaGlenjamin: yeah repl is nice
15:24bbloomc'mon bots
15:24bbloomanyway
15:26bbloomi'm back, stupid irc
15:26bbloomif you say _ is a blackhole value, then do is a special case of let
15:26arrdembbloom: black hole is dangerous in a language where forms must be evaluated for side effects.
15:27arrdemthen you get silly people like me who want to throw away unreached pure forms
15:27bbloomarrdem: it's only dangerous if your optimizer is broken :-P
15:28bbloomobviously all clojure forms are lifted in to a context in which JVM effects exist :-)
15:28bbloomso really you're getting (JVM ctx ret) and binding ret to _
15:29bbloomwhich means that you really can throw out some work if you're black holign something... as long as you run the expression up to it's last side effect
15:29tbaldridgeBronsa: I wouldn't take Rich's problems with :statement/:expression too seriously, it was more off hand. Knowing what I know now I would probably support the way you do it now. It's sometimes easier to do code emission if you know more about the context
15:30bbloom,(let [x (atom 1), _ (do (swap! x inc) (swap! x * 2) 123)] @x)
15:30clojurebot4
15:30bbloomsame as:
15:30bbloom,(let [x (atom 1), _ (do (swap! x inc) (swap! x * 2))] @x)
15:30clojurebot4
15:39arrdemBronsa: okay I can't just clobber :context because I'll break tejvm, so I'm gonna use ::context and lob a :context higherarchy patch at you later.
15:43Bronsatbaldridge: noted, thanks
15:44Bronsaarrdem: jeez, make up your mind! :)
15:44arrdemBronsa: quiet you
15:44arrdem /s
15:45BronsaI was just getting ready to be offended for life.
15:45arrdemas long as you take patches and feature requests I don't really care one way or the other :D
15:46Bronsa;_;
15:46arrdem<3
15:48bbloomi absolutely love that i can prn a GIANT expression to a file, change a boatload of code, then just slurp that expression back in and = it to make sure i didn't break anything
15:48bbloom<3 values
16:16sveriHi guys, I am the author of friendui a wrapper which sets a web ui on top of friend and stores the user data in datomic, now, after watching "simplicity matters" the third time it occured to me that I am complecting a friend user interface with datomic and I got the idea to just set a UI on top of friend which accepts some callbacks to load and store user data so that ppl can use every datastore they want, what do you think of this?
16:18technomancyI think that writing open source code that depends on proprietary software is silly.
16:20tbaldridgesveri: abstraction is often a good idea. Why not use protocols instead of callbacks?
16:20whodidthisstupid sexy datomic
16:21tbaldridgetechnomancy: frendui - "a web frontend for friend connected to datomic" kindof seems like the point of the project.
16:22technomancytbaldridge: I understand that
16:22Glenjaminabstracting the user storage seems like it would broaden the appeal, certainly
16:23microamptbaldridge: i wonder if rich hickey/cognitect had considered neo4j-like licensing for datamic? (https://github.com/neo4j/neo4j)
16:24microampsorry if it has been mentioned earlier
16:24kbaribeauhey, is this a known eyesore with dashes in namespaces and using defrecord/java-interop? https://gist.github.com/kbaribeau/d0d94c02a598490653de
16:24sveriI need this library for a private project where we use datomic, however, it occured to me that it might be possible some we may use some different storage in a different project
16:24sveriI think I will decouple it
16:25mdeboardmicroamp: I've wondered that myself, but I suppose they want to spend their time building a product vice building a service-oriented company
16:25sveritbaldridge: I have not used protocols yet, my idea was to pass some functions to friendui to retrieve a list of users and things
16:26tbaldridgesveri: probably better to define a protocol, and then pass an instance to frendui. That way all the functions are in one thing, instead of having to pass multiple callbacks
16:26amalloykbaribeau: it's a known issue, but it seems to come up pretty rarely, somehow. i guess just avoid putting new types in namespaces with dashes
16:26sveritbaldridge: a protocol that defines functions to retrieve a list of users, save a user instance, update a user instance etc?
16:27amalloyusually there's a more clever way to namespace stuff anyway: my.project.protocols instead of my-project.protocols, for example
16:28tbaldridgemicroamp: to be honest, I've never really cared enough to look into it (I'm not part of the Cognitect product team). Personally I've used proprietary software so much in my career using it doesn't bother me at all. Better to use good tech, IMO, then wine about it not being OSS.
16:28tbaldridge*whine
16:29tbaldridgenot to mention that I consider GPL to be a rather horrible license.
16:30hiredmantbaldridge: calling open source software advocates whiners seems needlessly pejorative
16:30kbaribeauamalloy: thanks, I kind of suspected it might be that way
16:32caternhiredman: don't try to correct him - it marks him as stupid very quickly so others don't have to waste time
16:32arrdemwooooah
16:32tbaldridgehiredman: advocating is fine, complaining that some tech isn't OSS is. If I want to write OSS software that's awesome, but why should I complain when some cool tech isn't?
16:33tbaldridgeIf I spent 2+ years of my life writing some cool tech, why should people complain when I don't want to give away all my hard work? I just don't understand it.
16:33caterntbaldrige: things being open source isn't about them being available for free
16:33microamptbaldridge: i see, thanks for sharing your thought btw
16:34technomancywell, this *is* freenode
16:35TimMctbaldridge: Because they want to modify it?
16:35tbaldridgecatern: in a sense it does, if you read my source, you now know my algorithms. What's left then? patents?
16:35hiredmantbaldridge: I think you are painting with a very wide brush there
16:36hiredmantbaldridge: open source is a lot of things, but, for example, datomic has free editions you can use, I doubt that in any way has stopped people from asking about it being open source
16:36tbaldridgehiredman: agreed, but doesn't everyone on this subject? :-)
16:36hiredmanso obviously people are just looking to get it for "free"
16:36tbaldridgehiredman: why is the free version not enough?
16:36technomancytbaldridge: vendor lock-in
16:36Glenjaminbecause people want to build their businesses on software without paying for it, clearly
16:37caterntbaldridge: no, you didn't read what I said. It isn't about getting your algorithms for free. It's about, for example, not tying my company or technology to your whims
16:37hiredmantbaldridge: hard to say, I, for example, would just be interested in looking through the code
16:37arrdemcatern: all you said was that tbaldridge could be discarded as a fool for disagreeing with you :P
16:37tbaldridgehiredman: as would I :-)
16:38hiredmantbaldridge: for example at work we use elasticsearch rather extensively, and while I don't like doing it, from time to time it is helpful to look through the code instead of treating it as a black box
16:38caternarrdem: actually, I foolishly said something else after that, sigh
16:38Glenjaminthe lock in point seems pretty solid
16:38dinduksHello
16:39Glenjaminbut i guess that's the price you have to pay if you want to use it
16:40arrdemI get the "but I want to modify it" argument, sort of, but I fail to see the lock in one. As Dalvik is unfortunate proof it is possible to do a clean room implementation of a closed API.
16:40caternfeel free to charge me, please charge me, for commercial access to your open source project. I have no opposition to paying, just to paying for things that don't give me some basic freedoms about how I use them
16:40tbaldridgearrdem: or not, since they still got sued for it.
16:41arrdemtbaldridge: that's the point unfortunately.
16:41dinduksI was wondering if there were CLJS "frameworks" similar to Meteor or MEAN, that can allow fast (and spectacular) development of web apps. Anything?
16:41gtrakdinduks: seen om yet?
16:41technomancyarrdem: possible doesn't mean practical
16:41Glenjaminarrdem: take MySQL for example - people decide they don't like the Oracle direction, so they take the open source and fork
16:41technomancyno libre implementation exists in the real world
16:42arrdemtechnomancy: fine, but if you decided it was cost effective you could build one
16:42tbaldridgeGlenjamin: note that that project started as OSS originally.
16:42arrdemtechnomancy: the point to me of purchased software is rewarding someone else for incurring the risk of building something nontrivial.
16:42Glenjaminyes, that's my point
16:42arrdemtechnomancy: and escaping the cost of doing so yourself
16:42technomancyarrdem: doesn't mean there's no lock-in
16:42gtrakdinduks: I think the closest thing to full-stack is hoplon http://hoplon.io/, look at pedestal too.
16:42Glenjaminif its OSS, you cannot be locked in if you don't like the vendor's direction
16:43Glenjaminfinancing OSS is, it seems, a fairly hard open problem
16:43caternarrdem: open source software can be "purchased software", weren't you just mentioning neo4j?
16:44caternOh that was someone else. Anyway.
16:44tbaldridgeGlenjamin: so yes, that's the price you pay with any non-OSS tech. Having used so much proprietary software in my life, and having experienced so little vendor lock-in I guess it doesn't bother me.
16:44arrdemtechnomancy: as long as copyrights and patents don't prohibit clean room implementations (which they seem to do so this is a moot point) my point is that lockin is or should be a non-issue because it's a risk you have to incur if you decide that mitigating that risk by cloning isn't viable.
16:44Glenjaminyou haven't experienced lock-in, or you haven't had problems because of it?
16:45technomancyarrdem: theoretically correct. yet completely impractical
16:45caterntbaldridge: doubtful. I think you're just used to the vendor lock in and don't even notice it anymore, you perhaps think that is just how software is
16:45tbaldridgeBut bringing the conversation back around, I just don't understand the need to say "building OSS that requires proprietary software is silly".
16:45arrdemtechnomancy: given that we have retarded IP laws sure
16:45gtraktbaldridge: apparently microsoft is pretty aggressive about deprecating APIs.
16:45Glenjamini agree with tbaldridge there, dependant on proprietary or not, open source is better than not
16:45technomancyarrdem: completely impractical even modulo legal issues
16:46PigDudewhat is -Werror in clojure? I have reflection warnings of unknown origin
16:46hiredmanthere is a, I dunno what you call, a margin cost? we store a lot of data on s3 in various formats, I think something like datomics model would work well for us, but it is sort of outside of the use cases that the company seems to be focused on (s3 storage isn't "fast" enough for a real time database backend), and even if it was I don't know that the storage is enough of a problem for us to go out and buy something
16:46PigDudei need to see a stacktrace when this happens.
16:46Glenjaminreflection warnings usually come with a file and a line
16:46amalloyPigDude: there is no stacktrace to be had, because those get generated when your code is being compiled, not when it's being run
16:46PigDudethat they do
16:47technomancyarrdem: that's like saying it's fine to deploy on Windows because ReactOS exists
16:47PigDudeamalloy: makes sense
16:47PigDudeamalloy: however this reflection warning comes from inside of clojure.java.jdbc
16:47Glenjaminthat's odd
16:47PigDudeamalloy: i guess i do not have the power to correct it if it happens when compiling java.jdbc
16:47technomancycurl http://p.hagelb.org/nope.gif | display
16:48GlenjaminPigDude: what version/file/line ?
16:48tbaldridgetechnomancy: are you suggesting it's wrong to deploy Windows?
16:48PigDudeGlenjamin: 148 in jdbc.clj, where it is parsing a query string. my code doesn't use a query string, so i should've discerned that this is not my problem
16:49stompyj(into {} coll) seems quite with large hashes. Is there a quicker way to do this?
16:49technomancytbaldridge: not like ... morally wrong
16:49GlenjaminPigDude: in 0.3.3 that function looks to have the correct typehint https://github.com/clojure/java.jdbc/blob/java.jdbc-0.3.3/src/main/clojure/clojure/java/jdbc.clj#L141
16:49technomancyjust that if you ever find yourself in a position where that seems reasonable, you need to seriously re-evaluate the life choices that led you to this point
16:49amalloyGlenjamin: it's https://github.com/clojure/java.jdbc/blob/java.jdbc-0.3.3/src/main/clojure/clojure/java/jdbc.clj#L147
16:49justin_smithstompyj: there is also (apply hash-map coll), but into should be faster
16:50Glenjaminamalloy: oh right, no hint on the .split retval
16:50stompyjjustin_smith: I’lll try that, thanks. I would have never guessed that method would so be slow
16:51Glenjaminstompyj: have you profiled?
16:51PigDudeGlenjamin: it is the correspondence between .getQuery and .split, it seems
16:51amalloyGlenjamin: well, actually, i guess it's the next line. that first .split is fine, because query's type is known. but the type of kvs is not
16:51amalloy(which, by the way, should really be called kv, not kvs)
16:51Glenjaminyeah, needs ^String kvs
16:51PigDudeah right it's all in the for loop :)
16:52PigDude*comprehension
16:52stompyjGlenjamin: I just ran (time (into {} return-val)) and it’s taking ~20-30ms
16:52stompyjO_o
16:52PigDudethanks Glenjamin, amalloy
16:52Glenjaminand what is return-val? a large lazy sequence?
16:52mdeboardI'd rather read a spirited/occasionally mean argument about OSS than that one ebaums world porn spammer
16:52mdeboardor whatever
16:52mdeboardthat was weird
16:52stompyjGlenjamin: yeah
16:52tbaldridgetechnomancy: it's that assumption I kick against. The idea that if I wish to deploy Windows (or proprietary software in general), there is something wrong with me. But we've digressed so much at this point I suppose I should let it drop.
16:53Glenjaminyou may find that most of the time is reading the sequence, rather than building the map
16:53Glenjaminbut yeah, jvisualvm is probably a good place to start
16:53technomancyeh, kick all you want
16:53stompyjawesome, thank you
16:53justin_smithPigDude: also, if the coll is lazy, you may find performance is better if you don't hold the head of the sequence
16:54tbaldridgetechnomancy: I see no problem with well written proprietary software. Hence the reason I tend to use Macs over Windows/Linux...it just works for me. I know it doesn't for everyone.
16:54PigDudestompyj: ^
16:54PigDudestompyj: was for you i think
16:54amalloythat sounds like a complete red herring, justin_smith
16:54stompyjPigDude / justin_smith thanks
16:54PigDudestompyj: heh i didn't help you :)
16:55justin_smithoops, I replied to PigDude by mistake about stompyj's question, oops
16:55michaniskinis the correct way to deprecate functions demonstrated in the core.memoize https://github.com/clojure/core.memoize/blob/master/src/main/clojure/clojure/core/memoize.clj#L188-L191 ? or is there another, better way i should be doing it?
16:56tbaldridgemichaniskin: why not just add it to the doc string?
16:56tbaldridgemichaniskin: and to the changelog. If people don't read the change log, their bad for upgrading before reading.
16:57michaniskintbaldridge: i'd like to have something displayed to the user at compile time telling them how to use the new replacements, maybe? i know people should read the changelog but i thought this might help the rest of the people
16:58stompyjGlenjamin: if reading the sequence is indeed the issue, what is the idiomatic way to fix that?
16:58michaniskinis it a bad idea to print warnings like this at compile time?
16:59technomancymichaniskin: the only danger there is non-aot'ing users might miss it.
16:59amalloystompyj: the point is that *producing* the sequence may be slow, just because there's a lot of work to do. you can't tell just from running (time (into {} xs)) that anything is slower than it should be
17:00technomancymichaniskin: one thing I have done with Lein is have the deprecated function force a delay that prints a warning, so it only happens once
17:00stompyjamalloy: hmmm. fair enough, makes sense
17:00technomancymichaniskin: I mean when it's run
17:01michaniskintechnomancy: you're saying if they aren't AOTing the warning might not print when the macro is used? Also, I like the delay idea
17:01stompyjas with most things in life, I can fix this by fixing my data model, however, I’m more curious about looking into this behavior, since I hadn’t had to deal with it before
17:01stompyjthanks
17:02tbaldridgemichaniskin: you can do what you want, but if it were me, I'd just rip out the old code, put in the new code, put a note in the changelog and the release email, and reduce the size of that file by 50%. But I can see why you're doing it this way.
17:02dinduksgtrak: thanks. i'll check these out.
17:02technomancymichaniskin: oh, I missed that it was a macro. in that case compile-time is probably fine.
17:03gtrakdinduks: om is hard to search for: https://github.com/swannodette/om
17:03gtrakit makes the frontend very fast to build.
17:04michaniskintbaldridge: the old stuff still works fine, but some of the names were really terrible and things like that. i don't mind keeping the old names around forever to keep compatibility but i'd really like to help the user by telling them what the new names are, because i'll be removing the old names from the examples and tutorials etc.
17:20technomancyhttps://i.imgur.com/wfNZNyo.png =(
17:22gtraktechnomancy: read clojure documentation with Tor.
17:23technomancygtrak: well I don't expect much when I visit clojure.org, but I do have an expectation that I can successfully establish an HTTP connection. =\
17:30mmmm_hey guys,
17:32mmmm_problems with leiningen and so - I create project with libraries in the deps
17:32danneuSomething at twitter changed this past month and most of my automated tweets (a few per day) fail with an error 'This request looks like it might be automated.' -- I guess their http POST api was intended for hand-typed curl requests
17:33danneuI have some audacity
17:33mmmm_lein deps works - I run the repl - but I don't access the libraries in the repl
17:33mmmm_ (use 'seesaw.core) -> nil
17:34justin_smithmmmm_: so what's the symptom?
17:34justin_smith,(use 'clojure.set)
17:34clojurebotnil
17:34mmmm_CompilerException java.lang.RuntimeException: Unable to resolve symbol: frame in ... etc
17:34mmmm_Leiningen 2.4.2 on Java 1.7.0_55 OpenJDK 64-Bit Server VM
17:34justin_smith,(ns-publics clojure.set)
17:34clojurebot#<CompilerException java.lang.ClassNotFoundException: clojure.set, compiling:(NO_SOURCE_PATH:0:0)>
17:34justin_smith,(ns-publics 'clojure.set)
17:34clojurebot{union #'clojure.set/union, map-invert #'clojure.set/map-invert, join #'clojure.set/join, select #'clojure.set/select, intersection #'clojure.set/intersection, ...}
17:35justin_smithmmmm_: if you check the ns-publics, what do you see?
17:35mmmm_justin_smith: cannot access symbols
17:35justin_smithI mean call (ns-publics 'seesaw.core)
17:35mmmm_(ns-publics 'seesaw.core) {foo #'seesaw.core/foo}
17:35mmmm_only foo
17:36justin_smithmmmm_: did you by any chance try to switch to the seesaw.core ns before requiring it?
17:37mmmm_probably not - what is switching? (I call (use 'seesaw.core) before
17:37justin_smithtry '(require 'seesaw.core :reload)
17:37justin_smithwithout that first '
17:38amalloymmmm_: do you have a file named seesaw/core.clj in your own project?
17:38mmmm_did reload - still only foo in the seesaw.core ns
17:38mmmm_nope
17:38mmmm_ahh yes... aggghhhh
17:39justin_smithyou shadowed the ns?
17:39mmmm_yep
17:39mmmm_...
17:40danneuoh, so you must've `lein new seesaw` and it created the seesaw.core/foo
17:40danneuawesome
17:40mmmm_yes
17:41mmmm_put to some of your "collected" :)
17:44danneui don't know if i've every really stopped making basic errors that take me 30 min to figure out. like (let [name (:name user)] ...) and then trying to (clojure.core/name ...)
17:46amalloythat one's pretty nasty, danneu. i've made it enough times that i generally manage to avoid it or fix it quickly
17:46amalloybut it is not a lot of fun
17:47technomancyluckily it only happens with that one function =)
17:47amalloyi wonder...if i see "String can't be cast to IFn", is that the first mistake i assume i've made? i've kinda grown up enough that i don't really put in too many parens anymore...what else would cause that exception?
17:48amalloypassing args in the wrong order, i guess: a string where i meant to put a callable and vice versa
17:48technomancyamalloy: someone plz write an nrepl middleware to make fun of you for doing that
17:48amalloyit won't be me. i'm pretty sure there's no swank middleware support
17:49technomancymaybe that'll be the killer feature that finally gets the slime diehards to upgrade
17:49technomancy:repl-options {:sarcastic true}
17:49amalloymaybe we can get the vim users on board too
17:49amalloy"a sarcastic repl? sign me up!"
17:50technomancy"Finally, your editor can be as tired of these type errors as you are."
17:50arrdemtechnomancy: but then we need to get tanal in between the repl and the compiler..
17:50danneui've also run into issues that throw a generic low level clojure error on line 1, column 1 even though it's because of an ad-hoc `(require '[some.ns])` on line 832 i forgot to remove before rebooting my repl
17:50technomancyarrdem: nah just hard-code it to the clojure.core/name bug; that's good enough for an 80% solution
17:51arrdemtechnomancy: dude that's not even a 20% solution...
17:51arrdemtechnomancy: lets see you write a regex that tracks bindings..
17:51technomancyarrdem: I mean based on the "String can't be cast to IFn" message
17:53TimMctechnomancy: Match #"^\s+name\s" and #"\[name\s" and I think you've got a pretty good guess at trouble spots.
17:54arrdemor you could just use tanal and (ns-maps) to detect all import shadowing :P
17:55justin_smithanother big one is count - perfectly cromulent as a noun or verb, so very ready to get shadowed
17:57amalloyi've done it with map sometimes
17:57amalloywhich is particularly tricky to track down, because maps tend to be callable and just return stupid results
17:58justin_smithouch
17:58arrdemIFn ALL THE THINGS
17:58justin_smithahh, especially as you would normally be doing the three arg version, so you get the unmodified sequence back
17:58justin_smithlol
17:59cbp`except for regex ;(
17:59amalloyyep
17:59seangrovearrdem: Strings implemented IFn in cljs for the longest time
17:59seangroveFun times
17:59arrdemRFC: me.arrdem/regular: crowbars int core and implements IFn for regexes :P
17:59arrdems/int/into/g
18:00technomancynothing has ever made me sad about not using cljs like callable regexes
18:02dgleesonso when you return a 404 using ring it doesn't add the extra tomcat formatting. I'm curious if anyone has experience munging the error codes so they look like tomcat's default presentation?
18:03justin_smithdgleeson: how are you returing the 404 status? {:status 404} with no body key?
18:05gtraktanalysis
18:06dgleeson{:status 404 :body "some message"}
18:06dgleesonif I return just a status code it's a blank page
18:07justin_smithdgleeson: oh, I had hoped that might cause it to use the default 404 body
18:09dgleesonMy other java servlets use the HttpServletRequest/sendError work flow
18:09dgleesonwhich triggers it
18:10dgleesonbut since ring-servlet wraps that with a map, I'm not exactly sure how to trigger that code path
18:23seangrovednolen_: Might be time to bump mies-om template
18:28kzarRaynes: :o did I mess something up?
18:28Rayneskzar: Nope, it was a previous pull request by someone else.
18:28RaynesJust changed some var names.
18:28RaynesI had forgotten about it was was like "RELEASE! RELEASE! RELEASE! SHIPIT!"
18:28RaynesNothing to be done about it now.
18:29kzarllol
18:32dnolen_seangrove: ah right, thanks for the reminder
18:32seangrovednolen_: No worries, just coming back to it after some time in the js world
18:38noncom|2does anyone know anything about DotLisp?
18:39noncom|2what's the project status?
18:40justin_smithnoncom|2: interesting, looks like a clojure predecessor
18:41noncom|2yes, it is, i am to ressurect it for my practice - i have to work with unity3d, which is based on mono, which is based on net framework 2. so far, dotlisp is the only sane lisp for net i have found (besides ironscheme)
18:41noncom|2coincidently, it is made by the same man :)
18:42noncom|2its crucial +s are 1) net 2.0 compatibility and 2) lightweighness like never before
18:42noncom|2so i wanted to know what's up with it officially
18:42justin_smithnoncom|2: what about the clojure clr backend?
18:43justin_smithis that just not usable?
18:43noncom|2too bad, but clojure clr requires net 3.5+, it will not work in unity3d
18:43noncom|2also, we target android...
18:43noncom|2so dotlisp seemes to me like a neat little brother (or sister) of clojure
18:44noncom|2the standard boot.lisp defines much, but i am writing boot2.lisp which brings it closer to clojure in terms of functionality
18:44noncom|2since i'm used to clojrue :)
18:44noncom|2ofcourse, no stm and such, but unity3d hardly requires it
18:45noncom|2i wrote a mail from the sourceforge site to both maintainers, but no answer yet...
18:46noncom|2i thought about ressurecting it and creating a good unity3d support
18:46noncom|2currently unity3d lacks lisp
18:47noncom|2so i thought maybe anyone knows, how can i write a mail to rich about it, since that project did not seem to have any community at all..
18:55TEttingernoncom|2, are you sure unity allows anything but C#, Boo, and UnityScript?
18:55TEttingerI think it has arbitrary constraints
18:56noncom|2well, firstly it is based on an ancient mono version, which is about framework 2
18:56noncom|2all clr langs moved far since then, as did clojure
18:56noncom|2but i want a lisp with a repl
18:56noncom|2the only 2 sane candidates are dotlisp and ironscheme
18:57noncom|2ironscheme is another story, lets discuss dotlisp
18:57TEttingerright but I have never heard of anyone being able to use anything but those 3 in the unity environment
18:57noncom|2i have managed to implement a repl and it wokrs perfectly fine
18:57noncom|2i already can do anything with it
18:57TEttingermono has a C# repl actually
18:57noncom|2but not for unity3d :)
18:57TEttinger:-(
18:58noncom|2actually, unity3d is a piece of ancient crapware
18:58noncom|2(dont tell anyone)
18:58TEttingerwhy not libgdx if you're using clojure?
18:58hiredmanb
18:59noncom|2currently i have a project with libgdx and i also use jmonkey when appropriate, that is fine. but there is a second story in my life - my new employee is based on unity3d
18:59noncom|2i am actually a jvm + clojure guy
18:59TEttingerheh ok
18:59noncom|2but forced to work for a unity3d c# company
18:59TEttingerC# isn't that bad, tbh
18:59noncom|2if i propose the initiative inside the company, they will accpet it
18:59TEttingerLINQ is a nice breath of functional air
19:00noncom|2well, i do not like it much, but yeah, the language is ok, on par with java
19:00noncom|2but there are other implications too..
19:00noncom|2using a lisp will help us much
19:00noncom|2and also, i just want to work with a lisp
19:00noncom|2:)
19:01noncom|2you should try unity3d if you did not have a chance yet
19:01noncom|2to see all its crappyness
19:02TEttingerheh, I was going to, but I'm sticking with either C#/MonoGame or Java/Clojure/LibGDX
19:02noncom|2i vote for java :) since i worked 3 years in that field - java/clojure/jme/libgdx
19:03noncom|2i think that seeing some unity3d is useful in terms that you can learn, how you should NEVER design your software
19:03noncom|2it has some good spots though
19:03noncom|2but they jsut dont cut it
19:15deathknight(format "test/%s/foo")
19:15deathknightwhat does %s mean?
19:15arrdemformat in a string here
19:15deathknightis there a term I can look up that explains what you just said?
19:16cbpdeathknight: http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html
19:16arrdemjava.lang.String.format
19:17deathknightstill dont quite understand
19:18deathknightspecific example: (api/simple-request (format "/calendars/%s/events" (api/decode cal)) token)
19:18deathknightis token being placed where the %s is?
19:18cbpno, (api/decode cal) is assumed to be a string and placed where the %s is
19:18deathknightNICE
19:19deathknightthank you!
21:38Farehi
21:39caternhi
21:39Farewhich clojure deftype vs defrecord vs ... to use for data with inheritance of fields?
21:43justin_smithFare: if all you need to do is inherit some default values, you can just call merge on a map
21:43hellofunkFare: while polymorphism is quite nice in Clojure with defrecord, inheritance is a different matter and I think generally not recommended
21:43hellofunkas justin_smith notes, using data instead of object-oriented ideas tends to be more idiomatic in Clojure
21:45Fareso more like, include a subrecord?
21:45Faree.g. if I want each record to contain provenance information
21:46hellofunklearn all the functions on maps and you'll likely find some good ones for your purposes. assoc, dissoc, merge might be useful: Fare
21:46justin_smithuntil you absolutely need the performance benefits of a custom deftype or defrecord, use a map, and write a function that makes a map of the right shape
21:47justin_smithusing maps and using types / records happens to have identical semantics, so upgrading is not very hard
21:48justin_smithif you want, you can even name the function returning the map "constructor"
21:48hellofunknote that while defrecord supports associative functions, deftype is a much simpler API; I don't think assoc etc work on deftype?
21:48justin_smithhellofunk: ahh, good call, maybe not
21:48justin_smiththat's probably why I have never used it actually
21:49justin_smithanyway, at worst it's a question of (.slot thing) vs. (:slot thing)
21:49hellofunkgenerally deftype is not going to be useful unless you want to, for example, write a Clojure compiler for a different platform, you can build out your base with custom types
21:49justin_smith(for access that is)
21:51justin_smithas I don't use deftype much, this is a helpful reminder of how they work / compare http://clojure.org/datatypes
21:54justin_smithFare: especially not the heading on that page "Datatypes and protocols are opinionated"
22:00deathknightusing http.async.client, how do I specify the content-type as JSON?
22:03justin_smithdeathknight: (http/POST client "url" :body [{:mime-type "application/json" ...}])
22:03justin_smithhttps://github.com/neotyk/http.async.client/blob/development/docs.org
22:06deathknightI...am...so close....thank you Justin!
22:06deathknightIf my body already looks like this, should I still put a vector around it with the inclusion of mime-type? :body {:end {:date "2014-06-16"} :start {:date "2014-06-16"}}
22:07deathknightor would this work-- :body {:mime-type "application/json" :end {...}...}
22:08Fareclojure in some ways seems to be miles ahead, and in other ways, lagging.
22:08FareI'm not yet sure exactly which though.
22:09justin_smithFare: I think clojure is much more opinionated
22:09Fareis that your opinion?
22:09hellofunkFare, which ways do you feel clojure is lagging?
22:10hellofunkit is fair, Fare, to say that clojure is a bit more encouraging to a particular programming style than is CL
22:10justin_smithdeathknight: I think the way it works is you make a :query that consists of some magic key, so it's :query {:request (your map that bcomes json here)}
22:11deathknighthmm
22:11deathknightlooks a bit different than what I'm working off of that works so it's a bit over my head :)
22:11justin_smithhellofunk: two ways that I would agree clojure is lagging is startup time and step debugging
22:11deathknightI'm doing some finicky balancing on these shoulders
22:12justin_smithdeathknight: heh, OK
22:12justin_smithdeathknight: http://neotyk.github.io/http.async.client/doc/http.async.client.html#var-POST
22:12justin_smiththat's pretty comprehensive I think
22:12hellofunkit's definitely true that Clojure debugging is pretty primitive
22:12deathknightDanke!!
22:24deathknightso even though content-type is usually defined in the headers, http.async.client has it chosen in the :body?
22:24justin_smiththe docs may be wrong?
22:24deathknightoh! what you were saying earlier with :query!!!
22:24deathknightthe json data goes in that!
22:25deathknightholy topanga!
22:25justin_smithyeah, query is just part of the body I guess?
22:25hellofunkno, when you see a specialist and he says you have the flu and it turns out to be typhoid, *then* the docs are wrong
22:25deathknightLOL
22:27hellofunki'm just sayin
22:29deathknightSo I'm getting clojure. Right now my :body is throwing this-- IllegalArgumentException No matching clause: http.async.client.part/create-part (part.clj:42)
22:29deathknight:body [{:mime-type "application/json"}]
22:29deathknightand here are the docs referencing create-part -- http://neotyk.github.io/http.async.client/doc/http.async.client.part.html
22:29deathknightgetting closer*
22:30justin_smithoh, in order to submit json does it need to be multipart?
22:31Farewell, I miss CLOS
22:31deathknightI have no idea
22:31FareI really like the everything-pure-by-default of Clojure.
22:31FareI don't understand protocols yet.
22:32Fareis there no inheritance of methods?
22:32hellofunkFare records and protocols are basically the decoupling of object properties and object methods, makes things a lot more simple and flexible. Can adopt as many protocols as you want.
22:32justin_smitha protocol is a more clojure-y view of an interface, which is a class but not really that is there for implementing rather than inheriting from
22:33deathknightwhat multipart type would json require?
22:34hellofunkFare it depends on how you need inheritance. in many languages, inheritance is a prerequisite for polymorphism, and if polymorphism is what you need, you get that in clojure with multimethods without using inheritance
22:35Fareno, I want mixins, just like I can have with CLOS.
22:35Faremixins are good.
22:35Faremultiple inheritance
22:36Fareis there anything in clojure that will let me do multiple inheritance?
22:36Fare(I suppose I could roll my own on top of maps using macros... bleah)
22:36hellofunkFare, well again it depends on what you need, exactly. You can certainly adopt multiple interfaces, which is similar to multiple inheritance in some languages.
22:37gfredericksFare: the hierarchies used by multimethads support multiple inhertance
22:37gfredericks,(derive ::square ::shape)
22:37clojurebotnil
22:37gfredericks,(derive ::square ::word)
22:37clojurebotnil
22:37Farehellofunk, except that in CLOS, I can inherit multiple interfaces AND their default (and/or next-method) implementations
22:38gfredericks,(defmulti describe :type)
22:38clojurebot#'sandbox/describe
22:38gfredericks,(defmethod describe ::shape [_] "it is a shape")
22:38clojurebot#<MultiFn clojure.lang.MultiFn@195d263>
22:38hellofunkFare as gfredericks mentions, check out the derive methods
22:38gfredericks,(describe {:type ::shape})
22:38clojurebot"it is a shape"
22:38Fareok
22:38Farethanks!
22:38gfredericks,(defmethod describe ::word [_] "it is a word")
22:38clojurebot#<MultiFn clojure.lang.MultiFn@195d263>
22:38gfredericks,(describe {:type ::square})
22:38clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Multiple methods in multimethod 'describe' match dispatch value: :sandbox/square -> :sandbox/shape and :sandbox/word, and neither is preferred>
22:39gfredericks,(prefer-method describe ::word ::shape)
22:39clojurebot#<MultiFn clojure.lang.MultiFn@195d263>
22:39gfredericks,(describe {:type ::square})
22:39clojurebot"it is a word"
22:40bbloomFare: i'm not saying that next-method et al aren't ever useful, but they are A LOT LESS USEFUL than you'd think in clojure
22:41bbloomFare: it's also pretty easy to merge maps & use ##(doc extend)
22:41lazybot⇒ "([atype & proto+mmaps]); Implementations of protocol methods can be provided using the extend construct: (extend AType AProtocol {:foo an-existing-fn :bar (fn [a b] ...) :baz (fn ([a]...) ([a b] ...)...)} BProtocol {...} ...) extend takes a type/class (or interface,... https://www.refheap.com/86698
22:41bbloomso if you really do need concrete "inheritence" you can simply compose maps & call extend
22:41bbloomrequires some pre-meditation, but the results are much simpler
22:41bbloomagain, i've only ever needed to do this once in practice
22:42gfredericksbbloom: is that how CinC would likely handle ASeq and other inheritance patterns in the java code?
22:43bbloomgfredericks: one possible way, sure
22:43deathknight"post request requires a content-length header"
22:43deathknightjustin, does that ring a bell? :O
22:43bbloomgfredericks: problem is that for the core-most parts of clojure, best perf is given if interfaces are implemented when classes are defined
22:44bbloomgfredericks: protocols really are quite fast, but for code that is on ALL USERS critical path, the small overhead isn't worth it
22:44bbloomso it's more likely that there'd be some macro-fu with quoted code
22:44gfredericksbbloom: ah ha right
22:45gfredericksthey'll have to bring in ztellman
22:45amalloygfredericks: ztellman has abandoned protocols, last i checked
22:45amalloyuses interfaces instead
22:45gfredericksamalloy: sure
22:45gfredericksreplacing java with a few nested backticks
22:46bbloomspeaking of odd things w/ protocols
22:47bbloomhttps://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/AFunction.java#L20
22:47bbloomthat's only ever used for protocol stubs
22:47bbloomseems kinda weird to throw an extra field on every function ever
22:49bbloomclosing over values makes fields, but you can't have a mutable local... and since protocols are mostly defined in clj, *every* function gets a bonus mutable local in case it might be used for a protocol
22:49bbloomand then ztellman shows up again: https://github.com/ztellman/proteus
22:49hellofunkthis is some pretty great info
22:50amalloybbloom: do you know if protocol functions still get callsite method caches?
22:51amalloylike, when i write (fn foo [] (proto 1)), where proto is a protocol function, does the class generated for foo's implementation have fields for caching the most-recently-used protocol definition?
22:51gfredericksamalloy: isn't that what he linked to?
22:51amalloygfredericks: no, that's a single cache on every function
22:52gfredericksand you're talking about a static field?
22:53amalloyi'm talking about multiple fields, one for each protocol function that is called
22:53gfredericksah hum
22:53amalloya quick disassemble suggests this is no longer the case
22:54bbloomamalloy: i haven't studied the compiler side of protocols too closely yet
22:54gfrederickswould The BBloom Field serve that purpose then?
22:54gfredericksor does it do something else I forgot to understand?
22:54bbloomthat field is a per-method cache
22:54bbloomnot a per-callsite cache
22:54amalloya year or two ago things were arranged such that if you wrote a function that called ten protocol functions, you got like thirty fields, three each for caching each call site
22:55gfredericksso what does The BBloom Field accomplish?
22:55bbloomside note: if you deftype, then extend-protocol, and keep re-evaling that file while you work... you leak memory :-P
22:55amalloywhich is fine for functions with only one instance, like (defn foo), but is *terrible* for lambdas that get returned, or things which are instances of a defrecord
22:55bbloomnot a lot, but a leak is a leak
22:55bbloom,(defprotocol P (f [x]))
22:55clojurebotP
22:55bbloom,(deftype T (f [x] 1))
22:55clojurebot#<AssertionError java.lang.AssertionError: No fields vector given.>
22:56bbloom,(deftype T [] (f [x] 1))
22:56clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol>
22:56bbloom,(deftype T [] P (f [x] 1)) ; i suck
22:56clojurebotsandbox.T
22:56bbloom,(deftype T [] P (f [x] 2)) ; i suck
22:56clojurebotsandbox.T
22:56bbloom,(deftype T [] P (f [x] 1)) ; i suck
22:56clojurebotsandbox.T
22:56bbloomer i still suck
22:56bbloom,(deftype T [])
22:56clojurebotsandbox.T
22:56bbloom,(extend-type T P (f [x] 1))
22:56clojurebotnil
22:56bbloomP
22:56bbloom,P
22:56clojurebot{:impls {sandbox.T {:f #<sandbox$eval225$fn__226 sandbox$eval225$fn__226@1ce1b2b>}}, :on sandbox.P, :on-interface sandbox.P, :sigs {:f {:doc nil, :arglists ([x]), :name f}}, :var #'sandbox/P, ...}
22:56bbloom,(-> P :impls count)
22:56clojurebot1
22:56bbloom,(deftype T [])
22:56clojurebotsandbox.T
22:57bbloom,(extend-type T P (f [x] 2))
22:57clojurebotnil
22:57bbloom,(f (T.))
22:57clojurebot2
22:57bbloom,(-> P :impls count)
22:57clojurebot2
22:57gfredericksw00t
22:57gfredericksdo old classes normally get GC'd?
22:57bbloomi have no idea
22:57bbloomi hope so
22:57amalloygfredericks: yes, if there are no references to them
22:58gfredericksokay so this is a leak not just in the size of that hashmap but also the classes not getting GCd
22:58bbloomgfredericks: right
22:58bbloomb/c the keys are actually the types
22:58bbloomi dunno if this is filed anywhere
22:58bbloomnot sure if it matters really though
22:59FareI like the first-class class thing
22:59bbloomFare: that's just standard java
22:59bbloomand it should be standard *everything*, since it was standard in smalltalk back when :-P
22:59ShayanjmI wish lighttable addressed issues faster
23:06trptcolinbbloom: wow that definitely explains some stuff i’d seen w/ reloading locally
23:06bbloomtrptcolin: what have you seen?
23:06trptcolini’d assumed it was something in here: http://dev.clojure.org/jira/browse/CLJ-1152
23:07trptcolinpermgen exploding
23:08hellofunkShayanjm agree. I really have high hopes for light table but my reported issues appear ignored and some things bother me too much, so I switched back to emacs.
23:08bbloomtrptcolin: if you can create a small project that exhibits the problem in a bad way, please go ahead and file the ticket :-)
23:08Shayanjmhellofunk: I'm trying to dive into clojure, and have been using lighttable for its instarepl thing
23:08Shayanjmbut I actually discovered a discrepency in their repl vs. the repl provided by lein
23:08Shayanjm(which I would assume is a pretty big issue)
23:08hellofunkShayanjm what kind of discrepancy?
23:09Shayanjmhttps://github.com/LightTable/LightTable/issues/1520
23:09hellofunkShayanjm light table is nice for quick start in clojure learning, i like its built-in docs and the automatic inline autocompletion and documentation
23:09bbloomhellofunk: don't use `ns to switch between namespaces
23:09bbloomuse `in-ns
23:09bbloom(doc in-ns)
23:09clojurebot"([name]); Sets *ns* to the namespace named by the symbol, creating it if needed."
23:10bbloom(doc ns)
23:10clojurebot"([name docstring? attr-map? references*]); Sets *ns* to the namespace named by name (unevaluated), creating it if needed. references can be zero or more of: (:refer-clojure ...) (:require ...) (:use ...) (:import ...) (:load ...) (:gen-class) with the syntax of refer-clojure/require/use/import/load/gen-class respectively, except the arguments are unevaluated and need not be quoted. (:gen-class ...), when supplied, de
23:10trptcolinbbloom: trouble is, (1) it’s just a dev-time thing, (2) it’s with a non-core unit testing library (3) restarting my local test process gets me working again, (4) i’m not even working on that project these days.
23:10bbloomtrptcolin: yup, dev-time only issue... there are way worse problems that prevent "never restart a repl" from being a reality
23:11loliveirahi, does anyone know why i’m getting this error: https://www.refheap.com/86699 ? I am new to clujurescript.
23:11hellofunkShayanjm in your posted issue, it's not clear that you may not have re-evaluated your defs after you switched to the new namespace
23:11hellofunkYou certainly could have, and maybe you didn't, but if you had, then they'd appear in the new namespace
23:12bbloomtrptcolin: there, i added a bullet point here: http://dev.clojure.org/display/design/Never+Close+a+REPL
23:12bbloomrather than make an issue, since it will never get fixed :-P
23:12Shayanjmhellofunk: That's a good point, I'm not sure if the instarepl automatically re-evaluates every def
23:12trptcolinthese days i basically only file issues that either force me to monkey-patch core or that i’m certain are bugs that i have the correct fix for
23:12bbloomit's a shame, but me too
23:13hellofunkShayanjm in any case, emacs is a much much smoother editor overall
23:13bbloomShayanjm: i meant that msg for you, not hellofunk
23:13hellofunkin light table, the actual emphasis on fonts seems to change as you cursor through the code, which is ridiculous.
23:14Shayanjmbbloom: oh, I see. I mean either way, that doesn't address the discrepency between Lein & Lighttable REPLs
23:14Shayanjmthere's no reason for one to evaluate differently to the other given the same set of commands
23:14Shayanjmhellofunk: I should probably pick up emacs then. I'm an ST3 user and thought Lighttable looked interesting
23:14bbloomShayanjm: i think light table does some "clever" bits with respect to ns forms
23:14hellofunkShayanjm bbloom i re-iterate that your test in those screenshots is not a good one unless you are certain the defs were not re-evaluated after you switched ns
23:15technomancyhellofunk: how is re-evaluating defs after switching namespaces not broken behaviour though?
23:15Shayanjm^
23:15hellofunktechnomancy he could have actually re-evaluated the defs manually in the instarepl since they are right there, isn't it easy to evaluate any line in the instasrepl?
23:16technomancyShayanjm: you could check using (meta #'thing2) though just to see what flavour that particular brokenness happens to take
23:16Shayanjmhellofunk: All of the code in the instarepl was written inline
23:16Shayanjmand the issue can easily be replicated
23:17hellofunkShayanjm i will try it out right now on my light table out of curiousity.
23:21hellofunkShayanjm ah, in live mode as you are typing the refer statement, it will refer everything before you get to the :only part of the forum
23:21hellofunk*form
23:21Shayanjmoh fucking hell
23:21hellofunkthis is not a bug, it is by design, that is what the "live" mode does
23:21Shayanjmwell that actually makes me feel a lot better
23:22hellofunkyou can turn off the live mode, of course
23:22Shayanjmthanks for investigating hellofunk
23:22loliveiraany help? https://www.refheap.com/86699
23:22hellofunkShayanjm i'd recommend updating or closing your Github issue
23:22hellofunkit's not a bug
23:22ShayanjmDoing so right now
23:23technomancyhellofunk: does it eval it before the paren is closed, or is it eval-able because of paredit-ish stuff?
23:23hellofunktechnomancy it evals immediately everything you type inside a form, and the close paren is already there due to paredit
23:23hellofunkit will re-evaluate on every keystroke
23:23technomancywow
23:24hellofunkhence the "insta" in "instarepl"
23:24hellofunkBut there is a Live button right there up front for turning that off
23:24technomancydoes it have a failsafe to autodetect rm -rf calls? =)
23:25hellofunkThe screenshot in the github issue indicate that Live mode was on for the test
23:25hellofunkLight table is quite interesting and nice in many ways, but my workflow is better for now with emacs
23:26deadghosthttp://stackoverflow.com/questions/24254689/change-vectors-to-lists-using-postwalk
23:27deadghostdoes this count as a bug and should I report it somewhere?
23:28hellofunkPart of the problem with Light Table is that it's most important part - the code editor - is not even written in Light Table. It's a third-party open-source JS library. And the code editor is not that good IMHO. Chris has said that if you want to see the editor improve, you should support that other library as well. And so it's a trickle-down problem of quality.
23:29deathknightGetting "UnsupportedOperationException nth not supported on this type: Character" when introducing JSON to an HTTP POST request
23:29danneucan anyone provide a db-spec string/map example they're using to connect to their heroku postgres db remotely (i.e. from their laptop)? been at it for an hour with no success
23:29deathknight(cheshire :) )
23:29Jaoodmy issue with LT is that it doesn't run in the terminal :P
23:31ddellacostadanneu: this used to work for me, no promises as I haven't used heroku lately: https://www.refheap.com/06d7b4600d81d539106b29669
23:32ddellacostadanneu: ah, sorry, you said remotely from laptop?
23:33ddellacostadanneu: like in your repl?
23:36hellofunkddellacosta what would be the clojurescript equiv of this JS: var client=new ClientMsg({"logon": toLogon}); -- can it be done in a single line?
23:36danneuddellacosta: yeah. i'm on a scavenger hunt to find the magical incantation. i've tried things like merging in {:ssl true, :sslfactory "org.postgresql.ssl.NonValidatingFactory"} from old stackoverflow answers, but no luck
23:37ddellacostahellofunk: (let [client (ClientMsg #js {:logon toLogon})] ...) I guess?
23:37ddellacostadanneu: hmm, well, maybe that article at the link in my example could help, and maybe there are some clues in there, but that is for connecting to the db on heroku, sorry. :-(
23:37hellofunkddellacosta would you need a dot, ClientMsg. since it is a "new" JS form? My JS is quite bad to be honest
23:37ddellacostahellofunk: sorry, should probably be ClientMsg.
23:37ddellacostayeah
23:38hellofunkcool thanks
23:45deathknightholy crap, it's the ddellacosta *_*
23:46deathknightdid you write the friend-oauth2 examples? I can't remember what project I saw your name attached to
23:47hellofunkddellacosta do you ever get to a point where the browser just shows exceptions on the ring server and without changing code, restarting the browser resolves them? has started happening to me recently, rather odd. no need to restart the Ring server, just the browser.
23:47danneuddellacosta: finally gathered all the pieces https://gist.github.com/danneu/c3d1b15d0b977ee3a154
23:47ddellacostadeathknight: yes, I wrote that. I really have to update that, got some outstanding pull requests. :-(
23:47deathknightI just emailed you about the issue/4! and I figured it out! woohoo
23:47deathknight(yesterday, I believe)
23:47ddellacostahellofunk: can't say I have seen that...sounds quite strange
23:47ddellacostadeathknight: excellent. :-)
23:48deathknightwhat's your preferred HTTP client?
23:48deathknightI'm using http.async.client and I'm failing at making a POST to google calender
23:48ddellacostadeathknight: I don't know that I've tried that, I've only used clj-http I believe
23:49ddellacostadanneu: so, does that db-spec work when you use say, clojure.java.jdbc to connect?
23:49ddellacostadeathknight: are you Harry?
23:49deathknightHenry :)
23:50ddellacostadeathknight: ah, okay! sorry I didn't respond sooner, but glad you got it worked out. :-)
23:50deathknighttis all gravy
23:50ddellacostadeathknight: sorry for screwing up your name too...haha
23:50deathknightnow it's brimstone
23:51ddellacostadeathknight: you are very dark, with your deathknight and brimstone. Kind of a different vibe than Henry. ;-)
23:51danneuddellacosta: yeah, i use clojure.java.jdbc directly - https://gist.github.com/danneu/c3d1b15d0b977ee3a154
23:52ddellacostadanneu: gotcha, so you can basically run migrations locally for your remote heroku db? I never thought of that but that would have solved a lot of problems I had in the past. Very nice.
23:53danneuddellacosta: the real reason is that i like to develop straight against my remote dev server.
23:53loliveiraresolved adding thre folowing dependency: [com.google.guava/guava "17.0"]
23:53deathknightddellacosta: it would cool the embers in my soul if you could try to convert this to clj-http's version of a POST request: http://pastebin.com/5mRwMFwX
23:54ddellacostadeathknight: well, I think it's pretty straightforward--have you checked out the docs here? https://github.com/dakrone/clj-http#usage
23:55ddellacostadeathknight: if you give that a shot and have trouble I'm happy to help, but I'll make you do the initial work. ;-)
23:55deathknight:)
23:55deathknightthat is a smile of vengeance
23:55ddellacostahahaha
23:55deathknightI'm going to take you up on that offer
23:55ddellacostadeathknight: alright, sounds like a plan.
23:55deathknight:)