#clojure logs

2016-01-18

00:55QuezionIs there a way to use a defined multi-arity function to satisfy a multi-arity protocol implementation?
00:55Quezione.g. instead of wrapping color-rgb, directly use the defined function to fulfill the protocol. http://pastebin.com/cN4zD9nw
00:56rhg135,(doc extend)
00:56clojurebot"([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, see below), and one or more protocol + method map pairs. It will extend the polymorphism of the protocol's methods to call the suppl...
00:56rhg135I think it'll work, but I've never tried
00:57justin_smithusing extend loses the dispatch efficiency that comes with protocols though
00:57justin_smithrhg135: one of the examples there uses multi arities, yeah
00:57QuezionLooks like extend isn't implemented in CLJS, but I'll see if I can find a workaround. TY
00:57rhg135well, it's the only way it could work, justin_smith, inline would be madness
00:58justin_smithright, just saying that since it can't be inline it has that disadvantage
00:58rhg135then you'd have to eval in the macro
01:02vrdhnhi. a cider/company mode question: f1 in company-complete says 'no documentation available' ; how to get doc ?
01:03rhg135NaN strikes again... NaN% of battery
01:08vrdhnlein search is just stuck at downloading nexus-maven-repository-index.properties !!
02:22amalloyrhg135: you shouldn''t have bought a batery with 0 capacity!
02:23rhg135I assure you it had 106 right before
06:16lxsameerI'm looking for a good book to read on distributed programming topic, any suggestion ?
06:23owlbirdanyone has used Cursive for clojure editing ? https://cursive-ide.com/
06:24owlbirdDoes it support segment compiling like C-c C-c in emacs ?
06:25scottjowlbird: clarify: segment = file, region, top-level expression?
06:25owlbirdregion
06:26owlbirdby using emacs with cider, I could C-c C-c to compile a region, or C-c C-k to compile the whole file. don't know how to do it in cursive
06:27owlbirdI'm trying to persuade a group of java programmer to have a try with clojure, they were familiar with intelliJ, so...
06:28scottjowlbird: did you look through the keybindings dialog?
07:45owlbirdscottj: IntelliJ has no suitable operation for a region compilation
07:46beakyhello
07:46beakyare there alternative ways to use a database in postgres besides clojure.jdbc
07:46beakyin clojure*
07:47beakyi wanna be able to invoke stored procedures and stuff
08:26neoncontrails,(map #(assoc-in {:a false :b false :c false} [%] true) [:b :a])
08:26clojurebot({:a false, :b true, :c false} {:a true, :b false, :c false})
08:27neoncontrailsHow to edit this function so it returns {:a true :b true :c false})?
08:34ridcully_,(reduce (fn [m k] (assoc m k true)) {:a false :b false :c false} [:a :b])
08:34clojurebot{:a true, :b true, :c false}
08:35neoncontrailsridcully_: that's the ticket. thank you!
08:44beakyhello
08:44beakyhow do i build a rest api with clojure
08:45ridcully_beaky: have you looked on some of the options there? http://www.clojure-toolbox.com/
08:46Ricardo-ArgesThere's also a brief write up on options on the JUXT technology radar.
08:47beakywow so many options
08:47beakywhats juxt
08:47ridcully_the function or the company?
08:49beakythought it was a technology
08:49beakyhttps://juxt.pro/radar.html oh this one
08:49ridcully_beaky: missing there: kekkonen. and i'd add catacumba also to the restfull stuff, since there is handler for it
08:52Ricardo-ArgesPlus, fwiw, JUXT mentions that "Pedestal [or compojure/ring] may be easier" than Liberator. I've yet to find a case where Pedestal is easier than any of the smaller alternatives. That may come from the fact that they already had adopted it.
08:53mpenetwell, radar stuff is highly subjective
08:54Ricardo-Arges@mpenet Certainly.
09:04winkhttps://twitter.com/bodil/status/597766837548507136 :P
09:05winkI still like reading them, if not for discovering new things
09:07oracle123I want to use rabbitmq to do task on multiple hosts, and also want to use core.aysnc. What's the best solution for core.async+rabbitmq? I saw there is a lib kehaar on github, is it the one I should go?
09:12mpenetwink: :] sure it's entertaining, and you might discover interesting libs. I guess the tone is the real controversial part.
09:12beakyi love sql
09:20beakywow
09:21beakyhttps://github.com/friemen/aggregate this is a life saver
09:21beakyhow have i been doing sql with clojure without knowing about this lib
09:25beakyi love clojure
09:25beakymost clojure libs are so tiny even i can read and understand what they really do
09:25beakyjust like nodejs
12:24irctcHello, these may be a dumb question or already answered somewhere, but what (if any) would be the path to look down if one wanted to add syntax for clojure? for example, if i wanted "!(false)" to return true *not that i want this, just example*, or (/re.ex/ "regexs are cool") to expand to ((partial re-find #"re.ex") "regexes are cool")? any resources to look into are appreciated (or just letting me know if not easily possible)
12:24justin_smithirctc: for things like that you would need to fork clojure itself, and change the java code that implements the parser
12:27irctc@justin_smith: roger that, kinda a bummer but thanks for letting me know. i think regexes somewhat like that would be somewhat slick, like how you can use (:a {:a 1 :b 2}) or (map :a list-of-maps), it would be nice to do with regexes on strings maybe, but oh well, i just thought would be neat, i havent ran into the specific need for it yet or anything
12:38ridcully_justin_smith: i followed your example and uberward me some clj-http, specter, puget and a little state for url/request defaults
12:39justin_smithridcully_: cool, how did that work out?
12:39ridcully_using it to handle elasticsearch api right now. super sweet
12:40yazirianirctc: there is limited reader extensibility with e.g. tagged literals http://clojure.org/reference/reader#_tagged_literals
12:40yazirianwithout getting into whether it is recommended or not to do that :)
12:43irctcyazirian: thank you, ill check it out, and roger that on it being potentially the non-reccomended way of doing things
12:58mpenetirctc: dunno what's the context for you, but if you have to create a mini lang that compiles to clojure instaparse is a good starting point
12:59mpenetI had to do this recently to create a bastard child of lucene-like & sql like language and it took hours
12:59luxbockirctc: you could do what you suggest with regexes if IFn were a protocol like it is in CLJS
12:59luxbockbut it's not :P
13:57irctcmpenet:, luxbock: thank you for the leads, looks like someone had a similar idea (and actually did it) in cljs using the IFn thing. https://gist.github.com/alandipert/2346460
15:26benjyz1hi. I'm trying to understand agents. I've read several explanations, but still don't quite get it. what is a typical example?
15:41jjttjjbenjyz1: I remember the explanation in the book Clojure Programming made agents click for me, seems like you can get a pretty big exerpt from it here: https://www.safaribooksonline.com/library/view/clojure-programming/9781449310387/ch04s10.html I particularly liked the web crawler example at the end
15:43benjyz1yes, I'm reading it
15:43benjyz1"The one we’ll build here will be extraordinarily basic,34 but it will demonstrate how agents can be used to orchestrate and parallelize potentially very complicated workloads."
16:07sdegutisHey you all.
16:07sdegutisHow is this going?
16:16gfrederickshas anybody tried to make a datomic-like lazy-map API on top of a relational database?
16:16gfredericks(accepting the obvious downsides w.r.t. caching that datomic doesn't have)
16:18gfredericksI'm just thinking again about the problem of having a database-exploration experience that remotely approaches ActiveRecord
16:18gfrederickseven if it isn't clean enough for production code
16:19gfredericks(removing production as a target use case frees up a lot of magical tactics to get succinctness)
16:21hiredmangfredericks: you are saying it would return a map that would automatically and lazily follow fk relationships?
16:22hiredmankorma's database stuff may have done something like that
16:22sdegutisgfredericks: that sounds epic
16:23sdegutisgfredericks: what your describing reminds me of ActiveRecord tho
16:25gfrederickssdegutis: I mentioned ActiveRecord as the inspiration so that's not surprising
16:25gfrederickshiredman: yeah that sort of thing is the main idea
16:26TEttingergfredericks: you did some intensive research into JVM PRNGs, right?
16:26gfredericksTEttinger: FSVO intensive
16:27TEttingerI was shocked by how slow j.u.Random is
16:27gfredericksI think it has extra slowdown because it wants to be threadsafe
16:27gfredericksIIRC
16:28TEttingerahhh
16:28gfrederickswhereas j.u.SplittableRandom removes that and the docs say "don't share this between threads you dummy"
16:28gfredericksI think it amounted to something like a 5x slowdown
16:28TEttingerthat would explain it, I was wondering how an LCG takes roughly 9.8x as much time as a... whatever splitmix64 is. the one SplittableRandom uses
16:28TEttingerhttps://github.com/SquidPony/SquidLib/blob/master/squidlib-performance/src/main/java/squidpony/performance/RNGBenchmark.java#L53-L67
16:29TEttingerJMH is weird for benchmarking java
16:29TEttingerI have some freaky results in there, things that wrap another class being faster than the class they wrap
16:30TEttingerRNGBenchmark.measureRandom and RNGBenchmark.measureRandomInt use j.u.Random, the first makes a billion longs, the second a billion ints
16:32TEttingerthe weird results are on the other RNG algos, especially when wrapped in the extra-features-slightly-slower-maybe 'R' suffixed variants
16:33TEttingerLightRNG there is SplitMix64, Permuted is PCG-Random (RXS M XS -- random xorshift, mcg multiply, fixed xorshift variant)
16:34TEttingerI might be doing something wrong on the permuted
16:34neoncontrailsFunny y'all mention Korma. I came across it a few hours ago, it looks charmingly user-friendly
16:36sdegutisgfredericks: hmm I musta missedit
16:40neoncontrailsSpeaking of Korma. Can I bounce a question off you database experts?
16:40neoncontrailsWhat's the preferred datatype to store lists?
16:41neoncontrailsI see SQL doesn't have lists, which makes sense. That would have to be constructed in memory after all
16:42neoncontrailsBut if you're ultimately converting the values back to lists, is there an obvious best choice for the data type? I'm leaning JSON
16:46sdegutisneoncontrails: I use lists in Datomic.
16:48neoncontrailssdegutis: I'm almost certainly going to look into Datomic the next time I make a db app
16:48sdegutisCool beans.
16:51neoncontrailsjdbc works, but the documentation is a bit thin. Hard to figure out what I can do vs. what's optimal, particularly from the Clojure vantage point
16:51neoncontrailsSeems like Datomic is a bit more... Clojurey
17:16sdegutisjdbc is great
17:20gfredericksTEttinger3: yeah benchmarking that stuff can drive you crazy
17:21gfredericksif you want to fully go crazy, try also testing for randomness quality
17:33kenrestivohow does one actually do that? come to think of it, who determines that a CSRNG is actually strong enough?
17:35p_lkenrestivo: long testing and looking for biases
17:38gfrederickslots of stats
17:39gfrederickskenrestivo: https://en.wikipedia.org/wiki/Diehard_tests
17:41kenrestivocool, thanks, fascinating
18:10rhg135is there a way to use a map with reify to implement a protocol ala extend?
18:27justin_smithrhg135: sure, but it might be easier to just use defrecord
18:29rhg135I guess, I wanted to let users implement a protocol without having it available, but thats not a good idea anyway
18:30justin_smithso you were trying to hide the protocol?
18:36rhg135in essence
19:30WickedShellHow do you type hint passing an array (such as an array of strings) (IE I'm trying to call this FN https://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/ui/SelectBox.html#setItems-com.badlogic.gdx.utils.Array- )
19:39gfrederickssomething like ^"[String" I think
19:40WickedShellohhhh qoutes! I never thought of adding the qoutes :D
19:41justin_smithgfredericks: that with a semicolon I think?
19:41justin_smith,(class (into-array ["a"]))
19:41clojurebot[Ljava.lang.String;
19:41justin_smithso yeah, it needs an L, the java.lang part may be optional, and it needs a semicolon
19:43WickedShelland it needs the qoutes I'm assuming so that the [ doesn't run off?
19:44justin_smithso that the reader doesn't barf on it basically
19:44WickedShellyeah
19:45gfredericks~I dunno it |could be| anything
19:45clojurebotRoger.
19:45gfredericks~there's no way |to| tell
19:45clojurebotc'est bon!