#clojure logs

2015-05-19

01:15tmtwd> foldl f z [a,b,c]
03:26zotI have the feeling that type hinting is shooting me in the foot: datascript.core.Datom cannot be cast to datascript.core.Datom — any ideas how to debug?
03:48TEttingerzot: I think you may have multiple different Datom types defined somehow.
03:48TEttingerI don't use datascript though, is it for CLJS?
03:48zotyeah, eventually realized it was defrecord + repl
03:48TEttingerah good
03:48zoti'm working on the CLJ port of it
03:48TEttingernice!
03:49zotit's been fun and … educational. lots of little annoying diffs between the two.
03:49zotbut still awesome that it's possible.
03:49zot(can't blame the designers — sticking to the host language/vm creates roadblocks, and the need for detours.)
04:36zotis there any magic to getting data_readers.clj to work w/in clojure.test? i'm failing miserably, and not finding an example
04:40ordnungswidrigzot: an example gist might help
04:40zottrudat. a moment, please.
04:43zothttps://gist.github.com/anonymous/282abf8448e5f1cca608
04:43zotit mostly works in the REPL, as i can directly run the test, or simply type the check in the repl
04:44mpenetzot: odd, the data_readers.clj file is in src?
04:44zotyep
04:51zotis there any way to confirm that it's being loaded properly? i see no errors at compile time (as I once did when there was a typo in data_readers.clj)
04:53zot(reinserting typo confirms that compiler fails, but i see now way to assert that the target functions are … targeted.)
04:54justin_smithzot: a job for unit tests?
04:54zotjustin_smith: that's what's failing. see the gist above.
04:59zotjustin_smith: any ideas? :)
05:12justin_smithsadly no, it looks like it should work
05:13zotshould i take anything from the fact that it says "No reader function for tag Datom" instead of "datascript/Datom" ?
05:59martinklepschhow again can I refer to a symbol that is at compilation time not resolvable?
06:00martinklepsch(but at runtime it will be)
06:05zotno clue, but does #'foo/bar work this way?
06:05justin_smithmartinklepsch: resolve
06:06justin_smith,(resolve 'this-does-not-exist)
06:06clojurebotnil
06:06justin_smith,(resolve '+)
06:06clojurebot#'clojure.core/+
06:06justin_smithit returns the var, so sometimes you want @(resolve 'foo)
06:07martinklepschjustin_smith: thanks, that was what I've been looking for!
06:08justin_smithmartinklepsch: I used resolve recently to construct a shim for jsvc, so that I would not need to aot compile any of my code
06:08justin_smithother than one very small file, that uses require inside a defn, plus resolve, to call my actual main ns
06:09martinklepschjustin_smith: neat. actually didn't know about jsvc until now :)
06:10justin_smithjsvc is a great way to make a proper daemon out of a clojure project
06:10justin_smithbut you likely know that now
06:11justin_smithI may even make a project out of this jsvc shim. Just a macro where you supply the symbol of your real main ns, and it compiles to do the proper runtime resolution
06:14martinklepschjustin_smith: it does not handle classpath stuff for you does it?
06:14martinklepschjustin_smith: or do you use uberjars with it?
06:15justin_smithyeah, it needs to be an uberjar
06:15justin_smithwhich is why the shim - so that only one tiny ns needs aot compilation
06:17justin_smithmartinklepsch: another option would be to set up the -cp arg in a script, and let lein generate the classpath as a build step
06:17justin_smithbut uberjar is convenient for deploy anyway
06:18jonathanjjustin_smith: is any of that shim code published?
06:18justin_smithjonathanj: it's really small, I'll definitely publish the lib if I make it
06:19justin_smithbasically (defn -start [& args] (require 'real-ns) ((resolve real-ns/-main)))
06:19justin_smithwith similar for stop, init, destroy
06:19justin_smithinside an ns that has (:gen-class) extending the proper daemon class of course
06:20justin_smithoh wait
06:20justin_smith(defn -start [& args] (future (require 'real-ns) ((resolve real-ns/-main))))
06:20justin_smith-start needs to return quickly :)
06:20jonathanjwhat's with the -?
06:21jonathanjis that the default prefix for gen-class exports?
06:21justin_smithjonathanj: it's the default method implementation prefix for gen-class
06:21justin_smithright
06:21jonathanjnice
06:21justin_smith$google jsvc clojure
06:21lazybot[rkn.io - Clojure Cookbook: Daemonizing an Application] http://www.rkn.io/2014/02/06/clojure-cookbook-daemons/
06:21justin_smiththat's a decent intro
06:21jonathanjjustin_smith: ah, neat
06:21jonathanjjustin_smith: thanks
06:21justin_smithnp
06:22justin_smithjonathanj: the motivation for using a shim, is it means I don't need to pre-compile the entire app
06:22jonathanjnext question, how do i rewire my brain to stop reading that as (js)(vc)?
06:22justin_smithhaha
06:23justin_smithjonathanj: clearly it's true nature is to be a venture-capital firm for javascript
06:23jonathanjjustin_smith: right, so presumably that reduces the amount of time required to produce an uberjar
06:23jonathanjprobably quite significantly
06:23justin_smithand it avoids tools like cider compiling all your stuff every time you start the repl
06:24oddcullyisnt there some hip way to pronounce it, that shows you really know you stuff (like wizdul). maybe jazvic?
06:24jonathanjjustin_smith: ooh
06:24justin_smithoddcully: heh
06:24jonathanjoddcully: haha
06:24justin_smithso a big part of it is that this avoids slow repl startup
06:24justin_smithbecause otherwise you'd get that gen-class run, which would be transitive, and would hit all your code
06:25justin_smithand all your libs...
06:28noncomis clojure.edn included with the core clojure distribution?
06:28justin_smithsince 1.5 iirc
06:28noncomhmmmm...
07:17noncomjustin_smith: i cannot spot it in the jar.. where is it?
07:17noncomclojure.edn i mean...
07:18noncomneither it is present in the local maven repo..
07:48sveriHi, I have a function that takes an argument and then adds or substracts something to that argument (defn foo [x] (+ x 1)) or (defn foo2 [x] (- x 2)). Now I want to have an edn file / map that provides the function that is executed inside foo or foo2, something like {:foo (+ x 1) :foo2 (- x 2)}. what is the idiomatic way to do that? just writing x and y inside the map does not work as it does not recognize the vars
08:14dstocktonsveri: anonymous functions maybe? (fn [x] (+ x 1))
08:14dstocktonand then ((:foo my-map) x)
08:20sveridstockton: sounds like an idea, I try that, thanks
08:21dstockton#(+ % 1) for shorter
08:28noncomsveri: also, if you will have many functions and will need good stack traces for debugging, consider naming the anonimous functions like (fn my-anon-fum [x] (+ 1 x)) ...
08:33sverinoncom: yea, nice hint, but I won't need it I think, but good to know :-)
08:34noncomyeah, i find it useful only occasionally
08:45noncom,(re-find (re-pattern "(\\d+)") "refs #123456 hello!")
08:45clojurebot["123456" "123456"]
08:45noncom^^^ why there are 2 same results?
08:46noncom,(re-find (re-pattern "#(\\d+)") "refs #123456 hello!")
08:46clojurebot["#123456" "123456"]
08:46noncomwhat is that..
08:46noncom?
08:47dstockton,(re-find (re-pattern "#\\d+") "refs #123456 hello!")
08:47clojurebot"#123456"
08:48dstocktonone is the captured result and one is the overall match
08:48dstocktonfirst one is the overall, second is the captured number
08:48dstockton( ) means remember this for later
08:50noncomah..
08:53crocketre-think
08:54crocket(re-think #"your life")
08:57oddcully,(re-find #"(\d)(\d)(\d)" "refs #123")
08:57clojurebot["123" "1" "2" "3"]
09:16TEttingernoncom: also you can use ##(re-find (re-pattern "(?:\\d+)") "refs #123456 hello!")
09:16lazybot⇒ "123456"
09:16TEttinger(?:whatever) will match whatever but not capture it
09:16TEttingerit's a pure grouping operator
09:17TEttingerhttp://www.regular-expressions.info/brackets.html is amazingly useful for the weirder regex stuff
09:27crocket,(doc re-find)
09:27clojurebot"([m] [re s]); Returns the next regex match, if any, of string to pattern, using java.util.regex.Matcher.find(). Uses re-groups to return the groups."
09:39CookedGryphondoes anyone know if/when test.check is going to support nested for-all?
09:44noidiCookedGryphon, could this help? http://blog.jessitron.com/2014/08/quick-reference-monads-and-testcheck.html
09:45noidiisn't that pretty much what a nested for-all would look like?
09:45CookedGryphonmore or less, that's essentially what i'm doing manually
09:46crocket(let [sexy? #(true)] (if (sexy?) (println "yay") (println "woo")))
09:46crocket,(let [sexy? #(true)] (if (sexy?) (println "yay") (println "woo")))
09:46CookedGryphonwould be nice to have it as a part of the standard for-all macro though
09:46clojurebot#error {\n :cause "java.lang.Boolean cannot be cast to clojure.lang.IFn"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Boolean cannot be cast to clojure.lang.IFn"\n :at [sandbox$eval25$sexy_QMARK___26 invoke "NO_SOURCE_FILE" 0]}]\n :trace\n [[sandbox$eval25$sexy_QMARK___26 invoke "NO_SOURCE_FILE" 0]\n [sandbox$eval25 invoke "NO_SOURCE_FILE" 0]\n [clojure.lang.Compiler e...
09:47crocket,(if true (println "go go go"))
09:47clojurebotgo go go\n
09:50oddcully,((constantly true))
09:50clojurebottrue
09:57crocketWhy does (defn- private-function "ohai" []) fail after executing (in-ns 'cheese.analysis)?
09:57Bronsacrocket: in-ns doesn't refer all of clojure.core
10:09maioanyone using clojure.test.check + core async code?
10:09crocketProject Euler
10:11CookedGryphonmaio: I tried
10:11CookedGryphontesting core.async is hard
10:11CookedGryphonreally want something like step.async but official so it covers everything
10:11crocketTesting?
10:11crocketIt seems clojure books don't really focus on writing tests.
10:11CookedGryphonso you can do things like step through every combination of takes, puts nad timeouts
10:11crocketLike unit tests.
10:14Ricardo-Argescrocket: The one by yogthos does (Web development with Clojure).
10:15crocketAre tests not important in clojure?
10:15pbxcrocket, Clojure Programming (O'Reilly) has a chapter on tests
10:16crocketpbx, Do you mean http://www.amazon.com/Clojure-Programming-Chas-Emerick/dp/1449394701/ref=sr_1_1?ie=UTF8&qid=1432044980&sr=8-1&keywords=clojure+programming&tag=donations09-20 ?
10:17pbxcrocket, yes
10:18pbxaka http://amzn.com/dp/1449394701/ :)
10:20crocketpbx, How did you get the short link?
10:21oddcullyclojure applied will also have a chapter about testing. but it is missing as of beta 2
10:24pbxcrocket, i have a side project for generating non-redirect shortlinks like that. (it's broken right now so i'll skip the url)
10:40cemerickWhat are people doing to cope with the new default exception printing?
10:41gfredericksdoes anybody know if using cider with multiple projects might be buggy when one project is a subdir of another?
10:41gfrederickscemerick: "cope with" meaning "aah s-expressions are harder to read at a glance!"?
10:42cemerickgfredericks: that's putting it politely, yes
10:42cemerickthis is particularly painful w/ the prints of error :results in test.check, etc
10:42cemerick[hhalp.fsm$eval125347$notification_generator__125348$fn__125352$iter__125354__125360$fn__125361 invoke "fsm.clj" 147]
10:43gfredericksoh I see there are docs about the cider thing
10:43cemerickum, yeah, that's an sexpr
10:43cemerickmy best idea so far is to restore the (saner) default via a print-method impl in user.clj for Throwable
10:43gfrederickscemerick: I'm trying to figure out what the main differences are here -- e.g., the old behavior would still print that long classname, or not?
10:44gfrederickssurely it must
10:45gfredericksapparently cider has a "default connection" that all buffer evals go to regardless of project
10:46gfredericksso I'll just have to toggle that around a bunch
10:46cemerickgfredericks: yeah, the rotate-connection thing is the only option to control the direction of your evaluation
10:49cemerickgfredericks: no, the old behaviour was that throwables were printed unreadably, e.g. #<ExceptionType message-string>
10:49cemericknow they are printed readably by default
10:51cemerickI guess the change was prompted by the (aborted, AFAICT) stream-socket REPL idea, but the result at this point is pretty painful
10:56dnolencemerick: socket REPL is just postponed far as I know
10:57cemerickdnolen: "aborted for 1.7", is what I meant
10:57puredangerwill be in 1.8
10:59cemerickpuredanger: since you're here, I'll save my msg to clojure-dev; is the new printing defaults remaining in 1.7 given the delay? I find the new presentation pretty unhelpful as things stand (esp. w/ test.check results, at the moment)
10:59puredangernot sure what "is the new printing defaults remaining in 1.7 given the delay" means?
10:59puredangerI guess I'm not sure exactly what you're asking
11:00puredangerthere are no more changes planned for 1.7
11:00cemerickI have my answer, then :-)
11:01cemerickpuredanger: was wondering if the new default printing for Throwables and Object were going to be reverted
11:01puredangerno, definitely not
11:01cemerickok; I can fix that for myself in user.clj or something
11:02puredangerI'm curious what's unhelpful about it though
11:02puredangerand in particular what you're seeing with test.check
11:03gfredericksyeah I was trying to figure that out too
11:03gfrederickscemerick: you're saying you didn't get the stacktrace at all before and you liked it better that way?
11:03noncomif clojure.edn is shippen with the main clojure distribution, then where is it in the jar? i cannot find it..
11:03noncom*shipped
11:04puredangertest.check (or whatever) can use the new Throwable->map function to get the data as a map and do whatever you want with it re printing
11:05puredangernoncom: yes, it's in the clojure jar
11:07noncomfound it! sorry, somehow missed it.. heh :)
11:07cemerickpuredanger: the return value of `quick-check` includes :result slot that can be a thrown exception; this used to print concisely, now prints the full readable representation of the error, including the stack, etc.
11:08puredangeryeah, I'd say that's up to test.check to customize as desired
11:08cemerickpuredanger: but the exception is part of the return value; I don't think anyone would want test.check messing with that
11:10puredangeris the contract to return that data or as a string representation of the data
11:10cemerickAnyway, the unhelpful part is that exceptions (and other Objects to a much lesser extent) now make default REPL prints far noisier
11:10puredangerI'm guessing the former?
11:10gfredericksyeah that's an interesting use case
11:10gfredericksI thought of the new behavior as mainly replacing unreadable stack traces
11:11puredangercemerick: there is no difference in the repl behavior when an exception is thrown
11:11gfredericksthis is a different kind of situation
11:11cemerickpuredanger: The exception, or the value that failed the test, yes
11:11cemerickpuredanger: only when the REPL catches the exception
11:12puredangerthere are competing use cases here
11:12cemerickgfredericks: there's no accounting for taste, but I think it'd be rare to find someone that'd claim that the new readable printing of throwables is better for humans
11:12gfrederickscemerick: do you often use t.c/quick-check instead of t.c.c-t/defspec?
11:12puredangerhaving the ability to represent the Throwable as data and print as data enables you to leverage tools you have to make what you want
11:13cemerickgfredericks: fairly rarely, but the latter just passes along the results of the former
11:14cemerickpuredanger: yeah, I'm +100 on a readable representation of throwables being available. Being the default for any exception printed @ the REPL? Not so much.
11:15puredangerwe had an explicit function available in the socket repl ticket for printing with the prior string form
11:16puredangerthat didn't end up making it in
11:16gfredericks#error-summary {:msg "..."}
11:16puredangerand it seems unlikely it will the way things are going for the socket repl stuff
11:17puredangerbut a separate ticket for a Throwable summary printer might be a useful clojure.repl enhancement
11:18cemerickpuredanger: Having to be explicit about recovering a concise representation in an interactive context sort of defeats the point?
11:18cemerickThe socket REPL is another topic IMO; this is strictly a question of default REPL UI for me
11:19cemerickI very vaguely recall hiredman making a similar point when this was being batted around in connection w/ the socket stream REPL, but I wouldn't dare try to find his msg in that thread now :-)
11:20puredangerjust to reiterate this - if an exception is thrown and caught by the repl, there has been no behavior
11:20zoti have a map {:a [1 2], :b [2 3]} … and want to invert it (and convert to sets), a la {1 #{:a}, 2 #{:a :b}, 3 #{:b}} — is there a concise way to pull this off? my solution is a bit ugly w/ reduce and for loops together
11:20puredanger^change in
11:20cemerickpuredanger: yes, but that's not the only scenario when an exception is part of a value printed at the REPL
11:20mmeixsorry for basic question: what's wrong with https://www.refheap.com/101288 ?
11:21cemerickAnyway, if things are as they are to be, that's cool, I'll just re-def the necessary print-methods to their previous default
11:21puredangercemerick: I understand, but I think that's the majority use case
11:21cemerickpuredanger: depends on how much one uses test.check :-)
11:21xeqimmeix: your using v inside the loop body instead of in
11:21mmeixdoh ...
11:21mmeixthanx (ashamed)
11:22puredangercemerick: that's unfortunate for sure and that's why I'm trying to understand more
11:23xeqimmeix: no ashamed, no sorry for basic questions. You're free to ask those here. Everyone starts somewhere
11:23xeqiI've done that same thing before
11:24mmeixlesson: be consistent, when renaming vars
11:24gfrederickspuredanger: the use case of printing a repl-caught exception is irrelevant to cemerick's point I think -- he's saying that *assuming you're already trying to print an exception as a normal value* the verbose way is probably too noisy
11:24gfredericksfor repls
11:24puredangeryeah, but it didn't print as a "normal value", it just printed some string gunk
11:25cemerickpuredanger: Understand that I'm not advocating per se, just feedback: the REPL is my primary UI when programming, so everything presented there should be suitable for human, not machine consumption.
11:25gfrederickspuredanger: but it was short and it did have *some* information
11:25puredangercemerick: again bringing up the socket repl ticket just b/c that's where I worked on it the most... we had the ability in that patch to use a dynvar to set the error printer which is an idea that would help you
11:25puredangerand I can see that being a reasonable thing to set to a concise printed form when using the repl
11:26cemerickpuredanger: that sounds cool. I don't think its presence would impact my opinion on defaults, tho.
11:26puredangerI'm saying it could be the default when in the repl
11:26cemerickah
11:27puredangerthis is helpful and it can feed into where the socket repl stuff is going
11:27gfredericks#error-summary [some.ClassName "the msg"]
11:27cemerickwell, then I'm confused as to why the default changed at all, since we seem to be in violent agreement about what it should be
11:28puredangerI think the major issue was in it not being data
11:29puredangerI don't know Rich's thinking on why verbose vs summary
11:29cemerickpuredanger: I'm getting the distinct impression that I'm the first person to raise this?
11:33puredangerthis aspect, yes
11:33cemerickcemerick, the princess and the pea of the clojure world
11:35cemerickanyway, I upgraded to 1.7.0, and my test output was suddenly completely dominated by machine-readable stack traces. Probably a 10:1 ratio on the screen. So, I'm surprised.
11:35puredangeryeah, no one's mentioned that :)
11:35andyf_Just heard about this today. Wonderful: http://friendda.org
11:37andyf_gfredericks: How do we teach Clojurebot that cemerick is a princess? :)
11:40puredangercemerick: so you have these in results like {:result true, :num-tests 100, :seed 1431522180984, :test-var longrange-equals-range} where :result is a Throwable?
11:41cemerickpuredanger: exactly
11:41puredangerisn't this potentially an issue for any result that is "large"?
11:42cemerickpuredanger: I have a couple of library projects that do funny things with exceptions as well, which return multiple exceptions in various data structures here and there
11:42puredangerI'm just trying to figure out if you're just a weird user :)
11:42cemerickpuredanger: not insofar as :result is otherwise an instance of a type or other data structure that I've constructed, is domain-relevant, and is printed using very familiar/useful notations
11:43cemerickmeanwhile, the readable stack traces has things like [hhalp.fsm$eval125347$notification_generator__125348$fn__125352$iter__125354__125360$fn__125361 invoke "fsm.clj" 147]
11:43cemerickand lots of them, which is _completely_ useless as a human
11:44puredangerit's "read"able but maybe not readable if you know what I mean :)
11:44hyPiRionparseable
11:44cemerickyeah, the terminology is problematic :-)
11:46puredangercertainly having nested Throwables in the result implies that you want something in the printer, not in test.check
11:47cemerickpuredanger: yah, trying to cope with this on a case-by-case basis would be nuts.
11:50puredangerso my take on this is:
11:50puredanger1) I understand your problem and it seems like a reasonable complaint
11:50puredanger2) many people would not be affected by this - I think you're more exposed than most which is why we haven't seen it
11:50puredanger3) there is a hook in the printer to hack around it for now
11:50puredanger4) some of the work in the queue for 1.8 could address this as well and I will try to factor it in
11:58cemerickpuredanger: there's a hook in place now? I don't see anything obvious in core_print?
11:58puredangercan't you just override the print-method?
11:59cemerickpuredanger: of course, I thought I misunderstood you previously and that a dynvar was available now
11:59cemerickhttps://gist.github.com/cemerick/c8ed5730b0055f41cbef
11:59cemerick(if anyone wants a quick copypasta)
11:59puredangeroh, no that was in the former socket repl work
11:59puredangerwhich is not going to go in
12:01puredangerif you wanted just to change throwables you should be able to defmethod print-method on Throwable
12:02cemerickpuredanger: yeah, I prefer the un`read`able printing of Namespaces, too. :-P
12:02cemerickpuredanger: again, not *trying* to advocate for anything, mostly trying to "just" be a user at this point :-)
12:05puredanger:)
12:14andyf_If I have a local in a function, x, and its value is the symbol next, is there some code I can write to take x and produce the Var #'clojure.core/next ?
12:15TEttingerthe symbol next, but not in the right namespace?
12:16TEttingererr
12:16TEttingerI admit I'm a bit fuzzy on symbols and vars
12:16TEttinger,(resolve "next")
12:16andyf_Ah, got something: (get (ns-publics 'clojure.core) x)
12:16clojurebot#error {\n :cause "java.lang.String cannot be cast to clojure.lang.Symbol"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.String cannot be cast to clojure.lang.Symbol"\n :at [clojure.core$ns_resolve invoke "core.clj" 4214]}]\n :trace\n [[clojure.core$ns_resolve invoke "core.clj" 4214]\n [clojure.core$ns_resolve invoke "core.clj" 4211]\n [clojure.core$resolve invoke "core...
12:16TEttinger,(resolve next)
12:16clojurebot#error {\n :cause "clojure.core$next__4109 cannot be cast to clojure.lang.Symbol"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.core$next__4109 cannot be cast to clojure.lang.Symbol"\n :at [clojure.core$ns_resolve invoke "core.clj" 4214]}]\n :trace\n [[clojure.core$ns_resolve invoke "core.clj" 4214]\n [clojure.core$ns_resolve invoke "core.clj" 4211]\n [clojure.core$resolv...
12:16TEttinger,(resolve 'next)
12:16clojurebot#'clojure.core/next
12:16Bronsaandyf_: isn't that just resolve?
12:17andyf_Yeah, I think I have almost never needed resolve before, so off my familiarity chart
12:17Bronsaor ns-resolve if not in the curr ns
12:19TimMcI don't know if this got brought up in the exception-printing discussion, but could println and prn behave differently here?
12:23mmeixcan I do a (let [ ... ]) inside a loop? like (loop [x (...)])
12:23mmeix(loop [x (...)] (let [ y (* x x)] ... ))
12:25cemerickpuredanger: thanks for listening, appreciated
12:26puredangerTimMc: 's good question - print-method and print-dup could be different
12:26shoky,(loop [x 3] (let [y (* x x)] (if (> y 20) y (recur (inc x)))))
12:26clojurebot25
12:26shokymmeix ^
12:26mmeixgreat!
12:27mmeixthanks
12:28TEttinger(inc shoky)
12:28lazybot⇒ 5
12:32BronsaI too find the new readable printing a step back for the normal REPL
12:36TEttingeragreed, Bronsa
12:44iamjarvois there a way to to not pass in app-id to create-cert (talkGET "/certs" [app-id] (create-cert app-id)) ?
12:47mmeixa stylistic question: is it more idiomatic to write "(if (= :up x)..." or "(if (= x :up)..."?
12:48mmeix(I think the first focuses more on the 'switching' value)
12:50TimMcI like the latter unless you're comparing x each time in a whole chain of these.
12:50TimMcAnd maybe even then?
12:51mmeixmaybe because it's more with the flow of the language
12:51mmeix(I'm not a native speaker)
12:52mmeix(just now found it easier: "case x :up ... :down ...")
12:53TimMcoh, definitely
13:02ionthasHei there. Is there any way to destructure a vector comming from a function call inside a let?
13:03Bronsa,((fn [x] (let [[a b] x] b)) [1 2])
13:03clojurebot2
13:03TEttinger,(let [[x y] (vector 1 2)] (+ x y))
13:03clojurebot3
13:04TEttinger,(let [v (vector 1 2) [x y] v] (+ x y))
13:04clojurebot3
13:04TEttingerdoes one of those satisfy the request, ionthas?
13:07ionthasyes thanks!
13:07justin_smithor ##(let [[_ a b] (range)] (+ a b))
13:07lazybot⇒ 3
13:17TEttingerjustin_smith: show-off
13:24mmeixIf someone experienced would be so kind and have a look at https://www.refheap.com/101292 ... thanks!
13:25mmeix..
13:27xemdetiammeix, here is some advice I see passed around from time to time about style. https://github.com/bbatsov/clojure-style-guide
13:28mmeixah, thanks - will look into it
13:30xemdetiaand if my understanding of what you are trying to do is correct you would be more functional if you used map instead of a loop. It's just not obvious to me since I am unaware of music what you are trying to do there
13:30xemdetiabut smaller functions glued together with map seems more appropriate
13:31mmeixit solves a graphical problem: on which side of the stem do noteheads go in music notation
13:32mmeixlok, will try to
13:32mmeixbreak it up in smaller parts
13:32mmeixthanks!
13:32xemdetiaright, and since you are basically saying 'foreach note do a thing and generate a value' that is really what map is for
13:34mmeixtried this first but had the problem, that I need to do "book keeping" about already occupied positions (this is what "slots" collects for me)
13:35mmeixsince every next value (note) needs to know about this to find its value
13:36mmeixcouldn't wrap my head around doing this in parallel
13:36mmeixbut will try - thanks fpr advice!
13:36xemdetiawell you may not be able to if it is a natively sequential process
13:38xemdetiaif the processing of an element is dependent on the elements adjacent is no longer trivially parallelizable
13:39Crate_if you're just keeping/combining state as you accumulate elements tho, that's a reduce/fold
13:39mmeixyes, this is the case: the placement of a note is dependent on the ones before it
13:39Crate_which i feel like might work here
13:40mmeixreduce/fold is in core, or in another ns?
13:40Crate_reduce
13:40Crate_in core
13:40mmeixreduce I know
13:41mmeixfold I didn't
13:41Crate_fold is just what its called in other langs sometimes
13:41mmeixok
13:41xemdetiayeah a reduce does make sense here
13:41xemdetiaI am just not thinking :)
13:42mmeixI tried with reduce, but couldn't wrap my head around 'keepng the state'...
13:43xemdetiadid you do the (reduce f val coll) style or did you try using (reduce f coll)
13:43mmeixreduce f val coll
13:43mmeixbut val is somehow multidimensional
13:44mmeix(not sure though)
13:45xemdetiaaccording to your problem you are returning a list of vectors
13:45mmeixyes
13:45xemdetiaso would it break the universe if you returned a list of maps
13:45xemdetiamight be easier to work with
13:46mmeixI tried with maps, with the pitches as keys, but the problem is, that pitches can occur multiple
13:47mmeixso I would have to create some sort of index
13:47xemdetiawouldn't the list itself be implicitly the order?
13:47mmeixah, ok
13:47xemdetiaI mean I am assuming you are doing music graphical things going left to right in common notation
13:47mmeixyes
13:48xemdetiaso if first is the leftmost note and last is the rightmost note
13:48xemdetiathen you don't need an index and can just draw from it as a sequence
13:48mmeixbut in this case it's about arrangement of noteheads on a single stem
13:49xemdetiaso the case I indicated would not be true then
13:49xemdetiaand my assumption was wrong :)
13:49xemdetiaeven still a list of maps could handle this as part of a reduce
13:50xemdetia({:pitch [a b] :stemside :n}) would be equally as valid right?
13:50mmeixhttp://blog.steinberg.net/wp-content/uploads/2014/02/acc-stack-finale.png
13:50xemdetiaso if you were in a situation where you were trying to merge dots to a single stem
13:50xemdetiayou could join them that way
13:51xemdetiaso is your goal to resolve an individual stem or many stems
13:51mmeixone stem
13:51mmeixand then the next :-)
13:51xeqimmeix: is next-free-slot the same as (first (remove (set (sl p)) [:n :f :sn :sf]) ?
13:52mmeixlet me read this for some seconds ...
13:53mmeixah!
13:53mmeixmust play around with this - thanks!
13:53xemdetiaso maybe a map like { :a :n :b :f } would be perfectly fine for a shared stem
13:54mmeixyes, this would work
13:54xemdetiaand make it so the key's existence in the map is implying it is there and the value is what you want to draw
13:54mmeixI see
13:55mmeixthis is all great input - really appreciating it!
13:56xemdetiayeah I think something that you were missing is that the structure of your data is allowed to determine part of your value, e.g. an existence in a map or the order of a list.
13:56xemdetiathat would definitely help you be more clojure-y
13:57mmeix(beginning to understand)
13:57mmeixit's quite a journey :-)
13:57xemdetiaI mean you don't have {:length 5 :value [1 2 3 4 5]} you just have [1 2 3 4 5] and as a value on its own you ask it how long it is via a function (count [1 2 3 4 5])
13:58mmeixyes, this I understood, but obviously I didn't see the data pattern
13:59xemdetiayep, you could see that with what you wrote but sometimes it's hard to get out of the problem domain to see it
13:59mmeixso my reducing function would need to ask all former elements somehaow
14:00xemdetiawhich is fine, that's available through val
14:00mmeixok
14:00xemdetiabut you should say that this function works on one stem at a time, and this function composes multiple stems
14:00mmeixno, not really
14:00xemdetiaor maybe better described: this function takes the description from a vector and makes a stem, and this other function composes many stems
14:01mmeixsometimes a stem gets split, graphically
14:01xemdetiaright with the 'flip' case in the image you showed right?
14:01mmeixyou are talking about the doc string?
14:02xemdetiayeah I can only go by that
14:02mmeixyes: if a notehead cannot go on the proper side of the stem, it has to flip over
14:02mmeixwithout colliding with other notes already there
14:02xemdetiabut I mean then you have a recursive problem definition. A stem with one notehead writes to the normal side
14:02mmeixyes
14:03xemdetiathe n+1 stem writes to side flip or normal based on the last n noteheads already decided on
14:03mmeixright
14:03mmeixthe n+1 notehead
14:03mmeix(not the stem)
14:04mmeixthe noteheads attach all to a single stem
14:04xemdetiasorry, but I think you got what I mean
14:04xemdetiaand if you need an implict order for pretty printing
14:04xemdetiawell you are already using a sort somewhere
14:05xemdetiaso if things are in a known order thats meaningful to you, and you are starting with a trivial basecase then iterating n+1 until you resolve all n noteheads should be not that bad
14:06mmeixok: I'll learn to calculate the n-2, n-1 ... cases into n
14:06mmeixreading back the result val
14:06mmeixso far
14:06mmeixright?
14:06xemdetiayep, since at each application of f during the reduce is the n+1 case
14:08mmeixthe difficulty was, that sometimes f needs only the last n, but sometimes it has to look it 2 or 3 vals back,
14:08mmeixthere are several possible combinations
14:09mmeixbut yes, I had the feeling, that I don't need a loop really
14:10xemdetiammeix, well that's where the sort comes in
14:10xemdetiaif everything is in the order you expect it to be in so you can always work from beginning to end consistently then that would resolve any weirdness
14:11mmeixyes ...
14:13xemdetiaI am imagining your problem like this. given a list of #'s if for a given number I, I-1 = n-1 then do the opposite of n-1's direction
14:13xemdetiaotherwise do normal direction
14:13mmeixyes, that's the simple case
14:13mmeixbut there are cases, where this doesn't work
14:13mmeixalas
14:13xemdetiacan you show me one of those cases?
14:14xemdetiaI am too unfamiliar with what you are trying to do
14:14mmeixjust searching ...
14:16mmeixcan I paste a png here?
14:17xemdetiawell you could use imgur or something
14:17xemdetiaI mean unless it is nsfw music notes or something
14:17mmeixhttps://www.dropbox.com/s/k0wfniq1gsawmeg/Split%20Stem%20Cluster-2.png?dl=0
14:18mmeixthis is one of those more complicated cases
14:19mmeixthe calculaton begins - in this case - with the highest note head
14:19mmeixand the works down
14:19xemdetiawell that's what I say if you have an ordered list
14:19mmeixyes
14:19xemdetiagoing by my previous logic the vector would be [1, 2, 3, 5, 6]
14:20xemdetiabecause 3,5 fail the adjacent test it would be normal normal
14:20mmeixor rather [1 2 2 3 5 6]
14:20xemdetiais that thing that is tangentially attached part of the same stem?
14:20mmeixyes
14:20mmeixa "split stem"
14:21mmeixbecause this one doesn't fit on normal neither on flipped
14:21xemdetiawhat does it mean?
14:21xemdetiais it because it is a # note or something that normally would be put there?
14:21mmeixit belongs to the chord, but there is just not enaough room to place it on the normal stem without colliding
14:22mmeixthe accidentals are another complication
14:22mmeixand both those have different pitch, yes
14:23xemdetiait seems like you might have to change how you are structuring the problem and first do a pass where you bucket every notehead into someplace that is meaningful
14:23xemdetiaand then process that the way I was describing before
14:24mmeixso two passes, in a way
14:24xemdetiabecause you are effectively saying 'I have only so many buckets, and if a bucket is already filled it goes in the overflow bucket, and if that overflow bucket is filled it goes in a third bucket'
14:24mmeixyes
14:24xemdetiaso really first you should make some structure that says 'here are all the noteheads that should go in bucket #3'
14:25mmeixbut this depends on the situation, and cannot be calculated beforehand for every case
14:26mmeixbut I understand the message
14:26xemdetiaI am not saying it should be, but how I look at it is that you have a stem with six noteheads
14:26mmeixyes
14:28mmeixbut it should be possible to decide one by one, in which bucket the heads should go, you are right
14:29mmeixanother similar problem comes with accidental placement, this is a really devilish one
14:29mmeix:-)
14:29faveteli1guiswhat am i missing in this code https://gist.github.com/3e0b0a5d20d361128f9d?
14:30mmeixthanks again for thinktanking!
14:31xemdetiano problem it is an interesting formatting problem
14:32TimMcfaveteli1guis: An explanation of why you are dissatisfied with it.
14:33xemdetiaif accidentals are 'wiggly stacks of whole notes' according to google then the same bucketing strategy might work there
14:33justin_smithTimMc: well, a number will have a nil :beff
14:34justin_smithso it probably needs a default dispatch
14:34TimMcjustin_smith: I was trying to prompt for e.g. a stack trace. :-P
14:35faveteli1guisjustin_smith: does wy does not the dispach function return 1?
14:35justin_smithfaveteli1guis: ##(:beff 1)
14:35lazybot⇒ nil
14:36justin_smiththe dispatch function returns 1, but when you call (jump 1) or (jump 2), there is no dispatch for that
14:36faveteli1guisI thought it did ##(:beef {:beef 1})
14:36lazybot⇒ 1
14:36justin_smithwhy would it do that when you didn't write that?
14:37justin_smith(jump 1) is going to call (:beff 1) which will come up with no method found
14:37faveteli1guisI want to use :beef as dispatch function and i send {:beef 1} as input to the multi method
14:37justin_smithright
14:37faveteli1guisaa ok now i see thanks :)
14:38faveteli1guiswas blindly looking at the first call
14:38mmeixthankfully we beginners get lots of help here :-)
14:38justin_smithso maybe you wanted (jump {:beff (inc v)})
14:39justin_smithor maybe you want jump to have a default method that handles numbers
14:40faveteli1guiswould trampoline work for mutualy recursive multimethods?
14:40faveteli1guisto make them not stack overflow?
14:40justin_smithI guess you could use find-method
14:40justin_smithand return that
14:41justin_smith(doc find-method)
14:41clojurebotIt's greek to me.
14:41justin_smith(doc get-method)
14:41clojurebot"([multifn dispatch-val]); Given a multimethod and a dispatch value, returns the dispatch fn that would apply to that value, or nil if none apply and no default"
14:41justin_smithso you could combine trampoline with calls to get-method
14:43justin_smithor anonymous functions that involve calls to multimethods, even
14:47mmeix(inc xemdetia)
14:47lazybot⇒ 4
14:47faveteli1guisjustin_smith: why is it not working to just put the first call in trampoline? im not getting any errors
14:48faveteli1guishttps://gist.github.com/favetelinguis/3e0b0a5d20d361128f9d like so
15:12justin_smithfaveteli1guis: that usage of trampoline requires returning a function to call
15:12justin_smithalso, you'll run into the fact that jump is not defined for 3
15:19TimMcdevn: Actually, I can't tell if Rust's "procedural macros" manipulate ASTs vs. turn a token stream into ASTs.
15:19TimMcBoth work, I guess -- you can build the former from the latter.
15:20justin_smithTimMc: the latter lets you define new tokenizing rules, while the former does not (kind of like the reader-macro / macro distinction in LISP I guess)
15:20TimMcyeah
15:21TimMcDo you think I'm right about being able to build one from the other?
15:24justin_smithit's one way - the token stream to AST transform is a superset of transforming ASTs isn't it?
15:25TimMcWhat about recursive macroexpansion?
15:26TimMcI wonder what the compiler plugins have access to.
15:28justin_smithgiven the ability to take a token stream and return an AST, implementing transformation of that AST (like recursive macroexpansion) should be straightforward
15:29justin_smithas an ad-hoc step, even if that step does not formally exist
15:31TimMcI guess it woul dbe like a lisp-2, though.
15:32TimMcOh, no, I misunderstood that -- that's fns vs. data?
15:32justin_smithyeah
15:33justin_smiththe token stream to AST thing does not need to enforce that
16:44kaiyinhttps://gist.github.com/kindlychung/4745feeaec628cc8cda1 what does this cost function actually mean?
16:46amalloyit's a mystery, kaiyin, without understanding the context. presumably it is some sort of heuristic for a search algorithm in a specific search space laid out in the book
16:48justin_smithkaiyin: it's leading up to an introduction of an implementation of A* - it may help to look up A* and see what that's about
16:48justin_smith$google A* djikstra
16:48lazybot[Dijkstra's algorithm - Wikipedia, the free encyclopedia] http://en.wikipedia.org/wiki/Dijkstra's_algorithm
16:49kaiyinok, thanks.
17:30m1dnight_Hi, I was reading up on sanitizing my SQL before reading it/storing it from/in postgres. I found Cascalog which looks super awesome, but I'm wondering if somebody can point me in the right direction of "doing it myself". By it i mean make sure im not vulnerable to injection.
17:30m1dnight_Maybe fool around and build the minimal DSL myself..
17:32TimMcm1dnight_: You shouldn't "sanitize" SQL. Use parameters.
17:32justin_smithm1dnight_: are you using clojure.java.jdbc? if so, you can ensure that any parameters are used via parameterized queries
17:32m1dnight_(sanitize is a term i picked up reading google-fu)
17:33justin_smithm1dnight_: it's a flawed paradigm, as the security history of systems that count on sanitization will testify
17:35m1dnight_okay i think I misunderstood what parametrized queries were. I'm reading up on that now.
17:35m1dnight_justin_smith: im using that indeed
17:36m1dnight_thanks for the info, even though off topic guys
17:36justin_smithit's relevant because you are doing it via a clojure lib :)
17:37sandbagscan anyone remind me the name of that nice search engine that can search across all Clojure projects in clojars?
17:37sandbags(search sources i mean)
17:37justin_smiththe difference is that with a parameterized query, string contents can't be interpreted as SQL syntax, instead of escaping the string, you are getting a context where the string can't be an sql command
17:38sandbagskind of a cross-reference doc search/browser thingy
17:38m1dnight_I was just thinking about it justin_smith . Sanitizing input does not prevent that at all indeed.
17:38justin_smithsandbags: it's on the tip of my tongue - I know the one you mean
17:38sandbagsjustin_smith: annoying isn't it ;-)
17:38justin_smithsandbags: http://crossclj.info
17:39sandbagsbravo! thank you
17:41m1dnight_I recall somebody in #java saying that somebody should build something like that for java :D
17:41m1dnight_also, it has the cover of mutter as favico, if im not mistaken
17:41m1dnight_:D
17:42justin_smithm1dnight_: I thought that was a statue of the buddha
17:42m1dnight_hmm, that might look more like it
17:43m1dnight_oh yeah, im wrong :D I just looked up the cover. It's from another angle.
17:43justin_smithmutter, the rammstein album?
17:43m1dnight_yep
17:44justin_smithyeah, I think it's pretty similar to one of these statues https://s-media-cache-ak0.pinimg.com/originals/be/2e/47/be2e473783b3779164af51030252ab00.jpg
17:45justin_smithnew app idea: reverse image source for favicon.ico
17:46m1dnight_yeah definitely one of those statues
17:46m1dnight_cool site though
17:46clojurebotHuh?
17:46m1dnight_yes clojurebot !
17:46TimMcLove that site.
17:47TimMcm1dnight_: Depending on the definition of sanitize, it also means you can't enter names like O'Reilly, etc.
17:47TimMc(That's the stupider version of the term.)
17:48justin_smithinsanitize: https://github.com/prismofeverything/zalgo
17:48justin_smithI introduced my friend/co-worker to zalgo, and he immediately went and made the above lib
17:50justin_smithpossibly the best definition I have ever seen: https://github.com/prismofeverything/zalgo/blob/master/src/zalgo/core.clj#L146
17:50TimMcNeeds more unevenness and mid-height combining chars, I think.
17:51TimMcOh no, mojibake? https://github.com/prismofeverything/zalgo/blob/master/src/zalgo/core.clj#L101
17:51justin_smithcombining characters can do weird things when taken on their own
17:53justin_smithor maybe some errors have snuck into that codebase
17:53TimMcThey should just display offset at worst.
17:54TimMcIs your coworker on Windows?
17:54justin_smithOSX
17:55justin_smithare json-web-tokens worth using?
17:56TimMcDepends n your security and availability requirements.
17:56justin_smithdo you know of / have a good overview?
17:56TimMcI think they're just a formalization of the notion of HMAC in a web context.
17:57TimMcI haven't read up on them properly, though.
17:58justin_smithyeah, I am trying to do exactly that, someone wants to use them to persist credentials, I am trying to figure out how good an idea that might be
17:59justin_smithI'm seeing references to vulns as recent as April first
18:13TimMclink?
18:13justin_smithhttps://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries/
18:14TimMcthanks
18:15TimMc"This puts us in an awkward position: in order to validate the token, we have to allow attackers to select which method we use to verify the signature."
18:15TimMcInteresting.
18:16TimMc"Meet the "none" algorithm"
18:17TimMcლ(ಠ益ಠლ)
18:18justin_smithhaha
18:19TimMcfucking nope
18:20TimMcnope nope nope
18:20justin_smith"nope" algorithm: treats all contents as invalid
18:21justin_smithTimMc: yeah, that bug left me feeling very skeptical about the whole thing
18:22TimMcGive it another year and let Alexander Homokov take a swing at it, then reevaluate.
18:22justin_smithgood plan
18:22TimMcI'm pretty sure this is worse than rolling your own HMAC'd JSON.
18:22justin_smithyeah, I'm just gonna use ring session, and then cross-correlate with a store that the websocket client can reference
20:19sg2002Hello. I know there are many cider users here... Are there any effective ways of navigating my cider repl history? I know about M-p and M-r, but they're not as useful as the generic M-r in comint.
21:24justin_smithsg2002: I assume you are using a history file between sessions?
21:30sg2002justin_smith: Hello Justin. I've just found the solution to my problem. It's just that cider history search is kind of weird. You do M-s to enter the pattern and then M-p and M-s to cycle between candidates. I think I already discovered that, used for some time and then forgotten. It's just kind of a different convention. And it's weird that cider does not inherit comint.
21:55eraserhdNo remove-keys?
21:55eraserhdOh, it's just dissoc :/
21:55gfredericksdissoc?
21:56gfredericks,(def remove-keys dissoc)
21:56clojurebot#'sandbox/remove-keys