#clojure logs

2013-04-14

00:01mynomotocarlw2: https://www.refheap.com/paste/13605
00:01carlw2thanks
00:02carlw2cool
00:02carlw2thanks for that
00:02carlw2good to know that im close
00:03mynomotocarlw2: https://www.refheap.com/paste/13606
00:04mynomotocarlw2: My lobos.config and lobos.migrations. That will set you up.
00:06carlw2perfect, im going to switch this over
00:06carlw2thanks so much for your help
00:06mynomotoyou're welcome.
00:46carlw2does anyone have any thoughts on how to mock external services for tests?
00:59mthvedtit seems like defmulti custom hierarchies have to be passed as vars. is this true? and if so why isn't it documented?
02:01tyler_how do i get more decimal places on a java.util.Date inst?
02:07tyler_with the 3 decimal places it possible to get a duplicate inst string for different instances of state in my app
02:07tyler_it's*
02:09tomojyou can't get more decimal places on a Date
02:09tyler_is there another way to generate an inst string in clojure besides Date?
02:10tyler_i guess theres joda time
02:10tyler_never really played with that
02:11tomoj&(java.sql.Timestamp. 0)
02:11lazybot⇒ #inst "1970-01-01T00:00:00.000000000-00:00"
02:12tyler_woo 9 places
02:12tyler_nice
02:12tyler_ah nanosecond
02:13tyler_almost enough to show hyperfine groundstate transition
02:13tomojyou need to change the handler for 'inst maybe if you want that
02:14Apage43,(class #inst "1970-01-01T00:00:00.000000000-00:00")
02:14clojurebot#<SecurityException java.lang.SecurityException: denied>
02:14tyler_says Date
02:14Apage43yeah, it gets truncated to a Date by default
02:16tomoj(binding [*data-readers* {'inst clojure.instant/read-instant-timestamp}] (read-string #inst...))
02:16tyler_with all the emphasis on identity and time in the language, its kinda odd that the default implementation of time is so limited
02:32muhoothat's java
03:13devntyler_: check out clj-time
03:14devntyler_: emphasis on time doesn't mean a robust system for inspecting representing time with strings
03:15devntyler_: it's kind of fitting really
03:15tyler_not technically
03:15tyler_i meant odd from a cultural standpoint
03:17tyler_i would have guessed that people would want time to be modeled as accurately as possible given the mindset of the people doing the program
03:17tyler_programming*
03:25devntyler_: i dont think that's accurate
03:26tyler_i don't think its falsifiable conjecture
03:26devntyler_: dealing with time in a way that is "automatic", like regular time is, means not thinking constantly about it
03:26devnwhich means not managing locks
03:26devnthe order of things, etc.
03:27devntyler_: i just think i took away something completely different from reading whitehead
03:27devnwhich is totally unsurprising and a little ironic
03:27tyler_its the beauty of philosophy
03:27tyler_;)
03:28devni feel like whitehead trolls himself in part I
03:28devnlike he's setting up this impossible standard which he will eventually bow to
03:28tyler_by part 1 i assume you're referring to process and reality and not pricipia mathematica
03:28devnyeah
03:29devnevery sentence in that book is open to interpretation
03:30devnspecifically the sentences about precise language
03:31tyler_i think its awesome that part one has "scheme" in the title ;)
03:31devnheh i never noticed that
03:32devnlikewise, though, i think what i liked is that it all seemed so related to programming, but it was conceived at a time when all of what we know now was a figment of the imagination
03:33tyler_i would say that programming''s goal is to try to simulate reality, so i don't find it entirely surprising
03:33devnI think that's partly a lie
03:34devnIn civil engineering you have real physical things to worry about, like wind, for instance.
03:34tyler_i mean as far as lisp is concerned, in relation to its AI history
03:34devnWith respect to programming, those are things you *invent*.
03:34devnConstraints are an invention.
04:56augustlis it possible that leiningen loads another version of a dependency than the one I've specified when I tell it to use a specific version, such as "[0.7.1]"?
04:56augustlI'm getting an exception that I can't even find when grepping the source of version I depend on.. But the exception is there in older versions
04:59augustl"lein deps" doesn't print anything either. Never used it before, but isn't that a bit weird? It just hangs for a few seconds and then exits with no output
05:00noidiaugustl, try lein deps :tree
05:01noidiplain `lein deps` is deprecated, it was used in Leiningen 1 to download dependencies (they are now downloaded automatically)
05:02augustlmy dependency with the correct version (clj-http "0.7.1") is listed in "lein deps :tree". Not sure how to best figure out which version of the jar leiningen actually loads.. I'm pretty sure I wouldn't get this error if leiningen loaded 0.7.1
05:02augustlthe line numbers doesn't match up in the stack trace, etc
05:02augustlit could also be that the git tag in clj-http for 0.7.1 is wrong, but that seems unlikely
05:03noidiyou can use `lein classpath` to see the jars it puts on the classpath
05:03augustlchecking the actual jar file in ~/.m2 now, it seems identical to the git repo
05:03augustlnoidi: ah, thanks
05:05augustlthe correct .jar is in "lein classpath" too.. I guess something else must be wrong, then.. It's deleting code until error goes away to figure out what the problem is time! :)
05:07augustlif anyone got some general suggestions for how to debug stack traces that contains references to source code that isn't present in "lein classpath" I'm all ears :)
05:07noidihow you tried turning the REPL process off and on again? :) https://www.youtube.com/watch?v=PtXtIivRRKQ
05:08noidis/how/have/
05:08andyfingerhutHave you tried unzipping the .jar in the lein classpath and looking at the source code in there?
05:09andyfingerhutYou could diff that against the version that you checked out with a git tag for version 0.7.1, and see if they match or not.
05:09augustlnoidi: :)
05:09augustlandyfingerhut: yeah I've looked inside the jar that is on the classpath
05:09augustl(according to lein classpath)
05:10andyfingerhutI'd ask for a full refund on your Leiningen purchase price. Heck, triple for pain and suffering :-)
05:12augustltotally!
05:12andyfingerhut~refund
05:12clojurebotCool story bro.
05:13andyfingerhutAnyone know the incantation to teach Clojurebot to say something in response to a word or phrase?
05:14augustlwhere could leiningen possibly load a jar from other than ~/.m2?
05:14augustlI deleted the older versions of clj-http I had from .m2 and the stack trace still refers to line numbers that doesn't match with the only .jar of clj-http I have in ~/.m2 ...
05:18augustlperhaps cosmic radiation
05:18augustlI'll try opening a window and unplugging my phone from the charger
05:24andyfingerhutWhich version of Leiningen are you using? 2.x I hope?
05:25andyfingerhutYou could try deleting your entire ~/.m2 (or renaming it) and trying again.
05:32augustlandyfingerhut: yeah, 2.x
05:33andyfingerhutI only asked about the Leiningen version since the now-fairly-old 1.x versions copied .jar files into the project directory itself. 2.x doesn't.
05:35augustlah, I see
05:36augustlsomething somewhere caused clj-http 0.5.3 to be downloaded.. So that's a start I guess
05:36andyfingerhutDoes clj-http 0.5.3 show up in the output of "lein deps :tree" anywhere?
05:38augustlit does not
05:39augustlI also see that my ~/.m2 only has the pom for 0.5.3, only 0.7.1 has a .jar in it
05:39augustlso it seems that ~/.m2 is not where the old version is loaded from
05:45augustlwell this is interesting. I'm manually poking around in the .jar file (it mostly contains .clj files) and that causes weird compilation errors when booting my leiningen project with "lein ring server"
05:46augustlthe .jar file in ~/.m2 for clj-http 0.7.1 that is
05:46andyfingerhutAre you sure it is clj-http that produces the stack trace lines you are seeing, and not some other library?
05:46andyfingerhute.g. clj-http-lite?
05:47augustlnot sure, but the first line in the stack trace I'm getting says "client.clj:232 clj-http.client/wrap-input-coercion[fn]"
05:47augustlthen "client.clj:151 clj-http.client/wrap-output-coercion[fn]", etc. All lines which doesn't have those functions in them in the actual jar :)
05:50andyfingerhutThere are functions with those names in that source file in clj-http 0.7.1
05:50augustlI wonder why poking around in the .jar file causes exceptions like "Caused by: java.lang.RuntimeException: No such var: util/lower-case-keys" though. Where util/lower-case-keys is referenced in a file inside the .jar I just added a comment to and saved (via emacs, which supports editing inside zip files)
05:50andyfingerhutNot at those line numbers, agreed, but maybe you should go by the function names for now and assume the line numbers are horked?
05:50augustlmy clj-http 0.7.1 jar has a comment string for the function wrap-redirects on line 151
05:50augustlhmm
05:51augustlI suppose I can, since I've no idea what's going on anyway :)
05:52augustlthe line numbers doesn't match with clj-http 0.5.3 either anyways..
05:53andyfingerhutAre you poking around inside a .jar file while it is in use by a JVM? That doesn't sound like a recipe for reproducible behavior to me.
05:54augustlno, I'm restarting the jvm
05:55augustlor, I'm not able to start the JVM, since I get that exception when I try to start my app after poking around in the jar
06:00MikeSethhmmm, my python nrepl client is almost working
06:01MikeSethsoon y'all can have a working clojure repl in Sublime
06:03augustlgot rid of my "checkouts" symlinks, so that wasn't causing oddities either
06:09augustlperhaps the jar has been installed on some kind of "system" classpath - does the JVM have such a thing?
06:19augustlran a "find", can't find any clj-http outside of ~/.m2
06:28augustlperhaps versions on OS X is doing this.. </randomguess>
06:34mpenetuse lein classpath
06:34mpenetyou might find it there
06:36mpenetor in your situation: "lein classpath | grep clj-http"
06:37augustlmpenet: it's there, but my problem is that it seems that something somewhere somehow loads a completely different version
06:38augustlare there any generic debuggers I could attach to my running clojure process?
06:39mpenetritz I guess, but I am not sure how stable it is. I think CCW has something like that too
06:42mpenetoh btw, did you "lean clean" first? I had a similar issue after an update of a dependency where old compiled files would put me in a weird state
06:43augustlI did a "rm -rf target".. I'll try the "lein clean" too
06:43augustl"lein clean" did not help either
06:43mpenet:(
06:49augustlare there any generic debuggers for the JVM I could use?
06:49augustlall I really want to do is to attach a debugger to my java process and break on exceptions
08:47cldwalkerhi, any recommendations for a mocking library seeing that clojure.contrib.mock didn't get ported over?
08:47Ember-alter-var-root or midje
08:49cldwalkerI see https://github.com/EchoTeam/clj-mock but they haven't coordinated with http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
09:11bttfwhere can i find all my libs that lein pulls down?
09:11bttfim trying to take a look at some code for a library but i have no idea where it's located
09:14noidibttf, lein classpath
09:15katratxobttf: check ~/.m2/
09:16bttfok
09:17katratxo"jars can be referenced directly out of the ~/.m2/repository directory." https://github.com/technomancy/leiningen/blob/stable/doc/FAQ.md
09:18naegwhat's the best way to get the index of the highest number in a vector? e.g. [1 5 4 3 2] => 1
09:23hyPiRion,(->> [1 5 4 3 2] (map-indexed vector) (apply max-key second) first)
09:23clojurebot1
09:24hyPiRionIt's possibly not the best way though
09:24naegonly found similar solutions on the net
09:24naegthanks
09:25naegit's just a vector of constant size 7 anyway, so not that problematic
09:47jakzaleHi, I have a question regarding using vars in clojure or any global mutable state. May anyone explain the usage of set! special form or point me towards a site with it. I tried googling it, but I could not find anything useful.
10:26noidijakzale, you most likely don't want to use vars to hold mutable state. AFAIK their purpose is to allow interactive development by redefining functions and "constants" on the fly.
10:28noidivars are for the state of your program's definitions, and the various ref types are for the state that the program itself modifies
10:29jakzalenoidi: Ok, also, in the meantime I believe I found what I was looking for: use binding for function local mutable state.
10:30noidiwhy does your function need local mutable state? :)
10:30noidiclojure has excellent facilities for writing purely functional code
10:32ravsterhello all
10:33jakzalei think what I was actually looking for are monads, because keeping the state in functions can get quite messy
11:19llll,,:a
11:19clojurebot:a
11:19llll,:a
11:19clojurebot:a
11:19llll,:m/7
11:19clojurebot#<RuntimeException java.lang.RuntimeException: Invalid token: :m/7>
11:19llll,:7
11:19clojurebot:7
11:19llllwhy is that?
11:20kmicu, (keyword 7)
11:20clojurebotnil
11:20kmicu, (keyword '7)
11:20clojurebotnil
11:22llll,(keyword :m/7)
11:22clojurebot#<RuntimeException java.lang.RuntimeException: Invalid token: :m/7>
11:23bbloom,(keyword "7")
11:23clojurebot:7
11:23kmicu, (class :7)
11:23clojurebotclojure.lang.Keyword
11:23bbloom,(keyword "m" "7")
11:23clojurebot:m/7
11:23bbloom:m/7
11:24bbloom,:m/7
11:24clojurebot#<RuntimeException java.lang.RuntimeException: Invalid token: :m/7>
11:24bbloomyup
11:24bbloomthe keyword & symbol functions don't validate their inputs all that well
11:24nils_hi. is there a way to get the code of a specific multimethod implementation via source?
11:25llllits a bug?
11:50shriphaniHello everyone. I am trying to parse a very simple xml string: (xml/parse "<TIMEX3 tid="t2" type="TIME" value="2005-04-12T10:30">Apr 12 10:30am 2005</TIMEX3>") and this happens: NumberFormatException Invalid number: 2005-04-12T10:30 clojure.lang.LispReader.readNumber (LispReader.java:253) . Is there anything I am missing? Why should value be bound to a number ?
11:52borkdudeany great recent examples of clojure commercially used?
11:53shriphaniborkdude: prismatic has a few clojure repos : https://github.com/Prismatic
11:54borkdudeshriphani tnx
11:56babilenborkdude: worldsingles pops into my mind
12:00shriphanialso nvm about my question. just me being a super-idiot.
12:03kmicuNajs.
12:12shriphanidoes anyone here use clojure as a scripting language ?
12:16giaceccoborkdude: http://www.quora.com/Whos-using-Clojure-in-production
12:17borkdudegiacecco wow, nice
12:18giaceccoborkdude: pity the list is not accompanied by some kind of description of what they do with it, and what's the source
12:44ravsterhow do I make a 'map' call not be lazy?
12:45ravsterI should be having 587 objects but I'm only getting 64 :(
12:45mefestoravster: you could wrap the call in a doall
12:45mefesto,(doall (map inc (range 10)))
12:45shriphanihi. I have a java class of the form : public class A { public static class B() … }. I have imported A but I cannot seem to get B using either A/B or A$B. What am I doing wrong ?
12:45clojurebot(1 2 3 4 5 ...)
12:46ravstermefesto: oh, thanks
12:47mefestoshriphani: did you explicitly import the static inner class as well?
12:47shriphanimefesto: no
12:47mefestoshriphani: i *think* that is necessary
12:47shriphaniI only have imported the outer class.
12:48shriphaniumm so how does the import statement look ?
12:48mefesto(import '[myapp A A$B])
12:48shriphaniah.
12:48shriphaniand I use A$B as the symbol ?
12:48mefestoyea
12:48shriphaniok.
12:48shriphanithanks.
12:49shriphanialso. is there a way to make the repl reload everything?
12:49shriphaniCtrl-D and lien repl always is quite painful.
12:49shriphanilein *
12:51shriphanimefesto: another question. I need access to B.class (this is what I have in my java code). I tried (. A$B class) but clojure says there is no class field. What is the workaround for this ?
12:52mefestoshriphani: doesn't A$B resolve as a class?
12:52tomoj:)
12:54shriphanimefesto: yeah that worked. Sorry I am just converting some sample code someone wrote for a wonky library in java to clojure and I am bad at both so ..
13:35naeghey, wrote a connect four game with a basic minimax ai in clojure and would appreciate any feedback: https://github.com/naeg/clj-connect-four/tree/master/src/clj_connect_four
13:36naegspecifically about everything related to clojure, since I'm a newcomer (coding style, simplifications, ...)
13:49chessguyi think i have some fundamental misunderstanding of clojure.core.unify
13:49chessguy,(unifier 'foo 'bar)
13:49clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: unifier in this context, compiling:(NO_SOURCE_PATH:0:0)>
13:50chessguywell, this returns bar for some reason. i would expect it to return nil, because they don't math
13:50chessguy*match
13:55shriphaniHi. In python I could do: a,b,c = split("a b c") and have the valued bind. How do I do this inside a clojure let ?
13:55gfredericksshriphani: destructuring
13:56shriphanigfredericks: link ?
13:56gfredericks(let [[a b c] (something that returns a seq of three things)] ...)
13:56gfredericks$google clojure destructuring
13:56lazybot[Jay Fields' Thoughts: Clojure: Destructuring] http://blog.jayfields.com/2010/07/clojure-destructuring.html
13:56shriphanihmm and that won't work in a binding ?
13:56gfredericksbinding like for dynamic vars?
13:57shriphaniyea maybe like : (binding [[a,b,c] [1,2,3]] a)
13:57shriphani(binding [[a b c] [1 2 3]] a) gives me clojure.lang.PersistentVector cannot be cast to clojure.lang.Symbol
13:58gfredericksright binding doesn't support that
13:58gfredericksyou want to dynamically bind three vars at once?
13:58shriphanigfredericks: is that wrong ?
13:59BronsaI don't see much sense in that.
13:59gfredericksI think most people don't use dynamic vars that heavily
13:59Bronsaalso, let creates lexical bindings, binding only binds them
13:59chessguysorry, i had to reboot, not sure if anyone responded to my comment about unifier
13:59gfredericksthey tend to be for orthogonal configuration purposes
13:59Bronsadestructuring is usually used when creating binding
14:00Bronsabindings*
14:00dnolenchessguy: just seems like a bug
14:01chessguydnolen: well, it seems to be consistent.
14:01dnolenchessguy: core.logic's unifier returns nil for that case, those two terms don't unify.
14:01rationalrevoltcan someone help me understand why refs have associated history? I'm trying to read through refs from the book "Clojure Programming", and it mentions: In the case of reference types, deref is guaranteed to never block. However, inside a transaction dereferencing a ref may trigger a transaction retry!
14:02chessguydnolen: hmm, maybe that's what i went then
14:02noidirationalrevolt, they're needed so that clojure can provide your transaction with a consistent snapshot of the world, even though some of the refs' values change during it
14:03chessguyhere's another example: (unifier '(foo ?x) '(bar baz)) => (bar baz)
14:03rationalrevoltbut, isn't the existence of ensure leave that to the programmers choice?
14:04noidirationalrevolt, i.e. with refs a, b, c, even if the value of b changes from b1 to b2 during the transaction, clojure can still provide you with a snapshot containing [a1, b1, c1], because b1 is kept in the history
14:04chessguymakes me wonder if the core.unify unifier is trying to do something different
14:05rationalrevoltnoidi: thanks, that helped
14:07chessguydnolen: so the equivalent of my last example in core logic is something like this? (run* [x] (== '(foo x) '(bar baz)))
14:11dnolenchessguy: yeah I'm not sure what core.unify unifier is supposed to do. Probably worth asking on the ML. fwiw, unify and unifier in core.logic do the opposite of core.unify. unify returns the unified term, unifier returns the most general unifier (a substitution)
14:12dnolenchessguy: that's not quite right. (run* [x] (== (list 'foo x) '(bar baz))), which will fail.
14:15chessguydnolen: err, why do i need "list" there?
14:15dnolenchessguy: also, the actual core.logic translation would be (unify '[(foo ?x) (bar bbaz)])
14:15chessguyoh, i like that better
14:15dnolenchessguy: you quoted the list, x won't refer to the logic var.
14:16chessguydnolen: oh, silly me, of course. thanks
14:21berdarioUhm, since people are talking about core.logic, can someone look at this? http://cljbin.com/paste/516af389e4b0497d9e99b008
14:22berdarioit's the first code I've ever written with core.logic... and so there might be some obvious refactoring to be done
14:22chessguydnolen: the translation you gives me results in an arity exception
14:23berdarioso, any suggestion is welcome...
14:23chessguys/gives/gave/
14:23berdariouh, dnolen is gone :/
14:24chessguybummer
14:43iamdrwHi everybody. Does anybody knows how to attach meta-data to a deftype and later retrieve it. I do (deftype ^{:meta :data} Foo []) , but (meta Foo) returns nil :-(
14:46bbloomiamdrw: (= (class Foo) java.lang.Class)
14:46bbloomand Class doesn't implement IMeta
14:46bbloomalso, there is no #'user.Foo var that is created, so that won't have the meta
14:46bbloomi'm not sure if there is anything for that metadata to be hung on
14:47bbloomwhat are you trying to accomplish, maybe we can suggest an alternative
14:47iamdrwoh, I see
14:53iamdrwI'm trying to create a simple plugin system — I have a plugin protocol and a macro(that does deftype and extend-type) for creating such plugins. And what do I want is to have some static meta-data about this type of plugin, because current implementation has a method in protocol, which is bad — as I have to actually create a plugin in order to have meta-data. Which is confusing :)
14:58ravsterhey all, I'm not able to understand why my code is failing at the 64th element of a list <---- https://gist.github.com/ravster/5383799
14:58ravsterwell, 65th.
14:58ravsterbut when I run the code on the 65th object, it doesn't return any errors.
14:58ravsterjust some strange stringreader thing when its inside the map
14:59ucbravster: it's difficult to say without looking at the data. The number 64/5 may come from the fact that maps are realized in chunks of 32 items
14:59ravsterucb: what do you mean by 'realized'?
14:59ravsterI've tried a (doall ) around the map, bt that doesn't make a difference
15:00ucbravster: you know how maps are lazy? well, they're kind of lazy in that when you create one the first 32 items are realized. Forinstance, (map (fn [i] (println i)) (range 128)) shouldn't print anything, right? yet it prints numbers till 32
15:00ucb(or 31, haven't tested the code)
15:01ravsterit prints all the way to 127 for me.
15:01ucbin the repl, sure
15:01ucbtry wrapping that in a def
15:01ravsterbut it is in chunks of 32
15:02ucbe.g. (def not-so-lazy (map ...))
15:02ravsteroh okay
15:02ucbso, in any case, without looking at your data i can't really tell why it may be failing on the 65th item :)
15:04ravstergist updated https://gist.github.com/ravster/5383799
15:04ravsterwith data
15:04ravsterits plain json parsed and generated with cheshire.core
15:06ucblooks like not all items are the same shape?
15:07ravsteroh, so it could be that 65-97 might have a problem? Not just the 65th one?
15:08ucbperhaps
15:09ucbthe first few items don't seem to have the same shape
15:09ucbit's also difficult to see items 65- in that gist too ;)
15:09ravsterucb yeah :)
15:14ravsteryay, manual binary split-search!
15:29ucbravster: you found it?
15:30ravsteryeah, its failing around 92
15:31ucbravster: any thoughts why?
15:32ravsterno clue yet. All the keys seem valid. I need to look at the ones around it.
15:37ravsteryay. found out!
15:38ravstersome of the data doesn't have lat and longitude! They just don't exist on the planet earth! And naturally my code didn't check for extraterrestrial schools
15:38ravsterthanks for the 32-sets map thing hint, ucb .
15:46adrian`Hello all... I'm looking for advice about how to properly reason about and/or manage state for a multiplayer board game, like Chess.
15:52chessguyadrian`: what is your question, exactly?
15:53chessguyadrian`: your first line of defense in clojure is usually to use pure functions on some built-in data-structure, like, in this case, a map of pieces to squares, maybe
15:55adrian`So I've done that for the game board/positions
15:55oskarthappropriate nickname :p
15:56adrian`but I suppose my problem is ... I have no idea how to properly syncronize state between the client (the player) & server (the "AI")
15:57adrian`That is, without including the entire board in every call between the client/server
15:57adrian`I'd like to just transport the move in a message to be rendered by the UI
15:58chessguyso do that then
15:58naegwhat should one use to handle command line args?
15:58chessguyby the way, most serious UIs don't re-invent a UI
15:59adrian`If the goal were to just render the moves, then that would sufficient
16:00adrian`But the reason I'm doing this is because I thought taking a functional approach to AI would be interesting and a good learning experience, but I'm having trouble mapping the actual backend stateful logic into a functional domain
16:01chessguyadrian`: "backend stateful logic"? you mean drawing the UI?
16:02adrian`no, I mean the decision making for the AI's move
16:02chessguyadrian`: ah. have you read the famous "why functional programming matters" paper?
16:03chessguyadrian`: has a nice, long example of doing tree search in a functional style
16:03adrian`in order to make good moves the AI needs to maintain state of the game between moves, like positional data, zobrist keys etc.
16:03adrian`I haven't
16:04adrian`I'll check it out
16:05chessguyadrian`: definitely worth a read, though i haven't seen it translated to a modern engine with thinks like hash tables like you're describing
16:06chessguy*things
16:06adrian`But I should mention that my issue is not reasoning about the structure of the data from a functional perspective, (I think I have a decent grasp on that end) but rather about how to syncronize state between asyncronous agents in a proper "functional way"
16:07chessguyadrian`: why do the agents need to be asynchronous?
16:07adrian`By that I mean, if the entire game were encapsulated in a single function I wouldn't be having the problem
16:07adrian`The AI has to respond to a player's move, which then has to be syncronized
16:07adrian`but I don't want it to block
16:07adrian`What if the server is playing two players, for example?
16:08adrian`It has to be able to dispatch the move to the right game for processing
16:09adrian`but I can't think of a way to do that without recreating the entire state of the game every time, which would mean the transport data would be huge
16:13chessguyadrian`: well, i haven't played a lot with clojure concurrency yet, but what happens when you have multiple agents where the state is a board?
16:15adrian`I'm not sure what you mean
16:16chessguyhave you tried applying clojure agents (http://clojure.org/agents) to the problem?
16:17adrian`I have, but I'm having issues most likely due to my general ignorance about how to properly reason Clojure's way of handling state
16:19adrian`I have yet to find a good resource for working with agents/refs/atoms when dealing with data that is more "abstraction" oriented than primitive types
16:21adrian`Like, for example, let's say I want to have the game be an agent - any idea how to properly have the agent inherit the datatypes already implemented interfaces?
16:22adrian`Like if I have a protocol to model some chess playing intelligence - it has a board, a piece color, available moves set, a move history etc.
16:23adrian`I mean, a record
16:23iamdrwmember:adrian%60 (def board (atom {})
16:23adrian`Now that record implements some protocol
16:24adrian`How do I create an agent/ref/atom that when instantiated has the records protocol methods already implemented?
16:24adrian`@iamdrw That's a map
16:25adrian`What if the data is a record with lots of predefined structure, methods
16:25adrian`and it implements arbitrary protocols
16:25iamdrwwhy not use map inside defrecord?
16:26adrian`I mean, the move history is a map
16:27adrian`but other things are not easily represented by a map... like the zobrist hashes, they're an array of bitsets which are arranged in a way to reduce repetitive computation, and that's a necessary field of the game board for the AI to use
16:27adrian`That's just one field
16:28chessguyadrian`: can't that be one value in the overall map though?
16:28adrian`Well, records are basically maps
16:29adrian`but when you just define vars like (def board (Board. (atom (new-board))))
16:30adrian`since the board is a type being created as an atom, the atomic structure hasn't implemented the protocols of the Board type
16:30iamdrwif you are able to implement zobrist hashes in clojure vector/maps then you could use all clojure concurency — atoms, refs, agents, promises, futures and so on.
16:32iamdrwbut they are different — as maps are functions
16:32adrian`So basically I should refactor everything out of protocols/records into maps/vectors?
16:32iamdrwand record — is a java class
16:32iamdrwI guess you should find a balance between using your defined types and standard maps/vectors
16:34adrian`I guess I could do that
16:34iamdrwand also you could check the 11th chapter of Joy Of Clojure — for more info about clojure concurrency model
16:34adrian`Although I like the abstraction
16:39iamdrwyou could use the abstraction and use clojure map or vector of changes encapsulated inside record.
18:24_ViOn [this page](http://clojuredocs.org/clojure_core/1.2.0/clojure.core/*print-dup*) I see "serialize" and "deserialize" functions which use "read". But unlike in the documentation for "read", here there is no warning about "Don't deserialise untrusted data". I have just found those functions being used in my project...
18:28_ViHow to read with clojure.edn/read-string the data which was previously saved with that "serialize"? It begins with "#=(clojure.lang.PersistentArrayMap/create".
18:32bbloom_Vi: sorta the point of clojure.edn/read-string is that it can't read #= forms
18:32bbloom_Vi: if you trust the data is not malicious, then you can just use clojure.core/read-string
18:33_Vibbloom, The data is stored on remote server. I was thinking "I'm using official serialisation routing copied from official docs)" and only now found out that it is simple "read".
18:33_Vis/routing/routine/
18:35_ViNow I want to switch to EDN, but also want to be able to read old files. Is just stripping away that #=(clojure.lang.PersistentArrayMap/create enough to correctly read that? (it's a simple map of maps of various keywords and strings).
18:35_ViNow I want to switch to EDN, but also want to be able to read old files. Is just stripping away that #=(clojure.lang.PersistentArrayMap/create enough to correctly read that? (it's a simple map of maps of various keywords and strings and numbers).
18:36bbloom_Vi: #= implies you set *print-dup* to true, which must have been done for a reason... but regardless of the reason, the simplest thing to do is to port your data via clojure.core/read and then clojure.edn/pr
18:37bbloom_Vi: if porting the data in bulk is not an option, you'll need to get creative
18:37_ViIs simple data (without custom classes or such) saved with *print-dup* fundamentally different that data saved without *print-dup*?
18:38bbloomdepends on what you mean by fundamentally :-P in short: print-dup prints text that is NOT EDN, it is Clojure Forms, which is a superset
18:38bbloomit's also an UNSAFE superset
18:39bbloom_Vi: think of it as eval vs JSON.parse
18:42_ViFor my case it looks like if I just remove the beginning ("#=(clojure.lang.PersistentArrayMap/create ") and the end (")\n") clojure.edn/read-string successfully reads the thing.
18:43bbloom_Vi: like i said, you can get creative
18:43bbloom_Vi: just ask my good buddies sed and awk
18:44_ViBut the page about *print-dup* should be edited, I think...
18:44_ViIt should say: 1. deserialize is insecure for untrusted, 2. consider EDN, 3. it is not compatible with EDN...
18:45bbloom_Vi: EDN is very new & documentation moves slowly :-/
18:48dnolenchessguy: re unify translation earlier - works for me.
18:50dnolenpretty neat use of clojure.core.logic.fd http://github.com/namin/metasolfeggio/commit/0dcc51d7678b423984967e6b2147e6bbeb139339#comments, counterpoint via overtone
18:50brehautbbloom: quite a euphemism
18:52_ViBTW: is there a simple way to "prn" an object with identation. I'm not looking for big and slow pprint, just serialize data in _slightly_ nicer than one long line format?
18:52bbloom_Vi: who says pprinting has to be slow?! https://github.com/brandonbloom/fipp :-)
18:53_Vifipp is also slow: I've checked (fipp was suggested at StackOverflow).
18:53chessguydnolen: i'm doing something wrong then. i have (ns foo (:require [clojure.core.logic.unifier :as logic])), followed by (logic/unifier '(?x ?y ?z) '(1 2 ?y))
18:53bbloom_Vi: aw :-( bummer (i wrote fipp) there are plenty of opportunities for optimizing it
18:53_Vi(time (do (with-out-str (fipp (repeat 1000 [{:q 3 :d 4} 5]))) nil))
18:53_Vi"Elapsed time: 8945.981596 msecs"
18:54bbloom_Vi: yeah, you can definitely beat the pants of fipp with a brain dead indenter
18:54chessguydnolen: err, that's not exactly what you gave me, but i was playing with it a bit trying to get it working
18:54_ViJust prn is 132 msecs.
18:55bbloom_Vi: what do you get with clojure's pprint ?
18:55_ViNow using hacky way: (-> object prn-str (clojure.string/replace " {" "\n{") (clojure.string/replace ", " ",\n")). It more or less suits the task, but not a generic solution.
18:56_ViNow measuring.... Waiting...
18:56_Vi"Elapsed time: 17216.384673 msecs"
18:56bbloomyeah, about twice fipp is what i was seeing
18:56bbloomi can probably make fipp a lot lot faster
18:56bbloomit does a boatload of allocating right now
18:57_ViMaybe fipp should have a "simple mode" for serializing big chunks of data?
18:57_ViI expect indented output to be, for instance, 20%-30% slower than regular... But not 2 or 3 times slower...
18:58dnolenchessguy: yes that is not correct, unifier takes vector of terms, it does not take a terms as individual arguments.
18:58bblooma "simple mode" is unlikely to be where i'd start, since i suspect (although have not proven) that the perf hit comes from all the intermediate structures, not the measuring process
18:59_ViDoes fipp always print the same as prn (except of formatting)? No chance it breaks any data compared to prn?
19:01bbloom_Vi: fipp only has a couple of people using it (that i've heard from), but i haven't gotten any bug reports on the EDN correctness
19:01bbloom_Vi: that's about as confidently as i can answer that question
19:02ravsterI'm trying to do a case on (type foo), and its not accepting clojure.lang.PersistentArrayMap
19:02_ViBTW we have clojure.edn/read-string. Maybe there should be also clojure.edn/write-string. Even if it does the same as pr-str, it can be beneficial to have symmetry...
19:03ravsterthe exception I'm having it throw is returning "class clojure.lang.PersistentArrayMap" instead
19:03bbloom_Vi: that's a suggestion for the mailing list & may be best accompanied by a ticket/patch
19:04ravsterhmm, maybe thats something that happens when I do (str (type foo)) in the exception. But still it shouldn't get to that point
19:04_ViDoes the mailing list support sending without being subscribed to it? Or just open a JIRA ticket?
19:05bbloom_Vi: you can join the google group w/o signing up for a email subscription
19:05bbloom_Vi: well, that's the clojure users group, if you want to join the clojure dev group, you need a signed contributor agreement
19:06amalloyravster: case doesn't evaluate its test clauses. clojure.lang.PersistentArrayMap is a symbol, not a class; when evluated, it produces a class
19:08ravsterSo (type foo) creates a class?
19:08_ViStrange... My dev.clojure.org user account no longer works (and email is "forgotten" also).
19:09dnolenravster: case only works on compile time literals, I don't think you can make it work on classes.
19:09ravsterokay
19:09dnolen(could be wrong about that, but I don't think so)
19:09ravsterI'll just change that to a cond or something
19:10ravsterthanks amalloy, dnolen
19:16_ViWhy can't I neither log in to dev.clojure.org as "_Vi", nor recover the password/username, nor re-register as "_Vi" ("A user with this username already exists")
19:19ravsterd'oh, or I could just use map? and seq?
19:19ravsterderp derp
19:22yedidoes anyone know how to run scripts on an rds instance?
19:28bbloom_Vi: so both fipp and core pprint use multimethods for interpreting data structures (instead of protocols) which (according to some simple profiling) is a major cause of slowdown
19:30_ViDoes it mean "slow by design" or "we'll reimplement with protocols"?
19:32bbloomwell from i can tell, about 2/3rds of the cost isn't printing, it's translating the EDN structures into a printable structure, which can likely be done with protocols w/o much loss of flexibility
19:35_ViCan it be blazing-fast after this?
19:35bbloom_Vi: it's never gonna be as fast as prn
19:36_ViMeans at least to measure "N per cents against prn", not "N times"...
19:39pl6306How do I used reduce to add a new line character to a seq of strings?
19:40_Vipl6306, Do you mean something like (map #(str % "\n") seq-of-strings) ?
19:41pl6306I wanted the end result to be a string. So I thought (reduce #(str % "\n") str-seq) would work but it doesn't
19:42bbloom_Vi: holy hell. multimethods are SLOW
19:42bbloomi knew they were slow, but wow, crazy slow
19:42nightfly__pl6306: try the three argument variable of reduce
19:42andyfingerhutpl6306: Wrap that in (apply str ...) and you should get the result you want
19:42nightfly__*variant
19:43andyfingerhutpl6306: Ignore that. I must have been on drugs to say it.
19:43bbloom_Vi: your test takes about 2,000ms on my machine, but with protocols instead of multimethods, it needs about 600ms
19:43andyfingerhutI was thinking of map, not reduce.
19:44pl6306ok
19:45pl6306I think it should be a simple solution.
19:46IamDrowsywhat about (reduce #(str %1 "\n" %2) str-seq)
19:47bbloom_Vi: still, same test only needs 12ms with prn, heh
19:48_Vibbloom, Can there be some compromise solution with 30 ms?
19:48pl6306(reduce #(str %1 "\n" %2) str-seq)  works but why 2 args and not one?
19:48IamDrowsybecause reduce always needs a 2 arg fn
19:49pl6306Got it thanks!
19:50bbloom_Vi: dunno yet, i've been profiling/optimzing for all of 10 minutes :-P
20:00bbloom_Vi: I'll try a few more optimizations & then i'll post a follow up on stackoverflow later tonight
20:00bbloomgot some other stuff to take care of first
20:14callenI've generally deployed Clojure apps behind Nginx, what do you guys do?
20:26nightfly__Usually do the same for all web stuff
20:35gfredericksI've been fine with jetty so far; that's usually just json servers though
20:36callengfredericks: on port 80?
20:36callengfredericks: the idea behind using nginx is for static content so that JVM load isn't wasted on serving css/js/img
20:37gfredericksright; I didn't need either static content or particular ports
20:44callengfredericks: ah yes, well that's bloody convenient.
20:44gfredericks:)
20:44callenI'll stick with what I did last time then.
20:44callennginx + jetty
20:44gfredericksthat's why I qualified with "just json servers"
20:44callenand hope to fuck I don't need websockets/async
20:44callengfredericks: I knows, I knows. your use-case is about as a common as anything these days. Not a lot of libraries for us HTML schleppers.
20:46bbloomany suggestions on how to minimize the perf cost of ArraySeq? It seems that it calls java.lang.Class.getComponentType, which is surprisingly slow
21:26tieTYTi'm using seesaw. Can anyone tell me why my "destination-shortcuts" is only rendering on the right half of the vertical-panel it's inside of? https://www.refheap.com/paste/177a7f1ecb15b7db085fa858c
21:32amalloybbloom: let me know if you find anything. it's been bothering me too, recently
21:33bbloomamalloy: the ArraySeq thing?
21:33bbloomyeah, i think i did find something....
21:33bbloomsanity check me real quick?
21:33amalloysure
21:33bbloomin ArraySeq, look at the ct field, which is initialized via array.getClass().getComponentType()
21:34bbloomnotice it is only ever used to call Reflector.prepRet
21:34bbloomthen go look at prepRet
21:34tieTYTi wrapped it in a horizontal-panel and that fixed my issue
21:35bbloomamalloy: my thought is that if the array component type is object (as it is for RestFn calls) then that prepRet function is a no-op
21:35bbloomamalloy: in which case, i think it can be eliminated from ArraySeq
21:35bbloomamalloy: let me know if that makes sense
21:39bbloomif i am right about this, there's a pretty decent perf boost to be had for all usages of rest functions.... but i'm not sure yet
21:40amalloybbloom: sounds right, but i don't have time to double-check the details for you right now
21:42bbloomamalloy: actually, there are all these specialized versions below: ArraySeq_int, etc
21:45bbloomamalloy: ok, i'll run a test or two & then mail the dev list
22:22jasonjckndnolen: hey david, does core.logic support ("exists in set" set el) ?
22:22jasonjckndnolen: i looked around didn't see anything
22:22jasonjckndnolen: I could use a list but then you get dupes and every permutation
22:23bbloomif i make a perf patch for clojure, what should i file the ticket as?
22:26amalloybbloom: enhancement for sure
22:44dnolenjasonjckn: no there's no set membership ... yet, we're working on CLP(Set) next
22:46jasonjckndnolen: cool, who's we?
22:47dnolenjasonjckn: Nada Amin is also interested in working on it
22:48dnolenjasonjckn: she's already done a version in plain Scheme miniKanren, and Claire Alvis has done a version on top of cKanren, so it shouldn't be difficult to translate what they've done.
22:48bbloomamalloy: http://dev.clojure.org/jira/browse/CLJ-1200
22:49dnolenjasonjckn: re: min/max, I just need to power through some refactoring and I think I can at least get basic min/max support out the door.
22:49bbloomdnolen: since i had never seen RestFn prior to our discussion a week or so ago, you might be interested. but probably not
22:50jasonjckndnolen: awesome! yah I think both set and min/max are blockers for a storm CLP scheduler
22:50dnolenbbloom: nice
22:50amalloybbloom: i'm curious what library you found it in
22:51dnolenjasonjckn: min/max is fairly simple. I'm not sure what you need as far as set membership, like just for integers?
22:51bbloomamalloy: fipp
22:51amalloyi noticed it in cheshire, myself, but couldn't untangle what was going on in reflector and arrayseq; thanks again for finding that
22:53bbloomamalloy: yeah, i'm not sure what that prepRet thing is really needed for. i think there are a bunch of calls to it that can be eliminated
22:54amalloybbloom: it looks to me like all prepRet does is convert (Boolean. "false") to Boolean/FALSE
22:55bbloomamalloy: which is a leaky thing anyway that i'm not sure is worth doing...
22:55bbloomamalloy: it used to do more stuff.... git blame is kinda messy for it
22:55dnolenjasonjckn: I've been looking fairly closely at the feature listed here - http://www.swi-prolog.org/man/clpfd.html, if you have any feedback about that would be useful.
22:55dnolens/feature/features
22:56amalloybbloom: right, it looks like it's trying to convert boxed objects to some canonical representation iff the expected return type is a primitive
22:56amalloybut the only one that's not commented out is for booleans
22:57bbloomamalloy: which i think only made sense prior to the introduction of the various specialized ArraySeq impls
22:57callen"Could not connect to JRun Server." Ohhh acm. You're so adorable.
22:57amalloymaybe