#clojure logs

2015-03-16

00:30bacon198`question, how do I remove an element from a vector, and return the list with the removed element?
00:30bacon198`,(def x [1 2 3 4])
00:30clojurebot#'sandbox/x
00:34bacon198`i'm guessing subvec
00:40TEttingerI'm pretty proud of this clojure name generator, it had some odd reqs http://ideone.com/zwnFAL
00:40TEttinger,(def x [1 2 3 4])
00:40clojurebot#'sandbox/x
00:40TEttingerbacon198`, what output do you want?
00:41l1xhttps://www.irccloud.com/pastebin/m2BK6uxa
00:41l1xdoes this work for you?
00:41l1xit does not seem to catch ctrl+c or the printing is not happening for some other reason
00:43TEttingerl1x, in the repl ctrl-c would get intercepted by the repl itself
00:43l1xthis is not in the repl
00:43TEttingerthen maybe the thread being asleep is preventing it from receiving input?
00:47l1xmaybe
00:47l1xanyways i investigate it tomorrow
00:48l1xthanks
00:48amalloy*out* needs to be bound for println to do anything useful, and in a brand-new Thread it isn't. you can fix this by, for example, (let [out *out*] (Thread. #(binding [*out* out] (println ...))))
00:49TEttinger(inc amalloy) ; l1x, I love having people who are actually good at clojure here
00:49lazybot⇒ 236
00:50TEttingersince I am pretty much not
00:50l1xi am a noob
00:50TEttingerthat name gen has turned out well though
00:50l1xnot even full time software guy :)
00:50l1xbut amalloy and justin are great
00:50TEttingerheh
00:51TEttingerI miss technomancy
00:51l1xwhere is he?
00:51TEttingerdoing charity work
00:51l1xahh
00:51l1xthe unsung here is ztellman
00:51TEttingerindeed
00:51TEttingerprimitive-math is amazing
00:51l1xhis code is terribly good
00:52l1xi am using his library to build our new datapipeline
00:55justin_smithoh, hi
02:50eglil1x: datapipeline? Anything more specific?
04:05dysfunambrosebs: the last message i saw before i reconnected was you saying people think type annotations are documentation. methinks you're setting yourself up for a fight with the entire scala community there ;)
04:28dysfunhrm, any marginalia users around?
04:28dysfuntrying to embed code in the documentation of marginalia doesn't look so good
04:28dysfunit's example code so i don't want it to actually go into the library
04:43michaelr`Does a hashing function exist which takes any value but produces a configurable number of hash values?
04:46noididysfun, how about leaving the code in but wrapped in a (comment ...)?
04:47dysfunnoidi: i wondered why so many people were doing that
04:47dysfunis it because of marginalia?
04:48noidiI think it's mostly because that way you can use your editor's structural editing support on the example code
04:48noidiparedit or what have you
04:49dysfunah yes, paredit. one day i might actually make the time to give it a proper go
04:49dysfunso i came up with a hack for making midje tests intermingle-able with real code and stripping them out for uberjar build
04:50dysfuni'm concerned this is going to clog up the marginalia output too
04:51noidiI place something like (comment (gen/sample my-gen)) after each custom test.check generator
04:52dysfunah, i'm using midje
04:52noidiI can then see an example of the generator's output by moving the cursor to the commented form and pressing a keyboard shortcut
04:52noidiotherwise I'd have to either write that form in the REPL myself every time, or copy and paste it from a textual comment
04:56dysfun*nod*
04:57dysfunhttps://gist.github.com/jjl/266e4fd88846ab8674f4
04:57dysfunthis is the hack i'm using to make midje autotest work
05:00dysfunif i put those in a comment block, they won't run, obviously
05:01dysfunbut since i don't actually use (comment) for any other purpose, perhaps i can just make my hack work on that instead
05:02noididysfun, have you seen this? https://github.com/marick/Midje/wiki/Production-mode
05:02dysfunyes. there's no way to actually use it :)
05:03dysfunmarick says there'll be something coming soon
05:03dysfuntil then i'm left with this awkward hack
05:06noidiok
05:10eglidysfun: not the answer you want to hear, but I've been quite happy with codox
05:11egliand markdown format
05:13dysfunyeah, but i like marginalia output
05:13dysfunit's pretty
05:13dysfunpeople like reading pretty documentation that's helpful
05:13eglidysfun: yes, looks matter :-)
05:13dysfunand given how many times i've gotten writing this library wrong and how many times i've now written it to get it right, it'd be nice if other people didn't struggle to use it
05:41jonathanjis there a standard or common markup accepted by tools for use in docstrings?
05:43dysfunno. if you choose a documentation generator tool, most of those support structured markup
05:44dysfuni'm quite fond of marginalia
05:45dysfunthat embeds markdown
05:46mpenetI really don't like it. If you don't care about the code and just want to use the lib it's a too noisy
05:49dysfunmpenet: sorry, could you explain that please?
05:49dysfunyou mean that you'd prefer *not* to see the code?
05:51mpenetyes
05:52mpenetby default at least
05:52dysfunoh that's an interesting idea
05:52mpenetcodox is better imho for doc, you get the signature/docstring and a link to the code if necessary
05:52mpenetless noisy
05:52mpenet less scrolling
05:52dysfuni quite like codox output i must say. but i'm very fond of the idea of literate programming
05:53dysfunperhaps codox favours larger libraries and marginalia smaller ones?
05:54mpenetI wouldnt be so sure. unless it's a 10 line single namespace lib
05:54dysfunthis is a small library. less than a hundred lines of code
05:54mpenetit's nice to have, but shouldn't be the default doc imo
05:55dysfunwell i also like that when you go to your code, the docs are there too
05:55dysfuni wonder if you can just generate both
05:56dysfunoff to a great start with codox. i get an obscure error about hiccup
05:58eglidysfun: you should be able to produce both marginalia and codox doc. Just specify different output dirs
05:59dysfunyup. except `lein doc` (codox) throws bizarre hiccup-related errors i'm trying to figure out how to fix
06:01dysfuni give up. any ideas? https://www.refheap.com/98497
06:01dysfunthat's me trying with the last-but-1 version because the latest did the same
06:02mpenetmaybe a conflict with a user profile
06:04dysfunwell whaddya know?
06:04dysfunclj-ns-browser
06:04dysfunwhich i haven't been using anyway because it's not very good
06:06eglidysfun: *that* was the problem?
06:06dysfunyes
06:06dysfunit was in my dev dependencies in my profile
06:12dysfunnow i have to go fix my tests before i can generate it. heh.
06:16dysfunhrm. a marginalia-alike with live updating would be awesome
06:17dysfunyou could change the docstring and go to your browser to see the updated docs
06:17dysfunwithout having to trigger a rebuild and hit refresh
06:22zotanybody have suggestions on this warning in a loop/recur: "recur arg for primitive local: len is not matching primitive, had: Object, needed: long" actual code here: https://gist.github.com/anonymous/96404337149c10c52439
06:23dysfunthat sounds like a type error to me
06:23zoti found that doing a (long …) cast within the recurs fixes it, but that seems a strange fix
06:24zotsince the thing being cast is the result of (- foo bar), both of which are numeric
06:24zotbut i assume autoboxing is transparent, so maybe it's the only way?
06:39Glenjamin^long might work
06:42dysfunhrm. i'm writing a library that generally expects to be used in combination with an edn reader (it has lots of symbols and lists in, you'd have to do awkward quoting of things in clojure). do we think it's reasonable to depend on clojure.tools.reader and write a function to scrape edn and read it directly or do we think that enough people might want to feed it from clojure and not want the dep to make not doing so worthwhile?
07:01mpenetanyone knows how to run core.async cljs test suite?
07:01mpenetit doesn't seem to be documented anywhere
07:01noncomdysfun: i did not understand what you're asking.. :)
07:02dysfunnoncom: it would be slightly more convenient to have one import and one function call to use this from a file. doing so would make me depend on clojure.tools.reader (which most people will want to use). should i do that or not?
07:04noncomhmmm well, maybe i am not the most opinionated person to ask about this, but depending on clojure reader seems fine, since anyway, it is in the standard package?
07:04noncomand also i think there is no real alternative to clojure.tools.reader
07:04dysfunclojure.tools.reader is not standard, it's a pure clojure reimplementation
07:05noncomoh, i thought it's already inside...
07:06dysfunno. and i specifically want the edn reader
07:06dysfun(the format makes liberal use of lists and symbols which are very pretty in edn but require quoting and such in clojure code
07:21noncomdysfun: hmmm, interesting..
07:52jonathanjare there documentation tools that aren't centered around literate programming?
07:53jonathanjhrm, when i "lein run" my application on OS X i get a Java dock icon until my code exits
07:54jonathanji'm using flying-saucer-pdf, i'm assuming that someone starts up AWT or similar and the JRE thinks it's running a GUI app? is there a way to stop this?
07:55dnolenhttps://groups.google.com/d/msg/clojurescript/e3gOEUJlkMc/PATUU2JaBl4J
07:55dnolenClojureScript 0.0-3115 out
08:05dysfunjonathanj: codox isn't
08:05dysfunalso if you figure out how to stop the dock icon, i'd love to hear. i get it because i spin up netty
08:11justin_smithdysfun: maybe use a headless jre?
08:12noncomwhat is the current best option to validate passed function arguments?
08:12justin_smithjonathanj: oh yeah, java is really annoying in thinking that if you process something image related, you must want to connect to the GUI
08:13justin_smithnoncom: I like prismatic/schema for that, but there is also :pre conditions
08:15dysfunreminds me of old-fashioned assert()
08:17jonathanjjustin_smith: any suggestions to get rid of that?
08:19jonathanjhrm, how would i do the equivalent of `java -Dfoo=bar` from Clojure?
08:19dysfunwhat do you mean? how do you get access to the definitions? or how do you set them in-process?
08:20dysfunthe latter cannot be done but you can work around it by agreeing to only use a wrapper
08:20jonathanjhrm
08:20jonathanji was reading http://www.oracle.com/technetwork/articles/javase/headless-136834.html
08:20noncomin schema how can i say OR inside a type template?
08:20dysfunthe former, you do the java way, with clojure syntax
08:21noncomlike a value can be either [] or nil or keyword
08:21jonathanji'd like to just try -Djava.awt.headless=true as a quick once-off
08:21jonathanjbut it claims i can use System.setProperty to do the same thing, but apparently that code is broken
08:21jonathanjoh, hrm
08:21jonathanjthat's a static method
08:21dysfunhow are you launching clojure? like 'lein repl' ?
08:22jonathanjdysfun: i'm just using `lein run` at the moment
08:22dysfunah right. well System/setProperty should work
08:22jonathanjokay, so (System/setProperty "java.awt.headless" "true") in my main function does what i want (and stops the whole GUI start up thing)
08:22jonathanjsorry, i was an idiot and did (.setProperty System ...) initially
08:23dysfunheh, i do that often
08:24justin_smithjonathanj: I do "env _JAVA_OPTIONS=-DFOO=bar lein ..."
08:26justin_smithjonathanj: but you can also do :jvm-opts ["-Djava.awt.headless=true" ...]
08:26jonathanjah, thanks, that would have been useful to at least try this out
08:26justin_smith(in project.clj)
08:27justin_smithactually I do both - the former if I want to frequently change a def, the latter if it's a dev time def that doesn't change
08:29jonathanjhow do i manually include a java project in my clojure project?
08:30jonathanjso either i have the original Java source or at least a jar, but it's not available on any kind of central repository
08:33justin_smithjonathanj: would you be *allowed* to host it if you chose? because putting it in a mvn repo is likely the easy thing
08:33justin_smithotherwise you can put it in your repo on the classpath
08:34justin_smith(or java-source-path, of course, if you want lein to compile it...)
08:37jonathanjjustin_smith: it's not my code, the author is just kind of AWOL
08:38jonathanjif i use java-source-path, is it automatically compiled with my clojure code and available via (:import)?
08:39jonathanji guess i can just give it a try
08:41dysfun,(inc justin_smith)
08:41clojurebot#error{:cause "Unable to resolve symbol: justin_smith in this context", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.RuntimeException: Unable to resolve symbol: justin_smith in this context, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyze "Compiler.java" 6535]} {:type java.lang.RuntimeException, :message "Unable to resolve symbol: justin_smith in th...
08:41dysfunlol
08:42dysfunclearly i've forgotten the syntax
08:42agarman(inc justin_smith)
08:42lazybot⇒ 210
08:42agarman(dec dysfun)
08:42lazybot⇒ 2
08:42jonathanjjustin_smith: thank you!
08:42agarman(inc dysfun)
08:42lazybot⇒ 3
08:45justin_smithjonathanj: yeah, if you set :java-source-paths [...] lein will compile the classes under that path
08:59justin_smith,(str 'ba (repeat (rand-int 4) 'na))
08:59clojurebot"baclojure.lang.LazySeq@c27025f5"
08:59justin_smithblergh
08:59justin_smith,(apply str 'ba (repeat (rand-int 4) 'na))
08:59clojurebot"ba"
09:00justin_smith,(apply str 'ba (repeat (rand-int 4) 'na))
09:00clojurebot"bananana"
09:01dysfun:)
09:01dysfunthat's actually quite a nice way of introducing simple logic when teaching programming
09:02dysfunstealing that. thanks.
09:02justin_smithI'm sure it would go over great in a 5th grade classroom
09:02justin_smithheh :)
09:02dysfuni taught a friend to program clojure a few months ago that was odd
09:02gfredericks,(apply str 'ba (take-while (fn [_] (< (rand) 0.75)) (repeat 'na)))
09:02clojurebot"bana"
09:02dysfunhe'd not done anything more complex than excel formulae before
09:03gfredericks,(apply str 'ba (take-while (fn [_] (< (rand) 0.75)) (repeat 'na)))
09:03clojurebot"banana"
09:03gfredericks,(apply str 'ba (take-while (fn [_] (< (rand) 0.75)) (repeat 'na)))
09:03clojurebot"ba"
09:03gfredericks,(apply str 'ba (take-while (fn [_] (< (rand) 0.95)) (repeat 'na)))
09:03clojurebot"banananananananananana"
09:03dysfuni'm still not entirely sure how clojure has ended up with such a lesser need for parens than other lisps, but it's very noticeable compared to for example LFE
09:04justin_smith&(frequencies (repeatedly 100 #(apply str 'ba (take-while (fn [_] (< (rand) 0.75)) (repeat 'na)))))
09:04lazybot⇒ {"banananana" 4, "bananananananana" 5, "banananananananananananananananananana" 2, "banana" 14, "banananananananananana" 1, "banananananananananananana" 2, "bananananananananana" 2, "ba" 22, "banananananana" 4, "bananananana" 8, "bana" 21, "banananananananana" 3, "bananana" 12}
09:04justin_smithwow, it fit in one output!
09:04dysfun:)
09:05agarman(str (apply str (repeat (rand-int 16) 'na)) " " 'batman)
09:05agarman,(str (apply str (repeat (rand-int 16) 'na)) " " 'batman)
09:05clojurebot" batman"
09:05jonathanjhrm, how would i have lein include some loose jar in my project?
09:05justin_smithjonathanj: put it in your :resource-paths
09:05justin_smiththen it ends up on the classpath in the generated (uber)jar
09:05agarman,(str (apply str (repeat (rand-int 16) 'na)) " " 'batman)
09:05clojurebot"nanananananananananana batman"
09:05jonathanjjustin_smith: and for use during development?
09:05thheller@dnolen: if you call .disableThreads on the closure compiler the System/exit is not required as there will not be a lingering thread. the threaded model provides no benefit so there really is no downside to it.
09:06justin_smithjonathanj: yes, it will also be on the classpath while developing
09:06justin_smithjonathanj: but consider that it could also be pushed to a maven repo
09:06jonathanjdo you mean inadvertently?
09:07justin_smithno, I mean if you put it in a maven repo then you can use it like you would any other dep
09:07dnolenthheller: the threads are created to modify the stack size for Java 6, granted we are on Java 7 I rather not bother with it
09:07jonathanjyeah, it did occur to me, i guess i'll aim for that later on
09:09thheller@dnolen just never liked the System/exit call, just saw your wiki edit to add it. thought I mention it
09:09dnolenthheller: sure but it doesn't matter much and System/exit is fine here
09:10thhellerdnolen: yeah I guess so
09:31jonathanjjustin_smith: hmm, so i have :resource-paths ["src/main/resource"] and my .jar in that same directory (relative to project.clj) but (:import) fails with java.lang.ClassNotFoundException
09:32jonathanjthe failed path matches the package name and class name i'm expecting, is there some way i can debug this? (determine whether the jar is being included, etc.)
09:33jonathanji'm just using `lein run` to run my main (which imports the java class), hopefully that's not the issue
09:33cnb_is it possible to use definterface without the class being defined as final ?
09:34justin_smithjonathanj: oh, my bad, you need to add the jar itself to the resource-paths
09:34jonathanjjustin_smith: yay!
09:34justin_smithjonathanj: that worked?
09:35jonathanjis src/main/resource the convention for resource-paths?
09:35justin_smithusually it is just resources/
09:35jonathanjjustin_smith: yes, that worked
09:35justin_smithawesome
09:36justin_smithjonathanj: there isn't really a convention for embedding jars, because the "proper" way to do it is create a pom and upload it to a maven repo and use it as a regular dep
09:38jonathanjjustin_smith: is there some recommended reading regarding uploading jars to maven?
09:39cnb_is it possible to use definterface without the class being defined as final ?/
09:39justin_smithjonathanj: the mvn command can do this, there are some guides on sonatype too http://central.sonatype.org/pages/producers.html
09:40justin_smithcnb_: so you need an interface that isn't final?
09:40cnb_yes
09:40cnb_justin_smith: yes
09:41cnb_justin_smith I mean the class than implements the interface using the webservice annotations is being declared as final
09:42jonathanjjustin_smith: thanks again, you've been a tremendous help!
09:42justin_smithcnb_: so you need other interfaces to inherit from it? for normal usage of implementing the interface should be fine
09:42jonathanj,(inc justin_smith)
09:42clojurebot#error{:cause "Unable to resolve symbol: justin_smith in this context", :via [{:type clojure.lang.Compiler$CompilerException, :message "java.lang.RuntimeException: Unable to resolve symbol: justin_smith in this context, compiling:(NO_SOURCE_PATH:0:0)", :at [clojure.lang.Compiler analyze "Compiler.java" 6535]} {:type java.lang.RuntimeException, :message "Unable to resolve symbol: justin_smith in th...
09:42justin_smithjonathanj: the , isn't used for karma
09:42jonathanj(inc justin_smith)
09:42lazybot⇒ 211
09:43cnb_justin_smith this one is being created as final (deftype ^{WebService {:targetNamespace "o.m.g"}} FooService []
09:43cnb_If I look at the .class the class generated is final, I do not want to be final
09:43justin_smithOK, than really what you care about is the deftype creating a final class
09:43justin_smith*then
09:43cnb_yes
09:44cnb_justin_smith: yes, that is the problem
09:44justin_smithmaybe you need gen-class instead of deftype?
09:45justin_smithone moment
09:46justin_smithcnb_: this flow chart from cemerick is helpful http://cemerick.com/2011/07/05/flowchart-for-choosing-the-right-clojure-type-definition-form/
09:46dysfunhrm, i wonder if marginalia would be better served by inverting the order of functions in the source
09:46justin_smithcnb_: notice you are definitely inside the "interop zone"
09:46dysfunit seems to me that if you're doing user facing stuff, you'll put the function that has the neat api at the bottom to avoid having to put a (declare) at the top
09:47justin_smithcnb_: looks like if an instance of an anonymous type suffices you could get away with reify / proxy
09:48justin_smithdysfun: trufax
09:48cnb_justin_smith thank you very much
09:49dysfunjustin_smith: i guess it depends whether you hate your users or not ;)
09:49justin_smithcnb_: np, I use that flow chart a lot
09:50justin_smithdysfun: at this point my reading of a clojure file usually consists of a quick skim at the top to decide if I should read more from there or (at least 76% of the time) jump straight to the bottom and read from there up
09:50noncomare there any good tutorials or examples on clojure.tools.reader?
09:50dysfunheh
09:50dysfundo you use marginalia?
09:50justin_smithdysfun: some exceptions from the read-from-the-bottom thing - if there is a defmethod or defprotocol encompassing the functionality, that will be at the top, and that is the main thing to know about
09:51justin_smithdysfun: I've played with it, I wish it were more flexible
09:51justin_smiths/defmethod/defmulti of course
09:51dysfuni'm quite fond of it, but obviously i'm going to have to build my own because yaks always need shaving
09:52jonathanjreturning an OutputStream doesn't seem very clojure-like, is there a better alternative?
09:52jonathanj(i'm using a Java library that has InputStream and OutputStream parameters)
09:53dysfunjustin_smith: tbh i tend to avoid multiple dispatch. i understand it can become a performance bottleneck in heavy throughput use cases
09:54justin_smithjonathanj: seems fine to return an OuputStream, it's easy enough to slurp from it or use with-open or whatever
09:55justin_smithdysfun: multimethods aren't much slower than fns, and if you do them right protocol functions will be faster than regular fns
09:55dysfuni use protocols
09:55justin_smiths/protocol functions/protocol methods/
10:00noncomhow do i get line/column info from the clojure.tools.reader?
10:01dysfunif you use read it should supply it
10:01dysfunas metadata
10:02Bronsanoncom: use an indexing reader (either indexing-push-back-reader or source-logging-push-back-reader) and line/col info will be attached as metadata to the forms you read
10:04Bronsanoncom: http://sprunge.us/jQFL?clj
10:16noncomBronsa: thank you!
10:17noncomBronsa: what is the difference between indexing and source-logging?
10:18Bronsanoncom: a source-logging reader adds to the form metadata a :source key mapping to a string that represents the original source form, where possible
10:19noncomwow, so the metadata contains the source the form was built from? that's nice..
10:19noncomyou said "where possilbe" - what are the cases when this is not possible?
10:20Bronsanoncom: http://sprunge.us/aQdB?clj
10:21Bronsanoncom: well, when the form read is not an IMeta you can't possibily attach that info as metadata
10:21jonathanjare OutputStreams also InputStreams?
10:21noncomyou mean that #_foo is missing metadata ?
10:22jonathanji'd like to pass the output of one function as the input to another
10:22justin_smithjonathanj: no, but a pair can be connected somewhat like a pipe
10:22Bronsanoncom: no, #_foo is just a comment
10:22justin_smithjonathanj: yeah, I have a project where I do that, one moment
10:22Bronsanoncom: I mean that in "#_foo 1", there's no way to preserve the #_foo comment
10:22noncomgot it
10:22Bronsawhile in "#_foo [1]" it's preserved in the :source info of [1]
10:23noncomthat is an interesting detail..
10:23noncomwhy was it made to be preserved?
10:24Bronsanoncom: the more we can preserve of the original source, the better. the source-logging reader is used for source-maps support in cljs
10:24dysfunyes, i thought that form was supposed to 'guarantee' complete removal
10:25dysfuni realise it's just a source map, but hrm.
10:26noncomwell, source map is used for cueues... obviously cueuing is better with most things preserved..
10:26noncomi guess..
10:29justin_smith,(let [bytes (java.io.ByteArrayOutputStream.) _ (.write bytes (.getBytes "hello")) in (java.io.ByteArrayInputStream. (.toByteArray bytes))] (slurp in))
10:29clojurebot"hello"
10:29justin_smithjonathanj: ^
10:30justin_smithjonathanj: I think it is also possible without doing the toByteArray method call so that you get a proper pipe style setup
10:32justin_smithjonathanj: with a bit of research, it looks like a circular buffer is a nice way to do that
10:32noncomBronsa: what is the recommended way to read a source file of clojure with tools.reader? i assume that the source file contains many clojure forms, but readers read only the first one. ofcourse i know how to make it work manually, but probably there is an existing facility for that?
10:33jonathanjjustin_smith: i see there's also Piped{Input,Output}Stream
10:34justin_smithjonathanj: yes, but you should not use both in the same thread
10:34Bronsanoncom: no, readers don't read only the first one http://sprunge.us/fFOE?clj
10:35noncomah, so they keep note of the progress...
10:35noncomuntil we hit EOF i guess..
10:35Bronsayes
10:35noncomcool :)
10:35myguidingstaranyone please help explain why this core.async code doesn't print out anything? https://gist.github.com/af9128f7c9a092d7f87c
10:35justin_smithnoncom: yeah, readers are stateful, you can even bookmark, rewind or fastforward (not that you would want to for something like this)
10:35Bronsanoncom: so you can either read the whole file in a string and use that or you can pass an InputStream to an input-stream-push-back-reader
10:36noncomthat's really cool. i keep being fascinated by all this clojuric stuff and things you do, guys!
10:37Bronsanote that the input-stream reader is not an indexing reader so if you want to use it and get source info you'll have to compose it with an indexing reader, e.g. (indexing-push-back-reader (input-stream-push-back-reader my-input-stream))
10:38dnolenmyguidingstar: that code is going to stall on (>! ch j)
10:39myguidingstarthanks dnolen
10:41myguidingstardnolen, what's your advice for a minimal additional code to make it work?
10:43dnolenmyguidingstar: stop reading and writing to ch in the same loop
10:44myguidingstarokay
10:46noncomwhat is the best way to know my reader has nothing else to read? catching an EOF does not seem to be the best way around this..
10:50stuartsierranoncom: `read` takes extra arguments to specify an EOF value.
10:51noncomreally.. just have to first read the docs and the source i guess :)
11:11tbaldrid_myguidingstar: you have a race condition in that code. It's quite possible for the middle go to write a value to ch and then read it right back in again
11:11tbaldrid_actually that will always happen, I have no clue what that code is supposed to do,
11:12myguidingstartbaldrid_, that's what I intended to do
11:13myguidingstaractually it was a simplified version of my other real code
11:15ambrosebsdysfun: woah woah. I said people think type *hints* are documentation. They say almost nothing.
11:15ambrosebstype annotations are documentation.
11:18dysfunhehe. i disagree :)
11:18dysfuni don't disagree they're useful, i just think from a documentation pov, docstrings are more useful
11:19dysfunsadly not seeing a lot of that in scala
11:23Glenjamintype annotations are useful but not always sufficient, perhaps?
11:29dysfunyes
11:29dysfuni'd go with 'almost always insufficient' actually
11:30ambrosebsdysfun: erm doc + type is way better than just doc
11:30ambrosebsespecially when talking about clojure.core
11:30ambrosebsI never said type is sufficient
11:31dysfun*shrug* i don't mind reading a textual description. "Args: [foo bar]. foo is a map, bar is a value to look up in the map"
11:31Glenjaminthat's a type annotation
11:31Glenjaminjust an unchecked one :p
11:31dysfunheh
11:31dysfunan imprecise one perhaps
11:32dysfunhowever, you have the freedom to divert from the specific to the more easily understandable
11:33dysfuni like type systems, but i'm not convinced that it should be automatically what shows in the documentation
11:34ambrosebsdysfun: here is my perfect documentation http://crossclj.info/fun/clojure.core/*.html
11:36ambrosebsa few examples would make that perfect :)
11:36dysfunhrm, see i don't like the type signature there
11:36dysfunto me that should read number -> number and note in the docstring that it will perform conversion rules
11:37dysfunotherwise, that's pretty good
11:38dysfuni guess a lot of it is taste
11:38ambrosebsI don't know how to put it more precisely than in the type if you want to know more than just "conversion rules"
11:39dysfuni guess i'd like to see a simplified type signature. you could click to see a full type signature
11:39ambrosebsdysfun: agreed
11:39dysfuni get this for free with marginalia and codox because it just prints the signature without types and the text to describe it underneath
11:40ambrosebswell you get no type signature right?
11:40dysfunindeed. but i find the argument names and a bit of text describing them more helpful
11:41dysfunit's a problem of expression i think. how to express what it does concisely
11:42dysfuni think type signatures an inexpressive way to describe a process
11:42ambrosebswell I don't know if argument names help, but prose + examples is definitely helpful
11:43dysfunyes, i find argument names much more helpful than type signatures
11:44ambrosebsreally? sure if you can read the actual source it's all you need.
11:45dysfunthose type signatures are extremely confusing. what's the * doing in the middle?
11:45dysfunand the union symbol looks too close to a 'u'
11:45ambrosebsthe * is like a kleene star
11:45ambrosebs0 or more types
11:46ambrosebsso the type sig that you might want is [Number * -> Number]
11:46ambrosebsas in 0 or more numbers
11:47dysfunoh i see, it's indicative of arity?
11:47ambrosebsyes it says this function can take any number of arguments
11:47ambrosebs(even if it is implemented with 4 arities)
11:48ambrosebsso here's my favourite annotation in core.typed http://crossclj.info/doc/org.clojure/clojure/latest/clojure.core.html#_swap%21
11:49ambrosebstough to read at first but really captures swap! precisely
11:49Bronsathe some-fn one looks scary
11:49ambrosebsBronsa: it's also stupid :)
11:50ambrosebsBronsa: any sort of repeating pattern in a type that grows downwards is a TODO :)_
11:50ambrosebsyea some-fn is a ridiculous annotation
11:50ambrosebsLOL
11:50dysfunambrosebs: but now i've looked at that i'm struggling to have a clue what it does.
11:51ambrosebsdysfun: you're familiar with swap! ?
11:51dysfunyes, i use it, but for a moment it was like i didn't.
11:52ambrosebsdysfun: so the ... notation allows you to capture a sequence of arguments
11:52ambrosebs(All [b ...] [b ... b -> [b .... b -> Any]]) just returns a function that takes the same arguments
11:52ambrosebsthere's an example somewhere..
11:53ambrosebshttp://crossclj.info/doc/org.clojure/clojure/latest/clojure.core.html#_memoize
11:53ambrosebsso memoize takes a function and returns a function with the same interfact
11:53ambrosebs*interface
11:53ambrosebsdoes that make sense?
11:54Bronsaambrosebs: I'm totally ignorant wrt core.typed, is there a reason why some-fn looks that scary while other combinators e.g. partial don't? is it about the "conditional" nature of some-fn?
11:54dysfuni understand what it's doing. but it doesn't help that you use mathematical symbols where words would do
11:55dysfunand the b ... b is a very verbose way of saying 'potentially many b'
11:55dysfunhow do you for example map alternating repeating groups?
11:56ambrosebseg?
11:56dysfun(assoc {} :foo 1 :bar 2)
11:56ambrosebswell that works with HMaps
11:56ambrosebsthat's of type '{:foo (Val 1) :bar (Val 2)}
11:56ambrosebsah
11:56ambrosebssorry
11:57ambrosebsthat is specifically a hack at the moment
11:57ambrosebsbut that's possible
11:57ambrosebsyou need an Assoc type
11:57ambrosebsand there's a core.typed branch where this is actually implemented
11:57ambrosebslet me find the type
11:57dysfunsome days i actually wonder whether haskell got it right banning variable arity
11:58ambrosebshttps://www.irccloud.com/pastebin/DWEEV49b
11:58ambrosebsthat's the prototype syntax for assoc
11:59ambrosebsas in it takes a map m, at least 1 key and value pair, then a bunch of c's that must be even in number
11:59dysfunokay. so you've correctly annotated that behaviour. you have but one problem: augh my eyes
11:59ambrosebsdysfun: I'm open to suggestions
12:00ambrosebsas I said, it works but isn't merged because I'm unhappy with the syntax
12:00dysfunheh, i'll let you know. i've been doing my own mapping of edn data to semantics the last week so i know exactly how hard it is
12:00dysfunclojure is pretty flexible so you have to model in that flexibility, sure.
12:01ambrosebshttps://www.irccloud.com/pastebin/xTWjWznc
12:01ambrosebsthat's one idea I had
12:02dysfunhrm. it's a lot more concise for sure
12:03ambrosebsanyway the thing I like about swap! annotation is the b ... b for the second argument must agree with the b ... b you use after the function
12:03ambrosebsnote that b * would be less accurate since that's a kleene star. b ...b expands to something like `Number Boolean Foo`
12:03dysfunyes. this is one of the things scala struggles with a little
12:03dysfunobviously it doesn't have variable arity
12:04ambrosebsdoes scala support rest parameters?
12:05ambrosebsI assumed it did
12:05ambrosebsor is it the variable arity polymorphism (ie. the dots) that it doesn't support?
12:06justin_smithambrosebs: http://stackoverflow.com/a/1008836/2258453 this looks like a yes
12:07ambrosebsoh heh it uses the * syntax
12:07dysfunoh, i stand corrected
12:08ambrosebsjustin_smith: gold star!
12:08ambrosebsI'm guessing it's just an array like java varargs
12:09justin_smithmy hunch was that it would support varargs, because it attempts to be an ungodly union of java and haskell to every last detail
12:09justin_smithright
12:09justin_smith(union in the conjugal and mathematical senses here)
12:09jonathanjuh, i might be stupid but why does (.write System/out (.getBytes "arst")) actually produce anything on stdout from the repl?
12:10justin_smithjonathanj: it does in mine, but won't in cider
12:10ambrosebsBronsa: even partial is a big hack. Real annotation should (somehow) be: (All [r a ... b ...] [[a ... a b ... b -> r] a ... a -> [b ... b -> r]])
12:10justin_smithjonathanj: probably won't in fireplace.vim either
12:10ambrosebsyou can see the first few cases of a ... a are manually added then we give up
12:10jonathanji'm just running `lein repl`
12:11justin_smiththen yes, that should print
12:11ambrosebsit's not obvious how to work with two dots next to each other
12:11jonathanjweird
12:11justin_smithjonathanj: try adding a \n to that string
12:11justin_smithbecause newline buffering is the default iirc
12:13jonathanjis (.write an-output-stream array_of_byte) the correct thing to do?
12:13ambrosebsBronsa: the reason some-fn is so utterly ridiculous is that 1) it has the same problem as partial in that there is a repeating pattern with no way to abstract over them 2) ((some-fn number? symbol?) a) has to know what's true if it returns true or false
12:13jonathanjspit writes something like [B@6dd57b86 to stdout
12:13ambrosebsthat involves digging into the type of number? and symbol? for some inner information
12:13ambrosebswhich is currently disgusting to do
12:13justin_smithjonathanj: that's the toString of the array...
12:14justin_smithbecause spit expects a string
12:14justin_smithyou could also use (spit (String. array_of_byte))
12:14justin_smith,(String. (.getBytes "hello"))
12:14clojurebot"hello"
12:15hiredmanjonathanj: you likely need to flush after you write, or write a new line (many buffered streams flush on new line)
12:28dreampilotHello everyone, can anyone point me to some examples or tutorials of how to call clojure code from java?
12:29mpenet``,(== (hash ["a"]) (hash (java.util.ArrayList. ["a"])))
12:29clojurebotfalse
12:29mpenet``and hours where lost on this one again :|
12:29justin_smithmpenet``: value based hashes don't make much sense for mutable objects
12:29mpenet``were*
12:30justin_smithjust like you wouldn't want value based identity for mutable objects
12:30mpenet``well I am not sure I'd agree, at least in this case
12:31muraikidreampilot: http://www.braveclojure.com/java/
12:31justin_smithmpenet``: consider what happens if you used it as a key in a hash-map
12:31mpenet``in theory yes, but you encouter issues because of it all the time in the wild
12:31mpenet``exactly
12:31justin_smithif you want value based hash, use an immutable type?
12:32mpenet``not my choice, it's a db driver that returns nested DS with arraylists in that case
12:32mpenet``yes, I can walk them and convert all the values to ensure proper hash equality, but it's not free
12:33mpenet``,(= ["a"] (java.util.ArrayList. ["a"]))
12:33clojurebottrue
12:35mpenet``for some background on it: http://dev.clojure.org/jira/browse/CLJ-1372?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&amp;focusedCommentId=38184#comment-38184
12:36justin_smithdreampilot: I'm not sure if this is still the best way, but it will work http://clojure.github.io/clojure/javadoc/clojure/java/api/package-summary.html#package_description
12:40andyfjustin_smith: Regarding mpenet's issue, your argument about mixing mutable and immutable would be stronger if Clojure did not treat them as =, but it does.
12:42justin_smithandyf: yeah, that's a contradiction, but I think the answer lies in not treating mutables as equal to immutable, rather than using a value based hash-code for mutable objects
12:42justin_smith,(= (java.util.ArrayList. ["a"]) ["a"])
12:42clojurebottrue
12:42andyfUnfortunately changing = that way would be breaking change for some code out there, almost certainly
12:43justin_smiththat's true
12:43justin_smithwe could join php in having an ever unfolding variety of equality comparators
12:56bbloomambrosebs: type signatures are only documentation until you get up the haskell's lens package
12:56bbloomthen you need fake/simplified type signatures to document your type signatures :-P
12:56ambrosebsbbloom: truth
12:56ambrosebslove the scala fake map annotation
12:57or9obis there a way to clear/reset a ns in cider?
12:57ambrosebsI should get in the business of fake annotations
12:57or9obMy tests refer all fns from the ns under test and I have renamed things in there - but cider still complains about the old name
12:59justin_smithor9ob: you can manually destroy the ns with remove-ns, or use something like clojure.tools.namespace/refresh
13:00or9obah, thanks justin_smith
13:00justin_smith(doto 'my.ns remove-ns require) perhaps
13:01justin_smithor9ob: this may leave other namespaces that used / required that ns in a weird state though
13:02muraikihas anyone here used jclouds with clojure? I'm considering using it but haven't found much in terms of experiences
13:02muraikiI'd be using it with openstack in particular
13:07Bronsayay. http://dev.clojure.org/jira/browse/CLJ-1232 pulled into 1.7
13:08justin_smithcool
13:13stuartsierraJust 'remove-ns' doesn't tell `require` that the namespace hasn't been loaded, so you have to force reloading.
13:13justin_smithstuartsierra: oh, thanks
13:13stuartsierratools.namespace hacks into the internal machinery of `require` to make this work.
13:13justin_smith(inc stuartsierra)
13:13lazybot⇒ 19
13:13ajmagnificoLet's say I have a vector xs with 1,000,000 values in it. Let's say I have another vector indices with about 500,000 0-based index values in it. I want to select indices from xs. What would be the most efficient way to do that?
13:15justin_smithajmagnifico: the first thing I would try is to map or mapv the vector over the indexes. Though a reduce may perform better.
13:15justin_smith,(mapv [:a :b :c :d :e] [1 2 3 2 1 0])
13:15clojurebot[:b :c :d :c :b ...]
13:16justin_smith,(reduce #(conj % (get [:a :b :c :d :e] %2)) [] [1 2 3 2 1 0])
13:16clojurebot[:b :c :d :c :b ...]
13:18sm0kehello i am seeing a lot of `async-dispatch-...` threads in waiting state when using core.async
13:19sm0keAnyone else faced this?
13:19justin_smithsm0ke: what are they waiting on?
13:20sm0kethe dump says waiting on condition [0x00...]
13:20sm0keis it intelligible?
13:21OldTreeDoes the :source-paths option of Leiningen allow namespaces within a directory structure like src/clj/project_name/file1.clj to have ns names like project-name.file1? I ask because I am adding Clojurescript to this project and I changed the directory structure without changing the namespace names.
13:21justin_smithif they were waiting on a read or a lock, that would be an issue with your code. Waiting on a condition should be the normal thing in core.async right?
13:21sm0kehurmm i dont know, i have a lot of problem with core.async and threads in general
13:22eli-sehi
13:22sm0keone of my production system is bleeding threads profusely
13:22justin_smithsm0ke: well, core.async go blocks use a pool where they get reused...
13:22justin_smithsm0ke: are you using thread / Thread. extensively?
13:22sm0kejustin_smith: well the thread pool is famous numcores*2+42
13:23sm0kebut i am getting 12k threads
13:23justin_smithright, but it's not a leak if it's a constant amount
13:23justin_smithor am I grabbing the wrong part of what you are saying here?
13:23ajmagnificojustin_smith: Brilliant. (map xs indices) is blazing fast compared to the junk I was writing. I had forgotten that vectors can be used as functions. Thanks!
13:23ajmagnifico(inc justin_smith)
13:23lazybot⇒ 212
13:24justin_smithajmagnifico: remember to compare it in a situation where the lazyness is forced of course :)
13:24sm0kei am thinkng of giving aleph a try instead
13:24ajmagnificowill do, justin_smith, thanks
13:25justin_smithsm0ke: so aleph with manifold for the async dispatch?
13:25jonathanjcan i access a private static inner class from clojure?
13:25sm0kedont know much about the jargon here, mainfold?
13:25justin_smithjonathanj: via reflection, sure. But it's not guaranteed not to break things when you do stuff like that :)
13:26justin_smithsm0ke: manifold is what aleph does for async dispatch, so it's something you can actually compare to core.async
13:26justin_smithaleph itself is more comparable to ring-jetty-adaptor or http-kit
13:26sm0keah i see
13:27justin_smiths/does/uses
13:27sm0kejustin_smith: did you had a good experience wth core.async?
13:27Guest8609I've seen some comments that middleware is often not a good idea and I'd like to read something about it, anyone a recommendation?
13:28justin_smithsm0ke: yes, but I've only used it in production a couple of times
13:28sm0kei find it very compelling to use but in reality it causes a lots of problems
13:28justin_smithGuest8609: what kind of middleware? what's the context here?
13:29Guest8609justin_smith: I guess what I saw was in the context of http handlers but I didn't have a specific area in mind
13:30justin_smithGuest8609: I have yet to see a clojure project that doesn't use middleware with http handlers, what was the argument against middleware?
13:30justin_smiththat is, if they use http handlers, middleware gets used in every case I remember seeing
13:30jonathanjif i need to extend a java class and be able to call super, what are my options?
13:31jonathanji read that chart linked earlier but it doesn't seem to really account for this
13:31justin_smithjonathanj: proxy + proxy-super
13:31jonathanjoh cool
13:32Guest8609justin_smith: I don't exactly remember, which is partly why I'm asking
13:33Guest8609justin_smith: I equally see middleware being used everywhere so the position seemed unpopular, got me curious
13:35justin_smithGuest8609: without any of the arguments or context I don't really have much I can say about it? I mean I guess the biggest problem would be you would have to implement all the middleware features by hand, and use them explicitly in each endpoint, and that just seems silly
13:39cnb_could I use annotations in a gen-class method parameter ?
13:39Guest8609justin_smith: yeah nevermind then, thought someone might have seen the same thing or something
13:52Glenjaminhttps://twitter.com/fogus/status/575712574815125504
13:53justin_smithahh, that's likely the one
13:53cnb_I need to generate a coded deftype using gen-class but as my deftype uses annotations I do not know how to implement them using gen-class
14:03jonathanji don't know if i'm going crazy but this error makes no sense to me:
14:03jonathanjCaused by: java.lang.ClassNotFoundException: org.apache.fop.apps.FopFactoryBuilder
14:03jonathanjhttps://github.com/apache/fop/blob/fop-1_1/src/java/org/apache/fop/apps/FopFactoryBuilder.java
14:03jonathanjfop is a dependency in my project.clj and i can import other classes in that package
14:06hiredmanjonathanj: just because you can see it on github that doesn't mean the version you are using has it
14:06jonathanjhow can i actually verify that my dependency has it?
14:07hiredmanfind the source code for the version you have specified
14:07hiredman(or open the jar and look)
14:07jonathanjwhere do i get the jar from?
14:07hiredmanwhat version are you depending on?
14:08jonathanj[org.apache.xmlgraphics/fop "1.1"]
14:08jonathanji was wondering if there was some way to have lein fetch the jar for me and put it somewhere i can look at it
14:09hiredmando you have the whole tracktrace? how are you trying to use it? how do you know you have imported other classes from that package?
14:10hellofunkis there any reason to prefer one of these idioms over the other: (into [] (for [x (range 10)] x)) vs. (vec (for [x (range 10)] x))
14:10jonathanjyes, i have the whole traceback but it's mostly pottering around clojure's internals
14:11jonathanjhiredman: i imported something else from a repl
14:11jonathanj=> (import '[org.apache.fop.apps FOUserAgent])
14:11jonathanjorg.apache.fop.apps.FOUserAgent
14:11amalloyjonathanj: if someone asks you for a full stacktrace, "i have it but i won't give it to you" is the wrong answer
14:11amalloyit may be useless ot *you*, but hiredman knows a lot about clojure's internals
14:12jonathanjhttp://hastebin.com/omucubiyij.txt
14:12amalloy(i suspect this particular one won't be very illuminating, but i would be interested to see what hiredman expects to get from it)
14:12jonathanji didn't say i wouldn't give it to anyone
14:13jonathanji just didn't think anyone would find it particularly useful
14:13amalloyjonathanj: i'm with hiredman: whatever version of the library you're getting doesn't have this class in it
14:13hiredmanjonathanj: what happens when you do the same import in the repl for FopFactoryBuilder?
14:14jonathanjhiredman: pretty much what you'd expect:
14:14jonathanj=> (import '[org.apache.fop.apps FopFactoryBuilder])
14:14jonathanjClassNotFoundException org.apache.fop.apps.FopFactoryBuilder java.net.URLClassLoader$1.run (URLClassLoader.java:366)
14:15justin_smiththat's not a stack trace
14:15amalloyjustin_smith: nah, but we already got a stacktrace
14:15justin_smithoh, never mind :)
14:15hiredmanso lein, like maven, fetches jars and stashes them in ~/.m2
14:16hiredman`lein classpath` will actually should you the jars
14:16hiredmanyou might try `lein deps :tree` just to see if you are getting the wrong version of the library for some reason
14:17jonathanjso indeed, the jar doesn't seem to include a .class file for that class
14:22jonathanjit looks like whatever is on maven is the thing tagged as fop-1_1old in git and fop-1_1 is some thing that apparently never made it to maven
14:22jonathanjterrific
14:23hiredmansounds like an apache project
14:26djamesAny favorite hosted services for private Maven repos?
14:29djamesThis page doesn't list hosted options: http://maven.apache.org/repository-management.html
14:30sdegutisWhat seq-based function would you use to split "foo bar quux" into ["foo", "bar", "quux"]?
14:32justin_smithI wouldn't use a seq-based function, because that is a string. clojure.string/split
14:32Bronsasdegutis: why seq-based? that's what clojure.string/split is for
14:32sdegutisI'm trying to practice writing a recursive function that would do it.
14:32sdegutisBut I don't know how the algorithm should wokr.
14:32Bronsa,(clojure.string/split "foo bar quux" #"\s+")
14:32postpunkjustinI guess you could use reduce?
14:32clojurebot["foo" "bar" "quux"]
14:32postpunkjustinIf that's really what you want
14:33sdegutisSo I'm looking into what function would typically do this so I can see how it's implemented.
14:33sdegutisI thought maybe it's group-by or partition or something, but no.
14:33sdegutisClosest is partition-by.
14:33postpunkjustinOh yeah, maybe partition-by (complement clojure.string/blank?)
14:34postpunkjustinNot 100% sure
14:34sdegutisBut partition-by leaves the ' ' inthere.
14:34postpunkjustinjust filter it after?
14:34postpunkjustinThis is a super weird way to do it
14:34sdegutis,(partition-by #(= % \space) "foo bar quux")
14:34clojurebot((\f \o \o) (\space) (\b \a \r) (\space \space \space) (\q \u \u \x))
14:35sdegutisIsn't there a pretty recursive algorithm to do this
14:40justin_smiththe recursive version is ugly
14:40justin_smith,(loop [s "foo bar baz" part "" strs []] (if (empty? s) (conj strs part) (if (= (first s) \space) (recur (subs s 1) "" (if (empty? part) strs (conj strs part))) (recur (subs s 1) (str part (first s)) strs))))
14:40clojurebot["foo" "bar" "baz"]
14:49turbofail(defn split-by [pred s] (if (empty? s) s (cons (take-while (complement pred) s) (split-by pred (rest (drop-while (complement pred) s))))))
14:52ToBeReplacedany way to check if getting the next item of a seq would block?
14:53turbofailno. you can check if a value is available for a lazy seq, which will tell you that it for sure won't block
14:54ToBeReplacedturbofail: how? that's exactly what i want to do
14:54turbofailuse "realized?"
14:56ToBeReplacedokay, wasn't what i was looking for, that's okay; makes sense that you can't do what I want, just figured i'd ask in case i missed an obvious pattern
14:56justin_smith,(realized? (range))
14:56clojurebotfalse
14:56justin_smith,(realized? (doall (range 10)))
14:56clojurebottrue
14:57paulswilliamsesqWhoop, big win today on my introducing Clojure to where I work. Paired on a simple refactoring with a really well respected maths grad today, and he started raving about how easy Clojure is to understand and change.
14:57justin_smithnice!
14:57arrdemgood goooooood
14:57ToBeReplacedi can always just put the seq to a channel, since that's really what I'm doing, and then take with a timeout
14:57turbofailhuh. did you use a structural editor?
14:57turbofaili don't feel like it's all that easy to change without it
14:59ambrosebspaulswilliamsesq: congrats
15:00jonathanjhrm, is there any reason that (.write (output-stream ...) bytes) would be different to (.write System/out bytes)?
15:00paulswilliamsesqambrosebs cheers, I get frustrated by my slow progress in learning Clojure due to less frequent than I'd like exposure.
15:01justin_smithjonathanj: well, it's a PrintStream, dunno how much difference that makes
15:01paulswilliamsesqambrosebs Jay Field's talk at QCon London a couple of weeks earlier helped too :-)
15:01justin_smithjonathanj: the class heirarchy is OutputStream -> FilterOutputStream -> PrintStream
15:02jonathanjhrm
15:03justin_smith$javadoc java.io.PrintStream
15:03lazybothttp://docs.oracle.com/javase/6/docs/api/java/io/PrintStream.html
15:03justin_smithjonathanj: the docs indicate that PrintStream adds things like auto-flushing that OutputStream does not have
15:05jonathanjif i render this PDF and write it to System/out (and redirect it to a file in my shell) i get this weirdly broken PDF (it's totally blank but it has pages defined)
15:05jonathanjif i write it to a file from clojure then it's fine
15:06justin_smithodd
15:06jonathanjvery
15:08arrdemjustin_smith: ping
15:08justin_smithyello
15:08dysfunBronsa: which reader do i want to create to read edn from a file recording the line numbers?
15:10Bronsadysfun: an indexing-push-back-reader
15:11arrdemThinking about Grimoire editing.. current plan is that each "artifact" (documented Maven artifact) will somehow indicate where it's sourced from and if the where is github I can generate fork and pr links to edit content.
15:11dysfunBronsa: thanks
15:12arrdemcomments/complaints welcome I'm stressing over how to make the "edit link" thing extensible although fundamentally it may not be.
15:13arrdemI guess it just isn't because examples and notes are fundamentally Grimoire's data not docs which could be vendored.
15:13justin_smitharrdem: I guess you could have the app create pull requests, and the config would indicate which repo to make them on? But it may be easier to create a queue of proposed changes in a db.
15:14justin_smitha wiki model might make more sense than a source control model
15:14arrdemmeh..
15:14arrdema wiki may make more sense but I don't want to join Raynes in dealing with auth and spammers.
15:15justin_smithmakes sense
15:15arrdemGH gives me auth at the cost of a longer workflow.
15:15justin_smitharrdem: you can make it create refheap pastes out of submissions, and track the URLs heh
15:15arrdemlol that'd be nice..
15:16jonathanjhrm, i think the problem here is that my bytes are being encoded to UTF-8 or something
15:16justin_smitharrdem: ahh, so someone would use their own github account to push button create a pr for the doc update?
15:16arrdemjustin_smith: bingo.
15:16arrdemsame as I was doing back ~Grim 2.x
15:16jonathanjis it possible to just write plain bytes to stdout?
15:19justin_smithjonathanj: if this were c, the normal thing would be to reopen stdout with different parameters (raw vs. cooked mode, buffering, etc.)
15:20justin_smithI don't know if there is a java equivalent of this actually
15:22jonathanjoutput written directly to a file: https://pb.codehash.net/444fdc3368a042b2a6d8dddb321f195c
15:22jonathanjoutput redirected to a file: https://pb.codehash.net/d517012d69854973b2a13c9a6e133dbe
15:22jonathanjit's kind of bizarre, i've never actually seen this before
15:24jonathanjsomeone just pointed this out:
15:24jonathanj>>> name('efbfbd'.decode('hex').decode('utf8'))
15:24jonathanj'REPLACEMENT CHARACTER'
15:24jonathanjso it's definitely some kind of encoding trainwreck but i have no idea what's introducing it
15:24justin_smithjonathanj: it could be that the jvm thinks your stdout cannot accept those characters
15:25justin_smithbut you'd think it would notice a file redirect and handle that differently...
15:25jonathanjhow do i get the JVM to mind its own business?
15:30amalloyjonathanj: write bytes instead of characters, probably
15:31jonathanji'm pretty sure i am writing bytes
15:31amalloythis behavior makes me think you have a bytestream you want to write, and you're converting it to a string as if via (String. the-bytes) and then writing that
15:32amalloyjonathanj: what does the writing code for your "directly to file" look like vs "written to stdout"?
15:33jonathanjamalloy: well, i'm just giving an OutputStream to Flying Saucer's ITextRenderer.createPDF method
15:33jonathanjso the difference is whether i pass System/out or whether i pass (output-stream "xxx.pdf")
15:34jonathanji guess i could use a ByteArrayOutputStream and write the bytes to System/out to see if it makes a difference
15:34amalloyjonathanj: System/out is a PrintStream, though
15:35amalloywhich has a write(byte[]) method, which should work, but it's possible this createPDF thing has an overload for PrintStreams that does something dumb
15:35amalloyeg, i expect if you passed (PrintStream. (output-stream "xxx.pdf")), you would get similarly broken behavior
15:37jonathanjhrm
15:37jonathanjhttps://pb.codehash.net/34e68111fa894f049b8c249e6e1645fa
15:37jonathanjthis still produces the weird output
15:47jonathanjsigh
15:48jonathanjso if i write (.toByteArray byte-array-stream) to (output-stream "xx.pdf") and to System/out (via the write method) then i get two results
15:48jonathanjxx.pdf is intact and whatever was redirected is broken
15:49amalloybeats me, jonathanj. i don't think that's supposed to happen. if i try writing a byte-array with invalid utf-8 in it to System/out, i seem to get those bytes appearing as expected
15:54amalloyeg, if i take some bytes from your "good" output, and write them to stdout via a simple program containing only (.write System/out (byte-array (map unchecked-byte [0xe2 0xe3 0xcf 0xd3]))), then my stdout contains those four bytes unmolested
15:55amalloyperhaps your shell is mangling them? try running this program and see what output you get: https://www.refheap.com/92f7edb8dcc2542cb3f659492
15:56jonathanja bunch of replacement characetrs
15:56amalloyokay, so in lieu of further evidence i am blaming your shell
15:56clojurebotExcuse me?
15:56justin_smithtermcap?
15:56amalloyclojurebot: in lieu of further evidence i am |blaming| your shell
15:56clojurebotAlles klar
16:01jonathanjjonathan@Callisto ~/Coding/documint> python -c 'import sys; sys.stdout.write("\xe2\xe3\xcf\xd3")' | xxd
16:01jonathanj0000000: e2e3 cfd3 ....
16:06Frozenlockah! I just discovered dash.el to bring many clojure goodies into emacs.
16:06Frozenlock(for the curious https://github.com/magnars/dash.el)
16:11jonathanjamalloy: this also outputs the original bytes unadulterated: https://pb.codehash.net/9c58bb20462c4e3cbea445a4b7b53ee7
16:15amalloywait, how are you running your code? lein repl?
16:15jonathanj`lein run`
16:17jonathanjjava -jar /Users/jonathan/.m2/repository/org/clojure/clojure/1.6.0/clojure-1.6.0.jar -e '(.write System/out (byte-array (map unchecked-byte [0xe2 0xe3 0xcf 0xd3])))' | xxd
16:17jonathanj0000000: e2e3 cfd3 ....
16:18amalloyso taht version works fine, and lein run doesn't. what about lein trampoline run?
16:20jonathanjyeah, that works
16:21amalloyjonathanj: look for related issues in the leiningen repo, and if you can't find one i'd file a new bug
16:21amalloywell, i guess try updating to latest lein first
16:22jonathanjLeiningen 2.5.1 on Java 1.7.0_45 Java HotSpot(TM) 64-Bit Server VM
16:23jonathanji'm not sure how to determine the newest version, but i see the master project.clj is 2.5.2-SNAPSHOT
16:29justin_smithjonathanj: if java -jar works properly, that should at least be enough for the pragmatics - lein is better as a build tool rather than a launcher. Still good to track down the root of the issue of course
16:38justin_smithakkad: what I typically do is look for anything "suspicious" or unusual in the stack traces, and check the process CPU usage and the results of multiple jstack calls to see if something is in a tight loop
16:38justin_smithakkad: what are the symptoms? just the process sitting there not exiting, or are you also not seeing output you would expect?
16:39akkadstops responding to http requests
16:39justin_smithakkad: as in connection refused, or timing out with no response?
16:47dysfunhrm. lein can't find my gpg key for some reason. any ideas?
16:48dysfuni get this error https://www.refheap.com/98522
16:53akkadjustin_smith nginx timesout
16:53akkadtalking to clojure backend
16:54crash_epdoes Clojure support heredocs or any form of string literal that doesn't require escaping quote individual quote characters?
16:56jonathanjjustin_smith: yeah, unfortunately `java -jar` is kind of an inconvenient way to run my app while i'm developing it
16:57jonathanjjustin_smith, amalloy: thank you for your help and patience, i filed a bug with lein
16:57jonathanj(for reference, <https://github.com/technomancy/leiningen/issues/1857&gt;)
16:58justin_smithjonathanj: a workaround: lein cp > class_path; java -cp $(cat class_path) clojure.main -m my.ns
16:59justin_smithif you don't change your project.clj, you don't even need to run lein cp next time
16:59justin_smiththough of course, having lein fixed would be better
17:01amalloyjustin_smith: java -cp `lein classpath` ...
17:01amalloybut really, lein trampoline run is better than that
17:02justin_smithamalloy: I suggested my version because you can skip lein the second time
17:02amalloyespecially with LEIN_FAST_TRAMPOLINE=yes_please
17:02justin_smithand because $() is provably superior to ``
17:02amalloyjustin_smith: LEIN_FAST_TRAMPOLINE actually skips lein the second time too, and is better at remembering whether you've changed project.clj than you are
17:03justin_smithamalloy: fair point on that one
17:07expezWhat does it mean when (println my-map) prints #<PersistentArrayMap {:foo "bar"}> instead of {:foo "bar"}?
17:08snowstalkerexpez: it means it's a small map, it shouldn't affect your usage of it though
17:08hiredmanit means someone has been mucking with your print methods, or you are running multiple clojure runtimes
17:08expezsnowstalker: to get "bar" I can't do (:foo my-map) or (get my-map :foo), but (-> my-map first second) works fine
17:08snowstalkerexpez: oh, see what hiredman said
17:09hiredmanmultiple clojure runtimes, which, how you could do that accidentally I have no idea
17:09expezhiredman: the latter is true, the code runs inside classlojure
17:09hiredmanyeah
17:10expezhiredman: how did you know, what does #<..> mean?
17:10hiredmanit is how unknown objects are printed
17:10Bronsawere* :P
17:10hiredmansure sure
17:10Bronsaspeaking of which hiredman clojurebot behaves weirdly in this regard
17:10hiredmanpams are a known object, so for them to print as known, it means that pam is not the pam of the clojure runtime where println was called
17:11Bronsa,)
17:11clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>
17:11Bronsa,(Exception. "")
17:11clojurebot#error{:cause "", :via [{:type java.lang.Exception, :message "", :at [sandbox$eval47 invoke "NO_SOURCE_FILE" -1]}], :trace [[sandbox$eval47 invoke "NO_SOURCE_FILE" -1] [clojure.lang.Compiler eval "Compiler.java" 6784] [clojure.lang.Compiler eval "Compiler.java" 6747] [clojure.core$eval invoke "core.clj" 3078] [clojure.core$eval25$fn__26$fn__36 invoke "NO_SOURCE_FILE" 0] ...]}
17:11Bronsa,(throw (Exception. ""))
17:11clojurebot#error{:cause "", :via [{:type java.lang.Exception, :message "", :at [sandbox$eval71 invoke "NO_SOURCE_FILE" -1]}], :trace [[sandbox$eval71 invoke "NO_SOURCE_FILE" -1] [clojure.lang.Compiler eval "Compiler.java" 6784] [clojure.lang.Compiler eval "Compiler.java" 6747] [clojure.core$eval invoke "core.clj" 3078] [clojure.core$eval49$fn__50$fn__60 invoke "NO_SOURCE_FILE" 0] ...]}
17:11Bronsashouldn't the first one print like the other two?
17:12expezhiredman: aha! but why is it affecting the code? The keywords have been namespaced and :foo isn't was it once was?
17:12hiredmanthe first exception is actually happening in a different version of clojure of course
17:12Bronsaof course
17:12hiredmanexpez: the Keyword type from the different clojure runtimes is not the same
17:13expezhiredman: that makes perfect sense. Thanks a bunch!
17:13expez(inc hiredman)
17:13lazybot⇒ 75
17:15dysfunugh. can i test signing a jar without doing a lein deploy?
17:48justin_smithdysfun: you could run a repl with the lein deps, and call leiningen.deploy/sign directly
17:48justin_smithafter loading your project file manually etc.
17:49justin_smithwith leiningen.core.project/read
18:11akuttruffHello all -- I'm new to Cider and am trying to (println (str request)). Where can I see these?
18:12nullptrakuttruff: i believe these typically show up in the repl view (C-c C-z)
18:12justin_smithakuttruff: nullptr: if it doesn't show up in the repl window, it will be in the buried *nrepl server* buffer
18:12justin_smithor whatever it is called these days
18:13justin_smiththis happens because the print is happening from a thread that has not inherited your main thread's value of *out*
18:14justin_smithakuttruff: see my answer to this question on SO http://stackoverflow.com/questions/26743958/why-cant-i-print-from-background-threads-in-clojure-cider-repl-in-emacs/26744113#26744113
18:14akuttruffthank you! I appreciate the help
18:29patchwork(inc justin_smith)
18:29lazybot⇒ 213
18:33{blake}So, a while back I moved this utility routine (map-function-on-map-values) from my various source namespaces (it was in more than one) to a "utility" namespace.
18:33{blake}This is a web-based app. And when I change the code, it forces me to re-login.
18:34{blake}But sometimes, since I moved this function over, instead of forcing me to login, it just plotzes: Unable to resolve symbol:map-function-on-mapvals in this context.
18:34{blake}I can hit refresh and get past this, but it won't have the new code, it'll be running the old code.
18:36hiredmanbecause you are using lein-ring with its bizzaro code reloading
18:36{blake}hiredman: Yes, I am. I did not know it was bizarro. But I find that somewhat reassuring, I guess.
18:37{blake}So, this is like a dead parrot thing? "Yes, it'll do that."
18:39hiredmanI dunno, I don't use it, I sort of took a shot in the dark
18:39hiredmanif I want to load/replace/run code I do it via a repl
18:39hiredmannot by saving a file and crossing my fingers
18:40{blake}Aw, crap, I forgot to cross my fingers.
19:06fredddhey, all. i was explaining clojure's immutable data structures to my friend, and he asked me for real-world examples of where they are a benefit. i could only come up with two examples: how you don't have to worry about the data changing if there is some long-running computation that needs to be done, and how perhaps in updating/rendering, if you know the value of the root node, you can simply do cheap pointer equality checks to dete
19:06fredddcan anyone offer some other concrete examples of their benefits?
19:07amalloyfreddd: you never have to call clone. you can just share pointers to your data freely
19:07amalloyand trust that data someone else gave you won't suddenly evaporate in the middle of working on it
19:08johnmendoncafreddd: concurrent access, no need to worry about order of mutation by multiple threads
19:08{blake}freddd: And you don't need a long-running computation. Pass a collection of objects to any routine and you really don't know what you're going to get back.
19:09fredddamalloy: ok. i think that's perhaps a better, more general version of my first example. thanks.
19:09freddd{blake}: good point!
19:09ToxicFrogfreddd: you get infinite undo (for editors, etc) basically for free
19:09nullptrfreddd: i did a presentation on immutability targeted at c#/.net developers which attempts to make a case (may be nsfw depending on your "w") https://docs.google.com/presentation/d/1DlqP8Yil13RMbOc4OA4n-juuYQt5-YuN-YKIwH1H9HE/edit?usp=sharing
19:09amalloyfreddd: another example: java.lang.String
19:10amalloytry replacing every use of String in your programs with StringBuffer, and see how much harder it makes things for you to be correct
19:10ToxicFrogI mean, you have to spend the memory for the history, but structure sharing means that it's cheap and immutability means it doesn't really take any extra work to keep the history intact
19:10fredddjohnmendonca: yeah, i mentioned that, but he was looking for more concrete. i think substantial threading is not nearly as popular, so he (and i, quite frankly) are not super-familiar with where this would be an obvious win.
19:11fredddToxicFrog: yes, very true. i did mention that. thanks!
19:11fredddnullptr: that's great, as c# is his primary language, though I typically stay away, but will definitely the link.
19:11ToxicFrog(and substructure sharing means that doing this is much cheaper than cloning on every edit as you would in something where the state is mutable)
19:12{blake}fredd: You could check out Ants. That's kind of a cool short example with lecture by Rich Hickey and everything.
19:13TEttingeryeah, I'm going to be rolling my own "atomic updates to a single unified state variable" thing in C# to get infinite undo
19:14TEttingerI think knowing how clojure does it may help :)
19:14freddd{blake}: I have watched that, but forgot about it. i kept hashing out examples that seemed similar in retrosepct, but would then realize it was atoms/agents that were doing the most benefit, not so much the data structure.
19:14brehautTEttinger: step one: create an F# project...
19:15TEttingerI asked in the F# channel and got no response!
19:15nullptrTEttinger: ms distributes first class immutable collections these days for all .net langs, so this shouldn't be terribly difficult
19:16{blake}freddd: Well, I think the interesting thing about that is that you don't normally use atoms/agents. Most of your functions will be pure. So when it comes time to deal with the state, you give it the appropriate respect.
19:16TEttingernullptr: huh, I hadn't thought of using those. I'm currently making heavy use of C5, which is an expanded set of data structures for C#/CLR
19:16{blake}There is a mindset thing going on here.
19:21brehaut{blake}, TEttinger: do any of those collections do structural sharing?
19:21{blake}brehaut: Which collections? AFAIK, in Clojure, they all do. =P
19:22brehaut{blake}: the .net ones. obviously im aware that clojure does
19:22brehaut{blake}: the .net immutable collections specifically
19:23nullptrbrehaut: yes
19:23brehautnullptr: cool, thaks
19:23TEttingerbrehaut: that's what I'm implementing, effectively... the idea is to make some sort of way to update a data-holding class by giving it a new state that's partially filled
19:23{blake}nullptr, brehaut: Be interesting to see immutable collections that didn't. They'd end up having to clone everything, which presents some interesting problems.
19:24brehautand sorry {blake} i accidentally addresse you instead of nullptr
19:24{blake}brehaut: np
20:22raspasovhey guys, has anyone here used https://github.com/mcohen01/amazonica ?
20:54bostonaholicno, but I have used https://github.com/weavejester/clj-aws-s3 (only for s3)
20:55bostonaholicI haven't needed everything that amazonica provides, so I stuck with the smaller lib
21:03raspasovbostonaholic: thanks for input!
21:33MorgawrI have a question, I've been getting my hands on prismatic schema. The prismatic defrecord is nice if I want to have some sanitization/validation of inputs in my functions, however I noticed that it does not allow me to use maps that are supersets of the specified record type
21:34Morgawrfor example if I declare a record type to have :a :b and :c keys, if I pass a record with {:a X :b Y :c Z :d K} it will be invalid (where X Y Z K are whatever values)
21:34MorgawrI can use optional keys if I know what their name is going to be, however I will not know that in advance and all I care about is for the primary keys specified in the original record to be there, is there a way to do that?
21:45Jabberzso what's the choice validation library out there today -- formative? bouncer? validateur? red tape?
23:47bcmMorgawr: You can do that.
23:48bcmif you write a schema like (def a-and-anything {:a s/Str, s/Keyword s/Any})
23:48bcmi think that will work
23:51bcmlooks to work on my box, anyway.
23:51bcmNow I have a question! I have a curl that is pretty involved. What's the best way to turn it into a function using something like http-kit client or clj-http?
23:52bcmalso, there's some clojure-talk going on now on HN: https://news.ycombinator.com/item?id=9214603
23:52raspasovwhat do you mean by "curl that is pretty involved" ?