#clojure logs

2014-12-09

00:00dwysockiwell, my project depends on antlr and asm
00:00rritochFor my personal projects I'm trying to get away from gen-class dependence
00:00dwysockiperhaps those are the real issues
00:00dwysockias they're 100% java libraries
00:01dwysockiI think I'm just going to settle for marginalia here
00:01rritochjustin_smith: btw, I was able to implement custom numeric types
00:02dwysockiI would rather use codox, but it's not really important
00:02rritochjustin_smith: It is giving me problems with my unisgned types though since the minus function uses negate
00:02dwysockithis was just me trying to add nice documentation onto a school project
00:02rritochjustin_smith: So I'm now working on adding, or re-adding, real minus support
00:05rritochjustin_smith: Consensus is that clojure numeric type support of any kind is a hotly-debated topic, so this is probably going to be the point where this becomes a hard-fork.
00:06justin_smithI wonder if it would be easier to use signed types of at least twice the size. Since we have BigNum and all. And convert to the bitwise unsigned representation at the boundaries of the system as needed.
00:06rritochjustin_smith: Though this code does come at a price, my wife is really mad that I've been staying up till 5am coding
00:07rritochjustin_smith: Internally that is what my signed types are doing
00:08rritochjusting_smith: But I added a INumber interface, so when this version of clojure sees that interface, it knows to call those methods instead, to get the results to the various methods defined by Ops
00:09rritochjustin_smith: I've only found 2 bugs so far, the first with with the lt function, so I added a gt function to deal with it, that only is used when dealing with NumberOps
00:09rritochjustin_smith: The second issue is with minus using negate, since unsigned numbers can't be negated
00:10rritochjustin_smith: Other than that, it works fairly well
00:10justin_smith,(map (juxt + - * /) (range 3))
00:10clojurebot#<ArithmeticException java.lang.ArithmeticException: Divide by zero>
00:10justin_smitherr
00:10justin_smith,(map (juxt + - * /) (range 1 3))
00:10clojurebot([1 -1 1 1] [2 -2 2 1/2])
00:17rritochCan anyone explain the difference between add and addP, I'm really not sure what all these fP's are for
00:19justin_smithaddP checks for overflow
00:19justin_smithadd does not
00:19rritochjustin_smith: Ok, thanks :)
00:19justin_smithand it looks like addP promotes to BigInt
00:19justin_smithso there we go
00:19justin_smithP is promote I bet
00:19justin_smiththe difference between +' and +
00:19justin_smith$source +'
00:19lazybot+' is http://is.gd/OEoK2h
00:20justin_smithyup - notice that +. calls addP
00:20justin_smitherr +' calls addP
00:20justin_smithbut + just call add
00:21justin_smith,(+' Long/MAX_VALUE 1)
00:21clojurebot9223372036854775808N
00:21justin_smith,(+ Long/MAX_VALUE 1)
00:21clojurebot#<ArithmeticException java.lang.ArithmeticException: integer overflow>
00:21rritochjustin_smith: Hmm, well for my u1, u2, u4, promotion won't make any seense, so I'll probably unnimplement them, currently I just have them calling their non-promotional counterpart.
00:21justin_smiththat's the difference
00:21justin_smithI think not implementing them is better than implementing but not promoting
00:23rhg135anyone have a clue why leiningen.vcs is not picking this up https://www.refheap.com/94599 and it's in :plugins to load it in lein right?
00:24justin_smithrhg135: "leinenge.vcs.hg"
00:24justin_smithyou probably want another n in there
00:25rhg135thank you
00:25justin_smitheastwood is really good for finding errors like that
00:25rhg135man, i shouldn't be typing
00:25justin_smiththough that one would likely get caught by lein check too
00:26justin_smithbut anyway, eastwood is great, it will find stupid mistakes and save you a lot of time
00:26justin_smiths/stupid/trivial - the stuff that is easy to automatically detect but not always easy to see
00:26rhg135ill add it to my profiles.clj now :(
00:27justin_smithI keep meaning to add "lein do check, eastwood" as commit hooks for my clojure projects
00:27FriedBobStill need to clean my source texts up a bit, and tweak my algorith, but thenew one is coming along nicely.
00:27FriedBob(34 : Fluttershy: But I think of FIPS 140-2 compliance with the generated by the gaunt, lone creature was failing test for parsedfile provider instance.)
00:28justin_smithmarkov chain?
00:28FriedBobYeah
00:28FriedBobFound a more scalable example that what I first tried
00:28rhg135now i need to either fork leiningen quick or do some stuff with robert.hooke
00:29rhg135lein pom is hardwired to git for vcs
00:29FriedBobI'm not done compilnig my source texts, and it's already around 7 mb
00:30justin_smith"Along remember which she wood was onceived happy the wolf, butter to the brought living, "Good turned and dedicated in that from behind here, by the people, shall have thus father, who struggled her while Little Red Riding the earth.
00:30justin_smiththat's from my markov generator
00:33justin_smith But, in a larger screased dead shall measure of the does you have a portion the gave come and these honored world with here highly resting Hood knocked at the people, for her grandmother forth of the portion might here highly resolve thus far so well and so nobly advanced. It is altogether.
00:35FriedBobIhav a bunch of commit messages in mine, and it line wrapped (hard) to 80 chars, sogave me a lot of briken stuff,
00:35FriedBobSo I am having to clean that up to get better resules
00:36FriedBobI also still need to add 3 seasons of MLP:FiM transcripts still
00:36justin_smithmine builds the corpus on every run. It's actually very fast.
00:36justin_smithhaha, nice
00:36justin_smithmine was Little Red Riding Hood and the Gettysburg address
00:37justin_smith(for that example, it takes the files to use as command line args)
00:39FriedBobI'm using the Cthulhu Mythos, transcripts from MLP:FiM, MLP:EG, git commits to various Puppet Labs repos, and (sanitized) Jira ticket descriptions from said projects
00:39justin_smithoh, are you the one doing the lovecraft puppet labs tumblr?
00:39justin_smiththat is fucking hilarious
00:39FriedBobNo
00:39justin_smithoh, OK
00:39FriedBobThat's Branan, but he inspired me
00:40FriedBobI'm using some of the same corpus as him ( the it and jira bits)
00:40justin_smithPuppet Labs actually hosts the Clojerks meetups
00:40FriedBobWe host quite a few. I wish I was in Portland so I could attend more
00:40justin_smithare you nearby?
00:40FriedBobSpringfield, MO
00:40FriedBobSonot really.
00:40justin_smithoh, haha
00:40FriedBobBut I'll be in Portland next week
00:41justin_smiththere should be a Clojerks meetup next week
00:41justin_smithat Puppet Labs downtown I bet
00:41FriedBobI'll try to make sure I go
00:42FriedBobAssuming it doesn't conflict with one of mty already scheduled after work work outings
00:42justin_smithalso Voodoo Donuts is way overrated, but if you must go the one on the east side is nicer than the one downtown
00:43FriedBobI've not been there in any of my trips.
00:44FriedBobI had already figured out they were basically a tourist trap and there were better places to get maple bacon donuts
00:44FriedBob(not that I actually had a ahcne to visit said places)
00:58rritochAny suggestions on how to present these custom numeric types to clojure-dev once they are resolved, there are going to be at least 3 commits that all relate to this issue
00:58rritochI'm thinking I should create a separate branch for this feature, which only has one commit to produce it
00:59rritochProbably not important since it has a low probability of acceptance
01:01rritochWhich is really too bad because when it comes to vector operations, this system will make it possible to automate GPU and/or coprocessor accelleration.
01:04FriedBobCleaned up sources some more. Makes a huge difference.
01:04FriedBob(12 : Applejack: Wha! Wha... huh? The other friends are either checked in validation, and an internal security)
01:04FriedBobIt's almost getting to look real
01:07amalloyjustin_smith: i like king james programming better
01:17FriedBobTwilight Sparkle: I need to extend Windows::Handle from access the new code for the other hand, even though there is a colossal bats that nil resource fails the SQL query subtree of well-known group resources
01:18FriedBobIt's knida amazing what a difference just tweakinmg the formatting of the source makes
01:21rritochamalloy: What exactly is king james programming? I did some googling on it and all I find is bible quotes, but some are interesting https://news.ycombinator.com/item?id=7305122
01:21dwysockifor some reason marginalia only pulls out my doc strings for some functions and not others
01:22dwysockiI can't find anything explaining why
01:22amalloyyou followed the link from that ycomb page to http://kingjamesprogramming.tumblr.com/ and thought everything there was bible quotes?
01:22rritochdwysocki: Double check that your doc string is before the parameters, and not after
01:22dwysockirritoch: whooaa
01:23amalloyWe would like a procedure that expresses the concept of summation itself rather than only with particular sums — for example, (f 84 96) — it performs the work of the LORD
01:23dwysockiyou just blew my mind, rritoch
01:23dwysockiit didn't even occur to me that I could put the docstring before the parameters
01:23dwysockiexcept I've been doing it anyway in multi-arity functions
01:25rritochamalloy: Didn't even pay attention to the tublr post
01:25rritochamalloy: Anyhow, I've never really thought to apply the bible to programming, I know it's been done in physics with great success
01:27rritochamalloy: Anyhow, this quote here "All things come from God, through God, and return to God" Is clearly demonstrating a disign pattern, but I think it is a mistranslation. There are different words for God in the original language of the bible, so if I can find a better translation for that part I'm sure it gives some hints as to a good design system
01:29rritochamalloy: Either way, it seems to be referring to a function comprehension, like (comp God2 God1)
01:30rritochamalloy: I suppose it could be a function comprehension with itself, like (comp g g) but that deign pattern would be extremly difficult to apply
01:32rritochdwysocki: I've been down that road many times. That is why I always double-check my docs to make sure I didn't miss any docstrings, and to ensure the docstrings are in the right place.
01:35rritochHas anyone other than me noticed that just as you near completing a project, computer crashes are more likely? It isn't quite murphy's law, but this seems to happen to me very often.
01:36rhg135Its the, I call it, law of life
01:36FriedBobPretty sure that falls under one of Murphey's many laws
01:42dwysockiI think my project is finally complete
01:43dwysockithis is probably the greatest thing I've ever created
01:43dwysocki:')
01:43rhg135Link?
01:43dwysocki1 sec
01:43dwysockijust pushing everything to git
01:49dwysockiok, more than 1 sec
01:49dwysockilol
01:50FriedBobjustin_smith: Just got this one.. (73 : Info: Loading facts in Fillydelphia.)
01:52rritochFinally, the subtraction is working properly for custom (unsigned) types, and only had a minor computer crash.
01:53rhg135MCA are fascinating
02:02dwysockiok, here it is
02:02dwysockimy greatest work ever
02:02dwysockihttps://github.com/dwysocki/mini-java
02:03dwysockiothers before me have done the same thing
02:03dwysockibut I'm still impressed I pulled it off
02:04rritochdwysocki: Heh, Oswego... Trying to get a job at IBM?
02:05dwysockiright now I'm applying for grad schools in computational astrophysics / astroinformatics
02:05rritochdwysocki: Well your not far from the home of IBM
02:06rhg135Did it hurt?
02:06dwysockirritoch: where exactly is that?
02:06dwysockirhg135: it was less painful than I'd expected
02:06rritochdwysocki: It's in endicott.
02:07rhg135I applaud you
02:08dwysockirritoch: that's about as far as any other part of new york :P
02:08dwysockirhg135: thank you :)
02:08rritochdwysocki: My mothers, cousin's father (not sure what that makes him to me) was one of the original IBM execs, thats how I'm so familiar with IBM and their way of thinking
02:08dwysockido they have any clojure devs?
02:08rritochdwysocki: Hmm, really? I thought Oswego was only about an hour from elmira
02:08rritochErr, endicott
02:09rhg135dwysocki: I haven't even finished my lambda calculus compiler
02:09rritochMaybe it's elmira I was thinking of
02:09dwysockieh, only 2 hours actually
02:09dwysockinot as far as I thought
02:10rritochdwysocki: Oh, nm, I really was thinking of elmira. Your near syracuse, but it still looks like your only about an hour and a half away
02:10dwysockirhg135: now I have a strong desire to write a simple lisp compiler in C
02:10dwysockirritoch: yeah, syracuse is the closest city
02:11rhg135Goodness
02:11rhg135Goodness
02:11rhg135Oops
02:11rritochdwysocki: Actually, your not far from a major internet hub, I don't remember the name of it
02:11dwysockirochester?
02:11dwysockiwait
02:11dwysockiyou mean a city or a building?
02:12rritochdwysocki: I honestly don't remember, I just remember I was invited to the grand opening and just ignored the invitee because a 3 hour trip to visit a bunch of racks didn't exactly excite me.
02:12dwysockilol
02:16rritochAnyhow, I guess my clojure source hacking is coming to it's end. https://github.com/rritoch/clojure now supports dynamic namespaces and custom numeric types. There really aren't any other features I need right now.
02:20TEttingernice rritoch
02:21dwysockialright, it's past 2am
02:22dwysockitime to get some much needed sleep
02:22dwysocki'night all
02:24rhg135 dynamic namespaces?
02:25rritochrhg135: Yes, one moment, I'll get you a link with detalis
02:25rritocherr, details
02:29rritochSorry had to post to clojure-dev first, I wish I could edit posts there though, the typo in my latest post is painful to look at
02:29rritochrhg135: https://groups.google.com/forum/#!topic/clojure/O7xTmtsmKAE
02:30rhg135Thx
02:30rritochThe thread contains some implementation notes
02:30rritochIs it possible to moderate/delete your own post on google groups?
02:31rritochThis typo is painful
02:31rritoch> For review: Custon numeric types :(
02:38rhg135That's great
02:39rritochrhg135: Well, I need it to facilitate unsigned support in clojure
02:40rritochrhhg135: Unfortunatly, from what I hear, there is a lot of drama surrounding support for numeric types so chances are this fork is going to be a hard-fork.
02:40rritocherr, rhg135:
02:41rhg135I
02:41rhg135I've heard it's lengthy to get merged
02:42rritochThe support for the namespace isolation, even in this room, is limited, so if you like the features, try them out, and add your support for them in the forums so Rich Hickey will consider adding them to clojure.
02:44rritochI only posted the custom numeric types to clojure-dev though, and it takes about a day (with a signed contributor agreement) to get approval.
02:44rritochhttps://groups.google.com/forum/#!topic/clojure-dev/QF8P7_DK0rc
02:44rhg135I'm not on any yet, also I'll try it tomorrow
02:44rritochSorry about the typo, it's so painful *sniff* *sniff*
02:44rhg135Will later today :-)
02:47rhg135The only problem I see is (blob) + (blob)
02:47rhg135People be crazy
02:47rritochAnyhow, I appologized for the typo, it isn't the first time I've added verbal garbage to something that will be permanently recorded in internet history, but at least this way it may show up in searches correctly.
02:48gwenlohHello
02:48rhg135Hi
02:49rritochrhg135: Hmm, actually that is possible, you just need to extend the Blob type and implement the INumber interface, though it only works from this fork unless this gets added to the official version of clojure.
02:50rritochrhg135: Actually, now that I think about it, you need to wrap the blob type, since Blob's aren't numeric.
02:50rhg135I know, rritoch. I meant how people do crazy things with operator overloading
02:51rhg135Except clojure has none :x
02:51rritochrhg135: Yeah, well adding blobs would be an awesome feature since blobs require a lot of trivial code to work with.
02:52rhg135I meant it as a placeholder...
02:52rritochrhg135: oh, lol
02:52rhg135I'm clocking off now
02:53rhg135Its too late for logic
02:53rritochrhg135: I was thinking of https://docs.oracle.com/javase/7/docs/api/java/sql/Blob.html , even though it's an interface, the implementation will already provide it's own types for blobs which won't likely extend java.lang.Number.
02:54rhg135Ah
02:54rritochrhg135: The way I coded the feature, it must still be a Number AND an INumber.
02:54rhg135Good
02:55rritochrhg135: So it doesn't support unlimited crazyness.
02:55rhg135I once saw composition as + * and >>
02:56rhg135Just pick one
02:56rhg135Or better a comp function
02:58rritochHmm, well technically I would think the cons function would be a good function to do comp's
03:00rritochSince cons generally is used for applying one function to another, within macro's
03:01rhg135I think macros are the exception nobody mentions but all use
03:08rritochWell, comp can can be written as ##(cons 'f (list (cons 'g (list 'x))))
03:08lazybot⇒ (f (g x))
03:09rritochWhich was fairly common way of building structures in early LISP's
03:10rritochFor anything fairly complex, I still use cons a lot in macros
03:10rritochMostly because I haven't yet fully adopted the new clojure ways
03:10rhg135Hmm
03:15amalloyrritoch: really? even in CL i imagine you'd use ` and , to build most lists in macros
03:18rritochamalloy: Well, all let bound variables are available when you build structures using cons, and since cons is a core function (as is list) your as close to the "metal" as you can get.
03:19rritochI should say "where" core functions, I don't recall any let*, but that doesn't mean it didn't exist. I couldn't make much sense of LISP source code back then.
03:19amalloyboth of those statements sound like meaningless fluff to me. let-bound variables are all available in ` via the use of ~ or , (depending on flavor), and being close to the metal doesn't mean anything: you're just building lists one way or another
03:19rritocherr, were core functionss
03:20rritochWell, most code I saw back then used cons as aposed to `
03:21rritochI honestly don't recall ` existing, but this was a long time aago
03:23rritochIf you find any LISP code from about 20 years ago, you'll see cons was one of the most commonly used functions.
03:24rritochThis was in my college days, long before I knew anything about compiler design.
03:24rritochAnyhow, I have to run to the store. I'll probably bbl.
03:25RaynesSure am gonna miss that kid
03:51kenrestivowell the idea of doing an embedded project in clojure has been seducing me for years now, finally got to do one, and never again.
03:53kenrestivobut i guess at least it was worth doing.
04:12shemkenrestivo: why never again?
04:13kenrestivoit's just not fun on a resource-constrained system.
04:15kenrestivo10 minute, 15 minute repl restarts are the major pain point.
04:16kenrestivomight try the "fastload" branch but it appears it was just dead-end experiments in may/june, doesn't seem to be any path towards it becoming released.
04:16shemouch. i suppose new android phones are not quite that bad? i've been thinking of playing with neko when i get a new phone
04:17kenrestivothe android stuff might be further along. i'm not on android.
04:31kr-Hi, does anyone have any idea why the following tiny programs display function will print some output but not another to the repl? -> https://gist.github.com/KristoKoert/e09652bdda8acab8b214
04:35jonathanjis there convenient syntax for getting values for multiple keys from a map?
04:38jonathanji guess something like (vals (select-keys ...)) is convenient enough
04:40kr-You could (for [key [:a :b :c]] (key my-map)) maybe?
04:46jonathanjsince i need to pull certain values out maps in a seq i settled on (map #(map % [:a :b]) m)
04:48schrottihm rich talks, in his talk simplicity matters about those hairballs
04:49schrottiwhen I use leiningen i also have them hairballs :/
04:49rhg135jonathanj: try juxt :-D
04:49rhg135It's so useful
04:49Glenjaminjuxt?
04:49clojurebotjuxt is usually the right answer
04:50Glenjamindoes clojurebot have a botsnack?
04:50rhg135I don't think so
04:51clgvclojurebot: botsnack
04:51clojurebotThanks! Can I have chocolate next time
04:51rhg135Hmm
04:51rhg135I was wrong
04:51Glenjaminclojurebot: chocolate
04:51clojurebotactually I decided I prefer botsnacks after all.
04:51Glenjaminhahah
04:51Glenjaminwell played
04:52clgv:P
04:52jonathanjrhg135: niiice
04:53clgvwe should give him an Eliza plugin ;)
04:53jonathanji wish Clojure had some uuid stuff
04:53jonathanjjava.util.UUID is kind of useless
04:54rhg135You could use machine learning and analyze this chat
04:54clgvschrotti: why? declarative dependency specification is great. lately I had to work through a scons build file which is actually python code that I either need to interpret myself or watch the output to see what it is doing. that's just horrible
04:54jonathanjand clj-uuid gives me a giant pile of warnings about how various things already refer to other various things
04:55clgvjonathanj: depending on which warnings you see you should probably :refer instead of :use it
04:55clgvooops :require was what I meant
04:55jonathanjclgv: i think clj-uuid is using :use
04:55jonathanjWARNING: == already refers to: #'clojure.core/== in namespace: clj-uuid.bitmop, being replaced by: #'primitive-math/==
04:55rhg135Wow it's 4am already
04:56jonathanji dislike :use for the same reason i don't do from X import * in Python
04:56rhg135Bye everyone
04:56clgvjonathanj: ah, so the warnings are within its implementation.
04:56clgvjonathanj: what it the problem with java.util.UUID?
04:58kr- Does anyone have any idea why the following tiny programs display
04:58kr- function will print some output but not another to the repl? I'm kinda stuck :/ .. ->
04:58kr- https://gist.github.com/KristoKoert/e09652bdda8acab8b214
04:58jonathanjclgv: all i really wanted was a v4 UUID and the hex representation of it, turning a java.util.UUID into that appears to involve a giant pile of code
04:58clgvkr-: because `for` is lazy
04:58clgvkr-: you want to use `doseq` instead
04:59jonathanjin Python it's uuid.uuid4().hex, with clj-uuid it's (to-hex-string (v4))
05:00kr-Many thanks clgv :)
05:01clgvjonathanj: you mean like that? ##(let [uuid (java.util.UUID/randomUUID)] (format "%X%X" (.getMostSignificantBits uuid) (.getLeastSignificantBits uuid)))
05:01lazybot⇒ "2F45C495EE064E04ADF49F69AB4725F9"
05:05jonathanjclgv: yeah, i guess that is what i want
05:08jonathanjclgv: thank you
05:08clgv:)
05:09jonathanjclgv: is it possible to do that without the intermediate value?
05:10jonathanjthe intermediate variable, i mean
05:10clgvjonathanj: the actual UUID?
05:10jonathanjwithout the let
05:10clgvwhy would you want that?
05:11clgvthere is no performance penalty or similar on a let
05:11jonathanji thought it might read better
05:11clgvjust wrap that code in a function that fits your use case: (defn random-uuid [] ...) or (defn uuid->hex [uuid] ...)
05:15someplacefor extracting a number based off a regex.. I have this mess of a line, can it be cleaned up?
05:15someplace (-> (re-seq #"\(\d+,\d+,(\d+)\)" (first split-level)) last last str->int)
05:15cursorkjonathanj: What's wrong with ##(str (java.util.UUID/randomUUID))
05:15lazybot⇒ "7a64bae2-c79b-4b89-8f74-08eb9220474e"
05:16jonathanjcursork: just cosmetics, i don't like the dashes in a URI
05:16clgvjonathanj: ah right, you should take care of leading zeros in the code above
05:19clgvjonathanj: ##(let [uuid (java.util.UUID/randomUUID)] (format "%016X%016X" (.getMostSignificantBits uuid) (.getLeastSignificantBits uuid)))
05:19lazybot⇒ "617A39D4CBA24A718B37FAD8DFC71E7D"
05:20clgvjonathanj: ##(let [uuid (java.util.UUID. 47, 11)] (format "%016X%016X" (.getMostSignificantBits uuid) (.getLeastSignificantBits uuid)))
05:20lazybot⇒ "000000000000002F000000000000000B"
05:26SirRobinHi all
05:27SirRobinI'm using vim-clojure-static
05:28SirRobinand it sets iskeyword to match symbols in clojure
05:28SirRobinif I comment that, it breaks identation & coloration
05:29SirRobinis there a way to set iskeyword to something different for me, and let the plugin have its own?
05:30SirRobin(I'm just used to the default iskeyword and would like to use that when editing)
05:43schrotticlgv: because some deps require other deps, that will be downloaded with it
05:43schrottiso you end up with all that extra stuff you don't even know
06:07clgvschrotti: so what? you dependencies need those and you don't need to care. it would be really bad if you had to download the deps of your deps yourself
06:09clgvschrotti: if you can decide between different libs you can use the number of transitive deps as criterium for the selection if you like
06:17schrotticlgv: i see your point with manually downloading it
06:52dysfuni'm getting this error: CompilerException java.lang.IllegalArgumentException: Parameter declaration should be a vector, compiling:(tk0/util/response.clj:46:43) but it's just standard multiple arity function syntax and it works fine if i paste it in a repl
06:52dysfunit's at the top level in a namespace, everything is nested correctly etc., what am i missing?
06:52clgvdysfun: did you forget the parens?
06:53dysfunhttps://www.refheap.com/aff239e032c034fbc42298b82
06:53clgvdysfun: you need to provide a gist.
06:53dysfuni did not
06:53dysfunheh, ahead of you :)
06:53clgvare you sure that this is the offending function?
06:54dysfunthat's the line it's pointing at
06:54dysfunthe last line of that snippet
06:54clgv`assoc-in-smartly` is a function?
06:54dysfunit's definitely not a cacheing thing, i've inserted whitespace to change the line number
06:54dysfunyes, it is
06:54dysfunnot a macro or anything
06:55dysfunas i say, works fine at the repl
06:55dysfunhttps://www.refheap.com/32d031d7cfd3b8ce283073369
06:55clgvdid you restart the repl, already? (with lein clean in advance)
06:56dysfunof course :)
06:56clgvcan you provide a minimal snippet that can be compiled and has the same error? otherwise there is no more help to offer
06:57dysfunlet's see what i can do
06:57clgvI'd bet you find the error when trying to minimize the scenario ;)
06:57dysfunturns out that file has no external deps
06:58dysfunso i can actually show it all to you, what with it being open source
06:58dysfunhttps://www.refheap.com/8980afc3e6cee6780f8a3d1a1
06:58dysfunbut as you can see, there's nothing tricky in there at all
07:04dysfunbonkers, if i make it a single-arity function, it doesn't like it either
07:04clgvdysfun: yeah
07:04clgvbut all parens are matched correctly right?
07:04dysfunyes, first thing i checked
07:05clgvdysfun: if you comment `headers!` the error moves up to `status`
07:08dysfunclgv: which i commented out a minute ago :)
07:08clgvdysfun: try removing definitions from it until it stops throwing this error and then analyze the last thing removed and its effects on the remaining file
07:09dysfun*nod*
07:11clgvdysfun: if I comment out all after `headers!` it loads fine
07:11clgvso those line numbers seem to be wrong
07:11dysfunyes
07:11dysfunit's session!
07:11dysfunbut how?
07:12clgvdouble string ;)
07:12clgv"Returns" ""
07:13dysfunohhhh
07:13dysfunright, thus leaving it all open
07:13dysfungotcha
07:13dysfunthanks
07:13dysfunthought i was going mad
07:13clgvno just an empty string in position of the expected vector
07:14dysfunor that too
07:19dysfunit's a real pity there isn't a friendly channel like this one where you can discuss c++. it *badly* needs it, horrible language
07:34kungiI just saw a video where emacs sorted the required libraries at the top of a clj file automatically. What .el is this?
07:35dysfunyou might like to know there's #clojure-emacs for emacs-specific questions
07:36CookedGryphonkungi: slamhound
07:36kungidysfun: CookedGryphon thank you
07:36CookedGryphondoes a load of stuff like that, automatic imports, removing unused, organising what's there
07:38clgvdysfun: lately I have used clojure.de to articulate my feelings about c++ and certain libraries ;)
07:38dysfunclgv: one word: locales. Better known as hell.
07:38clgvdysfun: luckily none of my business ;)
07:39dysfun:)
07:39dysfunwish it weren't mine
07:39clgvdysfun: did you also hate the vast amount of semicolons in c++ after coming back from clojure?
07:40dysfunnot the semicolons per se, more the excessive syntax
07:40clgvthe strange placement of parens in c++ is almost no problem but all those semicolons ;)
07:40clgvdysfun: I had the impression I was programming while crawling on my hands and feet ;)
07:41dysfunheh
07:41dysfunyou know what, the error case of some code should never be a segfault
07:41dysfunperiod.
07:41clgvhow I miss those stacktraces.
07:41dysfunhave you seen how terrible LLDB is?
07:41clgvwell, c++ is scheduled for later today. now it's clojure time ;)
07:42clgvnope. what is LLDB?
07:42dysfunthe llvm debugger
07:42clgvah ok. never used llvm
07:42dysfuni mean obviously it's far more important to list the assembly you spat out rather than tying it back to any c++...
08:17jonathanjis there anything i can do to improve the startup times of clojure applications? (like lein)
08:25clgvjonathanj: do you restart it that often during development?
08:31jonathanji do
08:32jonathanjbut perhaps there is some way to avoid restarting my ring server just to run new code?
08:33weavejesterjonathanj: There are a few ways. You can just :reload, or use refresh from tools.namespace, or use a tool like Lein-Ring to refresh on file change.
08:34jonathanjas a more general curiosity, is likely that clojure applications will ever start up quickly? what's holding them back?
08:34rritochWhen should I submit my clojure features to JIRA?
08:34jonathanjweavejester: when you say :reload, what do you mean?
08:34Glenjamin(doc require)
08:34clojurebot"([& args]); Loads libs, skipping any that are already loaded. Each argument is either a libspec that identifies a lib, a prefix list that identifies multiple libs whose names share a common prefix, or a flag that modifies how all the identified libs are loaded. Use :require in the ns macro in preference to calling this directly. Libs A 'lib' is a named set of resources in classpath whose contents define a library of
08:34weavejesterjonathanj: You can reload a namespace in the REPL with (require namespace :reload)
08:34Glenjamineugh, why is :reload not in the docstring :s
08:34jonathanjhrm, i'm running my ring server with `lein ring server-headless`
08:35weavejesterjonathanj: But often you want to reload dependant namespaces as well
08:35clgvjonathanj: eager initialization of the whole clojure runtime causes the startup overhead
08:35weavejesterjonathanj: That should automatically reload files when they're changed.
08:35weavejesterjonathanj: What isn't reloading?
08:36jonathanjweavejester: i'm reasonably sure that nothing was automatically reloaded, do i need to configure anything to make it work?
08:36jonathanj(i will check again in a moment when i'm back at my development machine)
08:37weavejesterjonathanj: No, that should be the default.
08:39clgvjonathanj: my repls usually run for at least 1-2 hours
08:39weavejesterjonathanj: If it's not working, it would be useful to know the version you're using of Lein-Ring, and whether you're doing anything unusual in terms of source directories, ns declarations, or loaded data.
08:39clgvjonathanj: only when deftypes/defrecords are modified, than restarts might be needed more often
08:39clgv*then
08:59jonathanjweavejester: is there any output when it reloads?
08:59weavejesterjonathanj: Nope
08:59weavejesterjonathanj: Not unless you have a namespace that prints something when it loads
08:59jonathanjoh, maybe i overzealously reloaded my browser once and figured no output in the shell meant nothing happened
09:00jonathanjbecause i see now that it is reloading
09:00jonathanjsorry for being a dummy
09:01jonathanj(and thanks for writing wonderful software)
09:02weavejesterjonathanj: No problem :)
10:05simaoIs it possible to pass a map that is 'auto' destructured to a function that expects a map to destructure? for Example, I want to call f as (f mymap) where (defn f [{keys [a]}]) and mymap is {:a 1} instead of explicitly using (f :a 1)
10:06justin_smith,((fn f [{:keys [a]}] (inc a)) {:a 1})
10:06clojurebot2
10:07simaohm
10:07simaoI am doing something wrong then complains " No value supplied for key"
10:08simaowhen {:a 1} is in a variable
10:08justin_smiththat sounds like [& {:keys [a]}]
10:08justin_smithwhich is different
10:09simaoyes that's what I am using
10:09simaohow is it different?
10:09justin_smithright, that's not what you want
10:09simaoI also have a few params before the hash.. that's why I am using &
10:10justin_smith,((fn f [& {:keys [a]}] (inc a)) :a 1)
10:10clojurebot2
10:10justin_smith,((fn f [a {:keys [b]}] (+ 1 a b)) 1 {:b 2})
10:10clojurebot4
10:10justin_smiththat's what you want
10:11justin_smith& + keys means you want keys as args, not in a map
10:11lazybot⇒ #<core$_PLUS_ clojure.core$_PLUS_@bf35bad>
10:11justin_smithhaah
10:11justin_smithbut you see the difference, right?
10:11simaoah I thought & meant "optional arguments follow"
10:11justin_smithit does, but it interacts very oddly with {}
10:12simaook now it works
10:12justin_smith,((fn f [a & [{:keys [b] :or [b 42]}]] (+ a b)) 1)
10:12clojurebot#<NullPointerException java.lang.NullPointerException>
10:12justin_smitherr
10:12justin_smithI got that :or wrong
10:13dm3,(create-ns 'test-1)
10:13clojurebot#<Namespace test-1>
10:13simaobut this means I will always have to use the {} braces
10:13justin_smith,((fn f [a & [{:keys [b] :or {b 42}}]] (+ a b)) 1)
10:13clojurebot43
10:13simaoright?
10:13simaoI see
10:13justin_smithsee above for optional
10:13dm3,(binding [*ns* (find-ns 'test-1)] (def x 1))
10:13clojurebot#'sandbox/x
10:14justin_smithsimao: the trick is making the map a single optional arg, and not all the optional args (via the surrounding vector)
10:14dm3can anyone explain why the above doesn't work? docs for def suggest it should intern the var in the current (*ns*) namespace
10:16simaojustin_smith: but then I always have to pass a map, using {}, right?
10:16justin_smithsimao: see my last example, no map was passed, and it used the default
10:16justin_smith,((fn f [a & [{:keys [b] :or {b 42}}]] (+ a b)) 1)
10:16clojurebot43
10:17justin_smith,((fn f [a & [{:keys [b] :or {b 42}}]] (+ a b)) 1 {:b 12})
10:17clojurebot13
10:17simao ,((fn f [a & [{:keys [b] :or {b 42}}]] (+ a b)) 1 {:b 20})
10:17clojurebot21
10:17simao ,((fn f [a & [{:keys [b] :or {b 42}}]] (+ a b)) 1 :b 20)
10:17clojurebot43
10:17simaohm
10:18justin_smithdm3: ##(meta #'ns)
10:18lazybot⇒ {:macro true, :ns #<Namespace clojure.core>, :name ns, :added "1.0", :file "clojure/core.clj", :column 1, :line 5422, :arglists ([name docstring? attr-map? references*]), :doc "Sets *ns* to the namespace named by name (unevaluated), creating it\n if needed. referen... https://www.refheap.com/94615
10:18justin_smithit's not dynamic
10:18justin_smithbinding isn't the trick
10:18dm3##(meta #'*ns*)
10:18lazybot⇒ {:added "1.0", :ns #<Namespace clojure.core>, :name *ns*, :tag clojure.lang.Namespace, :doc "A clojure.lang.Namespace object representing the current namespace."}
10:18justin_smithdm3: ##(:dynamic (meta #'*ns*))
10:18lazybot⇒ nil
10:18dm3oh, yeah
10:18justin_smithsorry, forgot the earmuffs :)
10:19dm3thanks, the earmuffs confused me
10:19simaohm I was mssing [] arround {:keys ...}
10:19simaoargh this is confusing
10:19justin_smithsimao: destructuring is a bit odd at first
10:19justin_smithsimao: & [x] means "any number of args, the first one is called x"
10:20justin_smith& x means "any number of args, the collection of all args is called x"
10:20lazybotjava.lang.RuntimeException: Unable to resolve symbol: x in this context
10:20justin_smiththanks, lazybot
10:20justin_smithsimao: if you want to put it in one optional arg, then you are specifying one of the optional args, not the collection of all optional args
10:20justin_smiththus the need to do [{}]
10:21justin_smithto specify that {} is just one arg
10:22justin_smith&((fn [& [a b]] b) [1 2 3 4])
10:22lazybot⇒ nil
10:22justin_smitherr
10:22justin_smith&((fn [& [a b]] b) 1 2 3 4)
10:22lazybot⇒ 2
10:23simaojustin_smith: ah ok, that makes more sense now...
10:23justin_smith&((fn [& [[a b]]] b) [1 2 3 4])
10:23lazybot⇒ 2
10:23justin_smithextra brackets say "I am destructuring this one arg, not the whole arglist"
10:25justin_smithdestructuring in the arglist should be reserved for when you want to indicate to those calling your function the "shape" the data in the args should have
10:25justin_smithit's almost like a type signature
10:26simaoI see. It's quite confusing to learn this
10:26SagiCZ1so if i specify [a b] after & and call the function with 1 2 3 4 everything but 1, 2 gets thrown away?
10:26justin_smithSagiCZ1: you can use :as
10:27simaojustin_smith: thanks for your help
10:27justin_smith,((fn [& [a b :as all]] [b all]) 1 2 3 4)
10:27clojurebot[2 (1 2 3 4)]
10:27justin_smith,((fn [& [a b :as all :or {b 42}]] [b all]) 1)
10:27clojurebot[nil (1)]
10:27dm3justin_smith: interestingly, https://github.com/clojure/clojure/blob/clojure-1.6.0/src/jvm/clojure/lang/RT.java#L219 here the *ns* var is dynamic
10:28justin_smithmaybe the metadata is lying?
10:28Bronsayeah
10:28justin_smithdm3: ok I had more coffee
10:28Bronsa,(isDynamic #'*ns*)
10:28clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: isDynamic in this context, compiling:(NO_SOURCE_PATH:0:0)>
10:28Bronsa,(.isDynamic #'*ns*)
10:28clojurebottrue
10:28justin_smiththe issue is the code is compiled outside your binding block
10:28Bronsa,(-> #'*ns* meta :dynamic)
10:29clojurebotnil
10:29dm3metadata is lying
10:29dm3yep, still need to set! in order to allow def'ing
10:29dm3as in `in-ns`
10:30Bronsahttp://dev.clojure.org/jira/browse/CLJ-859 http://dev.clojure.org/jira/browse/CLJ-1057
10:30justin_smith ,(binding [*ns* (find-ns 'user)] (eval '(def a 1))) ;; will work in local repl
10:30clojurebot#'user/a
10:30justin_smithoh, and it works here too!
10:30dm3yep
10:30dm3thanks
10:30dm3I'll go with set!
10:31justin_smithyeah, better to avoid eval anyway
10:31EvanR,(swap! (atom 0) inc)
10:31clojurebot1
10:34dm3what's the custom here?
10:34dm3inc justin_smith
10:34dm3no
10:34dm3,(inc justin_smith)
10:34clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: justin_smith in this context, compiling:(NO_SOURCE_PATH:0:0)>
10:34dm3oh well
10:35EvanR(dec dec)
10:35lazybot⇒ -1
10:35dm3(inc justin_smith)
10:35lazybot⇒ 155
10:35justin_smithdm3: it only looks like clojure code
10:35justin_smithit doesn't even respect the semantics (inc shouldn't mutate)
10:35justin_smiththanks :)
10:38teslanickBug report: replace (inc ...) with (swap! user-name inc)
10:38justin_smithhaha, that would be a good idea
10:38EvanR(swap! user-name (constantly 9999))
10:44justin_smith$mail rritoch replying to back scroll: I find crashes most likely when I am using some variety of Windows, or if my hardware needs replacing.
10:44lazybotMessage saved.
10:55justin_smithshem: regarding some back scroll, I would hardly call android embedded. Android phones are more powerful than the desktop I learned to program on.
10:55ppppaulpprint in clojurescript?
11:00brucehaumancemerick: you here?
11:00cemerickbrucehauman: yup
11:01brucehaumancemerick: I just filed an issue on cljsbuld https://github.com/emezeske/lein-cljsbuild/issues/345
11:01brucehaumancemerick: it’s not about the other thread
11:01cemerickyeah, I saw
11:02brucehaumancemerick: I’m planning on devoting time to look at this today
11:10cemerickbrucehauman: replied
11:28shemjustin_smith: yes indeed, didn't mean to imply that. just came to mind. and quite recently people moaned about slow repl starts there. but not in 15 min. category, more like one minute or so.
11:28mkr00Any idea how to transform "input" to "output", see https://gist.github.com/kremers/4d72fb02a05ad54081be
11:29mdrogalisWhat's a good way to execute a Clojure form before a Leiningen plugin runs? I need to make a call to (Class/forName ...) before running Joplin to get a JDBC driver registered.
11:30mkr00I tried to solve it with 'reduce' but holding the reference to the last element was itchy
11:30llasrammdrogalis: a "way" to probably do it (maybe not "good way") would be to unquoted-reference ~fully.qualified.ClassName in your project file
11:30llasram(assuming by "plugin" you are talking about something which runs in the Leiningen VM)
11:30hiredman /win 19
11:31mdrogalisllasram: Hmm. Could work. Icky indeed, though.
11:31mdrogalisI wonder if I could pull it off with prep-tasks.
11:31llasramGotta keep track of those
11:33clgvlazybot can do that ;)
11:34clgv(inc hiredman-extra-space)
11:34lazybot⇒ 1
11:38hiredmanI donate all my extra space to the strategic space reserve
11:39justin_smithmkr00: how general does that need to be? how would the inputs vary?
11:40justin_smithdo we generally want to "step in" to an :ol with an increase of hN and "step out" with a decrease? or is this a very specific sequence to work on?
11:41mkr00justin_smith: :ol :li output with hiccup
11:42justin_smithOK, I assumed hiccup, but I don't see any :li being made here, and I was asking about how general the transformation has to be
11:42mkr00justin_smith: the element output will be [:li [:a {:href (str "#" name)} title]] for each link nested in :ol
11:43mkr00justin_smith: original input was {tag :tag [{{name :name} :attrs} title] :content} headings
11:43mkr00I tried to simplify it for the example
11:43justin_smithOK
11:44mkr00I've tried a loop/recur solution but I can't get the structure right.
11:44justin_smithit's definitely doable with a reduce
11:46mkr00I tried it with reduce with a structure of [last_element result] as first parameter. Changing last_element to build the hierarchy.
11:47justin_smithmkr00: I am going to use the index of :hN in the h list to decide how deep to do the update-in conj
11:48mkr00justin_smith: and how to build up the vector then?
11:48justin_smithconj
11:51mkr00justin_smith: does update-in work with vectors?
11:51justin_smithyes
11:51justin_smith,(update-in [[[]]] [0 0 0] conj :a)
11:51clojurebot[[[(:a)]]]
11:56clgv,(update-in [[[]]] [0 0] conj :a)
11:56clojurebot[[[:a]]]
11:56mkr00,(update-in [:ol [:ol [:ol [:ol [:ol [:ol ]]]]]] [0 0 0 0 0 0] conj [:li])
11:56clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to clojure.lang.Associative>
11:57justin_smithmkr00: one step too deep
11:57justin_smithtake out one of those 0
11:57clgvoff-by-one ;)
11:57clgvall of them those 0 ;)
11:58clgv,(update-in [:ol [:ol [:ol [:ol [:ol [:ol ]]]]]] [1 1 1 1 1] conj [:li])
11:58clojurebot[:ol [:ol [:ol [:ol [:ol [:ol [:li]]]]]]]
11:59mkr00ahH!
11:59justin_smithmkr00: yeah, I think that gets you very close to your reduce based answer
12:00justin_smithyou just have to make the indexes match up with the vectors you are creating
12:00mkr00,(update-in [:ol [:li] [:ol [:ol [:ol [:ol [:ol ]]]]]] [1 1 1 1 1] conj [:li])
12:00clojurebot[:ol [:li {1 {1 {1 ([:li])}}}] [:ol [:ol [:ol [:ol [:ol]]]]]]
12:02mkr00hmmm. I don't get it.
12:03justin_smithmkr00: it's no longer index 1 that holds the next vector
12:03mkr00How do the indexes change if an item is added to the vector?
12:03justin_smithin fact, the pattern is that you are putting the next vector at the last index
12:03justin_smithbecause you keep putting the vector at the end
12:04justin_smithyou could have put the vector first, and then it would always be at 0
12:04clgvthat pattern does not seem to be an elegant solution to any problem. you probably want some recursive solution.
12:05justin_smithclgv: if you look at the initial data, he wants the depth of nesting to insert each input to be based on a part of that input
12:05justin_smithand yes, there would be easier ways to do this if the data were structured differently
12:06mkr00clgv: I tried to do it with loop/recur but I didn't manage to get the structure right. conj-ing reversed the nesting. cons destroyed the type vector needed for hiccup
12:08justin_smithmkr00: I think it would be easier to build as {:data [] :children []} and then extracting the nested vectors from that when you are done building
12:08justin_smiththen you don't have the "magic index" problem any more
12:09justin_smithnot coincidentially, that will look more like the initial hiccup data you had :)
12:10mkr00my recursive "try" https://gist.github.com/kremers/d568c164809355d112f9
12:10mkr00compare_index is based on the last gist
12:11mkr00println output is perfect, just can't get the vector constructed properly
12:22trisshey all. I'm wanting to do some 2d drawing on html5 canvas
12:22justin_smithmkr00: getting your wanted vector from this will be easy https://www.refheap.com/94620
12:22trissis monet everyone's favourite for this or are there other libraries i should check out?
12:23ToxicFrogtriss: I've only used Kinetic, never heard of monet.
12:23justin_smith(updated the formatting just now)
12:23trisscheers ToxicFrog. I'll take a peek
12:26justin_smithmkr00: updated once more, to get rid of the noisey empty children
12:26justin_smithhttps://www.refheap.com/94620
12:27justin_smithmkr00: that has the exact shape you want, you just need to get vectors from those maps
12:28eraserhd,(into {} '((1 2)))
12:28clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to java.util.Map$Entry>
12:28eraserhd,(into {} '([1 2]))
12:28clojurebot{1 2}
12:29justin_smitheraserhd: map entries must be vectors
12:29justin_smith,(vector? (first {:a 1}))
12:29clojurebottrue
12:30YKYhello, I'm trying to RT.loadResourceScript to load a clojure source file using absolute path, but it doesn't work, why?
12:30justin_smithYKY: the word "Resource" in the name makes me think it needs a classpath relative path
12:31justin_smithresources are always relative to classpath
12:31YKYhas it to do with the fact that my file is not a class?
12:31justin_smithno
12:31justin_smitha resource is looked up relative to classpath, not to the filesystem
12:31YKYso I just need to put the source file in the classpath's directory?
12:31justin_smithso if it's in src/foo/bar.clj ask for "/foo/bar.clj"
12:32justin_smithyou need to add your source directory to the classpath, but lein does that by default
12:32YKYI'm using intelliJ
12:32justin_smithOK, intelliJ should also be setting up your classpath
12:33justin_smithalso, if you are using cursive, (which you should), cursive will use lein
12:33justin_smithbecause literally 99% of us are using lein
12:33justin_smith(us being "devs in the clojure community")
12:34TEttingerthere's a whole 1% not using lein somehow???
12:34lazybotTEttinger: Oh, absolutely.
12:35justin_smithTEttinger: I may have underistemated lein usage, for sure
12:36kungiWhat is the alternative to leiningen?
12:37kenrestivothis maybe? http://adzerk.com/blog/2014/11/clojurescript-builds-rebooted/
12:37justin_smithkungi: maven, manually constructing your classpath, letting a java IDE construct the classpath, boot
12:37CookedGryphonkungi: clojure itself and a few of the very very early projects still use maven
12:38justin_smithoh, even ant is an option
12:38CookedGryphonI don't see why you'd want an alternative to leiningen though, it's the best build system I've ever used, and I've used many
12:38justin_smithbut would you want to?
12:38CookedGryphonI use it for my plain java projects now
12:38justin_smithYKY: ^^ advice to live by
12:38justin_smithleiningen is really good
12:38kungiHmm I think I came the wrong way. I started using clojure for production before doing Java
12:38kenrestivoi did the same thing
12:38justin_smithkungi: me too
12:39justin_smithwoo clojure-first-club high fives!
12:39YKYI use lighttable sometimes
12:39kungijustin_smith: ^5
12:39YKYbut this is a scala + java project that calls clojure
12:39justin_smith
12:39YKYand the scala part caused me to use IntelliJ
12:39kungiI migrated from Perl for web development to clojure
12:40justin_smithYKY: you should be able to use cursive
12:40YKYsure, but scala tends to like intelliJ, that's what I found out
12:40CookedGryphonI'd probably in that situation, where you have a different build already set up that you want to use, just use leiningen to create a jar library, and pull that in
12:40SagiCZ1YKY: I strongly suggest to check out Cursive.. it is in its development stage but you can use it for free
12:40CookedGryphonpresumably scala, you're using sbt under the hood
12:40kungiWow my code is 10 Month old now :-) Just had a look at the initial commit.
12:41uris77my issue with cursive is deleting parenthesis. Sometimes it doesn't allow me to delete or add a parenthesis.
12:41YKYthis dependency stuff is going to kill me...
12:41uris77i have to select and use c-x and c-c
12:41SagiCZ1uris77: it is because you have the paredit option turned on
12:41justin_smithuris77: turn off structural editing, or better yet learn how to love it :)
12:41SagiCZ1i suggest leaving it on and learn about paredit
12:41YKYI'll just compile the clojure stuff into a jar, which is known to work
12:41SagiCZ1uris77: btw the option is on the right side of the bottom bar
12:42kungiOff to peeling potatoes. \o/
12:42uris77oh, ok. Too many things to learn at once :) I decided to give clojure a go after a year with Light Table because my brain couldn't handle emacs.
12:43uris77will definetely read up on paredit
12:43SagiCZ1uris77: it makes a whole world of a difference.. without paredit you lose the advantages of homogenous-syntax language
12:49sdegutisWhat are two good words that describe a collection of items available to you and a subset of those which you possess? I'm thinking "library" for one of them...
12:50SagiCZ1sdegutis: library is a pretty common word for such a thing from a design stand point
12:51sdegutisI'm thinking from the end-user's perspective, they walk into a store and buy a book, and they bring it home and put it in their bookshelf. I've heard the bookshelves of rich people called their "private library".
12:51sdegutisSo library could mean the collection of things you possess. But then I'm left wondering what to call the place you got them from.
12:51SagiCZ1sdegutis: i guess it would depend on the context and circumstances
12:52uris77hmmm, are you assuming the user will always purchase form a library?
12:52uris77can purhcase from a book store, convenience store, super market, online, etc...
12:53sdegutisWell specifically, I sell digital things from my Clojure web app. I want to call the collection of things you own your "library". Now I'm wondering what to call the page where you can see all the other things you can still buy.
12:53SagiCZ1store
12:53SagiCZ1shop
12:54SagiCZ1tool directory
12:54uris77pragprog calls it bookshelf: my bookshelf
12:54uris77and the main bookshelf is "The Pragmatic Bookshelf"
12:55justin_smithsdegutis: achievements, locked and unlocked
12:56SagiCZ1one does not buy an achievement.. one achieves it.. no?
12:56justin_smithshow a grayed outline of the book with a ? on it
12:56sdegutisjustin_smith: +1
12:56justin_smithyou achieve it by sharing your credit card info :D
12:56SagiCZ1:D
13:00EvanR,(let [x 'x] x)
13:00clojurebotx
13:01EvanRidea, for all symbols im expecting to use, def a variable with itself as the symbol value ;)
13:01EvanRconfusing maybe
13:01EvanRjustification, cant be arsed to put a '
13:03BronsaEvanR: that's a poor man's keyword
13:03EvanRtrue
13:06EvanRmore justifications, symbols standout when syntax highlighted against a bunch of keywords that are already there
13:09YKYhow can I compile just one clojure file in the project?
13:12justin_smith(doc compile)
13:12clojurebot"([lib]); Compiles the namespace named by the symbol lib into a set of classfiles. The source for the lib must be in a proper classpath-relative directory. The output files will go into the directory specified by *compile-path*, and that directory too must be in the classpath."
13:12llasramYKY: OOC, why do you want to do that?
13:12justin_smithYKY: like any other clojure function, it can be invoked via RT
13:12YKYI need the jar file to import to IntelliJ
13:13YKYI can't figure out how to do it in IntelliJ
13:13justin_smithYKY: you want "lein jar" or some equivalent
13:13justin_smithcompiling clojure makes bytecode, not a jar
13:13YKYI can make the uberjar
13:13YKYand it works
13:13justin_smiththat's all you need
13:13YKYbut I'm not sure if the entire uberjar is needed
13:13justin_smiththe compiling part is only needed if you want to use the classes without clojure.lang.*
13:13justin_smithyou can make a regular jar then?
13:14YKYI also have the regular jar
13:14YKYI'll try if it works
13:14YKYI suppose I can even shrink it down to the one function I need
13:14YKYto put in the jar
13:15YKYI mean, it's one sub-package in my project
13:15YKYanyway, I will try if the regular jar works or not
13:15YKYthe standalone jar is known to work
13:16ghanimahello all was wondering I could ask for assistance in reviewing the following clojure code... This code connects to a JAVA JMX port and queries for MBEANS defined in a YAML file.. I have searched this code as best I can, but can't find any evidence that is support the ability to pass user auth credentials for JMX access. Was wondering if soneone would be able to confirm my analysis. https://github.com/twosigma/riemann-jmx/blob/master/src/riemann_jmx_clj/
13:16YKYand the difference is 3.7Mb versus 37K =)
13:21YKYOK the regular jar doesn't work... the standalone jar is required
13:22YKYjava cannot import clojure functions if I don't add the standalone jar
13:22YKYis that expected behavior?
13:22justin_smithclojure is compiled at runtime
13:22justin_smithso you need the libs it uses available at runtime
13:23sdegutisI compile half of my clojure at runtime
13:24YKYthe loadResourceScript is actually not reading anything in the real directory
13:25YKYit's reading from the jar
13:25justin_smithright, because the jar is on the classpath
13:25YKYthe path is inside the jar
13:25justin_smithif something on disk were in the classpath, it would look there too
13:26bacon198`was wondering, is there a quick and easy way to start testing code with clojrue? I hate having to start a new project when I just want to test code out in a repl
13:26YKYbut in my project dir, the jar is nowhere to be found
13:26YKYI added it in IntelliJ
13:26justin_smithghanima: I think with that code, the authentication details could be hiding in the yaml
13:27justin_smithghanima: run-queries would find the user/pass or whatever and run each of those if present
13:27YKYand I don't know what is my classpath in intelliJ
13:27TEttingerbacon198`: you can run lein repl from any directory
13:27justin_smithghanima: this is based on a quick glance though, I could be off base
13:27ghanimajustin_smith: so the project has a reference example to the yaml: https://github.com/twosigma/riemann-jmx/blob/master/riemann-jmx.yaml.example
13:27ghanimabut I am not seeing how it would be set in the yaml
13:27SagiCZ1YKY: check out that the library is in the intellij external libraries tree
13:27SagiCZ1then use leiningen and its uberjar command
13:27TEttingerI have been known to /msg lazybot or clojurebot to eval code
13:28bacon198`TEttinger: so I can just start writing to a file? how do I eval it?
13:28SagiCZ1dont forget to set the main namespace, main function and set the namespaces to be :aot
13:28bacon198`do I just connect to the repl session or something
13:28bacon198`i'm using emacs
13:28TEttingeroh I meant just running the command lein repl, which could probably be done from a shell within emacs sure
13:28justin_smithghanima: my guess would be to add the authentication data under the reimann key.
13:28YKYI don't know any of those
13:29YKYbut it's running OK now
13:29YKYin my java code there is no namespace
13:29SagiCZ1YKY: oh.. i thought it was just clojure
13:29justin_smithghanima: wait, it isn't even checking for or using credentials when doing run-configuration to create the connection
13:29bacon198`oh, I see
13:30justin_smithghanima: so that's the part that needs patching - add the credentials to the yaml, and then change run-configuration / get-reimann-connection to use the username and pass
13:31justin_smithor maybe have a separate source of credentials outside that yaml file, but those functions would still need changing
13:31justin_smithTEttinger: I think cider doesn't really work right with projectless repls
13:31dnolen_bacon198`: lein repl + a lein user profile that includes cemerick's pomegranate
13:31dnolen_bacon198`: you can then start a lein repl from anywhere an try libs whenever
13:32justin_smithTEttinger: bacon198`: but you could use M-x inferior-lisp with lein repl without a project
13:32justin_smithno need for cider
13:32justin_smith(inc dnolen_)
13:32lazybot⇒ 8
13:32justin_smithyeah pomegranate is the easy way to do that
13:32justin_smith(inc dnolen)
13:32lazybot⇒ 18
13:33ghanimajustin_smith: I could be wrong but I think the JMX magic happes at the function... (defn run-queries)
13:33zB0hsim trying to write a vector of hashmaps to a post response body using http kit... when i try to include a vector in the body it just gets return as a string of the elements. is there an easy way to fix this?
13:33zB0hs(send! channel {:headers { "Content-Type" "application/json" } :body [1 2]}))
13:33ghanimajustin_smith: the run-configurations connections to another service that is not JMX based
13:33zB0hsreturns a body of "12"
13:34zB0hsusing numbers there instead of hashmaps but same idea
13:34weaveje__Does anyone happen to know a quick way of finding all values in a data structure that match a predicate?
13:34TEttinger(doc some)
13:34clojurebot"([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence, otherwise nil: (some #{:fred} coll)"
13:34TEttingerhm, that's first
13:35TEttingersounds like you want a filter
13:35weavejesterOh, I should add that I want to do it recursively!
13:35Bronsaweavejester: recursively? walk + an atom
13:35weavejesterThat's kinda an important detail ;)
13:35weavejesterBronsa: An atom? Yuck! :)
13:35Bronsait works, it's easy
13:35weavejesterI'd rather write a recursive search
13:35justin_smithweavejester: tree-seq + filter?
13:36EvanRyou dont need an atom
13:36justin_smith(doc tree-seq)
13:36clojurebot"([branch? children root]); Returns a lazy sequence of the nodes in a tree, via a depth-first walk. branch? must be a fn of one arg that returns true if passed a node that can have children (but may not). children must be a fn of one arg that returns a sequence of the children. Will only be called on nodes for which branch? returns true. Root is the root node of the tree."
13:36weavejesterAh! tree-seq! I knew there was something like that
13:36sdegutisThere have been 2 times when I thought I wanted tree-seq. Either it turned out I didn't, or it was sufficiently over-complicated and I just gave up and used something else. I forget which.
13:36weavejesterHm, might be tricky around maps...
13:37justin_smithbranch? would need to return true for a map, and then children would need to return (seq m)
13:37justin_smiththat should suffice right?
13:38weavejesterOh, or not, since a mapkey is a coll?
13:38justin_smithright, call seq, get a list of pairs
13:38justin_smithor if you only care about the vals, use vals of course
13:38Bronsa,(require 'clojure.walk)
13:39clojurebotnil
13:39Bronsa,(let [res (atom [])] (clojure.walk/prewalk #(do (when (number? %) (swap! res conj %)) %) {1 [2 #{3 4}]}) @res)
13:39clojurebot[1 2 4 3]
13:39weavejester,(filter symbol? (tree-seq coll? seq {:a [1 2] :b {:c #{'d}}}))
13:39clojurebot(d)
13:39ghanimaI have this defined function but having a hard type interpretting the following
13:39justin_smithweavejester: nice
13:39ghanimadefn run-queries
13:39ghanima [yaml]
13:39Bronsaah, tree-seq
13:39ghanima (let [{:keys [jmx queries]} yaml]
13:39ghanimaI understand the 1st 2 lines
13:39weavejester(inc justin_smith)
13:39lazybot⇒ 156
13:39Bronsanice, I totally forgot about it
13:40ghanimaSorry wrong code
13:40Bronsaghanima: use a nopate
13:40weavejesterBronsa: Yeah, I prefer to avoid local mutable state when I don't need it :)
13:40Bronsanopaste*
13:40justin_smithghanima: for multiple lines, please use refheap.com or similar
13:41ghanimaSorry everyone: https://www.refheap.com/94627
13:41ghanimaI understand the 4 lines
13:41ghanimabut I don't understand the 5th
13:41ghanimawhat exactly is the 5th line
13:41justin_smith$doc ->>
13:42justin_smith$grim clojure.core/->>
13:42lazybothttp://grimoire.arrdem.com/1.6.0/clojure.core/-&gt;&gt;
13:42Bronsaweavejester: sure me too. But I'm not going to feel bad about it if no obvious pure solution comes to mind. in this case tree-seq is much nicer though, yeah
13:42justin_smithghanima: see the above link for examples / doc / explanation of ->>
13:43justin_smithit's for chaining expressions without deep nests of parens
13:49ghanimajustin_smith: so on line 5 of that function your saying that jmx/with-connection is being chained to run-queries
13:52bacon198`another question... how do I take a zipper, and turn it back into it's original structure?
13:53bacon198`I have an xml structure I want to use a zipper on, and then I want to modify and return the change xml document
13:53justin_smithghanima: the whole (jmx/with-connection ...) is then fed to mapcat if I am reading it right
13:54justin_smithI would have used a let binding, since it is only feeding the one thing to the next
13:54justin_smiththat's a little heavyweight for the inside of ->> for my tastes
13:55sqdis there a nice way to combine quil with core.async? i’d like to plot data that is frequently written to a channel
13:55bacon198`nvm, I found an article on xml/emit
13:55sqdi currently have a go-loop that updates an atom with the last read value, but i wonder if it can be done nicely without atoms
13:56ghanimajustin_smith: so what is jmx_with-connection is that a function or a generic object
13:57justin_smithjmx/with-connection is at least a callable, or else clojure would reject it in that context
13:57justin_smithghanima: in your repl, you could try (source jmx/with-connection)
13:58justin_smithghanima: it is a macro, defined here https://github.com/clojure/java.jmx/blob/master/src/main/clojure/clojure/java/jmx.clj#L181
13:58justin_smithlooks like crednetials would go in :environment if anywhere?
13:59justin_smith*credentials
14:02ghanimajustin_smith: so credentials is an array right
14:02ghanimaif so would the yaml file look like this
14:03ghanimaenvironment : - [user, pass]
14:04justin_smithghanima: not sure about that part
14:04sqdis there a non-blocking clojure.core.async/<!! that returns something if nothing is available?
14:05justin_smithsqd: you could use alts!! with something that would return after a short delay, but there may be a nicer way to do it
14:06rhg135anyone know if i can find usage of a namespace in cursive?
14:06sqdjustin_smith: yeah, i prefer not using a delay there. want to call the function in the ‘update’ loop from quil (drawing library), which should be called every 15ms or so
14:08sqdwish i could easily use om in clojure (not in the browser) for realtime visualisation :-)
14:10rhg135it is a sad day when grep > ide
14:21justin_smithrhg135: I am 100% certain cursive can find namespace usages
14:21justin_smithI don't know exactly how though myself :)
14:22SagiCZ1alt+f7
14:23mikosif i have a list of strings, for example
14:23mikosif i have a list of strings, for example '("foo" "bar") and want to use those strings as parameters in a function call, would i be best off doing (eval (concat '(function-name parameter-1) '("foo" "bar")))?
14:24SagiCZ1eval is evil
14:24mikosi thought that might be the case, SagiCZ1 =)
14:24SagiCZ1dont u want apply?
14:24SagiCZ1(doc apply)
14:24clojurebot"([f args] [f x args] [f x y args] [f x y z args] [f a b c d ...]); Applies fn f to the argument list formed by prepending intervening arguments to args."
14:25bbloomi think github just added highlighting to diffs
14:26bbloombut i think that also made yet another clojure color scheme change
14:26mikosi don't think so, SagiCZ1, the function i'm trying to call has a set number of arguments; in this case 3
14:26mikosi have the first argument, but the other 2 are in a list
14:27SagiCZ1u can still use apply
14:27SagiCZ1,(apply (fn [a b c] (println a b c)) 6 [7 8])
14:27clojurebot6 7 8\n
14:28mikosah, of course!
14:28mikoslet me try it, thanks =)
14:30mikosbeautiful
14:31mikosthanks so much, SagiCZ1
14:31SagiCZ1apply unwraps any combination of lists and single parameters, just keep in mind that it unwraps just one level, so nested lists become lists
14:31rhg135justin_smith, i couldn't find it, it kept taking it as a package
14:32mikosgood to know, thanks again
14:32mikosanyone using yesql 0.5.0-rc1 yet?
14:34justin_smithrhg135: hopefully someone knows. Cursive has the best clojure integration out there right now, so it *should* have a working find-usages.
14:36justin_smithrhg135: did you find C-Shift-A to look up commands by name?
14:37justin_smithyou may be able to find the find-namespaces-usages function in that
14:48rhg135justin_smith, oh it works for symbols and keywords and packages
14:51oskarkvI'm using tools.namespace, and sometimes when I refresh and try to run my code, out of the blue, I get an error like "java.lang.IllegalArgumentException: No implementation of method: :start of protocol: #'game.common.core/Lifecycle found for class: game.client.hud.HudSystem" but it does have a start method, and just refreshing again gets rid of the error. Can anyone think of a reason for this?
14:52amalloyoskarkv: protocols and records hate being reloaded
14:52oskarkvhm ;(
14:53oskarkvamalloy so, what should i do? I want to use refresh, right?
14:53amalloyheck if i know. i certainly don't want to use refresh
14:53oskarkvhehe ok
14:53amalloyanyway, the issue is that you have an old object of type HudSysetm lying around, and reloading the namespaces doesn't delete it; but it implements the *old* Lifecycle protocol, not the new/reloaded one
14:54amalloybecause when you reloaded HudSystem and LifeCycle, you defined a brand new protocol and record class, unrelated to the ones in existence but with identical names
14:55oskarkvHm, so I try to use the old object later? That's not supposed to happen...
14:55amalloyit's also possible that the namespaces are reloaded in the wrong order; i don't know how refresh works
14:55amalloybut you'd see similar behavior even for new objects, if the record namespace were (incorrectly) reloaded before the protocol namespace
14:57oskarkvamalloy ok thanks, I will check if I mistakenly save something old.
15:02nicferrierI want to run a long running unix process from a clojure program, concurrently filter it's stdout inside the same program and catch it's exit when it finishes.
15:02nicferrierwhat's a good approach?
15:03nicferrieris core.async the right thing for that?
15:04EvanRtheres this library... popen https://github.com/tebeka/popen i just googled
15:04nicferrierwhat did you type into google to get that?
15:04EvanRpopen
15:04nicferrierfair enough.
15:05EvanRread its stdout until it closes?
15:05EvanRthen join to get the exit status
15:07nicferrierprocessbuilder is the necessary magic I guess.
15:07amalloypopen might be fine, but i've never heard of it and raynes/conch is sorta the standard one
15:08amalloyor, well, that's an overstatement. the standard one is clojure.java.shell, but it doesn't have a lot of features, so if you want something fancier many folks use conch
15:08justin_smithprocessbuilder/process are not super hard to use
15:08justin_smithit gives you an outputstream, and inputstream, and an exitvalue when the proc is done
15:09nicferrieryeah, I was playing around with java.shell ... but it seemed like it was hard to get the process stuff from it
15:09justin_smithyeah, I don't think java.shell is meant for long running stuff where you want to act on output as it is available
15:10nicferrierI vaguely remember processbuilder from java
15:10justin_smithif you look at the API for Process, it is really tidy https://docs.oracle.com/javase/7/docs/api/java/lang/Process.html
15:10justin_smithnot much complexity there
15:10nicferrierpopen looks reasonable... conch looks "better" idiomatically.
15:10stuartsierraI asked a while ago if there was any way to do nonblocking I/O on a sub-process' STDIN/STDOUT from Java; nobody had any answers.
15:11justin_smithstuartsierra: I use Process with a thread doing blocking read. There may be a lighter weight option though?
15:11amalloyi don't think there is, stuartsierra
15:11stuartsierraYeah, I was hoping not to have a dedicated thread per-subprocess.
15:12nicferrierI did this at work in scala and akka did a good job of making it easy. i don't know if akka was just making threads under the covers though.
15:12justin_smithstuartsierra: you could have a single thread that checks multiple sub-processes via checking .available on each of their outputStreams
15:12nicferrierI wanted to do the same thing in clojure.
15:12EvanRare threads a big deal?
15:12justin_smithEvanR: depends how many you need, it adds up
15:13nicferriersurely you can get an nio channel from a stream? can't remember any of that stuff.
15:13nicferrierok. I'll fess up.
15:13justin_smithnicferrier: well, if you can get an nio channel from a stream, the Process will gladly give you a stream
15:13nicferrierI want to write a process supervisor
15:13nicferrierso the threads would be pretty useless.
15:13stuartsierraEvanR: 10s of threads, no problem; 100s of threads, not that big a deal; 1000s of threads can be a problem
15:13nicferrierbut there wouldn't be that many I guess.
15:14nicferrier10x threads? basically screwed.
15:14nicferrier10x1000 I meant.
15:14EvanRyurg
15:14EvanRim trying to find notes on the implementation
15:15EvanRjava threads?
15:15rhg135is it just me or does https://github.com/rhg/flutterbot/commit/4359477ee31bf5c87a5a4f225d9bb302ac85036c seem like a bad thing?
15:15stuartsierraJava threads are the same as native OS threads in most implementations.
15:15EvanRi mean is that what you get in clojure
15:16nicferrierand most OSes do a good job these days. but you're still asking a scheduler to do a job that is about multiplexing IO.
15:17llasramrhg135: not just you I'm afraid :-)
15:17amalloyhaha that is pretty funny rhg135
15:18amalloydid github change their styling again? this commit looks a lot prettier than clojure code looked on github a couple weeks ago
15:21rhg135amalloy, i didn't want to invest the effor when i'm planning to excise mongo all together
15:22rhg135to do it properly i mean
15:22llasramrhg135: Sounds like the sort of thing to mention in the commit message!
15:22justin_smithrhg135: you can do a conditional (if (resolve 'somnium.congomongo/fetch) (this) (that))
15:22justin_smithno need for eval
15:23justin_smithor whatever thing you want to resolve
15:23justin_smith,(resolve 'clojure.core/+)
15:23clojurebot#'clojure.core/+
15:23justin_smith,(resolve 'does.not/exist)
15:23clojurebotnil
15:24llasramjustin_smith: I think the point is that the library will be there, but the configuration may not be
15:24justin_smithOK, he can do the same trick with the config
15:24oskarkvstuartsierra I had a problem with "no implementation of method" while using tools.namespace, and I think that maybe this is very bad for tools.namespace, right? https://www.refheap.com/4fae4a68dd778d1e4baf7c4d0
15:24justin_smitheval is still not needed
15:25stuartsierraoskarkv: sorry, busy now, but please file a JIRA if you have a reproducible bug
15:27justin_smithnicferrier: maybe this? https://docs.oracle.com/javase/7/docs/api/java/nio/channels/Channels.html#newChannel(java.io.InputStream)
15:27justin_smithand then I think you can select on a group of those
15:27akkadnicferrier: you converting to clojure? :P
15:28bacon198`alright, i've run into a strange problem. i'm trying to find and replace something in an xml document using a zipper, but when I look at a node using zip/node, I end up losing my place in the xml document, as it bumps me up a level or something
15:28nicferrierjustin_smith: yeah. I can't remember.
15:28nicferrierakkad: from what?
15:28nicferrierakkad: ah. no.
15:28rhg135the idea is to carry on if mongo isn't available, but as i said i'm about to excise mongo
15:28bacon198`is this normal, and is there possibly an easier way to replace a value in a list given a certain search criteria?
15:28oskarkvstuartsierra Sorry, I was not very clear. What I did was I had an ns declaration without requires at the top of the file, and then a few lines later I had the "real" ns declaration with requires, to get around a problem with a java library. But I guess tools.namespace uses the first ns declaration, right?
15:29nicferrierakkad: I'm just working with people who think the jvm is an operating system.
15:29rhg135as said coloqually i give not a s***
15:29justin_smithrhg135: yeah, in that case I would wrap anything mongo-specific in an if that checks if something from that namespace resolves
15:29justin_smithand the apropriate noop if not
15:30rhg135justin_smith, i'd rather fire my neurons when adding datomic backed storage
15:30bacon198`I suppose I could map over the elements, and evaluate which ones to replace with a different value
15:30stuartsierraoskarkv: correct. tools.namespace only looks at the first `ns` declaration
15:30oskarkvok thanks
15:30amalloyoskarkv: yeah, that looks like super-bad. why do you need multiple namespace declarations?
15:31rhg135justin_smith, also i did this to avoid editing callsites and jsut do a s&r
15:31oskarkvamalloy javafx does/executes something special when it is being imported, and that stuff does not work with clojure for some reason.
15:32llasramoskarkv: You can use the `import` macro
15:33rhg135it seems the bot still lives
15:34hiredmanyou can put multiple ns forms in a single file, but you cannot expect others to handle that with grace
15:37rhg135nevermind...
15:50justin_smithrhg135: if your plan is to do a proper replacement of mongodb for some other storage, what about starting by abstracting storage and retrieval, then pluggin in the new backend?
15:52mindbender1I'm looking for some good use of transducers.
15:53justin_smithmindbender1: invent a new source of data, then use transducers to get free impls of map, reduce, filter, etc. on that new datasource
15:53SagiCZ1does anybody know how to print clj-time? for example i want to print only the month like this "01_January"
15:54mindbender1justin_smith: okay I see. So this is mostly useful when I need to invent some new collection type.
15:55weavejes_SagiCZ1: Take a look at the clj-time.format namespace docs
15:55justin_smithor when you need optimum performance for composed operations on some data source
15:55SagiCZ1weavejes_: cant find the docs, only github readme
15:55justin_smithmindbender1: and I explicitly didn't say collection
15:55justin_smithit could be anything that gives you data
15:56mindbender1even a function?
15:56weavejesterSagiCZ1: The readme has a section on clj-time.format.
15:56weavejesterSagiCZ1: And the API docs are linked from the README
15:56justin_smithmindbender1: sure. The point of transducers is not needing to turn things into collections in order to get those transforming operations
15:56SagiCZ1weavejester: thanks
15:57EvanRi thought transducers were for composing reducing-like functions
15:57justin_smithmindbender1: so hypothetically we could transduce over a network socket
15:57rhg135justin_smith, i've learned you can't abstract a logic engine
15:57rhg135it's already abstracted enough
15:58justin_smithrhg135: transducers are about getting less abstract, and better performance, not about getting more abstract
15:58justin_smithsequences are already abstract enough, you are right
15:58justin_smithbut sometimes you don't want to build a sequence
15:59justin_smithif that sounds pointless to you, you can of course avoid transducers, that's fine
15:59rhg135my goal is datomic but regardless, trying to abstract swl, nosql and others into one abstraction isn't worthwile
15:59rhg135sql*
16:00EvanR(datomic results cant be streamed :()
16:00mindbender1justin_smith: sounds interesting to me
16:01rhg135justin_smith, i wasn't talking about transducers... which are awesome
16:01justin_smithrhg135: ahh, oops, conversation channels crossed, now I get it :)
16:01stuartsierraEvanR: just the datalog query results. There are streaming APIs for direct access to the indexes & storage.
16:01rhg135nbd
16:02EvanRstuartsierra: right.. which is precisely what would be convenient/performant to stream
16:02rhg135this is a bit ironic, i think, that the non hackish change is the one that broke it
16:03mindbender1justin_smith: are there some example somewhere on the internet that could help facilitate a deeper understanding. Or if you could offer them. I'd be glad.
16:04justin_smithmindbender1: I can't think of something specific off the top of my head. But I know the videos from rhickey are excellent
16:04justin_smithit might be informative to look at how core.async switched from map< filter< etc. to transducers with map, filter, etc.
16:05mindbender1justin_smith: where are the videos hosted?
16:05justin_smithyoutube
16:05justin_smithtop two hits for rich hickey video transducers
16:05justin_smithfor me at least
16:05mindbender1okay. I'll search there.
16:06mindbender1Are there no downloadable links?
16:06justin_smiththere are hacks to download youtube vids... dunno about any downloads
16:07justin_smithwe should have torrents for all the important clojure vids
16:07ToxicFrogmindbender1: youtube-dl works fine, IME
16:07ppppaulhow does one write tests using core.async?
16:07mindbender1ToxicFrog: is that a tool?
16:08EvanRyou dont want to watch ads?
16:08EvanRcommunist
16:09ToxicFrogmindbender1: yes, command line tool.
16:09justin_smithppppaul: my approach was to make things as modular as possible so I could swap in a lambda with a Thread/sleep for any external thing that takes time. Then I make assertions that I get all the results I expect, that they each look sane, etc. I also have an atom with a "being served" count and a "max served" and update those values inside my dummy fn, and make assertions about the parallelism
16:11justin_smithppppaul: maybe the clearer way to say it is: make your work function a thing you pass in, and replace it with something that records metrics and returns a plausible result
16:11SagiCZ1does anyone know what happens to files that get opened but never closed after reading? is it a very unsafe thing to do or just a bad practice?
16:12justin_smiththen you test the work function separately, outside an async context
16:12justin_smithSagiCZ1: if they go out of scope, the jvm is allowed to close them
16:12SagiCZ1justin_smith: does it happen automatically then?
16:12tuftSagiCZ1: when they get finalized i assume some low level resources get released
16:12justin_smitheventually... finalization is weird, but eventually yeah the resources get reclaimed
16:13tuftSagiCZ1: .. but yeah, it's bad practice to leave this implici
16:13tuftimplicit
16:13EvanRuse a wrapper that opens and closes a file for you
16:13justin_smiththis is part of why we avoid global bindings - it's easier to make sure things go out of scope
16:13justin_smithEvanR: like with-open
16:14SagiCZ1i would love to use with-open
16:14SagiCZ1but i read it with line-seq and i need to keep it lazy
16:14EvanRshouldnt that close it when its finished?
16:14YKYwhat's that form that lets you do one function and then another?
16:14EvanR(do one-function then-another)
16:14SagiCZ1EvanR: unfortunately it doesnt work like that.. the file gets closed immediately and the lazy-seq cant proceed
16:14justin_smithEvanR: the problem is that a lazy resource can leave the with-open scope, so the file the lazy seq relies on is closed, and ouch
16:15SagiCZ1YKY: do
16:15YKYthanks =)
16:15EvanRno no, not combining with file and line-seq
16:15EvanR,Doc line-seq
16:15clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: Doc in this context, compiling:(NO_SOURCE_PATH:0:0)>
16:15justin_smithYKY: also, fn, defn, let, when, while, etc. etc. etc. all have an implicit do inside them
16:15SagiCZ1(doc line-seq)
16:15clojurebot"([rdr]); Returns the lines of text from rdr as a lazy sequence of strings. rdr must implement java.io.BufferedReader."
16:16SagiCZ1if you return the lazy-seq from the with-open scope, the file gets closed
16:16ToBeReplacedSagiCZ1 do you need a LazySeq or is channel sufficient?
16:16EvanRwhen this sequence approaches its end, doenst it close the file
16:16EvanRer... BufferedReader
16:16justin_smithEvanR: the file gets closed before the sequence is even read
16:17ToBeReplacedyou could consider dumping to a channel and blocking until close inside of the with-open block
16:17EvanRjustin_smith: are you talking about with-file? im not
16:17SagiCZ1ToBeReplaced: : i just need to avoid loading the whole thing in memory as it wont fit.. can i use channel?
16:17justin_smithEvanR: so you either need to eagerly realize the line-seq before leaving with-open, or not use with-open
16:17EvanRer with-open
16:17justin_smithEvanR: OK
16:17EvanRso line-seq isnt about files, nevermind
16:17SagiCZ1EvanR: it is just as justin_smith says, and line-seq IS about files
16:17EvanRits about BufferedReader
16:18SagiCZ1ok, that
16:18EvanRwhich doesnt have a close method
16:18amalloybufferedreader doesn't have a close method??
16:18lazybotamalloy: Definitely not.
16:18amalloylazybot: c'mon, man. that's demonstrably untrue
16:18EvanRactually it does
16:18justin_smith$javadoc BufferedReader
16:18lazybotJavadoc not found. Try http://docs.oracle.com/javase/6/docs/api/
16:19SagiCZ1,(type (mapcat count ["hello" "bye" "word"]))
16:19clojurebotclojure.lang.LazySeq
16:19justin_smith$javadoc java.io.BufferedReader
16:19lazybothttp://docs.oracle.com/javase/6/docs/api/java/io/BufferedReader.html
16:19EvanRtherefore, line-seq should be able to call it near the end
16:19rhg135hmm
16:19rhg135i should fix that
16:19YKYwhat's the difference between list? and seq?
16:19SagiCZ1EvanR: but it is long out of the scope of the macro when its near the end
16:19YKYI saw a list and it's a seq
16:19EvanRwhat macro?
16:20SagiCZ1EvanR: with-open
16:20amalloyYKY: list? is awful, never use it
16:20EvanRdont use with-open
16:20amalloywhereas seq? is awesome, always use it
16:20SagiCZ1YKY: http://www.braveclojure.com/core-functions-in-depth/#2__The_Sequence_Abstraction
16:20YKYdrove me crazy...
16:21SagiCZ1EvanR: what else should i use?
16:21rhg135ah
16:21rhg135i probaly should have slepti more
16:21rhg135it's java.io hence it wouldn't be resolved
16:21EvanRSagiCZ1: it looks like line-seq does not do the close for you, after reading the source
16:21EvanRwhich would be nice
16:22llasramYou totally want `with-open`
16:22SagiCZ1llasram: ugh
16:22llasramDepending on complete processing a a lazy sequence to release resources is asking for tears
16:22EvanRthat too
16:22amalloyEvanR: urgh. line-seq should definitely not close for you
16:22rhg135^
16:22justin_smithOnce the BufferedReader goes out of scope, the jvm is allowed to close it. Just manage your scope properly.
16:22rhg135darn lag
16:23llasramSagiCZ1: Alternatively, hiredman has some good ideas about using reducers: http://ce2144dc-f7c9-4f54-8fb6-7321a4c318db.s3.amazonaws.com/reducers.html
16:23SagiCZ1justin_smith: i am about to do that
16:23amalloyjustin_smith: am i misunderstanding you? letting it go out of scope is not a solution
16:23amalloyyou need to call .close on it
16:23SagiCZ1amalloy: i dont think so
16:23EvanRlazy reading is the problem here
16:23llasramYou can also use an explicit dynamic scope for resource lifetimes: https://github.com/pjstadig/scopes
16:23EvanRmight as well go all out
16:23amalloythe jvm is *allowed* to close it, but by no means does it *promise* to close it
16:23justin_smithamalloy: if nothing has access to the underlying data source, the finalization should eventually take care of it, no?
16:24amalloyjustin_smith: it might just not get GCed for hours
16:24justin_smithamalloy: fair enough. But it will get closed before having it open is a problem at least. Outside pathological systems like Windows.
16:24justin_smithsure
16:24amalloyjustin_smith: that's just not true
16:24SagiCZ1gosh, reading a file lazily is such a basic concept, i dont understand why its not implemented in clojure correctly
16:24justin_smithinteresting, what's a good counterexample?
16:24amalloythe GC operates in mysterious ways, and it can be days and days between major collections
16:24SagiCZ1have you never had a 100 GB file?
16:25amalloyif your file handles happen to say alive long enough to make it into oldgen
16:25amalloyyou could easily run out of file handles
16:25amalloyhttp://blogs.msdn.com/b/oldnewthing/archive/2010/08/09/10047586.aspx is an article i think everyone should read
16:25llasramSagiCZ1: You can totally read a file lazily
16:25EvanRSagiCZ1: theres reading incrementally, and then theres treating the lines as a pure lazy sequence
16:25EvanRwhich its not
16:25llasramSagiCZ1: The issue is that Clojure provides laziness as a data structure, not via lazy evaluation
16:26SagiCZ1llasram: what do you propose?
16:26ToBeReplacedllasram: i like that statement, and agree
16:27EvanRllasram: how would lazy evaluation help here?
16:27llasramSagiCZ1: You manually manage the resource scope, by using either `with-open`, reducers, or the pjstadig/scopes library
16:27ToBeReplacedSagiCZ1; two choices... a) use with-open, block inside of it... you can do this by doing your processing inside of it or dumping to a channel
16:27SagiCZ1couldnt i make my own 'line-seq' which would hold on on the file and close it when the last element evaluates?
16:27ToBeReplacedb) don't use with open, handle open/close outside of your processing
16:28EvanRSagiCZ1: or when an error occurs
16:28llasramEvanR: You know what -- you are totally right. I assumed languages with full lazy evaluation semantics would have a solution, but apparently even in e.g. Haskell the recommendation is to always explicitly manage resource lifetimes
16:29EvanRlazy evaluation makes sense for pure code, no IO
16:29SagiCZ1line-seq is a two liner so i can try to reimplemented it with my requirement and let you check it out
16:30hiredmanllasram: haskell has iteratees
16:40ghadishaybanbbloom: can you say more words about an IOC macro for reduced handling?
16:40SagiCZ1i can detect when someone used the whole lazy-seq but if someone does (take 10 lazy-seq) i can never know if i should close it or not
16:40bbloomghadishayban: basically yield
16:41bbloomghadishayban: www.cs.indiana.edu/~sabry/papers/yield.pdf
16:41YKYI got a clojure list returned as java object, how can I iterate through it in java?
16:41SagiCZ1YKY: lists implement Enumaration
16:41amalloyYKY: do you remember the answers you got to this question yesterday? what is still giving you trouble?
16:41SagiCZ1busted!
16:42bbloomghadishayban: although monadic yield, like go's handling of asynchrony, is dynamic in extent. where as python or C#'s yield, like core.async's go, is lexical in extent (push down machine vs finite state machines)
16:42YKYthe result is a java Object
16:42YKYnot a List
16:42YKYI don't remember yesterday's answer =)
16:42SagiCZ1YKY: yeah you have to cast it
16:42YKYoh I see
16:42amalloyit's a List; its static type is Object, so you need to cast it to tell java you're sure it'll be a List
16:43yiatiIf you are sure it will be a list*
16:43SagiCZ1yiati: we use this assumption all the time with any dynamic language dont we
16:44justin_smithyiati: he means List as in the java.util.List interface I think. which list / list* implement
16:44justin_smithbut more importantly, seq, vector, cons
16:44yiatiRight
16:47bja_has the jvm grown a divmod lately?
16:48stompyjIs anyone here using transit with a schema, embedding a schema within transit?
16:49justin_smithbja_: doubt it, but at least we can do this ##((juxt quot mod) 7 4)
16:49lazybot⇒ [1 3]
16:50EvanR,(quot -1 3)
16:50justin_smithstompyj: in order to send your schema to someone else?
16:50clojurebot0
16:50EvanR,(div -1 3)
16:50clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: div in this context, compiling:(NO_SOURCE_PATH:0:0)>
16:50amalloyjustin_smith: quot goes with rem, not mod, generally
16:50justin_smithOK
16:51EvanR,(rem -1 3)
16:51clojurebot-1
16:51justin_smithI forget what the point of rem is sometimes
16:51EvanR,(mod -1 3)
16:51clojurebot2
16:51amalloythe difference is something to do with negatiev numbers, as i think EvanR is trying to show
16:51amalloyjustin_smith: rem is java's % operator
16:51justin_smithgot it
16:51EvanRwhats div?
16:51justin_smithshould be quot
16:51stompyjjustin_smith: well, I have a js client, and a clojure back-end, and I want the js client be able to perform validation on it’s end. but ideally using a shared schema, so that logic doesn’t only live in the js world
16:52EvanRtheres two interpretations for quotient when a or b is negative
16:52EvanRcorresponding with the two implementations mod and rem
16:52stompyjTransit keeps refering to “schema optional”, so I’m trying to figure out how people who want a schema would do such a thing
16:52stompyjI’d prefer not to use avro or json schema
16:54stompyjI just may be thinking about all this incorrectly, as well. heh
16:54EvanRbut i cant find the other one
16:54EvanR,(divide -5 3)
16:54clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: divide in this context, compiling:(NO_SOURCE_PATH:0:0)>
16:55EvanR,(unchecked-divide -5 3)
16:55clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: unchecked-divide in this context, compiling:(NO_SOURCE_PATH:0:0)>
16:55TEttinger,(quot -5 3)
16:55clojurebot-1
16:55EvanRit could be -1 or -2, so i guess you can just add 1
16:55TEttinger,(/ -5 3)
16:55clojurebot-5/3
16:56upwardindex,(get-in (iterate 0 inc) [0])
16:56clojurebotnil
16:57ppppauli'm using core.async with clojurescript. i'm finding that a lot of the example code i'm running into is specific to clojure. could someone help me out with CLJS links?
17:03SagiCZ1ToBeReplaced: i am going to try your method with channels, my idea was short-sighted.
17:07SagiCZ1is there any reason to use old fashioned java.concurrent.BlockingQueue over clojure.async channels? they seem more flexible and very simple to me
17:07ToBeReplacedgood luck!
17:07justin_smithperformance
17:08SagiCZ1justin_smith: is clojure.async slow?
17:08justin_smithcompared to just using a BlockingQueue, it has more overhead for sure
17:08ppppauli'm having a lot of trouble with core.async with cljs
17:08SagiCZ1i see
17:08ToBeReplacednothing wrong with j.u.c
17:08justin_smithnot saying any specific app would benefit from that switch, but it's an undeniable difference
17:09ppppauli can use some of the api "go, go-loop, put!, <!, >!" but not really anything else i try
17:09ppppaulcode examples tend to not work
17:09EvanRthis blog claims that juc blocking queue has overhead that limits the total number of threads that can be used in practice http://clojure.com/blog/2013/06/28/clojure-core-async-channels.html
17:16SagiCZ1any good clojure.async video?
17:20justin_smithEvanR: it's a tradeoff - if your logic wants more async units of execution, the core.async pool is a win, if you want faster processing and can keep the thread count reasonably low, j.u.c will beat core.async
17:25martinklepschwhat are some types that implement IPersistentList but not ISeq, and when would you want to use them?
17:28gfredericks&(re-matches #"[\Q\E^x]" "y")
17:28lazybot⇒ "y"
17:32gfredericks&(re-seq #"[\Q\E^x]" "xyz^")
17:32lazybot⇒ ("y" "z" "^")
17:32gfredericks&(re-seq #"[\Qb\E^x]" "xyz^")
17:32lazybot⇒ ("x" "^")
17:32gfredericks^ love this
17:34nicferrierhas anyone written anything to pull clojure-docs into emacs?
17:34nicferrierseems like it would be a useful thing
17:35kenrestivoi'd love to have either grimoire or crossclj.info in emacs
17:36nicferrierthat would be nice. but clojure-docs looks pretty good... it would be easy to make an eldoc or a C-h f like lookup thing with it inside emacs.
17:36nicferrierI am such an idiot. I love making work for myself.
17:37llasramkenrestivo: cider has grimoire integration
17:38kenrestivooh cool, thanks.
18:02tuftis there anything for interacting with clojure-docs from the repl? query, submit, etc.
18:02tuftenhancement for (doc ...)
18:04amalloy&(supers clojure.lang.IPersistentList)
18:04lazybot⇒ #{clojure.lang.Seqable clojure.lang.Sequential clojure.lang.IPersistentStack clojure.lang.IPersistentCollection}
18:04amalloy&(ancestors clojure.lang.IPersistentList)
18:04lazybot⇒ #{clojure.lang.Seqable clojure.lang.Sequential clojure.lang.IPersistentStack clojure.lang.IPersistentCollection}
18:05amalloyreally? ISeq isn't in there?
18:05amalloymartinklepsch: i'd be surprised to find such a type in the wild
18:07rasmustohow do I specify that I want java.sql.Timestamps instead of java.util.Dates from clojure.java.jdbc query results?
18:08MrPopinjayHi guys. inside a defn function is there an implicit let or anything like haskell's where statement? I want to assign some intemediate values to a name, but it's be nice to avoid the extra ()s from a let function
18:09amalloyMrPopinjay: no
18:09rasmustoMrPopinjay: you can do destructuring in the arguments vector
18:09rasmustobut yeah, not for non-arguments
18:09EvanRuse a let
18:09amalloyyou're sorta stuck learning to love the parens
18:10MrPopinjayThat's fine, just wanted to make sure I wasn't adding lots of stuff that wasn't needed! :)
18:10MrPopinjayThank you guys
18:10MrPopinjayAnd I'm certainly liking them more now I've discovered paredit.vim
18:10EvanRnow that adding them is easy
18:10amalloyyeah, paredit is a necessity
18:10rasmustoMrPopinjay: don't forget vim-sexp (as an alternative)
18:10EvanRthey should invent something so i can read them
18:11MrPopinjayI was put off sexp as it has lots of alt bindings
18:11amalloyi like the saying that trying to write lisp without paredit is like writing java without autocomplete
18:11MrPopinjayWhich is a big no no for me
18:11EvanRi only use the alt binding to swap expressions, occasionally
18:11rasmustoMrPopinjay: check out vim-sexp-bindings-for-normal-people (or something) by tpope as an alternative
18:11MrPopinjay<3 tpope
18:11EvanRthough it did require i fix the alt key
18:11MrPopinjay<3 fireplace
18:11amalloyit sounds like he MrPopinjay is perfectly happy with vim-paredit. why is everyone pushing vim-sexp?
18:12MrPopinjayI'm open to new ideas!
18:12MrPopinjayWhat's the USP of sexp over paredit?
18:12EvanRnone dont try it
18:12rasmustoit was just me, and only because I found it more vim-like
18:12MrPopinjayI'm mostly just like being able to delete a line without unbalancing the params
18:12MrPopinjayI'm not using much else I think
18:13rasmustoor that, yeah. it lets you be less "structured" about your editing, so paredit.vim is more pure
18:13amalloyi guess it was just you. for some reason it felt like a lot of people
18:13rasmustoamalloy: sorry, I've had caffiene today
18:13MrPopinjayI'll have to try it I suppose
18:14EvanRgetting your alt key to work in vim is its own reward
18:14MrPopinjayI use it for window management, I don't want editors to use it
18:15amalloyMrPopinjay: obvious solution: let your editor manage your windows???
18:15lazybotamalloy: Oh, absolutely.
18:15EvanRi tried to use windows key for window management
18:15MrPopinjayHow could vim manage my windows?
18:16amalloyMrPopinjay: it's not a real suggestion
18:16MrPopinjayOh, haha
18:16amalloyi'm half-mocking the folks who do everything from emacs
18:16MrPopinjayThat is pretty amazing
18:16MrPopinjayI should learn emacs + evil
18:16MrPopinjayAnd somehow embed firefox in it
18:17EvanRno
18:17rasmustopentadactyl you mean
18:17MrPopinjayI use vimperator, but close enough
18:17amalloyMrPopinjay: i hear evil is pretty good. i never got any good at vim, but i know at least one person who was an emacs fanatic, tried vim, and then settled on evil
18:18amalloyi sure envy you guys your more composable navigation commands
18:18MrPopinjayI think that's the best mix. Vim is better for editing text, Emacs is a better editing enviroment
18:18MrPopinjayMy RSI got too bad, had to ditch the mouse. Much happier with the keyboard alone now tbh
18:19SagiCZ1vim vs emacs, go!
18:19MrPopinjayBoth are lovely
18:19akkadvi vs emacs
18:19MrPopinjayneovim vs emacs, go
18:19EvanRthe only thing you need a mouse for is paint... and then most people prefer new fangled styli
18:19amalloyand also the ability to shout commands at someone you're pairing with: "just hit 4dd, mate"
18:19akkad"simple editor" vs "kitchen sink editor"
18:19MrPopinjaynotepad vs nano, go
18:19rasmustoconversation starter: "have you heard of text objects?"
18:19amalloyEvanR: i tried a mouse-free editor, but the poor flash support was just not tolerable
18:19akkadsimple editor without 14k scripts on vimscripts.org
18:20EvanRamalloy: text editor?
18:20amalloyer
18:20amalloybrowser
18:20EvanRah
18:20amalloyhttp://conkeror.org/ was fun
18:20EvanRthe only thing you need flash for is ads
18:20MrPopinjayI'd love to use dwb, but I found it too buggy. Really lovely interacting with it when it worked
18:20Bronsaflash and scrolling are 90% of what I use my touchpad for
18:21EvanRscrolling -> PgUp PgDn
18:21MrPopinjayDamn flash and it's focus stealing
18:21MrPopinjayI mapped j and k to 5j and 5k, and have a high key repeat, so I just use jk
18:21amalloyEvanR: ew. those aren't on the home row
18:22MrPopinjayOr just use /
18:22amalloyeven in chrome i use space and shift-space to scroll
18:22EvanRspacebar is not on the home row!
18:22amalloyBronsa: go join Raynes in the corner
18:22MrPopinjayHey, I didn't know you could do that
18:22MrPopinjay(What have I started?)
18:23RaynesHi guys
18:23Raynes:D
18:23rasmustoRaynes: did you have to click?
18:23RaynesI sure did.
18:23rasmusto<3
18:23Raynes<3
18:23MrPopinjaySoooo is it normal to start seeing all text in params as a function call after starting to learn Lisp?
18:23RaynesOh, get this: I moused over to the Textual window FROM an ATOM TEXT EDITOR window containing COFFEESCRIPT code that I just wrote.
18:23rasmusto(I don't think so)
18:23RaynesI'm so far gone, guys.
18:24EvanRi hope not
18:24SagiCZ1i just use countour roller mouse and i feel almost as cool as yall
18:24MrPopinjayI find it really interesting how new syntax makes my brain react differently to mundane things
18:24justin_smithMrPopinjay: pretty much. The best variation of this I have seen is nethack - email addresses look scary if you have played nethack enough
18:24amalloyMrPopinjay: it's probably a variant on tetris syndrome
18:24justin_smithexactly
18:24amalloybahahaha. i can totally believe that, justin_smith
18:25justin_smithamalloy: it's like "oh shit, stuck in a corridor, and monsters on both sides as far as I can see...
18:25justin_smith"
18:25amalloyat least it's a corridor. nobody wants to fight all that out in the open
18:25justin_smithseriously
18:25EvanRnever fight in a basement
18:25justin_smithEvanR: but the gnomish mines have some of the best early game armor
18:28MrPopinjayRight, night gang
18:28MrPopinjayThanks for the help :)
18:29bbloomdnolen_: where did cljs land on the js/foo.bar.baz shorthand?
18:30bbloomwas it made officially supported? or dropped? or what?
18:31Bronsabbloom: it's supported. I asked him about that for t.a.js
18:31bbloomok cool thanks Bronsa
18:34justin_smithEvanR: I started the perhaps silly process of a lib that interacts with the nethack-lisp nethack UI backend (originally made for elisp, but sexps are sexps)
18:35justin_smithso instead of drawing to the screen, it sends sexps describing UI updates
18:35justin_smithand then your program can display that for the user as it wishes, or act as an AI replacement for a player, etc.
18:37EvanRso its the same game, but it renders by emitting lisp code?
18:37justin_smithright
18:37justin_smithand takes strings as input
18:37justin_smithit's just a display backend. But since all UI is via lisp, that makes making a nethack player AI that much easier.
18:37EvanRheh.
18:38EvanRauto farming
18:38EvanRslow it down and you have progress quest
18:38justin_smithyeah, that's the low hanging fruit - something that is pretty trivial to script
18:38justin_smithor launch 20 instances in parallel, repeatedly playing until you have a 10th level wizard with the identify spell and the magic missile spell
18:39justin_smithwho cares how many times it fails, if it succeeds once in a reasonable time frame
18:39EvanRhook it up to that weird site that has everyone try to play at once
18:40justin_smithheh, yup
18:41justin_smithwait, do you mean twitch, or do you mean alt.org?
18:43{blake}I will be impressed if you can come up with an AI that can match "marvin".
18:43justin_smithI would be too :)
18:43justin_smithfor now I will be satisfied when I have a nice high level clojure symbolic interface to nethack
18:44justin_smithso that you can attach whatever ai you like to it's api
18:44kenrestivohow would i clear a cancellation exception that is pollutiing map, can't access it because it has a future with some exception, touching it causes it to throw
18:44{blake}You could make an ultra-sophisticated "robot wars" type thing, where victory is higher Nethack scores.
18:44trisshey all. I've got a project that use both clojurescript and clojure
18:45trissI#ve written a module called drummer-boy.pattern
18:45kenrestivoi.e. (println {:foo some-future-with-a-cancellation-exception}) => stacktrace every time
18:45trissits in src/
18:46trisshow do i use it from clojurescript file in src-cljs
18:46trissjust add something o :require?
18:46justin_smithkenrestivo: (try some-future-with-a-cancellation-exception (catch Exception e)) - that will give you nil as a val
18:46justin_smithyou can throw whatever you want after e to return that instead
18:47kenrestivothat feels kind of cumbersome, but sure, will do that
18:48justin_smithyou could make a macro (defmacro i-dont-even [& body] `(try ~@body (catch Exception e)))
18:48justin_smithyou may want a more succinct name
18:52rasmustois there a loop/recur styel syntax that'll make a lazy sequence?
18:52rasmustostyle*
18:52amalloyrasmusto: if you don't mind pulling in useful
18:52kenrestivonaw, this works (swap! c update-in [:dead-future-with-cancellation-exception] future-cancel)
18:53amalloyhttps://github.com/flatland/useful/blob/develop/src/flatland/useful/seq.clj#L108, used like https://github.com/flatland/useful/blob/develop/test/flatland/useful/seq_test.clj#L93
18:53rasmustoamalloy: cool, thanks.
18:54rasmustoI still find loop/recur syntax to be more grokkable than reduce for the kind of stuff that I'm doing
18:54amalloyrasmusto: reduce can't produce a lazy seq anyway...?
18:54amalloythe alternative is manual recursion, not reduce
18:55rasmustoamalloy: oh, right. Guess I forgot that
18:58gfredericks&(re-seq #"[a-e&\Q\E&c-g]" "abcdefgh")
18:58lazybot⇒ ("c" "d" "e")
18:58EvanRreduce cant produce a lazy seq?
18:59gfredericksEvanR: not the naive way you originally want it to
18:59EvanR(doc cons)
18:59clojurebot"([x seq]); Returns a new seq where x is the first element and seq is the rest."
18:59amalloyEvanR: well, reduce can't lazily produce a seq. it can eagerly produce a "lazy-seq", but that's not very useful
19:00justin_smithEvanR: it can produce a lazy seq, but it cannot itself be lazy.
19:02rasmustohm, I might be confusing myself
19:03rasmustoi have a map that I recur with, and I want a sequence within that map to be lazy... I think that's a chicken and egg thing, since the map won't be correct unless the seq is fully realized
19:05EvanRto create a "real" lazy sequence you need to use a built-in function like map right
19:05EvanRor range?
19:06amalloyEvanR: no. you just need to use lazy-seq, or something that uses it
19:07EvanR(doc lazy-seq)
19:07clojurebot"([& body]); Takes a body of expressions that returns an ISeq or nil, and yields a Seqable object that will invoke the body only the first time seq is called, and will cache the result and return it on all subsequent seq calls. See also - realized?"
19:07amalloymap, filter, and all that stuff, "just" use lazy-seq
19:07kenrestivois there a shortcut already in the language for #(when % (f %)) ? kind of like fnil that only runs a fn if the arg is not nil?
19:09EvanRinteresting
19:09gfrederickskenrestivo: some-> is related
19:09kenrestivosome-> 'ed work, thanks
19:10EvanRessentially (defn ctor [] (cons X (lazy-seq (ctor))))
19:11EvanRsubstituting X and the arguments to ctor to make any computable sequence
19:11amalloyEvanR: nuh uh
19:12amalloyyou can't build an empty sequence that way
19:12EvanRempty?
19:12amalloyor even one that ends
19:12amalloyyeah. a list with no elements
19:12EvanRi wasnt trying to make one that ended
19:12amalloyyou said "any computable sequence"
19:12EvanRok... infinite sequence
19:12amalloybut () is obviously computable, and can't be built with that ctor
19:13amalloythen sure. an unconditional cons around a lazy seq can build any infinite sequence
19:13EvanRfinite sequences are boring subtypes of infinite sequences
19:15EvanRcould you make an infinitely nesting map
19:15EvanRlazy tree, rather than a list
19:16amalloywell like...##(nth (iterate list (1)) 10)
19:16lazybotjava.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn
19:16amalloywell like...##(nth (iterate list '(1)) 10)
19:16lazybot⇒ (((((((((((1)))))))))))
19:16amalloyjust remove the nth, and you have an infinitely deep list
19:17brucehaumanhey guys
19:17brucehaumanis there a best way to read a namespace from a file?
19:17EvanRwell being able to get useful info before you get to infinity would be cool
19:18amalloy&(nth (iterate (partial list 1) '(1)) 10)
19:18lazybot⇒ (1 (1 (1 (1 (1 (1 (1 (1 (1 (1 (1)))))))))))
19:18amalloyit's not clear why you would want any of this. certainly not "useful" in real life
19:18EvanRoh of course not
19:19EvanRanother great idea goes out the window ;)
19:20EvanRgeneral lazily constructed structures happen a lot, just not always with nice language
19:25cflemingrhg135 justin_smith: actually Cursive's find usages has historically worked really well for everything except namespaces, for boring legacy reasons.
19:25cflemingrhg135 justin_smith: I'm actually in the middle of an enormous yak shave to fix that and other related problems for the next build.
19:26cflemingrhg135 justin_smith: I'd hoped that would be out today but it requires a lot of testing since it touches pretty much everything. Should be this week though.
19:33MorgawrI have a question.. is there some function/macro that I am missing that performs something like (something test-expr modifier data), if (test-expr) is true then it returns (modifier data) otherwise it returns data untouched
19:33Morgawr"something" is the name I'm looking for, if it exists
19:33Morgawr(otherwise it's trivial to make as a macro on top of (if )
19:35amalloyMorgawr: there's something like it in core now, i think test-> is it. but i prefer the version that's been in useful for years: (flatland.useful.utils/fix data test-expr modifier)
19:36Morgawramalloy: what's the difference?
19:36Morgawrhow big are the benefits for me to include something external instead of using test->?
19:36Morgawr(Also, thanks!)
19:37amalloywell, fix is a function. and it behaves differently if you have multiple test/modifier pairs
19:37Morgawrmmm.. I am using clojurescript and I can't find test-> on clojure 1.6.0, is it yet to be released and is only in the indev version?
19:37amalloyalso, the tests in fix are functions of 'something, rather than being booleans themselves, which means you can write like (fix x even? inc)
19:37amalloymaybe it's cond->? i forget what name eventually got decided on
19:38amalloy,(doc cond->)
19:38clojurebot"([expr & clauses]); Takes an expression and a set of test/form pairs. Threads expr (via ->) through each form for which the corresponding test expression is true. Note that, unlike cond branching, cond-> threading does not short circuit after the first true test expression."
19:39Morgawramalloy: thanks, I'll check both :)
19:39MorgawrI'm trying to get rid of all the "if" statements in my code, I hate ifs
19:41rhg135thanks cfleming
19:42rhg135ya it's so incredibly useful
19:44rasmustohm, maybe my lazy-loop/lazy-recur needs to be a self-calling recursive function after all
19:44amalloyrasmusto: what are you trying to do?
19:45rasmustoamalloy: my loop/recur produces a vector at the moment, because I'm conj'ing things onto it
19:45rasmustoI want it to be a lazy sequence instead
19:45amalloyrasmusto: uh huh, that's what lazy-loop is for. replace (recur (conj acc x) foo) with (cons x (lazy-recur foo))
19:46rasmustoamalloy: ooo, that's what I was missing
19:46rasmustothank you
19:46amalloylazy-loop is just a pretty thin skin on top of a self-recursive function
19:47amalloyadds the lazy-seq for you, lets you avoid making up a name for the helper function, and lets you write (lazy-loop [x 1] ...) instead of ((fn [x] ...) 1)
19:47rasmustoamalloy: ah, gotcha. I do like the style of it, especially because you don't have to do weird default function argument stuff, it's very explicit
19:55cflemingrhg135: No doubt, I don't know how anyone programs without it :-)
19:56rasmustoamalloy: lazyness just kicked in, this is AWESOME!
19:57amalloyrasmusto: i'm glad you're enjoying lazy-loop. i do also recommend trying to write the desugared form yourself, so you know what's really going on
19:57rasmustoamalloy: ok, will try that
19:58amalloy(lazy-loop [x 0] (when (< x 10) (cons x (lazy-recur (inc x))))) desugars out to just ((fn lazy-recur [x] (lazy-seq (when (< x 10) (cons x (lazy-recur (inc x)))))) 0)
19:58amalloyie, something it's very easy to have written yourself
19:59rhg135cfleming, me too
19:59rasmustoamalloy: ah, that's good to know
19:59rhg135red the commit msg, cfleming https://github.com/rhg/flutterbot/commit/800b0d3fed878e629f0ff821da6ee3723b8f7455
19:59rhg135should of used cursive
20:00rhg135and i am now
20:03xeqicfleming: is this yak shave related to the find-usages bug I showed you?
20:10cflemingrhg135: Haha , so true
20:10cflemingxeqi: It actually might be, although I haven't tested that case yet. I noticed another related bug when looking at the source of a dependency, so I'll investigate that.
20:11cflemingxeqi: I'm up to 91 changed files, so you never know, I might have fixed it by accident :-)
20:24xeqican't reproduce on master; must be fixed
20:25cflemingxeqi: Really? I haven't released a new version since the conj, although maybe you were on a previous version there?
20:26cflemingxeqi: Anyway, I'll test it and see if I can fix it for this drop.
20:26xeqicfleming: sorry, meant as a psuedo sarcastic issue closing comment
20:26cflemingxeqi: I may just use that :)
20:27xeqicfleming: ala https://github.com/technomancy/leiningen/issues/1666
20:28cflemingxeqi: Lovely
20:29cflemingxeqi: I actually need to do a round of issue triage and optimistically close a bunch of old ones reporting stack traces
20:31rasmustoamalloy: thanks again for the suggestions, I'm way more comfortable with laziness now
21:47nonubyjust getting my head around macros (albeit very late), this works yet probably not idiomatic, any suggestions to cleanup? https://www.refheap.com/94654 - basically adding auth to compojure routes (rather avoid middleware)
22:19justin_smithnonuby: `(list ~@x) is just `~x
22:20justin_smithand based on the rest of it, I think you can just return routes2
22:21hiredman /win 15
22:21rhg135any obvious improvements https://www.refheap.com/94653
22:22rhg135besides the unused step* i should remove
22:23justin_smithnonuby: also, best practices with macros is to do all your logic (or as much as possible) with a function, and only use the macro for custom syntax
22:24justin_smithand your macro should expand to a call to said function, of course
22:24rhg135sometimes you find you didn't need a macro
22:25justin_smithright, but he wants a magic syntax there
22:25rhg135ah
22:25rhg135sounds bad
22:26justin_smithrhg135: it's par for the course for compojure though
22:26rhg135sadly yes
22:26justin_smithI don't know about "bad", but it does aspire to be a DSL for routing, so to idiomatically extend it you could use a macro to extend the DSL
22:27rhg135s/bad/painful and frustrating/
22:27justin_smiththat said, making a macro because you would prefer to avoid middleware is like doing a cartwheel because you want to avoid walking
22:27justin_smithmiddleware is the simple option
22:27rhg135yes
22:28rhg135they're just fns
22:28rhg135at RUNTIME
22:28rhg135(emphazis on that)
22:34amalloyjustin_smith: i don't think (list ~@x) is like ~x very often, is it?
22:34amalloy,(let [x '(1 2 3)] `[~x (list ~@x)])
22:34clojurebot[(1 2 3) (clojure.core/list 1 2 3)]
22:35amalloyand the first of those two is something you rarely want to emit
22:35justin_smithahh
22:35justin_smithright, that's true
22:45nonubythanks guys, with regards to middleware different parts have different auth requirements, so unsure how to handle that, rather keep auth requirements near the specific handler
22:46nonubyunless I start doing path based discrimation e.g. { "/users" ["admin" "superuser"] "/contacts" ["sales" "accounts" "admin" "superuser" } etc.. but seems a little fragile
22:58rhg135nonuby, authentication happens at runtime whereas macros run at compiletime so I don't think a macro would help you much
22:58justin_smithnonuby: middleware can wrap individual endpoints
22:59justin_smithnonuby: it can actually go just about anywhere along the request handling cycle
22:59nonubybut with compojure you get only one endpoint?
22:59justin_smithindividual routes can have their own middlware
22:59justin_smithas can groups of routes, if you create those (I think compojure can do that one)