#clojure logs

2014-02-17

00:02dsrxhmmmm
00:02dsrx,(mapcat #(%))
00:02clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core/map>
00:02dsrxweird error message, that
00:03amalloyWild_Cat: rich is too cool for specs
00:03amalloyxensky: (defmulti foo [& args] (count args)), of course
00:08xenskyamalloy: thanks, this fixes my problem
00:45dsrxis there any semantic difference between (reset! my-atom my-sym) and (swap! my-atom (constantly my-sym)) ?
00:46pdkyou'd be creating a lambda with constantly
00:52muhoois there some way to make the damn colors turn off in aviso pretty's nrepl middleware?
00:53muhooa stacktrace with a bunch of unreadable ^[[1;31 chars is not much improvement over java's stacktrace :-/
00:58TEttingermuhoo, yes
00:59TEttingerit's called ansicon, and it make the colors actual colors :D
00:59TEttingerhttps://github.com/adoxa/ansicon
01:23sm0kehow do i define typehint for void?
01:26ambrosebssm0ke: why do you want that?
01:27sm0keambrosebs: i was using a macro which defines method signatures for gen-class by pulling typehints
01:28sm0keso the problem is 'void' is valid inside gen-class :methods
01:28sm0kebut ^void is undefined as a type hint in itself
01:28dsrxis it?
01:28sm0ke,(defn ^void foo [x] (prn x))
01:28clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: void in this context, compiling:(NO_SOURCE_PATH:0:0)>
01:29ambrosebs,java.lang.Void
01:29dsrxhmmmmmm http://clojure.org/java_interop#toc30
01:29clojurebotjava.lang.Void
01:29ambrosebsmaybe that works?
01:29sm0ke,(defn ^java.lang.Void foo [x] (prn x))
01:29clojurebot#'sandbox/foo
01:29dsrxhttp://i.imgur.com/VjJPkgd.png
01:29sm0keok thanks!
01:29sm0kedsrx: what that? rick rolling?
01:30dsrxlong story
01:30ambrosebssm0ke: if not, perhaps java.lang.Void/TYPE
01:31sm0ke,java.lang.Void/TYPE
01:31clojurebotvoid
01:31dsrxI guess that doc is just wrong then
01:32ambrosebsoh yea, that's weird
01:33sm0keanyways i am will use Void for type hints and gen class signatures from now on
01:33sm0kewhat
01:33sm0kei will*
01:33sm0keweird typo
02:03TheBusbyanyone using lein from Makefiles? Having issues with not being able to 1. name the output of lein, 2. have lein give me the name of the file it will output...
02:07dsrx,(identical? (str "foo" "bar") (str "foo" "bar"))
02:07clojurebotfalse
02:08dsrxon cljs/v8, that is true
02:08dsrxapparently v8 interns all string values, not just literals
02:08eggheadthats interesting
02:09dsrxoh hm, true in gecko as well
02:09eggheadthat's basically the javascript difference between new String("foobar") vs String("foobar")
02:10eggheadsince "foobar" === "foobar" but new String("foobar") !== new String("foobar")
02:10dsrxya, it wouldn't make any sense at all to intern string objects
02:11dsrxyou know, I guess it's probably down to what identical? is in cljs
02:13dsrxyeah identical? just compiles down to ===, hurf
02:18logic_progmultiple choice quiz: which of the following is true: (a) macroexpand-1 doesn't work in cljs (b) I'm an idiot (c) both of the above
02:18ddellacosta(str "a: " a ", b: " b) vs. (format "a: %s, b: %s" a b) ?
02:19ddellacostado folks prefer one over the other for any reason?
02:20Ember-depends
02:20Ember-I prefer the latter way when doing logging and so forth, first one when building logical strings for the app itself
02:21Ember-I'd guess the first one is more performant, but not sure
02:21logic_progI prefer format always.
02:21Ember-haven't checked the clojure implementation for str
02:21logic_prog(str ... ) makes it hard to see the overall picture of what i'm constructing
02:21logic_prog(format ... ) is like "here's a template, and we'll fill in shit later"
02:21Ember-yeah, it depends like I said
02:21Ember-(str "Value is:" foo) is kinda obvious
02:22Ember-but (str "a" a "b" b "c" c "d" d) is not
02:22logic_prog(str ... ) is like sleep deprivation
02:22logic_progat first you're like "it's a little, it won't hurt"
02:22Ember-str is ok for one dynamic parameter
02:22logic_progalright, fine, I'll give you that
02:22logic_prog(inc Ember-)
02:22lazybot⇒ 1
02:23ddellacostathanks logic_prog and Ember-
02:23Ember-whee, I got my first karma \o/
02:23ddellacostaheh
02:25ambrosebslogic_prog: afaik cljs uses clj macros, so you don't have mexpand
02:25logic_progyeah, but I need to _debug_ a macro
02:25logic_progthat works fine in clojure, and does something _slightly_ different in clojurescript
02:25logic_progso I'm curious about "wtf does clojurescript see when this macro is expanded"
02:25logic_progI apologize for not mentioning this in original question.
02:26ambrosebslogic_prog: call cljs.analyzer/macroexpand-1 iirc
02:26logic_proghttp://grokbase.com/t/gg/clojure/12bn9rd175/macroexpand-1-for-clojurescript-macros seems to suggest I'm not the only one struggling with
02:26ambrosebsin clojure
02:27ambrosebssomething like (cljs.analyzer/macroexpand-1 (cljs.analyzer/empty-env) '(my-form 1 2 3))
02:28logic_proghmm
02:28logic_progah
02:28ambrosebsthat's my guess at least
02:28logic_progI was wondering what to pass for the env
02:28logic_proghmm, NullPointerException
02:28logic_proglet's see what else is wrong :-)
02:28logic_progah, got it working
02:33dsrxif I specify a lein dependency in :plugins, does it need to be specified in :dependencies as well?
02:33logic_prog(inc ambrosebs)
02:33lazybot⇒ 5
02:34logic_progugly = (macroexpand-1 '(cljs.core.async.macros/go ... )) :-D
03:03amalloydsrx: plugins and dependencies are very different
03:04amalloyit goes in :plugins if you want it to be something that runs in your lein jvm, and :dependencies if it's something everyone who uses your project will need
03:04amalloy(and if it's in :plugins, it will be accessible *only* in the lein jvm, not your project jvm)
03:05amalloyso i can't really think of any instances of something you'd want in both. maybe nrepl?
03:08glosoliIs there anyway to catch several exceptions in one catch block ?
03:08glosolis/anyway/ any way
03:42akl(try <your code> (catch ExceptionClassA err1 (prn "got an A!")) (catch ExceptionClassB err2 (prn "got a B!")) (finally (prn "all done!")))
04:12sm0ke,(class 1)
04:12clojurebotjava.lang.Long
04:16clgv18% to 20% speedup with Clojure 1.6-beta1 compared to 1.5.1 :D
04:17clgvprobably due to the new hashing
04:35sm0kenice but only where maps are involved right?
04:35sm0keotherwise i heard it has gone slower
04:37clgvsm0ke: in this case overall on the whole program run
04:37hyPiRionsm0ke: The hashing itself is slower, but the collision loss may make up for it
04:38clgvsm0ke: I have at least one set of integers in there
04:38clgvthat's sitting in a bottleneck
04:38hyPiRionAre you working with negative values too?
04:39clgvno.
04:39hyPiRionvectors? set of sets? If not, then the hashing may not be the culpris
04:39hyPiRionculprit*
04:42clgvno. I would have blamed the set that contains a narrow range of longs, e.g. 100,101,...,199 where some of those are removed over time
04:42clgvhyPiRion: it is heavily optimized code.
04:46katoxinteresting, datomic doesn't work with upcoming clj 1.6 yet
04:46katoxback to stable for now, I guess
04:46sm0kewhat is the type hint for ArrayList<String> ?
04:47clgvhyPiRion: there aren't that many performance related fixes in 1.6 that could be the reason right?
04:48clgvhyPiRion: does the ASM library update have performance consequences?
04:49ambrosebssm0ke: just java.util.ArrayList should do it
04:49clgvsm0ke: yeah, there are no generics on JVM level
04:49clgvsm0ke: it's all compiler magic ;)
04:53clgvhumm type hints for the result of a primitive function do not seem to work (primitive arguments but object return type)
04:54clgvmanually specifying :tag metadata does not work either
05:49muhooTEttinger2: windows? 0_0 um, no. i'm inside emacs nrepl.el, on linux. and escape codes are messing up the stacktraces
06:34Gues_____what;s up
06:35Gues_____what kind of channel is this ?
06:42certaintyirc channel
07:11clgvcertainty: are you a mathematician?
07:19certaintyclgv: nope. why?
07:20clgvcertainty: you need a certain amount of time, your answer was absolutely correct but it did not help the questioner at all ;) :P
07:20clgvscnr to quote that math joke ;)
07:21certaintyclgv: heh! i vaguely remember that one. Wasn't there a manager involved somehow as well?
07:22clgvcertainty: I think there are different versions of that joke
07:24certaintyi see. a good one in any case
08:51Fenderhi there
08:52Fenderas always - I have a problem
08:52FenderI mean related to clojure
08:52edbondFender, good start
08:52Fenderso I map some 40 values by a function that takes approx 300 ms in avg
08:53Fenderwhen I pmap the thing (I have 2+2 cores), time is reduced to 200ms
08:53Fenderwhich is not ok
08:53Fendernow I knwo the partition-stuff and it doesnt hepl at all
08:54Fenderthe function for mapping is pure btw
08:54Fenderso I thought I try reducers
08:55Fenderfirst of all, there is no real documentation on the functions
08:55FenderI mean, there is the source code but CLJ is my first lisp and I am not familiar with foldcat and the likes
08:56Fenderstill I managed to hack something together, a r/foldcat on r/map
08:56Fenderwhile it is fast, I see that it is only using single core
08:56Fenderalthough I have Java 7 and (Class/forName "java.util.concurrent.ForkJoinTask") succeeds
08:57edbondFender, try more input values
08:57Fendermom, I'll try
08:58Fenderits calculating...
08:59Fenderdo you guys know where I could get a decent doc on reducers?
08:59loliveiradoes somebody know a json library that is able to parse the following json? https://www.refheap.com/40625 Note that the keys don't have ' or ".
08:59Fenderhttp://clojure.github.io/clojure/clojure.core.reducers-api.html -> 404
09:00Ember-loliveira: well, that is *not* JSON
09:00Ember-and I'm not even talking about the var x = ... definition in the beginning
09:00edbondFender, did you read blog posts? http://clojure.org/reducers
09:00Ember-json quite explicitly defines that keys *must* be strings
09:01loliveiraEmber-: I know. I need to parse it from a js file.
09:01Ember-even jquery doesn't accept json without string keys (anymore, it used to)
09:02Ember-loliveira: and you cannot add the string literals into that file?
09:02Fenderedbond, I did but it just covers some functions
09:02Fenderand specifically not the fork-join thing which I'dlike to use
09:02loliveiraEmber-: I don't have write access to that file. =(
09:03Ember-how about you do some regexp magic before trying to parse it
09:03Ember-find keys without quotes and add some
09:03Ember-should be quite easy to do
09:03loliveiraEmber-: i will try that way. thanks. =0
09:04loliveira=)
09:04Ember-Some people, when confronted with a problem, think
09:04Ember-“I know, I'll use regular expressions.” Now they have two problems.
09:04Ember-;P
09:05Ember-but seriously, that should work in your case if it is not a wierd one
09:05Ember-depends on the structure of that JSON
09:05Ember-loliveira: other solution is to do the parsing yourself
09:05Ember-json is really simple and not that hard to tokenize
09:06Fender(time (count (pmap get-field-data missing-fields))) ;; "Elapsed time: 7107.496882 msecs"
09:06Fender(time (count (map get-field-data missing-fields))) ;; "Elapsed time: 11904.429407 msecs"
09:06Fendereach call to get-field-data returns a vector of 170k values
09:06loliveiraEmber-: I'll try regexp first.
09:06Fender(count missing-fields) = 33 in this case
09:07Fenderhow could I get a decent speedup with r/reducers and fjreduce / fold?
09:08Ember-Fender: reducers help when your operations make a lot of garbage
09:09Ember-when your long living operations do not create that much work for gc then not so much
09:09Fenderthese ones do for sure, but I already optimized that stuff
09:09FenderI know but why wouldnt pmap bring at least a twofold speedup?
09:10Fenderfor a 2+2 cpu...
09:10Fenderusually it does
09:10AimHereSometimes pmap makes things slower with the overhead of sorting everything out again after you've done all your calculations at once
09:11Fenderhmm, I could try a thread pool instead
09:11Fenderbut still, sorting 33 values is not too much
09:13Fendermaybe it's a memory allocation thing...
09:15Fenderlooks like some 700MB are allocated in the heap
09:15Fenderwith no in-between GC
09:18hyPiRionFender: Don't use pmap, use ExecutorService instead. That should speed it up somewhat
09:19FenderI'll give it a try
09:21Fendercan you recommend some lib where you basically submit your tasks and have some control e.g. to cancel the tasks?
09:22hyPiRionFender: Whenever you submit a task to an executorservice, you get a future back which you can cancel
09:23hyPiRionI'm not sure if there is any wrapper for executorservice though. Let me have a look
09:23loliveiraEmber-: it seems that worked. =) (clojure.string/replace j #"(\w+)\s*?:" (fn [[_ m]] (str \" m "\": ")))
09:24Fenderah ok, I remember having tried that already earlier but I think I wrapped the future part inside my tiny lib and then I figured I coulndt cancel the stuff
09:24Fender...which I disliked
09:24Fenderdon't look, I can look for myself, it just happens that sometimes someone has a nice recommendation
09:26hyPiRionyeah. Well, I've worked with ExecutorServices in Java, and they are very, very painless.
09:27hyPiRionYou have to specify how many threads, but apart from that, it should be rather straightforward.
09:28Fenderok, I'll check it out
09:28Fenderthanks!
09:35lvhHi! I'd like a code review on a function I wrote. I'm parsing some CSV with a header and a bunch of entry rows into maps of {:k "v"}; some "v"s need to be parsed
09:36lvhhere's the code: https://gist.github.com/lvh/43d713e6812503f8fb5e
09:37lvhI wouldn't be surprised if this exists as a function already
09:46AimHerelvh, does that even run? I don't think those recurs look right
09:48AimHereAs in, normally I wouldn't recur a vector with the updated values, but rather just the values themselves
09:48AimHere,(loop [a 5 b 2] (if (zero? b) a (recur (dec a) (dec b))))
09:48clojurebot3
09:49AimHerelvh, also, that probably looks a little neater written using reduce
09:52lvhAimHere: Oops, you're right :)
09:52borkdudeis loop still a public macro? ;)
09:52AimHere,(type loop)
09:52clojurebot#<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/loop, compiling:(NO_SOURCE_PATH:0:0)>
09:53AimHereWell it's still a macro. Don't know what you mean by public
09:53llasram,(type @#'loop)
09:53clojurebotclojure.core$loop
09:54lvhhow do you spell def-but-private
09:54borkdudeˆ:private true
09:54llasramlvh: (def ^:private whatever ...)
09:54lvhah. Why isn't there a def-?
09:55llasramborkdude: Trying to confuse the new users? :-)
09:55borkdude(def ^:private hello 10)
09:55borkdudellasram yes, sorry ;)
09:56borkdudelvl because the clojure implementors are really lazy and don't generate every possible permutation of configuration up front for you ;)
09:56borkdudelvh I mean
09:56llasramOr because a general mechanism (^:private metadata) is more powerful than giving every `def`-style macro an associated "but private" version
09:57lvhfair enough; it's just because I knew about defn- that def- seemed like an obvious guess
09:57llasramI think `defn-` only exists because the original Clojure metadata syntax was much less compact.
09:57llasramThese days I pretty much only see defn- in code written by new users and rhickey
09:58borkdudehere's how you can make a private macro though: https://gist.github.com/borkdude/9052017
09:58lvhllasram: that's two extremes right there :)
09:59lvhllasram: So I should replace defn- with ^:private?
09:59borkdudelvl (def ^:private some-var some-value)
09:59borkdudewhy do I keep typing lvl instead of lvh
09:59hyPiRionllasram: :o You've never written code in Leiningen I see :p
10:01benmoss_do Clojurists agree that making fns private is a good thing?
10:01borkdudebenmoss_ it depends
10:02borkdude(pun intended)
10:02llasramhyPiRion: Haha. I did mean new code. Existing code bases from 1.2 days and before certainly use it, and better to be consistent
10:02benmoss_i guess for libraries and their APIs i still see the rationale
10:02llasramlvh: I don't think it matters as long as you're consistent. But using ^:private is more consistent since you can use the same mechanism for everything :-)
10:02borkdudebenmoss_ it depends if you want your functions to be exposed or not
10:03benmoss_yeah, i guess I thought at least internally its often more of an OO thing
10:04benmoss_hiding access to state
10:04shep-werkyou can hide state and only ever have public methods :-)
10:04arcatan(defmacro def- ...)
10:06hyPiRionllasram: :( I just pushed this https://github.com/hyPiRion/smallex/blob/dev/src/smallex/reductions.clj
10:07hyPiRionAlso I realised I commited the comment block, so now I'm finally reaching rhickey level
10:11lvhis there a safe parse-num in clojure?
10:11lvhI have a string; I want a number represented by that string
10:11lvhI don't want Integer/parseInt because it might be a big number.
10:12lvh(I also don't want parseInt because maybe it'll be a ratio)
10:12lvhI could do read-string, I suppose :)
10:13hyPiRion(Long/parseLong "12") or (BigInteger. "12")
10:14lvhhyPiRion: I guess that fixes most of them; I'll do ratios manually I suppose
10:15borkdudelvh yes, edn/read-string
10:15lvhhyPiRion: How do I get "BigInteger." as a function? (def i BigInteger.) doesn't work; I could write a lambda but that seems hacky
10:15lvhborkdude: oh man why didn't I think of that; wonderful
10:15hyPiRion#(BigInteger. %) ?
10:15hyPiRionNot really hacky
10:16lvh(edn doesn't do ratios but whatever)
10:16lvhhyPiRion: okay, if that's fine that's fine :)
10:16hyPiRionlvh: I agree that it sort of looks hacky, but it's really the only way to make it into a function =)
10:17borkdudelvh: https://gist.github.com/borkdude/cf0073190b8d2ff91260
10:18llasram(doc biginteger)
10:19clojurebot"([x]); Coerce to BigInteger"
10:19llasramlvh: ^^
10:19llasramFor specifically BigInteger
10:19llasramlvh: And I wrote https://github.com/llasram/method-fn
10:20borkdudefunction wrapping is idiomatic
10:20llasramlvh: Nobody else is using it yet, but now that Java 8 is going to have method and constructor references which produce automatic lambdas, I think it's time :_)
10:24lvhllasram: ooh!
10:25lvhis it bad form to have top-heavy let clauses?
10:25lvhIt seems to me like I end up writing a big bunch of bindings that makes me a bunch of functions/values that do/are what I awant, and then a relatively small body of the let.
10:26llasramlvh: Not necessarily. If you're binding a lot of values you then refer to only once, you can probably make more frequent use of the threading macros (->, ->>, etc) instead
10:27lvhllasram: https://gist.github.com/lvh/43d713e6812503f8fb5e
10:27lvhI don't think that counts but I don't know ->(>)? well enough to judge
10:29llasramlvh: That looks completely reasonable structurally
10:29borkdudelvh I think your code is fine too
10:31lvhgreat; thanks :)
10:37abakeris Stuart Sierra's "system workflow" still the best game in town for managing application state? i.e. this: http://thinkrelevance.com/blog/2013/06/04/clojure-workflow-reloaded
10:40abakeror I guess the area of dependency injection with config management is also blossoming: https://github.com/stuartsierra/component
10:47stuartsierraabaker: Yes, 'component' builds on the ideas in 'reloaded'
10:47abakerstuartsierra: cool, thanks
10:48wei__my API requests via clj-http are about 10x slower than the same requests in the browser. any ideas why?
10:57lvhI'm trying to parse dates with clj-time, but I want LocalDates, not DateTimes
10:59lvhand apparently you can't just use a custom formatter for format-local-time
11:00lvhwait, .local is a red herring; I want .format
11:02ohcibican someone explaine to me why I get Long cannot be casted into Keyword here https://gist.github.com/ohcibi/9053150?
11:11ceterumnethowdy all
11:11ceterumnetI have an interesting problem I can't figure out - I'm curious if anyone can shed any light on this: https://gist.github.com/ceterumnet/7b6bfc55874a26160941
11:12ceterumnetI am wondering if this is a compiler bug or if I am just not understanding bindings (I suspect the latter)
11:17fredyrceterumnet: what's the reason for using with-binding instead of binding?
11:17ceterumnetfredyr: no reason - I've tried both
11:18fredyrusing binding, I don't think you have to do #'symbol
11:18ceterumnetfredyr: yea
11:18fredyrlike the example here http://clojuredocs.org/clojure_core/clojure.core/binding
11:18ceterumnetstill doesn't work
11:20hyPiRionceterumnet: map is lazy, and is evaluated outside of the binding
11:20hyPiRiontry to replace map with mapv
11:20fredyrhyPiRion: nice catch
11:20ceterumnethyPiRion: thanks!
11:20ceterumnethyPiRion: that was my error
11:22ohcibithis is crazy.. I only get this error when I return a set that contains two vectors with the same size? what is wrong with that?
11:22ohcibihttps://gist.github.com/ohcibi/9053150?
11:24hyPiRionwhat error?
11:25ohcibihyPiRion: java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.Keyword
11:25ohcibilein midje :autotest even reports two failed checks although there is only one..
11:26TEttingerohcibi, do you get a line number for the error?
11:26ohcibiTEttinger: no, there is a long stacktrace which eventually mentions the test-file but with the line that starts with (facts ...
11:27ohcibiwhen i return a set with vectors of different size I get a normal "expected value is not the same as the actual one" error message from midje..
11:29ohcibioh
11:29ohcibiand when I return a set with vectors that contain both numbers its also working normally
11:34ohcibihm seems to be a bug with midje
11:34ohcibior lein-midje
11:42sdegutisHi.
11:42sdegutisDoes anyone in here deploy a Ring app to an EC2 server?
11:44`cbp~anyone
11:44clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
11:45BaraiusI did a little compojure app
11:45BaraiusWasn't anything particularly special about EC2.
11:47sdegutisIf so, what tools do you use for deployment? Do you use something like Chef, or something else? How do you handle automating EC2?
11:48BaraiusI have done it both ways.
11:49BaraiusVanilla AMI + Chef and configured AMI.
11:50BaraiusThe latest one has been very configured AMI. That makes ASGs easier. I also have it setup to pull the latest version of the code from a named EC2 bucket on startup. "Pull" deploys if you will.
11:50BaraiusIt has worked very well so far.
11:51sdegutisOh hmm, we're not even using ASGs or AMIs.
12:24danneuI switched from Heroku to Linode for the beefy CPU.
12:24danneuIt's just too good.
13:34muhooinsane idea: writing an alternative to freind that uses core.async go blocks instrad of all that mind-melting catching and throwing and redirecting
13:35muhooalso, possiby, alternative to liberator in core.async
13:35muhooinstead of callback hell
13:36muhooplease tell me why the stupidest idea ever and it could never work
13:38muhoocemerick: ^
13:40sritchiednolen_: seeing a bunch of "Cannot read property 'firstChild' of undefined" error messages coming out of om when I try to transact! within IWillMount
13:40aphyrmuhoo: synchronization primitive on every transition between components imposes more overhead than fn calls.
13:41aphyr(might be small for liberator, I dunno)
13:41sritchiednolen_: pushing the code to github, after a little more investigation -
13:41aphyrbut IIRC channels are require at least one CAS, so you might have to worry about unnecessary contention
13:42sritchiednolen_: actually, I did have one more high level question about how to organize an app so I don't thrash the dom
13:42cemerickmuhoo: you mean for characterizing the authentication of a request among multiple different workflows?
13:43sritchiednolen_: I'm building a stopwatch, so one piece of the pieces of state tracks the current time; I have a go block that updates it every 10ms
13:44sritchieat that same level of the atom, alongside :stopwatch-time, I have a :results key, with a vector of results; when the user hits a mark button, I add an entry to :results
13:44muhoocemerick: i meant doing a wofkflow as a workflow, faux-linear inside a go
13:44sritchieis it correct that om WON'T re-render the whole list of results every time the stopwatch is updated?
13:44sritchie(provided I'm careful about only passing that results cursor down into the "results" table component)
13:45sritchiestrangely, that go block runs three times for every "firstChild" error
13:45cemerickmuhoo: "workflow as a workflow"?
13:46muhooinstead of all the callbacks, throwing, etc. the whole flow as a linear block, and let go hide the asychrony
13:47cemerickmuhoo: workflows aren't asynchronous
13:47aphyrAgreed; HTTP state machine is definitely a decision tree.
13:48muhooi'm not describing this right. i should mock something up and post it
13:49muhooi read sritchie's thing on friend + liberator and went, my god, there has to be a way to make this less confusing
13:49cemerickmuhoo: are you talking about putting the interactions w/ e.g. openid/oauth/etc identity providers into a go block?
13:50sritchiecemerick: you could make it much less confusing by exposing the session management stuff, so that users could use that themselves deep in the routes
13:50sritchielike, the interactive form stuff doesn't belong in a middleware
13:50sritchieit belongs in a route
13:50sritchiecemerick: that's one thing that's so confusing, I think… workflows that don't affect the session make sense as overarching middleware
13:51sritchieworkflows that DO populate the session belong down in individual routes, like /login, etc
13:52yedi"once again, 99% of all disagreements can be divided in to one of two fundamental categories: operating from different definitions or operating from different motivational principals"
13:52yedibbloom, i like that
13:52cemericksritchie: friend doesn't presuppose how you construct your ring app; it's a ring library, not a compojure/liberator/etc lib. Providing "routes" (or whatever the analogous construct for the library du jour) isn't really germane.
13:53sritchiecemerick: yet the interactive form DOES take a route
13:53sritchieand matches on it inside the workflow, up in middleware
13:53sritchiecemerick: which is confusing for users - "wait, I already have a login handler… so now I have to remember that MINE only gets called after friend, and friend might intercept it..."
13:54sritchiecemerick: you seem really resistant to feedback that friend is confusing
13:54muhoocemerick: i might start with that. it's more of just thrashing to find some way to hide the callbacks and throws. again, english is not the best language, i shoudl mock up what i want the code to look like, then beat it with macros until it actually works that way
13:54cemericksritchie: it takes a URI path; "routes" mean different things in different libs
13:54sritchiesure, but it intercepts some URI about the typical routing layer
13:55sritchieit tries to do "routing" on that single URi,
13:55muhoomight not actually need too many macros, maybe core.async already has all the tools i need
13:55sritchiewith no notion of content type
13:55sritchieif the user wants the interactive-form workflow, for example, they probably have a routing layer in place
13:55sritchie(since you redirect to some other route after login)
13:55muhooit's a hard problem. auth is just confusing. there's probably not much that can be done that hasn't already been done, and friend is definitely an improvment over everyone hand-rolling stuff instead
13:55sritchieso rather than having them try to intercept that one route in a workflow,
13:56cemerickmuhoo: well, what I suggested as an interpretation is going to be tough; perhaps impossible given the way oauth/openid negotiation. But it'd be interesting to see if you can pull it off :-)
13:56sritchiemuhoo: I think the liberator + friend direction is compelling; I'm just not convinced that oauth, interactive form, etc should be done as these throw catch deals in the middleware
13:57muhoobut the itch i feel is that i've been using friend since its first release, on several projects, have written and contributed to workflows, and still everytime i look at it i feel lost again.
13:57ptcekAny best practices for defining function with following calling patterns?: [par1] [par1 opts] [par1 par2] [par1 par2 opts] ?
13:58muhoosritchie: thanks for that article, by the way. you explained it well.
13:58sritchiesure
13:59cemericksritchie: the redirection is always just a URI, either one that you were bounced off of because you weren't auth'd yet or the default landing URI. URI paths != "routes". Subtle, but important since routes mean very specific things in different libraries.
13:59sritchieI'm not talking about the redirection
13:59muhoohmm, and it's important to be routing-library-agnostic
13:59sritchiecemerick: I'm talking about the intercept of "/login"
14:00sritchieand if you exposed the internal friend tools to manipulate the session.
14:01muhoo /login is hard because that's basically route
14:01sritchieI think it'd be much easier to get around some of the really confusing workflows like oauth
14:01cemerickI've never used liberator, but it seems like a lot of the friend/liberator friction comes out of the latter needing to own/be aware of the entire state transition graph. Without knowing more, it sounds like that would make the compose-handlers-to-build-apps pattern in ring somewhat incompatible in general.
14:01bbloomtpope: ok, after using the new cpp behavior for a while, i wanna go back to the old behavior
14:01bbloomtpope: is there a quick vimrc override?
14:01sritchiecemerick: did you read that article I wrote?
14:01cemerickBut I may be mistaken re: liberator.
14:01sritchiecemerick: maybe I just need to sit down and implement the stuff I keep talking about
14:01sritchie:)
14:02cemericksritchie: There are no "internal friend tools to manipulate the session". It's just ring sessions, full stop.
14:02sritchieyou have a function in friend that, on succesful authentication, adds an identity into the session
14:02sritchiecorrect?
14:02muhooit stores state in the session. it also adds stuff to that session, i.e. identity
14:03sritchiecemerick: it's not "just ring sessions", it's a set of functions that manipulate the ring session
14:03sritchieI get that you're not hitting a session store directly
14:03sritchieI've read the entire friend codebase, and I get how it works
14:04sritchiecemerick: here we go
14:04sritchiehttps://github.com/cemerick/friend/blob/master/src/cemerick/friend.clj#L65
14:04sritchieokay, so it is exposed
14:04cemericksritchie: I think you're talking about make-auth? It's there, it's not even "private". What needs exposing?
14:05muhooanyway, now i feel bad about starting this argument.
14:05cemerickmuhoo: you didn't start anything :-)
14:05sritchieI guess it's not really worth going into - I know you're swamped with other stuff and not too open to changes on this stuff
14:05muhooor restarting it
14:05sritchiewhich is totally fine
14:05cemericksritchie: I'm open to any number of things, but concrete patches > irc hand-waving
14:06sritchiecemerick: yeah, sometimes discussion is useful before patches, as the author may have strong feelings for or against certain ideas
14:06cemerickI'm bummed that some people find friend confusing, but given the constraints of the space, it's my best effort.
14:06pbostromptcek: you can't do what you want, but you could either do [[par1 par2]] [[par1 par2] opts] -OR- [par1 opts] [par1 par2 opts]
14:06muhoosritchie: it's confusing, and even when well explained, it's confusing. even when understanding the codebase, it's still confusing. the confusion exists elsewere, deeper, and i'd bet it's in the way state is dealt with and all they asynchrony, which is a point you made in yoru article.
14:06muhoogah spelling
14:06cemerickIf someone else wants to totally destroy friend with a better library, I welcome that whole-heartedly. :-D
14:07sritchiecemerick: that's not the point :)
14:07sritchiecemerick: I'm happy to do some work to try and make it less confusing, but only if you're interested in that
14:07sritchieand you don't seem to agree that it's confusing
14:07sritchieso, that's the point of the IRC stuff - if you don't think a change is worthwhile, I don't want to push on it
14:09DomKMAnyone have experience packaging a JRuby gem with a Clojure lib or know of an example that I could check out?
14:09muhoosritchie: hell, i think it's confusing, and i'm willing to invest a non-zero number of hours on at least trying to come up with somethinc begter, either using or inspired by core.async. chas just said he's cool with that. the question is is it possible? i'm not sure.
14:09sdegutiscemerick: for what it's worth, I think Friend is just too specialized for a not-very-common use-case
14:09cemericksritchie: I need to hear concretely what the problem is, and what the solution may be, at least in faint outlines.
14:09sritchiedid you read the article I wrote?
14:09sdegutiscemerick: We went with an OpenID library since that's the only authentication we're going to be using for the foreseeable future.
14:10muhoothinking now, i remember dealing with pam. auth is just a PITA, seems not to matter what domain or language.
14:10cemericksdegutis: do what works for you :-)
14:10sritchiecemerick: does that thing I wrote not get across any confusion, even in faint outlines?
14:10sdegutiscemerick: Just trying to give helpful feedback.
14:11cemericksritchie: IIRC, I did a heavy skim of it; it was heavy in liberator specifics, which I wasn't looking to sink into
14:11cemericksritchie: link, pls?
14:11sritchieI would say the bulk of it was a description of friend
14:11cemerickwell, perhaps I did not RC :-P
14:11sritchiehttp://sritchie.github.io/2014/01/17/api-authentication-with-liberator-and-friend/
14:11sritchiehere's my "faint sketch" -
14:11sritchiethere's this concept of a workflow
14:12adsiscoanybody managed to get jrebel working with clojure in intellij? it doesn't auto reload when i make changes to a class
14:12sritchiesome workflows modify the session by intercepting some route, then don't come into play on future authed requests; some of them like the basic auth act on every request;
14:12sritchiesome, like oauth actually do their own handshakes and watch multiple routes
14:12sritchiebefore redirecting back into the user's routing later
14:13sritchielaher*
14:13sritchieit's just very confusing to sort everything out, since it all has to happen in a middleware ABOVE the user's routing later
14:13sritchielayer*
14:14sritchieanyway, if you don't find writing workflows and trying to massage this stuff confusing, I guess we just operate on different planes :)
14:15sritchieI think this could all be cleaned up by having workflows ONLY for stuff like basic auth
14:15sritchiethat requires middlewar
14:15sritchiee
14:15sritchiethen, you could inject the "unauthenticated handler", etc into the ring request
14:16sritchieand provide functions of request that logged a user in, logged out, redirected to the last URI, etc
14:16sritchieby not trying to do so damned much in the workflow middleware and just providing components, the whole thing would be much less confusing, and you'd still be routing layer agnostic
14:16sritchie(since everything you need is in each ring request)
14:18sritchiecemerick: that count as a faint outline?
14:21cemericksritchie: Perhaps. So you're suggesting that any one-time authentication should be just be a ring handler, and all decisions re: redirections, unauthorized access, etc all be made local to the rest of the app's handlers?
14:22sritchieyes, that's right
14:22sritchiecemerick: that allows you to take advantage of you chosen library's constructs for content negotiation, etc
14:22sritchiecemerick: like this, actually: https://github.com/cemerick/friend-demo/blob/master/src/clj/cemerick/friend_demo/signup_and_redirect.clj#L77
14:23sritchiethe signup post is a great example
14:25sdegutisAre there any Clojure testing libraries that are really obvious how they work internally?
14:27sdegutisLike, from the user's perspective, they're obviously just functions that use assertion macros and which get run through a test runner?
14:27cemericksritchie: yeah, that probably would work. FWIW, the biggest motivator of the middleware approach was the (consistent) handling of authorization failures. Getting that without an overarching middleware may be tough.
14:29cemericksritchie: You should totally build it, but it'd be silly to characterize it as a patch to friend. The model is totally different, the result would be a different library with different "workflows" and a different user-facing API.
14:29sritchieyou could still define default handlers in the middleware, and access them in the handler
14:29cemerickFriend is only ~500 LOC, so an alternative surely wouldn't be much more ;-)
14:29sritchiecemerick: :) good point
14:30sritchieyeah, I'll see if I can whip it up soon, would love to run it by you
14:31cemericksritchie: I don't know that it's a net win in terms of complexity; instead of throwing control, you're inverting that into fn calls to handlers hanging off of request maps. It'd basically be the same number of different things to keep track of, just accessed and used differently.
14:32cemerickIf you can manage to eliminate middleware entirely, and people are happy with the result, then I'll be behind it 100%.
14:35jergasonhow do i specify java maven dependencies in my project.clj? the leiningen tutorial mentions that a syntax exists but doesn't say what it is
14:36amalloyjergason: same as you specify clojure dependencies. they're not different
14:37jergasonamalloy: it refers to a "Maven format"
14:37TravisDIs the main purpose of loop/recur to define recursive processes without needing to put it into a named function?
14:37amalloyjergason: have you successfully written a project.clj that contains a dependency? like :dependencies [[org.clojure/clojure "1.5.1"]]?
14:37jergasonyes indeed
14:37amalloyTravisD: yes
14:38amalloyjergason: that is the maven format
14:38TravisDamalloy: Cool, thanks
14:38amalloytada!
14:38jergasonamalloy: magical!
15:12technomancysdegutis: I've heard "expectations" scores high on the "not too much magic" scale
15:13sdegutisThe most magical part about it is that it places assertions at the top-level of a file.
15:13sdegutisI don't know why but that makes me somewhat nervous.
15:13technomancyhaven't tried it myself
15:13sdegutisOtherwise I like its simple assertion syntax.
15:14sdegutisMaybe clojure.test is the simplest one. I kind of get how it works now, it just stores the test fn in :test metadata.
15:14technomancythere is a bit of unnecessary magic
15:15technomancybut virtually everyone knows how it works
15:31gfredericksI wrote a macro to help write a function with 12 nested loops, and the compiled version involves 4108 class files.
15:31gfredericksI was expecting one.
15:32Bronsayou should look at how much bytecode a single doseq generates.
15:32gfredericksI'm not using doseq
15:32SegFaultAXgfredericks: Wut.
15:32SegFaultAXgfredericks: Can you share this magnificent beast?
15:33gfrederickssure one minute
15:34SegFaultAXgfredericks: Also, how slow is this thing?
15:35hiredmangfredericks: the compiler will turn some (all?) nested loop/recurs in to fns
15:35hiredmanbasically bcause nested loop recurs in the jvm bytecode are a pain
15:35gfrederickshttps://www.refheap.com/40783
15:36gfrederickshiredman: that is interesting. still odd that I seem to get an exponential number of fns
15:36gfrederickscompiling the last form in that paste takes some 30sec on my slow vm
15:36SegFaultAXgfredericks: Oh man, that's awesome. Thanks.
15:36SegFaultAXHaha, seriously?
15:36gfredericksyep
15:37gfredericksthis is mostly just an experiment in how well I can optimize numeric clojure
15:37gfredericksI'm curious if this class blowup is a significant perf hit
15:37SegFaultAXMe too.
15:37hiredmangfredericks: it seems likely that the best way to omptize it is to generate the simplest bytecode possible for the jvm to jit
15:38gfrederickshiredman: I figured loops & arithmetic would do it, but apparently nested loops are bad?
15:38hiredmangfredericks: I would not recommend them
15:38SegFaultAXOh Quarto is a game? Never played it before but reading the wiki on it.
15:39gfredericksSegFaultAX: I think? I just had another guy describe it to me for the sake of the stalemate-counting problem
15:40gfrederickshiredman: this will be fun to flatten :)
15:40hiredmangfredericks: my guess would be with the nested loops as fns you'll be allocating fns at such a rate it will dominate the runtime
15:42SegFaultAXgfredericks: Interview?
15:42SegFaultAXBecause that'd be a pretty intense interview question.
15:42gfredericksSegFaultAX: no just having fun
15:42gfredericksI'm not good at interviewing
15:56Bronsahiredman: what problems are you talking about re: nested-loops? In tools.emitter.jvm I do fine without wrapping all loops in a ^:once fn*
16:00hiredmanBronsa: right, I am saying the once fn is a way to avoid the pain of trying to generate correct bytecode for nested loops
16:00hiredmanit effectively unests the loops
16:00clojurebotexcusez-moi
16:01Bronsahiredman: ah, ok. I thought there was some problem I underlooked
16:02hiredmanthe jvm has restrictions on how you can use goto, something about the stack depth always having to be the same at each point if I recall
16:03Bronsahiredman: honestly my understanding was that the :once fn* thing is needed only for locals-clearing purposes
16:05hiredmanthe ^:once is for that, but the fact that nested loops are hoisted out in to fns at all is because, and this is me guessing, rich discovered it was a pain in the ass / impossible to do the nested loops as nested loops
16:08Bronsahm, I have yet to run into problems with nested loops but I'll do some more testing to see if I need to wrap loops in a fn too.
16:12amalloySegFaultAX: quarto is a neat game. one of my early programming projects was to write a quarto ai
16:12amalloysadly the code is since lost to the mists of time
16:14amalloyeven with like a two-ply search whose heuristic was "make the board as complicated as possible so the human will get confused" beat me 90% of the time
16:20TimMcSo, I've been writing a tracking and analysis program for my sourdough starter. (I'd like to know at any given time how much of each flour remains, for both reproducibility and allergen reasons.)
16:20TimMcHere's the file format I've come up with so far, because I'm a horrible yak-shaver: https://gist.github.com/timmc/9059052
16:20TimMc(Because obviously it is very important that the history file format be general-purpose...)
16:26gfredericks"...and all that remained was a smoldering pile of shaven yaks."
16:26brehautTimMc: why not just use edn rahter than a mash up of columns and json?
16:29TimMcbrehaut: Hmm, I should include an apologia.
16:29brehauthaha
16:29brehautmaybe
16:30TimMcWhat it comes down to is that I kept wanting to use the key :type but it meant different things.
16:30TimMcType of entry, sub-type of entry, type of ingredient, type of measurement...
16:30brehautTimMc: i was thinking you'd still have positional items
16:31brehautevent change environment temperature {"scale": "C", "value": 25} would just become (event change environment temperature {"scale": "C", "value": 25})
16:31brehaut(or a vector if you prefer)
16:31TimMchmm
16:32brehauteasy to parse, and then you can destructure it in a multimethod easily too
16:32TimMcOr (to use JSON for a minute) {"type":["event", "change", "environment", "temperature"], "scale":"C", "value":25}
16:32brehautsure
16:33TimMcwhere "type" is the only restricted top-level key
16:33brehautbtw, high five for scale: "C"
16:33TimMc:-)
16:34TimMcI've been trying to use centigrade in everyday life.
16:35brehautthats got to confuse people
16:35TimMcIt does alarm people when I mention that the weather report predicts the high will be "negative two... celsius".
16:35brehauthaha
16:35AlainODeabrehaut: except everywhere other than the US ;)
16:35brehautAlainODea: i presume that americans mostly come into contact with other americans ;)
16:36AlainODeabrehaut: a valid presumption as most Canadians do the same :)
16:36amalloyexcept on the internet, where we are constantly beset by strangers who are confused why we use dumb units instead of sensible ones
16:37brehauti prefer to buy milk by the hogshead. dont you‽
16:37AlainODeaamalloy: and we get caremad about it too :) Which reminds me, why not use Kelvin? ;)
16:38AlainODeaHow many furlongs do you commute each day?
16:38amalloyi prefer to use Cromnians, which will be the standard unit a hundred years from now, just because it confuses people when i talk about degrees C
16:38brehauthaha
16:39brehautits 30 degrees by crom!
16:39TimMc(Rankine is an absolute scale, but has the same size "degree" as Fahrenheit.)
16:41gfredericksis this reminds me about that one thing
16:42gfredericksthere's a kind of algebraic structure that is curious because you can subtract things but not add them
16:42gfredericksbut I can't remember its name
16:43gfredericksclassic example: points in space
16:44brehautnot a monoid then
16:44gfredericksright
16:44gfredericksthis is not very googleable
16:45TimMcbrehaut: So you think the one-distinguished-top-level-key approach is good?
16:45brehautTimMc: if theres not an obvious name, i think positional is probably nicer?
16:46TimMcPositional is easier to process via non-JSON tools, such as eyeballs.
16:46brehautyeah
16:46TimMcI wonder if there are any tools that can parse JSON from the end instead of the beginning.
16:46brehauti think if your string of symbols is arbitrarly length id do [["foo" "bar" "baz"] {…}]
16:47brehautor perhaps [["foo" "bar" "baz"] {…} … {…}] if you want to have multiple args
16:47brehaut(not that its necessary)
16:47TimMcMultiple args can get names in a map.
16:47brehautyeah exactly
16:47AlainODeagfredericks: the folks on #haskell have a pretty good hit rate identifying data structures by their properties :)
16:48brehautjust depends on the functions you have: if you have existing functions that take args positionally it might be useful
16:48TimMcI could drop the outer layer then: ["foo", "bar", "baz", {"some":"data"}]
16:48gfredericksAlainODea: I don't think it would typically be considered a data structure
16:48gfredericksthough maybe it still applies to haskellland
16:48TimMcNo functions involved.
16:48gfredericksI'll go ask
16:48amalloygfredericks: well, neither are monoids and categories
16:48gfredericksamalloy: right
16:49brehautgfredericks: when has haskell land ever looked at an obtuse math concept and thought "you know, lets not turn this into code"
16:49AlainODeagfredericks: You are correct. I was fumbling for the right term :)
16:50AlainODeabrehaut: touché. It has merits when you need it and don't want to build it yourself though
16:51brehautAlainODea: im not saying its good or bad, just commenting on the nature of the community
16:51gfredericksAlainODea: haha they got it in like 8 seconds: "torsor"
16:51AlainODeabrehaut: not at all. It's a valid observation.
16:52AlainODeagfredericks: score!
16:52brehauti had one of those once, but it gradually ran out of wheels
16:52gfredericksthis wikipedia article has very little in it that I understand
16:53brehautwhat‽ who _doesnt_ understand principle homogeneous spaces!
16:54gfredericksclojurebot: who |_doesnt_| understand principle homogenous spaces!
16:54clojurebotAlles klar
16:54gfredericksclojurebot: who?
16:54clojurebotwho _doesnt_ understand principle homogenous spaces!
16:54gfrederickssomeday I will have taught clojurebot half of all he knows
16:56gfredericksoh dates are another nice torsor example
16:56brehautthe fruit or the unit of time?
16:56gfredericksthe romantic/social event
16:58gfredericksI guess if space is an example it makes sense that time would be too
16:59TimMcI don't buy this whole torsor thing.
17:01TimMcOh, wait, yes I do.
17:03TimMcbrehaut: OK, so this still has the property that you can't tell where the tag ends, but at least you can parse the entire line without having to understand it.
17:04TimMc(In ["foo", "bar", "baz"], is "baz" the payload or the end of the tag?_
17:04brehautyaeh and you dont have to mix parsers
17:04TimMcThanks for the sanity check.
17:04TimMcgfredericks: We've already got one!
17:05brehautTimMc: np
17:07TimMchttps://gist.github.com/timmc/9059052 updated, and makes more sense now.
17:10amalloygfredericks: you're teaching clojurebot brehaut's bad spelling habits :P
17:10amalloy(should be principal, not principle)
17:11brehautsigh
17:12gfredericks~spelling
17:12clojurebotI don't understand.
17:13brehautme either clojurebot, me either
17:17DomKMHow do I represent a non-standard dependency within the project.clj? Specifically the dependency has a "type" attribute. https://gist.github.com/daicoden/de146f45c565b5e3a3f4#file-pom-xml-L112
17:18DomKMI've tried :type "gem" (like :exclusions ...) but it is ignored.
17:19stuartsierraDomKM: That's not a standard Maven dependency. It looks like your pom.xml has a special plugin to handle "gem" dependencies. That won't work in Leiningen.
17:21DomKMstuartsierra: is there any way to use :pom-addition to make it work? It appears that Leiningen does support plugins https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L381
17:22stuartsierraDomKM: As far as I know, :pom-addition is only going to add extra XML to the pom.xml file produced by `lein pom`. Then you would still have to run Maven to build your project. Leiningen itself cannot execute Maven plugins.
17:25DomKMstuartsierra: Ah, I didn't realize that. Thanks for your help. By any chance do you know how to package a clojure library that depends on a jruby gem? (I figure you might have run into this since Cognitect also does Ruby work.)
17:25stuartsierraSorry, I don't know.
17:26DomKMokay, thanks anyway
17:51scape_what's a better way/more concise to do this?
17:51scape_,(first(map #(% :op) (filter #(map? %) [2 {:op :value1} 3])))
17:51clojurebot:value1
17:51whodidthishow do i reduce an #inst by 1 hour
17:59`szx,(->> [2 {:op :value1} 3] (filter map?) (map :op) first)
17:59clojurebot:value1
17:59`szxscape_: ^
17:59scape_`szx: thanks! that is better
18:00pbostromwhodidthis: clj-time is a nice library, but you might have to handle converting between java.util.Date and JodaTime dates
18:01hyPiRion,(first (for [e [2 {:op :value1} 3] :when (map? e)] (:op e)))
18:01clojurebot:value1
18:01scape_interesting alternative
18:12TimMc&(->> [2 {:op :value1} 3] (filter map?) first :op)
18:12lazybot⇒ :value1
18:13TimMcscape_: ^ the golfing continues
18:13TimMc(No need to use map if you are only going to take the first element of the sequence.)
18:15ticking&(->> [2 {:op :value1} 3] (some map?) :op)
18:15lazybot⇒ nil
18:15tickingdamn ^^
18:16TimMc$findfn map? [2 {:op :value1} 3] {:op :value1}
18:16lazybot[]
18:16pbostrom&(([2 {:op :value1} 3] 1) :op) ;probably not general enough
18:16lazybot⇒ :value1
18:16TimMchaha
18:17TimMcOr if you want the most concise answer...
18:17hyPiRion,(some #(if (map? %) (:op %)) [2 {:op :value1} 3])
18:17clojurebot:value1
18:17TimMc&:value1
18:17lazybot⇒ :value1
18:17tickingyes I
18:17hyPiRionTimMc: I was about to say ##((constantly :value1) [2 {:op :value1} 3])
18:17lazybot⇒ :value1
18:17tickingyes I vote for hyPiRion
18:18TimMcYeah, I yield -- that actually takes the form of a function. :-P
18:19tickingthere should be a higher order function that takes a pred? and turns it into a function that returns identity or nil
18:22`szxhttps://www.refheap.com/40864 - clean up my mess please?
18:23sdegutisoh boy
18:23sdegutis`szx: what are the inputs/outputs
18:25`szxsdegutis: line-segments is a path in the form of line args suitable for quil's line function, i.e. [[x1 y1 x2 y2] [x2 y2 x3 y3] ...]
18:27`szxsdegutis: segments-lengths are the magnitudes of each vector, cumulative-lengths are the cumulative lengths of the path up to that segment
18:27tickinghyPiRion, TimMc: ha suck it.
18:27ticking,(some :op [2 {:op :value1} 3])
18:27clojurebot:value1
18:28TimMcheh
18:28hyPiRionticking: ##(some :op [2 #{:op} {:op :value1} 3])
18:28lazybot⇒ :op
18:28TimMcor ##(some :op [2 {:op nil} 3])
18:28lazybot⇒ nil
18:28TimMcor ##(some :op [2 {:op nil} 3 {:op 5}])
18:28lazybot⇒ 5
18:29tickinghyPiRion, TimMc: yeah if fails fabulously ^^ oops
18:29tickingTimMc: what was the initial requirement?
18:30TimMcThe original was (first(map #(% :op) (filter #(map? %) [2 {:op :value1} 3])))
18:30hyPiRionfind the first value in a sequence which is a map, and return the value for the key :op
18:31tickingah yeah then I just golfed into a sand pit ^^
18:31TimMc:-P
18:34brehautbtw, for your golfing needs #(or :c %&) is shorter constantly
18:35tickingbrehaut: do characters count or the nodes in the code tree ^^?
18:35brehautcharacters of course!
18:35brehautwasnt this game invented in perl?
18:36tickingbrehaut: quite possibly, I just thought, nodes might be more lispy ^^
18:37brehautsecondary reason: characters makes golfed solutions more tweetable
18:37tickingbrehaut: good point
18:42tickingdamn having a new mac pro makes me really wish there was a up to date opencl lib ^^
18:45seangroveIs there a way to have a catch-all for a defmulti without the defmulti knowing what's implemented?
18:45hyPiRionseangrove: :default ?
18:46hyPiRion(defmethod my-method :default [args] body)
18:46seangrovehyPiRion: Ah, that's exactly it. Thank you
18:46hyPiRiongreat :)
18:46seangroveI nearly had all the right words, but couldn't quite get google to answer me
18:51TimMc&(clojure.string/split "banana" #"an")
18:51lazybot⇒ ["b" "" "a"]
18:51TimMc&(clojure.string/split "banana" #"na")
18:51lazybot⇒ ["ba"]
18:52TimMcWhy is the second not ["ba" "" ""]?
18:52TimMc&(clojure.string/split "nanabanana" #"na")
18:52lazybot⇒ ["" "" "ba"]
18:53amalloybrehaut: #(do %& :c)
18:53brehautah true
18:53amalloynot actually shorter, but a slight bit less awful
18:54TimMcand allows for falsey values
18:54amalloyTimMc: ##(clojure.string/split "banana" #"na" -1)
18:54lazybot⇒ ["ba" "" ""]
18:54TimMc*sigh*
18:54amalloysplit's default behavior is to discard trailing separators
18:55amalloyso *obviously* a negative number means to not discard them. any fool can see that's the right API
18:55TimMcThank you.
18:55amalloyjava's string APIs are just bizarre
18:56TimMcFiling a useless JIRA to either note that clojure.string/split passes this behavior through... or to fix it.
18:57tickingimho this should be fixed otherwise it has to be ported to all the other languages, urgh
18:57amalloyTimMc: neither will happen. this behavior has been discussed dozens of times in this very irc channel
18:58tickingamalloy: really? so clojurescript just emulates it?
18:58amalloyhuh?
18:59amalloyi don't know how you discerned anything about cljs's behavior from my statement
19:00amalloyhowever, i do see https://github.com/clojure/clojurescript/blob/master/src/cljs/clojure/string.cljs#L72-L79
19:02amalloyand the impl does look like it's working hard to mimic java's behavior
19:03seangrovesritchie: How did you end up handling timer elements with React?
19:09tickingamalloy: yeah that seems to be the logical consequence, this seems really horrible though
19:09tickingamalloy: I would definitely expect such behavior in clojure.java.string, just not in clojure.string
19:10amalloyi mean, clojure is hosted. you either have to implement everything yourself, or live with the fact that there are differences based on where you're running
19:10tickingyeah but I think it should be clear what parts are hosted, and what parts are abstracted
19:18shaungilchristI am curious if anyone is digging into the core.async GC issues in chrome (e.g. having channels stick around w/ their retaining tree pointing to state machine internals)
19:30michaniskin1i'm using the cljs compiler but not in lein-cljsbuild. i'm seeing ~3 sec incremental compile times when i used to see < 1 sec. are there some things i should look at to speed it up?
19:35tpopebbloom: I assume you could nmap <buffer> cpp cpab in after/ftplugin/clojure.vim
19:48tickingwow jocl (java opencl bindings) has highest good project to bad-readme ratio I've ever encountered http://cl.ly/image/3D05320q3Y2S
19:48tickingIt's ascii art even has a rendering bug in my browser
20:21holohi
20:23holoI need to push a jar to clojars using scp. no one ever pushed this one, so I guess it will be created in a canonical group. this library isn't mine, so I guess it should be better to put it in my own group. how do I do it with scp?
20:24bbloomtpope: unfortunately not, :scriptnames suggests that gets loaded, but no effect. if I run that nmap command manually, it works though
20:27bbloomtpope: presumably setup_eval is overriding that?
20:29bbloomtpope: i just hacked the fireplace.vim file directly, but if you've got a better idea... i'm still terrible at vim script. thanks!
20:29holooh I get it.. the group is in the pom!
20:39bacon1989so I was wondering, how many of you tried Om with clojurescript? I'm having a hard time figuring it out
20:39bacon1989should I try a few react tutorials first, and then try and get my head wrapped around Om?
20:41Tolstoybacon1989: I think it's easier than you imagine, though dnolen's examples tend to be ... compressed.
20:43bacon1989Tolstoy: I guess i'll have to start looking into it again
20:43TolstoyI think you can go a long way without using all that "component state" thing.
20:45TolstoyIt's a bit confusing. There are "properties" and "state", and there's the values you pass in to the function. But "properties" are really the "app state" and "state" is really the component's local stat?
20:45TolstoyOy.
20:46TolstoyI ended up just implementing all the interfaces and logging all the parameters, and then I could understand the docs. But I've since forgotten again. :) Ah, the memory of a hobbyist.
20:52shriphanianyone care to explain why this happens? https://www.refheap.com/40997
20:52bruceadamsi'm struggling to write a Clojure function that takes a Java class as an argument and creates an instance of that Java class. The "new" special form seems to demand the actual class name. I haven't found a way to to use a var containing a reference to the class.
20:53qbgbruceadams: use reflection
20:53bbloombruceadams: new will compile to an actual constructor call
20:54bbloombruceadams: yeah, what qbg said
20:54bbloomshriphani: seqs can't be used as key value pairs
20:54shriphanithey need to be vectors ?
20:55bruceadamsi'm using reflection for some field stuff, not sure how to talk about constructors in reflection land (looking...)
20:55shriphaniany particular reason ?
20:55bbloomshriphani: they need to implement java.util.Map$Entry
20:55qbgbruceadams: Do you have the class object?
20:55bbloomshriphani: what would (val (list "some" :long 'list)) be?
20:55bruceadamsqbg: yes
20:56qbghttp://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#getConstructor(java.lang.Class...)
20:56qbgor http://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#newInstance()
20:56qbgIf you want to invoke the ctor that takes no arguments
20:56shriphaniok nvm I see why
20:56shriphanibbloom, thanks
20:58qbgbruceadams: Does that help?
20:59bruceadamsqbg: pretty sure that'll work, yes. Thanks!
20:59qbgIf you use .getConstructor, last time I checked clojure didn't handle varags nicely, so you have to pass it in as an array
21:02bruceadamsqbg: seems kind of heavy, but will definitely work. i was trying to create a macro wrapped around Clojure's "new" special form, trying to get the class name in place. i got half-way there, then got stuck. (never wrote a macro before, which didn't help.)
21:02qbgJava is heavy :p
21:02qbgYou're writing a macro?
21:02bruceadamsyup. mostly much lighter with Clojure as the driver
21:03qbgDon't you have the class name available at compile time?
21:03bruceadamsonly as an attempt to get "new" to do what i wanted.
21:03bruceadamsI do have the class names, about twenty of them, available at compile time.
21:04bruceadamsI want a single Clojure function to be able to create instances of any of those twenty Java classes.
21:04qbgmacros aren't that magic. Now if you used eval on the other hand :p
21:04TimMcamalloy: Neither will happen, but I feel the need to lodge protest, at least.
21:04bruceadamseval wants a top-level var, not a local (such as a function formal argument).
21:04bruceadams(which is where I got stuck)
21:05qbgYou could create a function on the fly using eval, but reflection is the right way to go here
21:05bruceadamsmacros aren't magic! I'm sooo disappointed!
21:05qbgConnecting to your database at compile time and generating boilerplate code is just cool, not magic :p
21:07bruceadamsqbg: thanks for the help. reflection had not crossed my mind (even though I'm already using it for other stuff).
21:12akurilinQuick question: I like threading functions, but I also like using destructuring of parameters to avoid having to care about parameter ordering
21:12akurilinCan I have my cake and eat it too?
21:12bbloomakurilin: you mean like threading a map through a list of function calls? sure.... go for it
21:13akurilinAs in, threading relies on placing the threaded piece of data at the beginning or end of the list of arguments, but I'm looking for more of an assoc instead.
21:14bbloomakurilin: you'll have to be clearer than that
21:14akurilinOr is the common pattern to always leave the fist/last param by itself and keep the rest of of the list of arguments as a destructured map?
21:14akurilinwhen threading.
21:51quizdri'm a little confused about the relationship between def and set!. shouldn't i be able to set! a var defined with def?
21:52frozenlockI'm having some trouble with logic.core. I want to make a function to get the intersection of two lists. Here's what I have: https://www.refheap.com/41077
21:53bob2quizdr, set! is for java interop, right?
21:53noonianquizdr: i thought that too from how scheme's set! works
21:54bob2frozenlock, the set module has an intersection method, but not sure how your question relates to core.logic
21:54noonianquizdr: you can only set! dynamic vars that have been bound with (binding [*dyn-var* true] ...)
21:54frozenlockHere's the problem. With ---> (run 5 [q] (intersectiono [:bob :input :test] [:input :test] q)), I get this result: ([] (:input) (:test) (:input :input) (:test :input))
21:55frozenlockI was expecting to get only (:test :input)
21:55quizdrnoonian ah i see
21:56frozenlockbob2: thanks, I know that. I just want to practice my logic.core skills :-p
22:09RMacyquizdr did you get your question answered?
22:10quizdrRMacy yes, thanks
22:11quizdrRMacy noonian answered it above
23:09amalloyfrozenlock: it's core.logic, by the way
23:22ddellacosta,(* 360 (/ 2 12))
23:22clojurebot60N
23:30RMacy,(inc tired)
23:30clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: tired in this context, compiling:(NO_SOURCE_PATH:0:0)>
23:30RMacy&(inc tired)
23:30lazybotjava.lang.RuntimeException: Unable to resolve symbol: tired in this context