#clojure logs

2014-09-11

00:01wildnuxis this the idiomatic way of applying a function to every elements in a nested list?
00:01wildnux(map #(apply * %) [[1 2 3] [4 5 6]])
00:01wildnuxthis works, are there any other better way to achieve this?
00:01justin_smith,(map * [1 2 3] [4 5 6])
00:01clojurebot(4 10 18)
00:02justin_smith,(apply map * [[1 2 3] [4 5 6]])
00:02clojurebot(4 10 18)
00:03justin_smithor wait - you want (* 1 2 3) and (* 4 5 6)
00:03wildnuxjustin_smith: I want function to apply to each each element of the outer list (apply funtion to nested list)
00:03wildnuxjustin_smith: so that it should give (6 120)
00:03justin_smithright, so #(apply * %) is the best option
00:03wildnuxok
00:03wildnux,(map #(apply * %) [[1 2 3] [4 5 6]])
00:03clojurebot(6 120)
00:04justin_smiththough #(reduce * %) would also give the right answer
00:05wildnuxnow, if i wanted to get the max of the resulting elements i could do
00:05wildnux,(max (map #(apply * %) [[1 2 3] [4 5 6]])
00:05clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
00:05wildnux,(max (map #(apply * %) [[1 2 3] [4 5 6]]))
00:05clojurebot(6 120)
00:05justin_smithI think you want apply max
00:05wildnux,(reduce max (map #(apply * %) [[1 2 3] [4 5 6]]))
00:05clojurebot120
00:05justin_smithyeah, apply max and reduce max would both work
00:06wildnuxi could do that, now, my question is how do i get that list [4 5 6] because of which 120 (max) was returned
00:06justin_smith,(apply max (map #(apply * %) [[1 2 3] [4 5 6]]))
00:06clojurebot120
00:06wildnuxis there a way to get that list which has max product?
00:06justin_smithmax-key
00:07justin_smith,(max-key #(apply * %) [1 2 3] [4 5 6])
00:07clojurebot[4 5 6]
00:07justin_smithand again, if the args are all in one list, you can use apply, of course
00:08justin_smith,(apply max-key #(apply * %) [[1 2 3] [4 5 6]])
00:08clojurebot[4 5 6]
00:08justin_smithclojure is magical
00:08wildnuxjustin_smith: awesome :)
00:08wildnuxthis is sooo cool
00:09wildnuxjustin_smith: extending this, is there a funtion which takes any function instead of 'max' in max-key?
00:09justin_smith(first (sort-by f l))
00:09justin_smithl being a sequence
00:10wildnuxaah ok
00:11justin_smithand f should give the most qualified item the lowest score
00:11justin_smithotherwise you have to walk the whole sequence at the end
00:11justin_smithyou could also optimize that with a reduce
00:11justin_smith(in order not to build a collection you don't really need)
00:14justin_smith,(reduce (fn [[score mx] e] (let [s2 (count e)] (if (> s2 score) [s2 e] [score mx]))) [0 nil] ["hello" "this" "is" "sort by count"])
00:14clojurebot[13 "sort by count"]
00:15justin_smithappropriate if you don't want to call your f more than once per item, and don't want to build the whole ordered collection
02:01dorkmafiai copied my directory over to another computer then tried to run lein repl on it and now i'm getting this error: Exception in thread "main" java.lang.UnsupportedClassVersionError: org/jivesoftware/smack/Roster : Unsupported major.minor version 51.0
02:01amalloydorkmafia: your version of java is too old
02:01dorkmafiaoh yes
02:01amalloyi forget what 51 means, but i think it means you need 7 and have 6-
02:01dorkmafiathank u
02:01dorkmafiayup
02:02dorkmafiamakes sense i forgot about that
02:03dorkmafiado i need the jre and jdk? or just the jdk?
02:04beamsojdk
02:07dorkmafiaso I'm wrapping this xmpp lib and a lot of things require me to pass the connection to my functions I get the connection when the user logs in is a way for me to store in a def?
02:08dorkmafiathere*
02:09beamsoyou could store the connection in an atom
02:14dorkmafiaoh cool how would i do that? :B
02:15beamsosomething like (def conn (atom <however you established your connection>))
02:15beamsohttp://clojure.org/atoms
02:18dorkmafiaok cool thanks i'll check it out
02:28yedi_i'm making a metronome webapp, so timing is hugely important. it seems that there is some lag when using timeout. e.g: https://gist.github.com/yedi/1abcdf0d8675fd532eca
02:29yedi_there seems to 2-3 milliseconds of lag when using timeout (it jumps up to about 6-7 ms of lag in my actual application)
02:29yedi_is there anyway to nullify or account for this lag? or is there a better way to handle timing in clojurescript?
02:30beamsojavascript isn't threaded
02:30yedi_right
02:31beamsoi think even if it was threaded you would see the timeout being longer than the exact 1000 that you're looking for
02:31yedi_know of a better way?
02:33yedi_i guess i could try to test / calculate the lag and then adjust the timing based off of that. but it seems like that could get messy / won't be perfect either
02:39beamsoi found this : http://www.sitepoint.com/creating-accurate-timers-in-javascript/
02:40beamsobasically they are running a shorter timeout and adjusting by the difference in intended and actual timeout they encounter
02:47piranhabeamso: in reality you don't even need to adjust anything, just check what time is it now. Plus it may be worth it having a setTimeout instead of setInterval so you can try to ask for a shorter delay if you need that
02:47piranhaon the other hand, you can just have very short (1-5ms) interval and not worry about it, I guess
02:47piranhabut that still could backfire if the system is a bit overloaded :(
02:47beamsookay
02:48piranhaah, that's what they are doing (adjusting the timer) - didn't read till the end
02:49piranhabeamso: plus I see you're using async channels, and I think it could a bit of it's own overhead
02:49piranhamaybe it's worth to to stick with primitives in your case...
02:49beamsoi should be using async channels, but i need to learn about them.
02:49beamsoit was yedi_'s gist
02:50piranhabeamso: I need to drink coffee before I look into a clojure channel, I'm sorry :)
02:50piranhayedi_: ^
02:51beamsonot a problem.
02:52yedi_ah thanks guys
02:52yedi_i'll try using primitives before just going with the 'figure out the time difference and change timeout accordingly approach)
02:52yedi_though i just love using core.async for everything
02:52yedi_makes me feel nice n fuzzy inside
02:53piranhait does :)
02:53piranhabut in this case you want to get least amount of layers between a cpu and your code, and you've got js already :)
02:54piranhano need to add core.async on top for it to be not exactly real time :)
04:36magopiancan someone please point me at some docs on the "volatile!" function? can't find any :/
04:55maxthoursiemagopian: https://github.com/clojure/clojure/blob/42f68bc7688db3a24565dfcdc1cba92dd8a99159/src/clj/clojure/core.clj#L2390
04:55maxthoursieit's not exactly verbose though :)
04:56magopianah :)
04:56magopianso what's a volatile? :)
04:56maxthoursie* volatiles - there are a new set of functions (volatile!, vswap!, vreset!, volatile?) to create and use volatile "boxes" to hold state in stateful transducers. Volatiles are faster than atoms but give up atomicity guarantees so should only be used with thread isolation.
04:57maxthoursie(from changes.md)
04:57magopianok, so it's linked with transducers, that's why i see those come up from time to time (i'm trying to get my head around transducers, but still having issues atm)
04:58maxthoursieif I understand correctly it's just a wrapper around javas volatile
04:58maxthoursiethey were added as they were beneficial for the implementation of transducers
04:59magopianok ;)
04:59magopianthanks a lot for the answe r;)
04:59maxthoursienp
05:36CookedGryphonHow would I write a core async buffering strategy which does a distinct-by :id just for things in the buffer but keeping order
05:36CookedGryphonso I have a number of overlapping events, each of which have an id
05:37CookedGryphonand for each event i might receive an undetermined number of updates
05:37CookedGryphonI want to apply backpressure, but only keeping the latest event for each ID, as each event also contains all the historical data (persistent data structures rule)
05:38CookedGryphonfor extra credit, some way of controlling whether the order is maintained as first-id-in, or latest-id-updated
05:39CookedGryphonany ideas? My best so far was to create a chan per ID with a sliding buffer 1 and then merge them all, but keeping track of all that when the event ids are unlimited and constantly increasing is tricky
05:45gwsCookedGryphon: you could write your own buffer that implemented your strategy (maybe using a set for testing membership?) - see this for inspiration https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async/impl/buffers.clj
05:49CookedGryphongws: that looks like exactly what I need, thanks a lot!
05:51lvhI have a list of different arguments; I want to check if (apply f args) is equal to the same constant for each of them
05:52lvhcan I coerce core.test's "are" macro into doing that?
05:57gws,(apply = 42 (map (partial apply +) [[21 21] [21 21]]))
05:57clojurebottrue
05:57gws,(apply = 42 (map (partial apply +) [[21 21] [21 22]]))
05:57clojurebotfalse
05:58gwslvh: would that do what you want?
05:58lvhgws: hm, maybe yes
05:58lvhI didn't realize apply had an & colls part in the signature
06:01lvherr, or more accurately that = was variadic I guess
06:02gwsyep! and > and < and so on
06:02gws,(> 5 4 3 2 1)
06:02clojurebottrue
06:03gws,(> 5 4 3 2 2)
06:03clojurebotfalse
06:03gws,(>= 5 4 3 2 2)
06:03clojurebottrue
06:04lvhack, this unfortunately doesn't help me because these are byte arrays
06:05lvh(so = doesn't work :()
06:06lvhI guess what I really want is (apply are ...), except of course that doesn't really work (I think) because are's a macro?
06:08lvhevery? true? it is
06:26piranhaanybody using prismatic.schema here? I'm not sure what's the best way to express "for some values of :filter, :user_id should be specified" in {:filter (s/enum ...), :user_id s/Int}
06:29sm0kepiranha: look at s/pred
06:29sm0keyou can define a function there
06:30piranhasm0ke: but pred only gets it's own value to check, right? in this case how do I express "true if other value is something"?
06:31piranhaah, it could be much more complex than that
06:31piranhait's just pred is greatly simplified
06:31piranhaok, I'll try to look into that
06:32piranhaI actually made it work through s/either, but then error reporting becomes really obscure :\
07:13babygauhttps://www.refheap.com/ce7f89cbca4992e046c8dc50c
08:11rurumateHello #clojure, I want to find all (nonempty) subsequences of given sequence a. So for example, (sublists [1 2 3]) should evaluate to '((1) (2) (3) (1 2) (1 3) (2 3) (1 2 3)). I know (comp set #(map sort %) powerset) can do it, but it seems wasteful to calculate the full powerset and then throw away all the lists that are just permutations of the same sorted list.
08:17clgvrurumate: then just write a recursive function that directly computes the set of all unordered combinations
08:18clgvrurumate: I dont know how your powerset function is implemented, but you can probably steal the general idea from it
08:35jkjhttp://stackoverflow.com/questions/22959804/inserting-postgresql-arrays-with-clojure/25786990#25786990
08:49KamuelaIs clojure relational/logic programming?
08:49clgvKamuela: no, not the core language itself. but there is a library called core.logic that allows logic programming under clojure
08:51Kamuelaclgv, That seems to be what I'm using with this tutorial
08:56clgvKamuela: ok, so you are actually learning two things at once
08:57Kamuelaclgv, the tutorial purports itself as an introduction to logical programming
08:57clgvKamuela: yeah thats ok when they use core.logic
08:57clgvKamuela: Clojure itself is mostly functional programming, though there are imperative constructs for side-effects as well
09:05rurumatelist powerset, seems workey: https://www.refheap.com/90094
09:06clgvrurumate: recursive concat may blow your stack for large `xs`
09:08clgvrurumate: ah and non-tail recursion as well
09:13Kamuelaclgv, what do you think of core.logic for AI?
09:17clgvKamuela: I did not use core.logic, yet
09:18clgvKamuela: I only read about it
09:18rurumateclgv: yes it would be nicer with lazy seq
09:19rurumateclgv: what exactly do you mean "recursive concat"?
09:20clgvrurumate: when you wrap concats in each other
09:21rurumatehmm yes seems like that's the case there
09:27lvhreiddraper: Hi! I'm playing with test.check for the first time. Thanks for building it.
09:28lvhreiddraper: I was wondering if there's a better way to get length-n byte arrays rather than (gen/fmap byte-array (gen/vector gen/byte n))
09:28lvhDoesn't seem like I can use "bytes" for it. Also, if that would be a good thing to contribute to test.check :)
09:32clgvlvh: what is the problem with that? the possible overhead due to vector construction?
09:33lvhclgv: no, no problem with that, except that there's already a gen/bytes that *almost* does what I want
09:33lvhclgv: and gen/vector, a pretty close cousin, can be parametrized by length
09:34clgvlvh: but it's exactly the same structure
09:35lvhclgv: Yes, I created that thing by copying bytes' implementation
09:35lvhclgv: I'm trying to figure out if there are clever ways to constrain the generator's output
09:35clgvlvh: I think you could externally control its size
09:35lvhreading some of the code it looks like maybe there's something like that
09:35lvhby clever I mean "not generating a bunch of arrays and throwing away the ones that aren'te xactly 16 bytes long)
09:36clgvlvh: the probably that arity impl needs to be added^^
09:37lvhclgv: that's what I would guess but unfrtunately right now bytes isn't even supposed to be called, it's just a constant
09:39clgvlvh: thats no problem. it can be easily converted to a function with both arities
09:40lvhclgv: wtihout breaking backwards compatibility? really?
09:40lvhclgv: you teach it to be a regular value and then override its IFn behavior or something?
09:40AeroNotixI want to run a jetty/ring handler on port 0 (random port) how would I then retrieve the port number it is using? This is for tests.
09:41clgvlvh: well, were is written that you are not allowed to break backwards compatibility for improvements? imho you only need to communicate that there are breaking changes
09:41lvhclgv: oh, okay; yeah, sure -- I guess that's an implicit question for reiddraper :)
09:42mikerodIf we have something like: (LocalDate. 1) called, which constructor does Clojure call? LocalDate(Object) or LocalDate(long)
09:42mikerodI know clj numeric literals are boxed Long by default
09:43mikerodbut does the Compiler automatically cast it as primitive to call the LocalDate(long) in case like this? Perhaps this is a dumb question, but I'm a bit unclear how this part works.
09:52clgvmikerod: set warn-on-reflection on true and see what it tells you
10:10mikerodclgv: I have that set and it doesn't say anything
10:12lvhis https://github.com/paraseba/lein-reload still the thing I use if I want my tests to be constantly run?
10:13pjstadiglvh: https://github.com/jakemcc/lein-test-refresh is actively maintained
10:15lvhpjstadig: thanks!
10:15clgvmikerod: I'd vote for LocalDate(long) when you pass the primitive long - you can check via a decompiler.
10:16mikerodclgv: Do you mean when I specifically "ask" for a primitive though? Yes, I think I'll go to the decompiler for this one.
10:17bbloomBronsa: did you ever get around to looking in to jvm mechanisms for chaperons etc?
10:26clgvbbloom: what is a chaperon?
10:27bbloomclgv: racket stuff for meta-object protocol voodoo for checking contracts and other things dynamically via object proxies
10:27clgvbbloom: uh ok.
10:28bbloomclgv: http://docs.racket-lang.org/reference/chaperones.html
10:33ToxicFrogSo, with core.typed, I'm having two weird issues. I haven't added any type annotations yet, just enabled checking for a few namespaces in preparation.
10:33ToxicFrogThe first issue is that ns spellcast.core has (require '[taoensso.timbre :as log]) and then calls some things as log/foo ..., and this produces a 'no such namespace: log' message.
10:34ToxicFrogI also get a 'not checking spellcast.game: tagged :collect-only' -- but there's no such tag.
10:36jlongsterwhat is the use case for the transformation function in `transduce` taking in the final result of the transformation? https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L6521
10:37dnolen_jlongster: it's the completion step
10:37tbaldridgejlongster: consider starting with (transient x) and ending with (persistent! x)
10:38dnolen_jlongster: you imagine also imagine reducing over a resource like a file and closing it in the completion step
10:38jlongsterdnolen_: tbaldridge: huh, interesting. thanks. I can see that
10:38bounbanyone got a copy of rhickey's chunked sequences talk?
10:39ToxicFrogHmm. refer :all and (use) are just scope hacks, right? They don't actually change the contents of the current namespace?
10:44llasramToxicFrog: The opposite actually. All `refer`ing (include `:all`) modifies the `refer'ing namespace to map the name symbols to the target vars
10:45ToxicFrogllasram: huh. So if ns A refers, say, clojure.core.typed/ann, and ns B requires A, B can then call A/ann?
10:51llasramToxicFrog: I believe that is actually the case, yes
10:51CookedGryphononly if they fully qualify it though
10:52llasramMost tooling (and stdlib functions?) ignores vars which don't belong to the namespace refering them, but the namespace itself refers to the var
10:55llasramOh, nevermind -- I'm confused. Half of what I said is true, but namespaces differentiate between "interning" and "refering"
10:55llasramWell, kind of.
10:56llasramNo, they don't. Ok, so you can't say A/ann, but only because there's a check on lookup of `ann` in `A` to verify that the namespace of the var found for `ann` is the same namespace
10:58llasramhttps://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Namespace.java#L195-L200
10:59llasramBut the actual mechanics of what is stored in the namespace are identical for vars which "belong" to the namespace vs referred from others
11:00justin_smithllasram: woah, a validating sanity check, in Clojure? astounding news
11:00justin_smithI kid because I love
11:01ToxicFrogllasram: aah. Honestly that kind of seems like the worst of both worlds~
11:10mikerodDoes anyone know where the notation used in the Java specs is defined? Such as what <: means?
11:10mikerodI don't see it anywhere, it just starts being used...
11:10mikerodor <<
11:10mikerodI think I have a guess what they are meaning, but it'd be nice to have clarification
11:11clgvmikerod: reserved names or something like that?
11:12justin_smithmikerod: is it documented somewhere around here? http://docs.oracle.com/javase/8/docs/api/
11:12clgvmikerod: http://docstore.mik.ua/orelly/java-ent/jnut/ch02_05.htm
11:14justin_smithmikerod: do you have a link to a page using this notation you are unsure of?
11:33mikerodclgv: justin_smith ok to clarify, I'm not referring to Java language syntax
11:34mikerodI'm referring to notation used to describe the Java specs
11:34mikerodjustin_smith: example: http://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.12.2.2
11:35mikerodNotation like "Ai << Fi (1 ≤ i ≤ n) "
11:35mikerodwhat is "<<"
11:35mikerodOr "Ai <: Si "
11:35mikerodWhat is "<:"
11:35mikerodI do not see a page in the specs that introduce what these notations mean.
11:35mikerodSo apparently they have some more global meaning, but I don't know where that is defined.
11:36justin_smith ≤ is the mathematical less than or equal to
11:36mikerodEven better: " Ul <: Bl[R1=U1,...,Rp=Up]" I'm not 100% sure I know what the square brackets are here "[" "]"
11:36justin_smithis that what you mean by <:
11:36justin_smithmaybe it displays differently in my browser
11:36justin_smithoh never mind, now I see it
11:37mikerodYeah it is a less-than and a colon
11:37mikerodI don't think I have a browser issue, it seems like it intended to mean something
11:37justin_smithyeah, I found it
11:37mikerodit is about being a subtype of another type I'm sure
11:37justin_smithI just asked a mathematician friend, on the off chance he would recognize it from somewhere...
11:37mikerodbut I see nothing specific about this notation and it used throughout the specs
11:38mikerodand google searching for this notation is not so good :P
11:38justin_smithright
11:39justin_smithI bet it means something like inherits from / subtyping
11:39mikerodyeah, I'd like to know the difference between "<:" and "<<"
11:39justin_smithor derives
11:39mikerodand some specifics on this bracketed "Bl[R1=U1 <etc>]" notation
11:40mikerodI just think it is frustrating and would have expected it to be defined somewhere :P
11:40justin_smithmikerod: click the footnotes!
11:40justin_smiththere are hypertext footnotes on the rules that explain the notation
11:40mikerodThere was even http://docs.oracle.com/javase/specs/jls/se7/html/jls-1.html#jls-1.3 but no good
11:40mikerodoh
11:41justin_smith"U << V indicates that type U is convertible to type V by method invocation conversion"
11:41mikerodI don't see what to click on
11:41justin_smith". We write T <: S to indicate that that the subtype relation holds between types T and S."
11:41justin_smiththere are footnote links near each item
11:42mikerodah
11:42mikerodhttp://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.10
11:42mikerodlike that
11:42justin_smithmikerod: also, you can control-f here https://en.wikipedia.org/wiki/List_of_mathematical_symbols for things like <:
11:42mikerodjustin_smith: awesome
11:42justin_smiththough that does not have <<
11:42mikerodproblem solved hah
11:43justin_smithoh it has ≪ instead - thanks unicode!
11:43mikerod,(inc justin_smith)
11:43clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: justin_smith in this context, compiling:(NO_SOURCE_PATH:0:0)>
11:43justin_smithyou may not want the , there :)
11:43mikerod(inc justin_smith)
11:44lazybot⇒ 76
11:44mikerodoh, I didn't realize taht's how that one worked haha
11:44justin_smithit's a pseudo-clojure bot command
11:44mikerodI see
11:46mikerodWell now the Java specs are much more fun to read.
11:46justin_smithas in "not 100% bewildering"?
12:44izirkuhi all! is there a predicate to check if something is an atom
12:45justin_smithatom?
12:45justin_smithoh, I thought that existed, I guess not!
12:45llasram,(instance? clojure.lang.Atom (atom 0))
12:45clojurebottrue
12:45justin_smiththere you go
12:46izirkuaha! you just saved my life!
12:46TimMcphew
12:46TimMcI'm glad you didn't die.
12:47izirkucoming from CL, it's still a bit foreign, but I'm adjusting. Thank you all once again!
12:48justin_smithizirku: nb this is not "atom" in the sense cl calls something atomic
12:48justin_smithizirku: but I assume you allready knew that
12:49izirkujustin_smith: yes, I know, I just needed a check if I needej to (deref place) in my macro if it's an atom :)
12:49llasramScary
12:49tadni_`On a related note, what does Clojure call small the equivialant of a stereoptypical "Lisp Atom"?
12:50noonianit would be nice if there was an atomic? fn, but it doesnt come up as much since clojure collections are immutable whereas it mattered more in cl and scheme since they were mutable
12:50technomancytadni_`: I think "atom" means different things in lisp depending on how far back you go
12:50technomancyit used to be a synonym for symbol iirc? erlang uses that terminology.
12:51technomancybut I think the term you're looking for is scalar
12:51nooniani like the little schemers definition
12:51technomancy(meaning not compound)
12:51noonianyeah
12:51justin_smithtechnomancy: so numbers and other primitives were not atomic?
12:51tadni_technomancy: I've always known it as a term for things that are indivisible.
12:52tadni_Numbers, strings, some single charecters like "*".
12:53justin_smithbut numbers and strings are divisible into bits and chars...
12:53bbloomatomic or scalar is a matter of perspective :-)
12:53tadni_justin_smith: Well yeah, not my metrics though really.
12:54tadni_Kinda just what lisps, or at least Emacs Lisp intro quantifies.
12:54technomancyjustin_smith: depends how far back you go iirc
12:55dagda1_what does this type of expression mean (into {} *1)
12:56dagda1_it is in the docs for map http://clojuredocs.org/clojure_core/1.2.0/clojure.core/map
12:57hiredman*1 is bound to the result of the last expression in the repl
12:57technomancyjustin_smith: this seems to consider numbers and atoms distinct: http://www.softwarepreservation.org/projects/LISP/book/Weismann_LISP1.5_Primer_1967.pdf
12:57TimMcizirku: You can also check if something is an IDeref
12:58TimMcizirku: Why does your macro care if something is an atom?
12:58izirkuTimMc: IDeref?
12:58justin_smithdagda1_: look at (doc into)
12:59justin_smith*1 means "the last result evaluated in the repl session"
12:59dagda1_justin_smith: k
13:00izirkuTimMc: it's a PeopleSoft specific DSL wrapper on top of Korma. When I have an WHERE setid IN (...) ..
13:00TimMc&(map (partial instance? clojure.lang.IDeref) [(atom 0) (future 5) (promise) (var +) (delay 4) :abc])
13:00lazybotjava.lang.SecurityException: You tripped the alarm! future-call is bad!
13:00TimMc,(map (partial instance? clojure.lang.IDeref) [(atom 0) (future 5) (promise) (var +) (delay 4) :abc])
13:00clojurebot#<SecurityException java.lang.SecurityException: no threads please>
13:00TimMcanyway
13:00noonianyeah, *1 only means something in the repl, its not normal clojure magic syntax
13:00noonian,(+ 2 4)
13:00clojurebot6
13:00noonian,*1
13:00clojurebot#<Unbound Unbound: #'clojure.core/*1>
13:00justin_smithnoonian: *1 does not work with clojurebot, each command is a new repl
13:00izirkuTimMc: my values for IN are stored in an atom, I'm had to make sure I do deref it
13:00nooniani see
13:01noonian&(+ 1 1)
13:01lazybot⇒ 2
13:01noonian&*1
13:01lazybot⇒ #<Unbound Unbound: #'clojure.core/*1>
13:01justin_smithso "the last value returned by the repl" is unbound
13:01noonianshrug
13:01justin_smithyeah, it's inconvenient
13:01justin_smith,(do 1 *1)
13:01clojurebot#<Unbound Unbound: #'clojure.core/*1>
13:01izirkuTimMc: it works now. Thanks for the IDeref explanation, will come in handy!
13:01TimMcizirku: Oh, this is for the code the macro emits, not the macro's own processing.
13:03izirkuTimMc: yes, you are right on target :)
13:07yediis there a built-in data structure for / what's the best way to create a sliding queue with a size limit. (where new elements pop off old ones when the limit has been reached)
13:08yedicould just create a function for appending to a list, that also pops out the other end but I was wondering if there was a more elegant way
13:13justin_smithyedi: so a dequeue?
13:13yedilemme google
13:13justin_smithhttps://github.com/pjstadig/deque-clojure
13:13justin_smitha deque is a queue that supports efficient addition or removal from either end
13:14hiredmanthere is no built in immutable sliding queue, there is a queue, and building a sliding queue from that can be as simple as checking the size and poping when you add an item if the "size" would overflow your bounds
13:15nooniancore async channels can use sliding buffers, i'm not sure what your use case is but that might be more appropriate if you're comfortable with core async
13:15bbloomcore async's buffers are mutable
13:15hiredmanright
13:15hiredmannot values
13:19noonianyep, but yedi didn't say anything about what he wanted it for
13:19yedii need to record a bunch of things in real time, but I only will ever care about the last 10 things recorded
13:20hiredmanwell, he asked about built in data structures, and those are all values
13:20yedity hiredman, that's what i'll go with most likely
13:22justin_smithI keep forgetting about clojure.lang.PersistentQueue - it would be nice to have a literal syntax for it
13:22justin_smithmaybe #[]
13:22justin_smithseems a natural fit
13:23technomancy$google clojure queuefish
13:23lazybot[fogus: So long, and thanks for all the :-)-] http://blog.fogus.me/2012/07/27/so-long-and-thanks-for-all-the-queue-fish/
13:23hiredmanqueue fish!
13:25justin_smithhttps://groups.google.com/forum/#!topic/clojure-dev/GQqus5Wycno a convo about queue-fish
13:27stuartsierrahttp://dev.clojure.org/jira/browse/CLJ-1078 and http://dev.clojure.org/jira/browse/CLJ-976
13:31justin_smithI think queues are good enough for something like #[] instead of #queue []
13:35bbloomjustin_smith: i've needed an immutable queue a handful of times at most, and not once did i ever need a non-empty literal queue
13:35bbloomjustin_smith: seems pointless to dedicate syntax to that
13:38technomancy#q/ueue [] ; <- technically namespaced
13:39hiredman#q/u
13:39hiredmanbbloom: it would be nice to at least have a function that returns an empty one
13:41bbloomhiredman: yup
13:42hiredman(by which I mean, that is a good point about the non-empty бизнес
13:42hiredman)
13:49dorkmafia(defn foo [bar] ... ) (defn foo [baz] ... ) is this allowed in clojure two methods with the same name but different inputs?
13:49jcsimsno - there's no way for the runtime to differentiate between them
13:50dbaschdorkmafia: if you want polymorphism, take a look at multimethods
13:51dorkmafiacool is there a way to talk to python from clojure? (I should probably google it)
13:53justin_smithdorkmafia: what are your constraints? can you talk to it via the network? can it be the version of python that runs in the jvm?
13:54dorkmafiawhich version of python runs in the jvm? 2.7?
13:54justin_smithhttp://www.jython.org/
13:54dorkmafiathey will both run on the same box
13:55justin_smithyeah, looks like they have a 2.7
13:55dorkmafiacool beans
13:55justin_smithwell, with the jvm version it would be in the same process, and won't be able to use C bindings (with all the advantages and disadvantages that these imply)
13:56justin_smith(or maybe some C bindings, but it would be via jni or something similar)
13:56justin_smith*could be in the same process
13:56justin_smithI just picked that as an example as that is the tightest you could bind the two that I know of
13:56justin_smithwhile talking on a socket is a very loose binding between the two
13:57dorkmafiawell i was just going to try and get skype4py working since the skype4java that I tried before had issues
13:58technomancydorkmafia: hylang.org might be better for that
13:58technomancyI have had luck in the past communicating with skype over dbus
13:58technomancyfsvo "luck"
13:59dorkmafiaheh
13:59technomancyas much as anyone with the misfortune of having to use skype for nontrivial things can be said to have luck, I mean
14:06stwI'm using a future to run a third party java library with a timeout, when it times out because the 3rd party library fails the memory and cpu usage remain, what is the best way to isolate this third party call in clojure or to kill it off if it times out? I've looked everywhere, tried future-cancel to no avail
14:07justin_smithstw: what about putting the in its own vm, and shutting that process down as needed?
14:08stwI was thinking about that, wasn't sure if there was a more idiomatic solution
14:08stwin another language I would certainly fork a process for it
14:08vanilahi
14:09SegFaultAXUnfortunately that's a /really/ heavyweight solution.
14:09vanilaI've been looking at nanopass frameworkf for making compilers
14:09vanilajust wondering if anyone knows other modern compiler building tools?
14:09stwSegFaultAX: yes, any other ideas?
14:10SegFaultAXstw: Is the library still maintained? Is it open source?
14:12stwSegFaultAX: open source yes, maintained, doesn't look like it - contacted the author a while back to see if he was interested in making changes for me, but he wrote back that he's moved on
14:12SegFaultAXI'm wondering if it's practical to patch the library to make it behave better or even support timeouts natively for whatever it's doing.
14:12SegFaultAXstw: Well if its OSS, you could just fork it and make the changes yourself. Is that a reasonable solution?
14:12stwYes, that's a good thought, I may need to wrap the 3rd party method call
14:13SegFaultAXOut of curiosity, what library is it?
14:13stwSegFaultAX: yes, thats a good idea and I've already made some customizations to it, it's daisydiff https://code.google.com/p/daisydiff/
14:14SegFaultAXWhoa, that's pretty cool.
14:14dorkmafiatechnomancy: yah skype is horrid
14:14stwSegFaultAX: works well most of the time, gets hung up on some inputs
14:15technomancydorkmafia: at my last job it was used for multi-user chat ಠ_ಠ
14:15technomancylike, text chat
14:15dorkmafiayes thats what we use it for toO!
14:15dorkmafiacause who cares about security!
14:16technomancymy condolances
14:16technomancyhttps://github.com/dakrone/skyyy this is a thing
14:16SegFaultAXstw: Neat, what kinds of edge cases have you found?
14:17SegFaultAXtechnomancy: You still at Heroku?
14:18stwSegFaultAX: in the limited time I've been using it, tables don't work out so well, adds a lot of new lines, but for the most part pretty good
14:18technomancySegFaultAX: yeap
14:18SegFaultAXstw: Does it do some kind of semantic evaluation of the DOM?
14:18SegFaultAXtechnomancy: It's all IRC there, yea?
14:18stwSegFaultAX: we pre-process the html before processing with this
14:19technomancySegFaultAX: sadly no; we are on hipchat. but it can be bridged to IRC without too much fuss.
14:19bbloomtechnomancy: what, no chatter? ;-)
14:19SegFaultAXWe also use HipChat. The most recent UI update is just all kinds of terrible. :(
14:19technomancybbloom: haha, we are lucky enough to be fairly insulated from that
14:20technomancySegFaultAX: I wouldn't know; I use bitlbee =)
14:20technomancySegFaultAX: can't recommend it strongly enough http://www.phase2technology.com/blog/using-hipchat-through-an-irc-client-with-bitlbee/
14:21SegFaultAXtechnomancy: Awesome, thanks!
14:22caterntechnomancy: that's very neat
14:22technomancyit gets the job done
14:22stwSegFaultAX: somewhat, it parses the dom and compares inline nodes from what I've looked at
14:22caterntechnomancy: i mean the skyyy thing
14:23technomancyoh... well, same =)
14:23caternfills me with internal conflict though, because it would allow nice command line usage of Skype
14:23caternand... I don't know how to do command line usage of XMPP/Jingle, which I prefer
14:23SegFaultAXstw: Seems like a cool project!
14:24ToxicFrogHow does lein handle it when you require two libs that each require a different version of a third library?
14:24technomancycatern: bitlbee is nice for that
14:24caterntechnomancy: I mean the video chat part
14:24technomancyoh gotcha
14:24technomancycatern: I have just discovered http://talky.io which works reasonably well for small conversations
14:25technomancyall webrtc'd up
14:25caternmeh
14:25caterni'm willing to inconvenience people by forcing them to make XMPP accounts :)
14:25technomancyToxicFrog: whichever one is highest up the dependency graph wins
14:25technomancycatern: depends how badly you want to talk to them I guess
14:26ToxicFrogtechnomancy: aaaaaaaaaaaaaaa
14:26caternyeah, if I don't force them to make XMPP accounts I just use Google Hangouts or Skype
14:27technomancycatern: talky.io is nice because you can just hand out a short URL, no need for any account setup
14:27justin_smithhow hard would it be to make the repl show a stack trace of the running thread when you use an interrupt to stop an evaluation in the repl?
14:27AeroNotixafter running a midje test in a cider session I get a: IllegalArgumentException Wrong number of args passed to keyword: :irrelevant-return-value clojure.lang.Keyword.throwArity (Keyword.java:92)
14:27technomancyHangout invitations still confuse the heck out of me and I use them almost every day
14:27justin_smithAeroNotix: use (pst) to see a fuller stack trace
14:28justin_smithsee where you are calling :errelevant-return-value with 0, or more than two, args
14:28AeroNotixjustin_smith: it's in midje code...
14:28justin_smith(of course :irrelevant-return-value likely came back from some function you called)
14:28ToxicFrogHmm. Ok, I thought that core.typed and clj-http wanting different versions of tool.reader was causing the crashes, but apparently not.
14:29justin_smithMy point is, see where it intersects with your code. My guess would be you are executing something it hands back to you. Or midge is fucked and you should use clojure.test.
14:29AeroNotixjustin_smith: now I get it -- the midje syntax is a bit non-lispy
14:30ToxicFrogArgh. I just want to use core.typed, but I don't even know where to start figuring out what it's conflicting with.
14:32justin_smithAeroNotix: midje is "lispy" in the bizarro sense that rubyists call things lispy
14:32AeroNotixjustin_smith: :)
14:34bbloomlispiness aside, midje is just plain harder to use than assertions
14:34technomancy"lispy" -> offers you enough power to do really crazy things
14:34bbloomhell, clojure.test is harder to use than regular assertions
14:34nooniani never understood ruby people calling ruby a lisp
14:34AeroNotixbbloom: I've started using midje, seems to integrate with CIDER/Emacs better
14:35bbloomAeroNotix: i find that non-trivial classes of assertions require me to look at the (poor) docs with 100% frequency
14:35justin_smithAeroNotix: core.test integrates with clojure better - the tests are functions, you call them and they tell you if they failed
14:35dbaschnoonian: for the same reason people prepend "smart" to any product name
14:36justin_smithit's the same way Avril Lavine identifies as punk - it makes her and her fans feel cool, and the punks are all like "wat"
14:36AeroNotixSmart Water
14:37justin_smithI actually really like dumb products - I love having a phone that doesn't know what a cloud is, or how to upload my shit to one.
14:37technomancyI'm getting close to having a smarter keyboard than phone.
14:38technomancyprobably just need to drop my nokia on concrete a few times
14:38justin_smithheh - I'm just waiting until the atreus app store comes out
14:38technomancy(just finished my ARM port last night)
14:38justin_smithvery nice
14:39justin_smithlike - make dvorjack available as a free download, but with no shift key - then allow shift as an "in app purchase" on a per-keypress basis
14:39justin_smiththen rake in the dough
14:42caternwhaat
14:42caternctrl-m is enter and ctrl-i is tab
14:42technomancymind_blown.gif
14:42caterni already knew ctrl-[ is escape
14:42caternwhere can I find more of these
14:43caternhelpful things
14:43justin_smithcatern: and ctrl-j is return (distinct from enter)
14:43ToxicFrogcatern: man ascii
14:43caternToxicFrog: huh?
14:43justin_smithand control-space is the null byte
14:43ToxicFrogcatern: the capital letters on the right correspond to the control codes on the left when ctrl is pressed
14:43justin_smithcatern: there is a unix command called "man"
14:43justin_smithcatern: the man page for ascii has a bunch of nice info
14:44caternjustin_smith: yeah, but I don't see any of these ctrl-[ ctrl-m ctrl-i things in it
14:44ToxicFrog14:43 < ToxicFrog> catern: the capital letters on the right correspond to the control codes on the left when ctrl is pressed
14:44caternah
14:45ToxicFrogcatern: e.g. 015 13 0D CR '\r' (carriage ret) 115 77 4D M <-- ctrl-M corresponds to CR, carriage return
14:45caternmind blown
14:46technomancyyeah, control codes are sent just by flipping a bit on regular ascii codes
14:46justin_smithcatern: for example, I am sure you already knew Ctrl-D was EOT
14:47caternjustin_smith: everything begins to make sense
14:47ToxicFrogjustin_smith: to be fair it could plausibly also have been ETX or EM
14:48justin_smithfair enough
14:48caterndo ctrl-c or or ctrl-\ fit in this at all?
14:48dbaschcatern: back in the day computers only had the ascii charset. My TI99 used the values > 127 for graphics (e.g. horizontal line, vertical line, angles)
14:48caterngiven that they send signals
14:49cbpctr-c is etx
14:49caternyes
14:49caternetx doesn't seem very sigint-ish
14:49dbaschcatern: that depends on the shell
14:49justin_smithcatern: your terminal translates the keycode into a signal to the currently running process
14:49cbpalso known as 'break'
14:50caterndbasch: justin_smith: is it the shell or the terminal?
14:50ToxicFrogYeah, I think it's just ctrl-C for Cancel
14:50justin_smithcatern: the terminal - the keycodes work even when you exec (which makes the shell exit)
14:50justin_smithand it works even if the shell is not running when the keycode is sent
14:50caternjustin_smith: so wait, emacs understands C-c keybindings by *running a signal handler*?
14:50dbaschcatern: the terminal driver
14:51justin_smiththe terminal runs the signal handler
14:51justin_smitherr
14:51justin_smithn/m
14:51justin_smithyeah, it uses a singal handler I think :)
14:51justin_smithin the console
14:51caternweird
14:51caternit works, though
14:51justin_smithit works :)
14:52technomancyreading about terminals is like reading about mime encoding
14:52technomancyit simply increases your wonderment and awe at the fact that anything ever works
14:53bbloomfrickin' terminals...
14:55justin_smith"fucking terminals, how do they work? I don't want to talk to a computer scientist, motherfuckers lying, making me pissed"
14:56johnwalkertechnomancy: what did core.typed do to you ? :(
14:56johnwalkerwoops, wrong completion
14:56johnwalkerToxicFrog: what did core.typed do to you ?
14:59caternwait so
14:59caternwhy do both Ctrl-m and Ctrl-M send CR?
15:00ToxicFrogjohnwalker: when I lein typed check, it does this: https://gist.github.com/anonymous/c37a772c1c470b7b1812
15:00bbloom,(- (int \A) (int \a))
15:00clojurebot-32
15:00ToxicFrogAt first I thought this was because clj-http and core.typed wanted different versions of tools.reader, but if I drop the clj-http dependency or force them both to use the same version it still happens.
15:00bbloom,(- (int \a) (int \A)) ; heh, positive
15:00clojurebot32
15:01justin_smithcatern: the control bit and the shift bit interact oddly - I forget the details
15:01caternaaaieeeeeeeee
15:01justin_smithcatern: there is no such thing as C-m - it becomes C-M
15:01caternAIEEEEEEEEE
15:01johnwalkerToxicFrog: the easiest way to check is to move the core.typed dependency before anything else in your :dependencies
15:01bbloom,(char 45)
15:01clojurebot\-
15:01amalloyjustin_smith: is it perhaps as simple as, when there's a control bit set, everything but the bottom five bits are masked off?
15:01bbloom*shrug*
15:01technomancydang, catern's been gazing into the abyss again
15:01ToxicFrogcatern: historically, ctrl zeroes the two high bits, which includes the bit that shift sets
15:02justin_smithamalloy: hrm - I dunno, that sounds plausible?
15:02johnwalkerwhether there's some sort of dependencies collision. i don't have a clue why thats happening though
15:02amalloysounds like basically what ToxicFrog is saying, and i imagine he knows better than i do
15:02ToxicFrogjohnwalker: it already is.
15:02ToxicFrogjohnwalker: and lein deps :tree is clean.
15:02caterntechnomancy: i've learned things mere mortals are not meant to know, delved to abstraction levels that hide ancient horrors, and it has driven me mad
15:02ToxicFrog(since removing clj-http, that is)
15:03amalloyspeaking of ascii control codes, a while ago i started typing C-j instead of RET while editing source buffers. it's easier, really - i don't have to reach over with a pinky
15:03caternokay, got any reading on this subject? there's that one really long article about terminals I've seen in passing, but I haven't read it or bookmarked it..
15:03amalloyplus then in the repl you can use C-j to insert a newline, and RET to send a finished expression
15:03technomancyamalloy: it also should auto-indent out of the box
15:04technomancywhereas you have to configure RET to do newline-and-indent
15:04amalloytechnomancy: i'm on such an old version of clojure-mode that RET still does, i think
15:04amalloymaybe i upgraded and then reconfigured it to the old behavior
15:04technomancyamalloy: yeah, someone complained about that (rightly, I think) and now it works the same as everyone else
15:04amalloyyeah, i agree it was right to make that change
15:04technomancyI haven't really got in the habit of preferring C-j, maybe one of these days
15:05technomancyI only got using C-i because I was able to remove the TAB keycap from my ergodox
15:06ToxicFrogjohnwalker: yeah, that's the thing, I was thinking "ok, dependencies collision, I'll just remove deps until it goes away and then figure out how to fix things", but I pared it down to just clojure and core.typed and it still happened. But I know that core.typed 0.2.68 and clojure 1.6.0 are compatible because I'm using them in another project without crashing.
15:13ToxicFrogjohnwalker: blew away ./target and it started working. I guess it wasn't rebuilding something it should have been?
15:14johnwalkerToxicFrog: wow that is bizarre
15:14amalloyAOT compilation. not even once
15:14ToxicFrogI'm not even using AOT for anything but uberjar.
15:15johnwalkeri'm glad you fixed the issue though
15:17ToxicFrogNow, my types are all completely hosed after a year of updates without bothering to typecheck anything, but I know how to fix that~
15:19johnwalkergrep -v ann ?
15:25ToxicFrogOk, new core.typed question!
15:26ToxicFrogI have a function that's basically (defn register-foo! [& xs] (def foo (into foo xs)))
15:26ToxicFrogI gave it signature [Any * -> Nothing]
15:27ToxicFrogBut apparently it actually has signature [Any * -> (Var (Vec Any) (Vec Any))]
15:27ToxicFrogWhich kind of makes sense if I read (Var old-type new-type) as being the type of def
15:27ToxicFrogExcept Var doesn't exist in core.typed, so I can't use it as part of the signature!
15:31amalloyjustin_smith: i just saw your comments on http://stackoverflow.com/questions/25793668/why-is-my-clojure-code-running-so-slowly. it's funny, i didn't actually intend for the powers-of-two sequence to be especially inefficient as part of the problem; i didn't really imagine anyone realizing a finite-but-too-large piece of it
15:31justin_smithheh, here i thought it was an excellent design choice in constructing the puzzle :)
15:31ToxicFrogHmm, ok, it actually wants either (Var1 T) or (Var2 Tw Tr) even though the error message reports it on Var
15:32amalloysometimes i did create intentionally-large inputs so that you'd have to think about performance, but most of the time i just wanted any correct solution to work
15:33amalloyit's an interesting problem. looking back at it now i'm not even sure if the solution i wrote years ago is actually efficient or not: https://www.refheap.com/90119
15:34amalloyit seems inefficient because it goes over every seq but the first multiple times, but...can you do better? i don't know that you can
15:37justin_smithamalloy: https://www.refheap.com/90120 mine, does a bunch of sorting, so is likely slower
15:37amalloycertainly my in-lists? is a bad reimplementation of every?
15:37ToxicFrogSeriously tempted to just :refer :all when I use core.typed now, remembering which things need t/ and which don't is a pain
15:38amalloyjustin_smith: well, there are certainly inputs for which yours is faster
15:39amalloywell, maybe not. i dunno. performance is hard
15:39justin_smithbenching them now
15:40justin_smithuse criterium, it's a library, it's a space heater, it solves random clojure trivia
15:43amalloyjustin_smith: i was going to suggest using test.check to generate evil input sequences, but...since it just has to be N sorted collections, there's really nothing exciting it could do
15:45justin_smithas long as the solution is smart enough not to be over eager in reading any inputs
15:45justin_smithand that final test is good on that count
15:46justin_smithhttps://www.refheap.com/90122 looks like mine was significantly faster (> ms µs ns)
15:47justin_smithI dunno - is it worth benchmarking again predefining the functions?
15:47justin_smithmay as well
15:48amalloyjustin_smith: don't predefine them, just let them outside: (letfn [...] (bench ...))
15:48amalloybut no, i don't think it matters at all
15:52amalloyjustin_smith: you can improve yours quite a bit, actually, by not sorting and by possibly advancing multiple inputs at once: https://www.refheap.com/0142f12d90d7cef1ac56a0222
15:53dbaschjustin_smith: here's mine fwiw https://www.refheap.com/90124
15:54dbaschwhich has obvious improvements
15:54amalloydbasch: ah, using max is cute, although you can use drop-while instead of next, as in my recent suggestion
15:54dorkmafiahow do you create a new instance of a java class from clojure? (ClassName. (arg1) (arg2)) ?
15:54dbasch(I mean can be improved obviously)
15:54amalloyand, just for style points: (let [[mi ma] (apply (juxt min max) ...)] ...)
15:54justin_smithdbasch: interesting
15:54dbaschamalloy: that's what I meant, I look at it now and I could have done it less redundantly
15:55tadni_So, I'm glad to see that "Clojure From The Ground Up" should be more or less done by Janurary.
15:55dbaschjuxt wasn't on my radar at that point
15:55amalloyyeah, (apply (juxt min max) ...) is a trick that still confuses me
15:55amalloylike, i know it works, but my head hurts if i think it through
15:57amalloyi love that these 4clojure problems are still interesting years later, knowing much more about the language
15:57justin_smithyeah, it's pretty cool
15:59justin_smithamalloy: dbasch: I wouldn't have guessed so, but mine is still fastest - though dbasch's version is close https://www.refheap.com/90125
16:00amalloyjustin_smith: it'll depend on the inputs for sure
16:00justin_smithyeah, just using the "tricky" input
16:00justin_smithdbash's would excell with a longer input list
16:00amalloyand either yours or dbasch's would be improved by using drop-while instead of rest
16:00justin_smithtrue that
16:02Bronsabbloom: re: hours ago -- no I haven't :)
16:02Bronsaalso I just learned that src/foo/bar/baz/ is the same as src/foo.bar.baz for the jvm. I'm kinda tempted to mkdir clojure.tools.analyzer
16:02bbloomBronsa: heh, just for less work when cd-ing?
16:02justin_smithoh, wow, that's a weird thing
16:03Bronsabbloom: I have to tab like 6 times to find the first clj file on my tools.* libraries
16:03technomancyI wonder if that's imlementation-specific
16:03bbloomBronsa: i was super excited when github released the deep-jump links thingt
16:04Bronsabbloom: me too!
16:04technomancyI remember reading some crazy thing about how dashes in class names are actually supported by openjdk, just not the JVM spec
16:04Bronsabbloom: my actual comment on #clojure-offtopic "the first github UI change I approve"
16:04joobushow do I call Integer/parseInt from my code? I can call from the repl, but in my code I get a compile error.
16:04justin_smithbbloom: Bronsa: maybe we need deep-jump-find-file
16:04Bronsatechnomancy: dunno, I actually saw this on the openjdk source tree
16:05amalloyjustin_smith: ido-mode has a setting for that somewhere
16:05technomancyBronsa: the five users of Clojure on IBM's JDK will yell at you
16:05justin_smithjoobus: are you using it as if it were a first class function? it isn't one
16:06joobusjustin_smith: I guess I am. (map Integer/parseInt blah)
16:06justin_smith#(Integer/parseInt %) is one
16:06joobusok
16:06justin_smithjoobus: this is all because clojure functions are objects, not methods on some object
16:06joobusI guess that makes sense. i searched and found parseInt is a static method of java.lang.Integer
16:07joobusjust didn't know how to handle that
16:07joobusthanks justin
16:07technomancyI don't really get why Clojure doesn't auto-memfn or its static equivalent
16:07justin_smithyeah, the idea is that an arg to a clojure function can be an object or primitive, but it can't be a method, they are not first class
16:08technomancyare there ambiguous contexts in which it can't be determined?
16:08justin_smithtechnomancy: it would be another bit of magic, I support being skeptical of magic
16:09Bronsatechnomancy: that would almost always require runtime reflection
16:09technomancyjustin_smith: I don't see how it's magic. how else would you interpret (map .toString objs)?
16:09Bronsatechnomancy: compare Object foo(Object); Object foo(Object, Object);
16:10Bronsahow could you statically determine which one you're using when compiling (map Class/foo ..) ?
16:10bbloom(doc memfn)
16:10clojurebot"([name & args]); Expands into code that creates a fn that expects to be passed an object and any args and calls the named instance method on the object passing the args. Use when you want to treat a Java method as a first-class fn. name may be type-hinted with the method receiver's type in order to avoid reflective calls."
16:10bbloomnote that you have to provide type hints
16:10technomancyBronsa: I don't mind runtime reflection
16:11bbloomtechnomancy: the problem isn't that it requires reflection, it's that the reflection doesn't occur until later
16:11Bronsatechnomancy: I do
16:11bbloomi guess that the compiler would warn on reflection when auto-memfn-ing
16:11Bronsabbloom: I don't understand the distinction you're trying to make
16:12technomancythere's lots of stuff like that in clojure already; it seems like the line is drawn at a somewhat arbitrary spot
16:12bbloomBronsa: sorry, i didn't fully think that thougth out. i guess that's also true of fn too
16:12bbloomignore me :-P
16:13Bronsatechnomancy: for instance-methods it wouldn't even be a matter of only "it would require reflection" -- you wouldn't even know what arities are available
16:14tadni_justin_smith: Yeah, Clojure from the Ground up -- the more I looked into it, appears to be more an introduction to the lang more-so a general compsci introduction.
16:14technomancyyet memfn exists
16:14Bronsawhat would it do? turn .foo into (fn ([x] (.foo x)) ([x y] (. x y)) ..)?
16:14Bronsatechnomancy: you have to provide the argc to memfn, that's the point
16:14joobusw00t! I've solved 4 project euler problems in clojure. I'm feeling slightly less noobish...
16:14amalloytechnomancy: well, memfn is for a specific, single arity
16:15AeroNotixI'm seeing a http-kit/get call being blocked (where it should always return a promise). Any ideas why that would be?
16:15amalloyyou can expand into a million different arities, as Bronsa points out, but it's not super-clean
16:15technomancyBronsa: you actually don't?
16:16justin_smithtadni_: did you mean disillusioned? or does it disenfranchise you from some right you would otherwise have?
16:16joobusjustin_smith: lol
16:16justin_smith"this tutorial is opressing me"
16:16johnny_mckGreetings! I haz questions if anyone cares to answer some? (mostly about programming in a functional style...)
16:16dorkmafiais this the correct syntax for creating a java class from clojure and passing constructor args (ClassName. (arg1) (arg2)) ?
16:16amalloytechnomancy: yes you do. (memfn add) only accepts exactly one argument; (memfn add x) accepts exactly two...
16:17tadni_justin_smith: Well, if I were to follow the thinking in the "who is this guide for" and I was non-cis, or non-white and was using another guide ... then maybe. :^P
16:17technomancyhuh... I've never used the second arity of memfn
16:17tadni_I'm saying, it's not really a general compsci text as much as a general introduction to clojure.
16:17Bronsatechnomancy: you've only used on no-arg methods then :)
16:17justin_smithtadni_: true
16:18justin_smithjohnny_mck: we grant permission to ask questions freely
16:18joobusjohnny_mck: you should just ask and see if someone responds. that's what the pro noobs like myself do.
16:18amalloyjustin_smith: unless it's about the new iphone
16:18justin_smithheh
16:18justin_smithyeah, maybe I should have qualified that
16:24TEttingerdorkmafia: ##(java.util.HashMap. 64)
16:24lazybot⇒ #<HashMap {}>
16:24TEttingerdorkmafia: ##(java.util.HashMap. (64))
16:24lazybotjava.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn
16:25TEttinger64 is a constructor arg to that java class that is the initial capacity, IIRC
16:26justin_smiththere's that javascript compiler that removes lines of code until everything compiles, we should do something similar with clojure, and removing parens
16:27TEttingerI think there could be some ambiguity.
16:27TEttinger,(map identity [+ 1 2 3])
16:27clojurebot(#<core$_PLUS_ clojure.core$_PLUS_@15773de> 1 2 3)
16:27AeroNotixI'm seeing a http-kit/get call being blocked (where it should always return a promise). Any ideas why that would be?
16:27TEttinger,(map identity [(+ 1 2 3)])
16:27clojurebot(6)
16:28amalloyjustin_smith: the readme for wtfjs is sublime
16:29justin_smithindeed
16:50defndnolen_: Whaddya know about probabilistic programming? I want to dig in and am curious if you have suggestions on papers, resources, etc.
16:50dnolen_defn: not much I just surveyed some literature at one point, Church is a good jumping off point
16:51dnolen_defn: http://projects.csail.mit.edu/church/wiki/Church
16:51defndnolen_: Some fascinating stuff.
16:52defnYeah I found the church lang. So many recent papers and research topics involved that I'm feeling overwhelmed.
16:52defnProbmods.org was a good intro, but I need to see more in practice. Anyway, thanks again.
16:53defnOh, and mcmc has been done in clojure. If you're interested dnolen_
16:53defnhttps://github.com/farr/mcmc-clojure
16:53dnolen_defn: interesting though old and not maintained
16:54defnYeah :/. Looks like I need to take a page out of the dnolen book and write clojure.core.prob
16:57bbloomdefn: go for it!
16:58jdkealyHello, I have been trying to use the AMI startup script for Dynamo DB and AWS. I have gotten the startup script to launch a new instance, but it stops and restarts itself with the following error: ./startup.sh: line 26: kill: (1768) - No such process, /dev/fd/11: line 1: /sbin/plymouthd: No such file or directory ... has anyone here encountered anything like this before ?
16:58arrdemdefn: there's an implementation of distributions kicking around somewhere from contrib that may be interesting material as well although that's more probability modeling than a probabalistic structure
16:58defnjdkealy: I believe there is a #datomic channel
16:58jdkealysorry about that! I thought i was in #datomic :/
16:58defnNp
16:59defnarrdem: I'll have a look. I think I know the one you're referring to. Been a long while since I went through contrib
16:59defnThanks!
17:00arrdemdefn: there's an old implementation of a distribution monad. It doesn't make a whole lot of sense as a monad, but the distribution structure has served me well in a tabletop game project.
17:08dbascharrdem: wow, it hasn't been touched for 5 years https://github.com/richhickey/clojure-contrib/tree/master/src/main/clojure/clojure/contrib/probabilities
17:08arrdemdbasch: yep
17:08arrdemdbasch: oh do you still have that clojure vs clojurescript link?
17:09dbascharrdem: this? https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure
17:10arrdemdbasch: I found that... I seem to recall you mentioning some post about expressions that didn't behave the same.
17:13dbaschtrying to find it
17:14sdegutisQuick, what's a good name for an app that does your chores for you?
17:14andyf_sdegutis: littleBrother ?
17:15dbaschsdegutis: siri :P
17:15sdegutisSomething that won't invoke trademark infringement? :P
17:15justin_smithsdegutis: apprentice
17:15justin_smithit even has app in the name
17:17sdegutisThanks everyone!
17:17noonianman, i'm going to be pondering that all day now
17:21sdegutisOh maybe old maid? Or steward?
17:21sdegutiss/old//
17:23nooniani was thinking robo-maid or something
17:23noonianor no-chore no-more-chore
17:23sdegutis:D
17:23sdegutisCertainly not Golem.
17:24technomancyyeah, you wouldn't want folks thinking it was written in google go
17:24sdegutisOr that it's from LotR.
17:24AeroNotixI'm seeing a http-kit/get call being blocked (where it should always return a promise). Any ideas why that would be?
17:24justin_smithGoLem: a generator of high concept sci fi, written in google go
17:25sdegutistechnomancy: I wrote an 80-line script in Go the other day, which downloaded some .tar.gz archives from the net, extracted them in-memory, and output contents of files matching a pattern.
17:25cbpsounds like a clojure 5 liner
17:25sdegutistechnomancy: A few hours later, I replaced it with a 4-line Bash script.
17:25technomancynice
17:25sdegutisI have never found a good use for Go that I haven't rewritten in something better.
17:26ieureGo is great if you enjoy writing "if (err != nil)" every other line.
17:26sdegutis:)
17:27ieureAs someone who needs to write extremely correct software, Go sends me screaming.
17:27technomancyhey, when I was in school, you didn't have to get 100% on every test
17:27technomancyeven if you got just like 90% it was no big deal
17:28mdrogalisGonna put that on my resume. "I write sorta good code. Good enough anyways"
17:28ieureHah.
17:28mdrogalisieure: What industry do you work in?
17:28sdegutis<3
17:28ieuremdrogalis, Banking.
17:28sdegutisI was gonna guess "financial"
17:28mdrogalisUnit testing on your own bank account. Don't mess up too much, now.
17:28AeroNotixieure: so what language do you use then?
17:29justin_smithmdrogalis: nah, you just add a test fixture that resets the balance :P
17:29ieureAeroNotix, Depends. We're a JVM shop, but write Java, Scala, Clojure, and JRuby.
17:29sdegutis<3 Java
17:29ieureDepending on what the thing is.
17:29AeroNotixieure: and you think you can write more correct programs in Java than in Go?
17:29sdegutisSuch nice. So language.
17:29TEttingerJRuby seems like the thing to not use for correctness
17:29AeroNotixsdegutis: are you kidding?
17:30sdegutisWho doesn't love Java?
17:30sdegutis(Besides hipsters.)
17:30mdrogalisjustin_smith: "Gave myself some padding by adding a few zeros this week."
17:30ieureAeroNotix, I believe it is easier to write correct programs in Java than Go.
17:30technomancyJava: at least it has exceptions
17:30AeroNotixieure: could it be that you're just more familiar with it?
17:30ieureAeroNotix, No.
17:30AeroNotixoh ok. Case closed.
17:30mdrogalisHahah.
17:31sdegutisAt the end of the day, there's nothing really wrong with Java, it's perfectly suitable for writing any kind of serious app in. Clojure is just the icing on the cake.
17:31TEttingersdegutis, designed for average coders, by average coders?
17:31TEttingerOak, anyway
17:31AeroNotixsdegutis: that's not a very nuanced opinion.
17:32arrdemTEttinger: read the CVs of the Java language committee and lets hear you say that again
17:32TEttingerI was kidding
17:32sdegutisAeroNotix: uhh
17:32sdegutisTEttinger: uhh
17:32mdrogalisNot sure how you can appreciate Clojure without realizing what's wrong with Java. D:
17:32TEttingerI know they got some very experienced devs on that team
17:33TEttingerand it is interesting how Java got by with less serious design flaws at an early stage than most other large languages
17:33TimMcPity about the type system, though.
17:33TEttingerthey had to do a big rewrite for generics, and they still aren't great
17:33sdegutismdrogalis: There are quirks in every language, and that's kind of why I have a job actually, because writing software is kind of hard.
17:33ieureJava Generics are really terrible.
17:33ieureIs typed Clojure usable yet?
17:34ieureIt seems very promising.
17:34sdegutisI could try and write Haskell all day but the tools I use now work fine.
17:34TEttingerI have wondered the same, ieure. it seems to be, though I haven't tried it.
17:35ieureI've been appreciating static typechecking more since I started writing systems that have to correctly deal with millions of dollars of other peoples' money.
17:35TEttingerthe main thing I use clojure for right now is one-liners of very dense code.
17:35TEttinger##(clojure.string/join" "(repeatedly 2000(fn [](apply str(concat[(rand-nth ["rh""s""z""t""k""ch""n""th""m""p""b""l""g""phth"])](take(+ 2(* 2(rand-int 2)))(interleave(repeatedly #(rand-nth ["a""a""o""e""i""o""au""oi""ou""eo"]))(repeatedly #(rand-nth ["s""p""t""ch""n""m""b""g""st""rst""rt""sp""rk""f""x""sh""ng"]))))[(rand-nth ["os""is""us""um""eum""ium""iam""us""um""es""anes""eros""or""ophon""on""otron"])])))))
17:35lazybot⇒ "rhauchaumor peobus rhamor pourkoistum teongeochium phthongoushor theonarstis zeofor phthaungeorstotron girtoirtanes pospeoshiam chepum toumon loitocheros zixophon lamon sabousotron gespium toxortis soirtenor laspum chomum paurteopis zeofepus moigum thortousheum togo... https://www.refheap.com/90131
17:35justin_smithieure: there is also prismatic/schema
17:35sdegutisIn fact, I'm betting on the fact that people are overly picky about languages, and I'm embedding 4 different scripting languages into my upcoming commercial app.
17:36dbaschTEttinger: future you would like to have a word with present you
17:36sdegutisThey can choose between Ruby, Java, Python, or Lua.
17:36ieurejustin_smith, Looks interesting.
17:36arrdemdbasch: lol
17:36sdegutiser, JavaScript
17:36TEttingerdbasch: the reduced need for spaces helps with these one-liners fitting in 400 or so characters
17:37amalloyand imagine the savings on commas
17:38dbaschamalloy: I like my machine code to have more ones than zeros because it saves ink when printing them out in binary
17:40TEttingerI'm currently almost exclusively writing C# for a rapidly-expanding-in-code-size renderer for voxel models. I'm hoping to use the rendered stuff from clojure using play-clj when I get closer to done.
17:43dbascharrdem: I found this in my browser history, it only goes back 90 days https://gist.github.com/alandipert/2346460
17:44arrdemdbasch: thanks for looking
17:51sdegutislol, Proletarian
17:59TEttinger,(filter #".*foo.*" ["foobar" "goobar" "foobaz"])
17:59clojurebot#<ClassCastException java.lang.ClassCastException: java.util.regex.Pattern cannot be cast to clojure.lang.IFn>
17:59TEttingerhm, I guess it doesn't work in vanilla clojure without further black magick
18:00llasramTEttinger: yeah -- in JVM Clojure there's no way to turn existing classes (like regular expressions) into IFns
18:00technomancyyou could define a clojure.lang.Regex
18:01TEttingeryou could add a reader literal to create your own REFn
18:01technomancysince no one has ever used #"" regexes for interop ever
18:01TEttingerit could also be a subclass of the java regexp
18:02technomancyllasram: no seriously
18:02technomancyI would be mildly surprised if anyone on this channel has ever done it
18:02BronsaTEttinger except Pattern is final :)
18:02TEttingerwat
18:02Bronsahttp://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html
18:03TEttingerthen you could have another class that has a Pattern as a member and itself implements IFn
18:03technomancyTEttinger: I would vote for that =)
18:04BronsaTEttinger you couldn't use that for interop then
18:04noonianwhy do you need it to work with just a literal?
18:04llasramIf classes aren't explicitly designed to be extensible, best to make them final. Keeps things all neat and tidy.
18:04llasramPrevents the proletariat from getting uppity etc
18:04TEttingerright, but you could get the Pattern out of it once and use that for interop
18:04TEttingerI dunno
18:05BronsaTEttinger but there'd be no way to always known statically when you're passing a MyPattern instead of a proper Pattern to "unbox" it
18:06TEttingerI guess. the best solution would be to not interop, I suppose
18:06Bronsayou'd need to add instance checks + "unbox" paths everywhere you call a method taking a Pattern
18:06Bronsawhich might not be too bad actually
18:06technomancynoonian: filtering on a regex is many orders of magnitude more useful than interopping a regex, so it's unfortunate that the latter is convenient and the former is not
18:09BronsaI might actually attempt a patch for that one of the next days
18:10Bronsait might break code that explicitely tests for j.u.regex.Pattern though
18:12dorkmafiahttp://paste.debian.net/120473/ why does line 17 throw a java.lang.NullPointerException the first time i call it but after that it's fine?
18:14noonian,(filter (partial re-find #".*foo.*") ["foobar" "goobar" "foobaz"])
18:14clojurebot("foobar" "foobaz")
18:14nooniani'm happy enough with that though
18:16dbaschnoonian: I'd probably want re-matches behavior rather than re-find
18:18nooniandbasch: it wouldn't matter for filtering though right? both would return a truthy value if there are any matches or nil otherwise if i'm not mistaken
18:18dbaschnoonian: it depends on the regexp
18:19nooniandbasch: ah, good call
18:19noonian,(filter (partial re-matches #".*foo") ["foobarfoobar" "goobar" "foobaz"])
18:19clojurebot()
18:19noonian(filter (partial re-find #".*foo") ["foobarfoobar" "goobar" "foobaz"])
18:19noonian,(filter (partial re-find #".*foo") ["foobarfoobar" "goobar" "foobaz"])
18:19clojurebot("foobarfoobar" "foobaz")
18:22dorkmafiais there something wrong I'm doing with the chaining of functions?
18:24dbaschdorkmafia: what parameters are you calling that with? What's the exception?
18:26dorkmafiadbasch: http://paste.debian.net/120474/
18:29dbaschI don't see any calls there, just definitions
18:30dorkmafiait's in the handler
18:32noonianso where do you create the handler? it looks like all those functions get it passed in
18:32dorkmafiahttp://paste.debian.net/120475/
18:33dorkmafiahmm
18:33dorkmafiamaybe it's passing nil as the from-user?
18:34noonianyeah maybe, you might get a message where the body isn't blank but there is no :from-name
18:35nooniani'd definitely print the message for now so you know what it's getting
18:38dorkmafiahmm
18:38dorkmafiak
18:41dorkmafianope the from-user is correct
18:42dorkmafiait doesn't print out twice which is strange
18:55dorkmafianoonian: i think it has to do with the roster not being defined
18:57dorkmafia(defn roster [conn] (when conn (.getRoster conn) )) am i using when correctly here?
18:59dbaschdorkmafia: it depends on what you want. If conn is falsey that will evaluate to nil.
19:02dorkmafiahm i dunno
19:03nooniandorkmafia: i'd change it to an if for now and print something if the conn is nil
19:03noonianits nice to have more information during dev/debugging
19:06dorkmafia (.getEntry (roster conn) uname) )
19:06dorkmafiacould it be due to taht?
19:06dorkmafiai'm going to try and use a local variable for the roster there
19:07technomancyIMO you should check for nils as early as possible and error out
19:07technomancyletting them leak through any old place in your program makes for bugs that are tedious to track down
19:08dorkmafiaall of the inputs are fine
19:13dorkmafiais it possible I need to set java types for the return types of some of these methods?
19:14amalloydorkmafia: no
19:15tufttechnomancy: they can work like a poor man's maybe monad, which is nice
19:16technomancymonads without a type checker... poor man indeed =)
19:23dbaschdorkmafia: I still don't know how you're starting the whole thing. I assume you call starter-bot, but what is smack/start-bot?
19:23amalloysounds like bot abuse to me
19:24dbaschamalloy: you just reminded me of a Futurama episode
19:26dorkmafiadbasch: there is another class i missed lol sorry
19:27dorkmafiahttp://paste.debian.net/120478/
19:36dbaschdorkmafia: that code is pretty convoluted, where does it come from?
19:36dorkmafiayah that's why i'm trying to make it better it's from xmpp-clj
19:36dorkmafiaon github
19:46dorkmafiadbasch: should i just start over? lol
19:48aderethI wish I had done the Heroku Clojure walkthrough sooner. That was really easy.
19:48aderethMade a toy: http://templar-clj.herokuapp.com/
19:48aderethhttp://templar-clj.herokuapp.com/?url=http%3A%2F%2Ftemplar-clj.herokuapp.com%2F
19:55justin_smithadereth: is it giving a templated version of the page provided?
19:55lockscute
19:56justin_smithAn error occurred in the application and your page could not be served. Please try again in a few moments. If you are the application owner, check your logs for details.
19:58aderethYes
19:58aderethIn Enlive, Hiccup, and Hickory style
19:58aderethOh noes. Still?
21:12yedijsut to confirm, clojure lists have 0(1) prepending and appending correct?
21:12bbloomyedi: prepending only
21:13yedioh... that's unfortunate. is there a data structure that also keeps a pointer to the end of the lis tas well
21:13bbloomyedi: concat constructs a lazy sequence in O(1) time
21:13bbloomyedi: vectors have fast push/pop from the tail and can be converted in to a seq in O(1) time
21:14bbloomif you genuinely need push/pop from both sides, there are contrib libs for finger trees and rrb vectors
21:14justin_smithyedi: there is a lib with a persistent deque (which does fast prepand and append)
21:14bbloombut it's pretty rare that you actually need that
21:14yedijustin_smith: ah i think that was the library you linked me to before
21:14justin_smithyedi: probably
21:14yedibbloom: well i'm creating a queue that needs to be able to append on one side and pop from the other
21:15justin_smithbut you wanted a queue actually, right? and there is a built in Persistentqueue if you want fast front insertion and fast tail removal
21:15bbloom,clojure.lang.PersistentQueue/EMPTY
21:15clojurebot#<PersistentQueue clojure.lang.PersistentQueue@1>
21:15yedithis is on clojurescript btw
21:15TimMc"by the way"
21:15yedi>_<
21:15bbloomyedi: i think cljs has persistent queue also...
21:15yedisweet, ill go check
21:17TimMcI'd be curious to hear what you find.
21:17bbloomit's there
21:18yediyep
21:48zeebrahadereth: is there a link to the walk through?
21:52truebuddiany tips or good reading links about how an experienced OO dev can think of modeling data in a functional world?
21:53rubygeek maybe this? https://leanpub.com/fp-oo
21:53matthoffmantruebuddi: I quite liked that one
21:54justin_smithtruebuddi: many of Rich Hickey's video talks are about contrasting Clojure style functional programming to Java style OO
21:55truebuddiI did a lot of reading .. practiced almost everything from iloveponies.github.com; watched quite a few talks from rich hickey .. recently started looking at joy of clojure .. i get the language but am having trouble getting something real done in clojure ...
21:56justin_smithtruebuddi: what real things have you tried to do?
21:57truebuddijustin_smith: well i wanted to build a small web app .. for fun kind ..but have some starting trouble ...
21:58justin_smithwhat were your roadblocks?
21:58matthoffmanit can be tough to stare at a blank page and think of how to model the world functionally when you're used to OO; i found it easier to try adding a feature to an existing project.
21:58matthoffman'cause then i had to walk through existing code and figure out how they modelled things
21:59jasonjck_following SICP in clojure is a good way to learn
22:00jasonjckni think there's a whole clojure book on webapps
22:00jasonjcknit's not joy of clojure
22:00justin_smithtruebuddi: anyway, if you have specific questions, feel free, all of my largest clojure projects have been either web apps or my work on a web app framework, and I know a number of other folks here do clojure web apps too
22:00truebuddi@justin ... for eg, i want to build a "trip journal" where you have a "group of people". each person can comment on a trip...trip cannot be deleted by anyone else other than that person who created it ... things like that ...
22:01bjawhere has prismatic/schema been all of my life?
22:02justin_smithtruebuddi: on a data modeling level, a database is by definition not functional (unless you use something like datomic that has an immutible history, but frankly I think that is often overkill) - functional programming can use persistence and mutation judiciously, just as OO can use immutible data or static methods
22:02justin_smithbja: I know, right?
22:03justin_smithtruebuddi: the key, for me, is to have a clear mental model of where and why the mutation / persistence occur (they often go hand in hand), and how they integrate with the purely functional ecosystem that is the rest of my code
22:03bjabuilt a coercer to handle configs pulled in via environ/zookeeper
22:03bjamy life is now simple
22:04justin_smithbja: as long as you don't expect to be able to use watches, or treat it like a db, zookeeper is awesome
22:05truebuddijustin_smith: initially i am not even worried about persistence ... for the most part I am only concerned about how you would you model something? say I want anemic object Person .. with a name, profile picture, some description ... you make the person a map or a record or what...thats the kind of stuff that isn't clear to me yet
22:05justin_smithtruebuddi: to be more concrete, I will usually associate a request with gathering db data coming in, and then writing db data on the way out again
22:06justin_smithtruebuddi: use a map until maps are a bottleneck
22:06justin_smithtruebuddi: use assertions or prismatic/schema to make sure the data has the shape you expect
22:06bjajustin_smith: what's wrong with using watches?
22:06justin_smithbja: they are flawed inside zookeeper
22:07justin_smithbja: oh, I mean avout - the clj zookeeper binding that acts like an atom
22:07justin_smithit makes zookeeper extremely easy to use, but the watches are not worth it (and don't use it for large data sizes)
22:07bjaI've been using watches for settings updates
22:08bjabut have not been using about
22:08justin_smithbja: I specifically meant watches on avout/atom objects
22:08bjaah, ok
22:08justin_smithbja: http://avout.io/ check out the example code - they do make it very similar to clojure.core atoms
22:09justin_smith(and refs also, but there is less reason to use those)
22:09bjaoh, I saw that on /r/clojure I think
22:10justin_smithbut I am sure zookeeper is awesome on its own too (and in some ways simpler when it doesn't try to pretend to be a standard clojure reference type)
22:10bjayeah. We're just using it to distribute settings
22:11justin_smithright, that is what I did too, but being able to look at the settings like atoms was a bonus
22:11bjahaving a config schema makes it easy to know that a bad settings push won't blow up my production systems
22:14justin_smithtruebuddi: another revelation for me was focusing less on creating structures that emulate the real world and more on creating stateless transformations that can be composed to create the process I need
22:15justin_smithtruebuddi: if my map needs a new key in it, or the list needs to become a vector, this is a simple change if I wrote my code well - the interesting part isn't getting the data model perfect up front, its being able to quickly iterate the data transformations until I have the program I need
22:17truebuddijustin_smith: so you suggest I start with something basic ... just model as much data as I could with what I know ... maps...lists ... vectors..sets and then refactor later?
22:17justin_smithtruebuddi: yeah, that is how clojure programs typically evolve
22:17justin_smithand all the operations on maps are supported on records
22:17justin_smithso if you need something more specific later, you can upgrade easily
22:18truebuddijustin_smith: now that makes me worry next about ownership ... usually in OO you can have a repository which owns a list of people .. so in a fp world who owns say a list of my persons? another structure eventually in a global context?
22:19justin_smithtruebuddi: maybe you've seen that Alan Perlis quote? It is better to have 100 functions operate on one data structure than 10 functions on 10 data structures."
22:19justin_smithtruebuddi: when you have ubiquitous immutibility, ownership becomes less important - when you need mutation, keep it near the owner, and export something immutible at the earliest practical moment
22:19truebuddijustin_smith: I didn't know it was from Alan Perlis but heard of that quote when doing some reading about Clojure and Rich Hickey quoted it somewhere i guess ..
22:21ToxicFrogHow do I express "this function does not return" in a core.typed annotation?
22:22justin_smithtruebuddi: so, since you need a mutible storage of user data (assuming that is what "people" are for here), I would make a people ns, keep all implementation details internal to that ns, and clearly delineate the functions comprising the API, which returns immutible people for queries, or takes update maps and manages state based on those updates
22:23TimMcToxicFrog: Declare it to yield _|_, obviously. :-P
22:23truebuddijustin_smith: so use ns to organize functionality .. hmmm
22:24justin_smithtruebuddi: yeah, for me an ns represents some group of related abilities provided to other code
22:24TimMcToxicFrog: (No, I don't actually know if core.typed supports bottom.)
22:25truebuddijustin_smith: what do you think of https://leanpub.com/fp-oo that was suggested earlier to me ..
22:25justin_smith⏟⏟ <- a much more shapely bottom, thanks to unicode
22:25ToxicFrogTimMc: it describes "Nothing" as "the bottom type"
22:25justin_smithtruebuddi: I have not read it
22:25TimMcjustin_smith: Oh, Unicode and its shapely bottoms...
22:26truebuddijustin_smith: been a few years since I did web dev ... anyway do you have a suggestion for a small but practical web app that I can study preferably one in clojure/cljs
22:26TimMcToxicFrog: But then the docs say "Nothing is the bottom type that inhabits no types except itself." which I think disagrees with (say) the Haskell notion of bottom.
22:26TimMc_|_ is supposed to inhabit *all* types, right?
22:27truebuddijustin_smith: I played around with compojure, http-kit .. so i am not too concerned about the technology but am more interested in how things like sessions, cookies, web sockets are mixed with business end of things in clojure
22:28justin_smithtruebuddi: https://github.com/prismofeverything/schmetterling is by a friend of mine (I contributed extensively to the design, but less to the actual code) - sadly I can't think of a really good web service in clojure for reading off the top of my head (all my good ones are closed source client work)
22:28justin_smithTimMc: stupid sexy unicode
22:31TimMcjustin_smith: http://www.boardsandrec.com/showthread.php?t=82114
22:31TimMc"unicode butt" is now in my google search history, forever
22:32justin_smithlol
22:34justin_smithand all along, I was looking for: ⊥ "UP TACK"
22:34justin_smithwhy the hell is it called up tack? who knows
22:35TimMc*files, also
22:35teslanickLooks like a tack sitting on its head, pointing up?
22:35justin_smithright, but I have never heard it called that name in a mathematical context, though it is categorized as a mathematical symbol
22:36justin_smithTIL http://en.wikipedia.org/wiki/Up_tack
22:36justin_smith"falsum"
22:37justin_smithalso, (⊥) has an antonym, (⊤) and both look kind of butt-like when parenthesized
22:38teslanickIndeed. It's like the two great taxinomies of highly convex rear-ends.
22:38teslanickI think Sir Mix-A-Lot wrote a ballad to the union of both taxonomies.
22:39justin_smith(inc teslanick)
22:39lazybot⇒ 2
22:39teslanick\o/ I will treasure this.
22:44ToxicFrogMan, apply+core.typed is my worst enemy
22:44ToxicFrogTarget: (IFn [java.lang.String Any * -> java.lang.String])
22:44ToxicFrogArguments: (clojure.lang.PersistentList String)
22:45ToxicFrogThose look type-compatible to me!
22:45justin_smithToxicFrog: is apply worse than other higher order constructs?
22:45ToxicFrogjustin_smith: well, it's the only one giving me grief
22:46justin_smithone of these days I will take the core.typed plunge - I think I'll try using prismatic/schema more extensively first though
22:46ToxicFrogAn earlier issue with it was entirely my fault -- (apply f x ys) matches the type [X Y * -> ...], not [X (Vec Y) -> ...]
22:46ToxicFrogBut here it looks like it should be type-compatible; the PersistentList String expands to String String String... when applied, so it should match the signature [String Any * -> ...]
22:48ToxicFrogI also get this new and exciting error:
22:48ToxicFrogType Error (bltool/data/default.clj:26:1) Internal Error (bltool/data/default.clj:26:1) Unreachable method: Local inferred to be bottom when applying multimethod filter
22:50ambrosebsToxicFrog: that will fail for an empty list
22:51truebuddi+cnt
22:51ToxicFrogambrosebs: in this case, the list is generated by macro expansion and is known at compile time to be nonempty.
22:51ToxicFrog(and I don't control the macro, it's slingshot's throw+)
22:52ambrosebsToxicFrog: very likely throw+ will need a typed variant.
22:52ambrosebsfor any complicated macro it's usually the case
22:52ToxicFrogAs in, write my own type-annotated replacement for it?
22:52ambrosebsyes
22:52ToxicFrogD:
22:52ambrosebslike clojure.core.typed/for is for clojure.core/for
22:53ToxicFrogI don't suppose there's some way I can tell it to just not check anything inside a throw+ block
22:53ToxicFrog(also, any idea on the internal error?)
22:54ambrosebsToxicFrog: hmm I'd need to see the defmulti/defmethod
22:55ambrosebsToxicFrog: core.typed just macroexpands out everything blindly and checks it
22:55ambrosebsthe solution is another macro unfortunately
22:59ToxicFrogambrosebs: they're pretty simple: https://gist.github.com/ToxicFrog/73e20b453e4b578ab590
22:59ToxicFrogAnd it's only the second one that it generates that error on, which is especially weird.
23:00ambrosebsToxicFrog: the return type should not be Nothing
23:00ambrosebsNothing means an error
23:00ambrosebsof write-games
23:01ToxicFrogWhat should it be, then? nil?
23:01ToxicFrogAlso, that passes type checking, it's read-games that it objects to.
23:01ambrosebsoh right I see
23:02ambrosebsToxicFrog: so it's saying that read-games with dispatch value "nil" is unreachable based on the type of the multimethod
23:03ambrosebsperhaps the first argument of read-games should be (U nil String)
23:04ambrosebsnote that core.typed shouldn't really be complaining this loudly
23:04ambrosebsit should just ignore the method and move on
23:04ambrosebsbut I decided to be noisy at least while core.typed's implementation is relatively young
23:04ToxicFrogYep, if I changed it to (U nil String) it stops complaining about that one and starts complaining about the fourth one.
23:05ambrosebsright same issue I guess
23:05ToxicFrogYeah.
23:05ambrosebsnothing to do with the Nothing return type
23:05ToxicFrogEither can be nil for "argument not specified"
23:05ToxicFrogAnd now all four of them are complaining about "bad arguments to apply" from throw+'s use of format, which is more in line with what I'd expect.
23:07ToxicFrogFor now I think I'll just mark that ns :collect-only, I really only care about it for checking the other defmethods associated with it.
23:07ambrosebsgood idea
23:10ToxicFrog...hmm. How do I mark it :collect-only? I can't find docs for this, and I thought it was just (ns bltool.data.default ^:collect-only ...) but that doesn't appear to do anything.
23:11ToxicFrogOh, I see. It's either (ns foo {:core.typed {:collect-only true}} ...), or (ns ^{:core.typed ...} foo ...)