#clojure logs

2014-08-25

00:02TEttingerarrdem: " my two space indented block"
00:03TEttingerarrdem, markdown seems to have won in that arena
00:03arrdemTEttinger: sure point is that parsing text into indented blocks and paragraphs is dead easy but for stuff like Grimoire where I'm dealing with irregularly formatted but paragraphed text I want a way to bludgeon text into some form that I can machine edit
00:04TEttingerso adding {:op :indent :width 2 :children [:text] :text " ...} is less work than hand-editing it?
00:05arrdemI can build a parser to do that shit for me.
00:05TEttingerI'd use nesting to handle :children
00:05TEttingerrather than referencing :text twice
00:06arrdemwhat... something hiccup like?
00:06arrdemthat'd probably be nicer to hand type at any rate...
00:06TEttingerI dunno, my experience with text formatting mostly is limited to complex regexps processing TSVs
00:08arrdemhum... this is feeling more involved than a quick one off that belongs in my "random shit" lib...
00:12TEttingerthis is the extent of my clojure text processing https://dl.dropboxusercontent.com/u/11914692/class-formatter.clj
00:17rberdeenwhat's the right way to check if (seq x) will succeed?
00:19arrdemrberdeen: will succeed or does succeed?
00:19arrdemrberdeen: will is impossible without core.typed, does is just a precondition
00:20arrdemunless I missunderstand the question
00:21jk9357is clojure a play on the word closure or am i wrong
00:22TEttingerjk9357, closure, jvm, clr, yes
00:22rberdeenarrdem: I think I was looking for this: https://github.com/clojure/core.incubator/blob/16aed877cdfa24371099b0d13877d2716908cc91/src/main/clojure/clojure/core/incubator.clj#L83
00:22TEttingerit was initially intended to target both and be functional (with closures)
00:28rberdeenis there anything in clojure.core that will return true for an empty lazy seq or java.util.ArrayList?
00:28rberdeeni guess I'm not sure exactly what the common property would be called
00:34TEttingerrberdeen: ##(identity true)
00:34lazybot⇒ true
00:34TEttingerwhat do you want it to be false for?
00:35rberdeeni'm trying to validate that some input is list-ey
00:38rberdeenso arrays, java iterables, vectors, strings, etc would all result in true
00:39rberdeensequable? from incubator looks close
00:39rberdeeni was hoping for something that worked in clojure and clojurescript
00:39rberdeenis this not a common problem?
00:43sarcherTEttinger: thanks for the help, I got what I needed, now just learning more :)
00:47shekiboboweirdest thing
00:47sarcherwhat's the best practice for building out a data structure in clojure?
00:47shekiboboI have a method that takes two arguments
00:47sarcheri'm parsing the xml, but now I need to store it in a 'friendly' structure.
00:48shekiboboI changed it to add a third one which is expected to be a vector
00:48sarcherlike a map or something.
00:48arrdemsarcher: I think you'll find it's already in one..
00:48shekiboboand now I'm getting a nullpointerexception that I can't track down
00:49sarcherarrdem: i guess it is...so i should just pass / use the structure as-is?
00:49arrdemshekibobo: paste (refheap.com please) or we can't really help
00:49arrdemsarcher: yarp
00:49TEttingerrberdeen: sequential?
00:50TEttinger(doc sequential?)
00:50clojurebot"([coll]); Returns true if coll implements Sequential"
00:50TEttinger,(sequential? (java.util.ArrayList.))
00:50clojurebotfalse
00:51TEttinger,(#(and (seq %) (empty? %)) (java.util.ArrayList.))
00:51clojurebotnil
00:52TEttinger,(#(and (seq %) (empty? %)) [])
00:52clojurebotnil
00:52TEttinger,(#(and (seq %) (empty? %)) [1])
00:52clojurebotfalse
00:52TEttingerhm
00:52rberdeenanything with (seq) in it won't work, because
00:52TEttinger,(seq (java.util.ArrayList.))
00:52clojurebotnil
00:53TEttinger,(seq 1)
00:53clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
00:53TEttingeroh...
00:54shekibobohttps://github.com/shekibobo/knapsacker/pull/1
00:55shekibobothat's the diff and the error print
00:55TEttinger,(empty? 1)
00:55clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
00:56rberdeenall the clojure.core functions like seq? and map? seem to restrictive
00:56rberdeen,(= {} (java.util.HashMap.))
00:56clojurebottrue
00:56rberdeen,(map? {})
00:56clojurebottrue
00:56rberdeen(map? (java.util.HashMap.))
00:56rberdeen,(map? (java.util.HashMap.))
00:56clojurebotfalse
00:59grimoire~cols
00:59clojurebotCool story bro.
00:59grimoire~colls
00:59clojurebotcolls is http://www.brainonfire.net/files/seqs-and-colls/main.html
00:59TEttingerhm, you can check the source here, rberdeen: http://clojuredocs.org/clojure_contrib/clojure.contrib.core/seqable_q
00:59arrdemrberdeen: Clojure's type predicates are famously trash
01:00rberdeenTEttinger: yeah, i guess I am just copying that function
01:01shekiboboupdated the diff to be a little more conservative. stack trace from failure is in the comments: https://github.com/shekibobo/knapsacker/pull/1/files
01:01TEttingerit won't likely work on cljs, since it uses java classes I think
01:01rberdeenalthough it has since moved from clojure.contrib.core to core.incubator
01:02rberdeenthanks ClojureDocs from 2011
01:03rberdeenTEttinger: thanks for the help
01:03TEttingerno prob
01:03TEttingerI think arrdem may be better to ask :)
01:06arrdemTEttinger: heh clojurescript is not my forte
01:06arrdemJVM clojure weirdness... maybe.
01:08shekiboboall I'm doing is passing the vector of items into the function and all instances where it is called. Before it was calling a hard-coded method to get the collection
01:09lkjgggHey, where can I find good tutorials for clojure?
01:09shekibobonow I pass the items so that they can be retrieved in what I thought would be a safer way, and it should be working fine
01:09shekibobobut I get a NullPointerException on line 64 https://github.com/shekibobo/knapsacker/pull/1/files#diff-6262075c1285d0c0dd8d7a191717d811R64
01:10shekibobobut it doesn't seem to make much sense to me
01:10shekibobolkjggg: http://www.braveclojure.com/ << this one was pretty cool
01:11TEttingerlkjggg: http://learn-clojure.com/ might be good to start too
01:13shekibobomotherF*****
01:14shekiboboso why doesn't (get things index) work if it's a list?
01:14shekiboboIsn't that part of the collections interface?
01:15shekiboboI have to explicitly use (get (vec things) index), otherwise I just get a null
01:15arrdemnth, don't vec it
01:15shekibobonth
01:15shekibobook
01:15arrdemhttp://grimoire.arrdem.com/1.6.0/clojure.core/get/
01:15arrdemhttp://grimoire.arrdem.com/1.6.0/clojure.core/nth/
01:17shekiboboarrdem: thank you, I've been tearing my hair out for the past two hours trying to figure this out
01:18arrdemshekibobo: :/
01:19arrdemshekibobo: sorry about that... this is one of those abstraction weirdnesses of clojure. Vectors are indexed, because they are potentially lazy/infinite Sequence are not indexed in general. hence your issue.
01:19shekiboboyeah, I remembered reading something about them being different, but didn't remember seeing nth
01:19arrdemmeh I need to roll the next version of Grimoire at some point
01:52dawkirstfor a newcomer (coming from Ruby), do I read Programming Clojure or Clojure Programming (or both)?
01:52seangoneYou'll get different answers from different people.
01:53seangonePersonally, I prefer the O'Reilly book but they're both good.
01:54seangoneI suspect most Clojurians have multiple books :)
02:04BalvedaEvening
02:04BalvedaAnyone on?
02:06seangoneyeah, some of us are Balveda :)
02:07Balvedacool, alright
02:07BalvedaI have something that's pretty dense to me
02:07BalvedaI've got this function I'm trying to make
02:07Balveda(defn iterate-over [map fnc & args]
02:07Balveda "Takes a map, a function, and arguments to apply to the function. Applies the function to the map, iterating over it."
02:07Balveda (loop [m map
02:07Balveda n nil]
02:07Balveda (if (not= (count m) 0)
02:07Balveda (recur (rest m) ((into n (apply fnc (first m) args)))))))
02:07BalvedaOf course it's a bit of a mess right now, but I was wondering if I could get any tips to make it work
02:09seangoneBalveda so fnc takes a pair (key and value) and optionally other args?
02:10BalvedaThe idea is that you'd have a map you're feeding iterate-over with, and you're giving it a function and optional arguments to apply
02:10Balvedafnc would take the first item of this map, and apply args
02:11BalvedaThen the next map you're giving it is the rest of the map
02:11BalvedaWithout the first
02:12Balvedahuh
02:12BalvedaI think I fixed it
02:12seangoneBalveda maps aren't ordered so it's not clear what you're trying to achieve here...
02:14seangoneYour fnc only operates on each key/value pair (plus optional args)... are you trying to get a map back?
02:15BalvedaOh, should've specified
02:16BalvedaUsually what I'm working with is vecs of maps
02:16seangoneso does iterate-over take a vec of maps, or a single map?
02:16dawkirstseangone, beamso thanks :)
02:16Balveda[{"dat1" 1 "dat2" 2 "dat3" 3} {"dat1" 4 "dat2" 5 "dat3" 6}] example
02:17seangoneand you want what back? a vector?
02:17BalvedaI want to apply a function to the individual maps, and store that
02:17Balvedahence the into
02:17seangonestore it? what do you mean?
02:17beamsostore the calculated value back into the map?
02:19seangonewhy not just use mapv? (defn iterate-over [vec-of-maps fnc & args] (mapv (fn [m] (apply fnc m args)) vec-of-maps)
02:19seangoneer... )
02:20seangonethat will give you a vector back
02:20BalvedaStore the value into a result map
02:20Balvedamapv.. I'll check it out
02:20TEttingerit's like map but eagerly returns a vector instead of a lazyseq
02:20Balvedaah
02:20seangonehmm, if you want to process multiple values and accumulate the results into a single value, you probably want reduce
02:21BalvedaDoesn't reduce apply a function to the res
02:21seangonethat's why i asked if you wanted a vector back (vector of results) or a map
02:21Balvedaduh, yeah
02:21BalvedaI'll see
02:21Balvedaso
02:22Balvedalet's see
02:23seangonegood luck... i'm outta here for the night...
02:32BalvedaThat seems to have done it
02:32clojurebotCool story bro.
02:32BalvedaThanks seangone
02:32Balveda(inc seangone)
02:32lazybot⇒ 1
02:32BalvedaStay out of it, clojurebot
02:49arrdem(inc sheangrov)
02:49lazybot⇒ 1
02:50arrdem$karma sheangrove
02:50lazybotsheangrove has karma 0.
02:50arrdem(deck seangrov) ;; clean up the mess..
02:50arrdem(dec seangrov) ;; clean up the mess..
02:50lazybot⇒ -1
02:50arrdemdefuq
03:03amalloyarrdem: go home, you are drunk
03:04arrdemamalloy: actually haven't been drinking tonight... guess I can't late-night-#clojure on 0% BAC
03:11kenrestivo(inc dec)
03:11lazybot⇒ 1
03:11kenrestivo(dec inc)
03:11lazybot⇒ 8
03:12SagiCZ1(inc inc)
03:12lazybot⇒ 9
03:12kenrestivo(inc inc dec dec inc dec inc dec dec)
03:12lazybot⇒ 1
03:13SagiCZ1is clojure.core automatically refered?
03:13kenrestivo,(doc ns)
03:13clojurebot"([name docstring? attr-map? references*]); Sets *ns* to the namespace named by name (unevaluated), creating it if needed. references can be zero or more of: (:refer-clojure ...) (:require ...) (:use ...) (:import ...) (:load ...) (:gen-class) with the syntax of refer-clojure/require/use/import/load/gen-class respectively, except the arguments are unevaluated and need not be quoted. (:gen-class .....
03:13arrdemSagiCZ1: yes
03:13SagiCZ1,(ns 'xyz)
03:13clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol>
03:14SagiCZ1,(ns xyz)
03:14clojurebotnil
03:14SagiCZ1,refer
03:14clojurebot#<core$refer clojure.core$refer@1a7ffb3>
03:14SagiCZ1but if i use "in-ns" the core is not added right?
03:14arrdemcorrect.
03:14SagiCZ1i see
03:14arrdemyou can also have (:refer-clojure :only []) to include none of core
03:15SagiCZ1what use is that?
03:16arrdem(ns foo (:refer-clojure :only [])) will also put you in a namespace that doesn't have core referred.
03:16arrdemthat's it
03:17kenrestivoif you wanted to shadow a bunch of core fn's, i guess
03:17arrdemthe :only also lets you do selective referral if that's your thing
03:17arrdemyeah
03:17SagiCZ1but why would i use "ns" over "in-ns"? if the only difference is that "in-ns" does not include the core?
03:17arrdemns is just a macro providing syntactic sugar for the common case of wanting to include core and other deps
03:18arrdemin-ns is a clojure special form that fucks with the *ns* var to actually change the "current" namespace
03:18arrdemns is built atop in-ns and some other stuff
03:27Capt_Morganclojurebot: Hello!
03:27clojurebotexcusez-moi
04:16otfrommorning
04:22SagiCZ1arrdem: Thank you.
04:24arrdemSagiCZ1: happy to help
04:27Bronsaarrdem: I can't understand how your with-kwargs macro should be used
04:43arrdemthe idea was (with-kwargs :foo :bar :baz :quxx (my-shitty-kwargs-fn))
05:18hellofunkwhat an elegant way to use regex to determine if a string contains only digits? I'm a bit new with re-find and others...
05:21clgv,(re-matches #"\d+" "028937397")
05:21clojurebot"028937397"
05:21clgv,(re-matches #"\d+" "02893AA7397")
05:21clojurebotnil
05:21hyPiRion^
05:21clgvhellofunk: ^^
05:21hellofunkthanks guys
05:21clgvhellofunk: + or * depends on whether the empty string is allowed as well
05:22hellofunkif I wanted to accept digits with a decimal, it would be #"\d+.\d+" ?
05:22hyPiRionyou'd have to quote the dot
05:22hyPiRionso #"\d+\.\d+"
05:23hellofunkah
05:23hyPiRionbut that assumes you always have the dot, and always have digits in front and after it
05:23hellofunkoh
05:23hellofunkhow to make decimal; optional?
05:25hyPiRion#"\d+(\.\d+)?" – but now you get back a different type of result
05:25hyPiRion,(re-matches #"\d+(\.\d+)?" "028937397")
05:25clojurebot["028937397" nil]
05:25hyPiRion,(re-matches #"\d+(\.\d+)?" "028937397.0")
05:25clojurebot["028937397.0" ".0"]
05:25hyPiRion,(re-matches #"\d+(\.\d+)?" "fo")
05:25clojurebotnil
05:26amalloy,(re-matches #"\d+(?:\.\d+)?" "028937397.0")
05:26clojurebot"028937397.0"
05:26amalloyto get the optional behavior with the original result type
05:26hellofunknice!
05:27hyPiRion(inc amalloy)
05:27lazybot⇒ 163
05:33thesaskwatchHi .. I have a question - if core.contrib is now deprecated then where can I find deep-merge-with function?
05:35Bronsathesaskwatch: https://github.com/flatland/useful/blob/48e517a1514ecfed769d17ea9f27041c6db6bdb3/src/flatland/useful/map.clj#L152 should be what you want
05:54lvhI'm trying to write a macro that compiles down to two defmethods
05:54llasramThat seems honorable
05:55llasramWhat's the struggle re: `
05:55lvhI don't think I want syntax-quote, because that means the parameter gets namespace-qualified
05:55lvhbut I'm not sure :)
05:55llasramWell, you want to syntax-quote the bulk of most macros
05:55llasramAny unquoted symbols will generally be passed in as arguments to the maccro
05:56llasramOr under rare circumstances: ##`[example ~'example]
05:56lazybot⇒ [clojure.core/example example]
05:56lvhllasram: Here's what I have: https://gist.github.com/lvh/af778be8644de39506f2
05:57lvhllasram: which does what I want, *except* that the "request" arguments in the defmethod calls I'm making are getting namespace-qualified.
05:57lvh(macroexpand '(defstep :a {} (a) (b))) ;; => (do (clojure.core/defmethod icecap.handlers.core/get-schema :a [icecap.handlers.core/request] {}) (clojure.core/defmethod icecap.handlers.core/execute :a [icecap.handlers.core/request] (a) (b)))
05:58llasramRight. So the hideous way you shouldn't do it is the trick above, where you unquote-quote the symbol w/in the syntax quote
05:58llasramThe IMHO more idiomatic approach is you change your macro arguments slightly
05:58llasramAnd use a gensym
05:58llasramHere, just a sec
05:58lvhllasram: Thanks!
05:59lvhllasram: So, the thing that came to mind was the gross trick you mentioned
05:59lvhthen I remembered that I *probably* don't actually want that :)
06:00llasramlvh: https://gist.github.com/llasram/63b9e84805d3aa9458a9
06:00lvh~'request does indeed do what I asked for, although perhaps that is not what I *want* ;-)
06:00clojurebotAck. Ack.
06:00llasramSo you can use a gensym for the `get-schema` arg, since the user of the macro never sees it
06:00llasramThen let them provide their own symbol as a full fntail for the `execute` implementation
06:01lvhllasram: Huh. I don't understand how that works; is there a missing [request#] in the second ...
06:01lvhoooooooh.
06:01lvhyes yes yes, I see; you're making the parameter decl part of the macro call :)
06:01llasramExactly
06:03lvhllasram: thanks a lot :)
06:03llasramnp!
06:04lvhllasram: this will definitely work for now; at some point I would like to add the schema (that's a prismatic/schema) annotation to the parameter
06:04lvh(there's only one parameter that that thing can ever reasonably take, hence why I madei t part of the macro originally)
06:04lvhunfortunately I haven't quite figuredo ut how I'm going to extend schemas (https://github.com/Prismatic/schema/issues/140)
06:06llasramlvh: You just want to ensure the argument matches the schema?
06:06lvhllasram: Yes, but ideally ahead of time
06:07lvhllasram: The thing is that the schema describe steps, serialized to a database
06:07lvhllasram: the useful time to tell someone that the steps don't make sense is when I store them, not when someone tries to execute them
06:07llasramSure. So, just evaluate them then?
06:08llasramprismatic/schema supports just checking that some data matches a schema
06:08lvhright, but ideally I would like to describe the behavior of "call this method in order to get the subschema" as a schema
06:08llasramI don't think it works that way :-)
06:08lvhthe reason I want that is because these steps are themselves composed
06:09lvhhttps://github.com/lvh/icecap/blob/master/src/icecap/schema.clj#L24
06:10lvh(I appear to have worked myself into a pickle :))
06:11lvhllasram: So basically I would like to be able to validate a Plan, which consists of just schemas, vecs of plans, or sets of plans (so, eventually schemas, if you dig down deep enough)
06:12llasramCan't a custom checker predicate just recursively invoke the schema-checking machinery?
06:14llasramOh, or is it that you need to check that some data is a valid schema?
06:15lvhllasram: Yep, that's what I'm doing :-) a checker predicate could do that, but then you have two problems: 1) you don't know if they're s/check'ing or s/validate'ing 2) IIUC predicates don't allow useful errors to be passed around
06:15lvhand useful validation errors is why I'm doing all of this schema business in the first place
06:24lvhWhat's the appropriate way to unit test stuff that uses core.async/timeout?
06:25lvh(ideally without actually having the tests wait n msec)
06:36TimMc$karma sheangrov
06:36lazybotsheangrov has karma 1.
06:36TimMc(dec sheangrov) ;; undo behavior indistinguishable from drunkenness
06:36lazybot⇒ 0
06:37lvh(inc llasram)
06:37lazybot⇒ 36
06:37TimMc(inc seangrov) ;; this one too
06:37lazybot⇒ 0
06:37TimMcThere we go. (Just in case anyone has those nicks.)
06:50milos_co1agenquit
06:51milos_co1agenoops, pardon
07:12thesaskwatchBronsa: thanks :)
07:19laurioIs it possible to see which leiningen profile is in use when i run it? currently i get "'midje' is not a task. See 'lein help'." after running 'lein midje' although [lein-midje "3.1.3"] is added into plugins under :dev profile.
07:20laurio'lein pprint' also shows it to be defined under my :dev profile
07:21ivankwhy would someone use (reduce (fn [_ x] x) nil) someseq) to get the last element in someseq, rather than just using (last someseq)?
07:22llasramivank: Because the former idiom would work on something which isn't a seq
07:23llasramAnd even if it were seqable, might avoid allocating seq wrappers for each element
07:23llasram(The former reason is fair; the latter is probably premature optimization)
07:23hyPiRionNow the question is: Why isn't last implemented this way?
07:23ivankok. and I guess a set isn't a seq, since there's no order?
07:24hyPiRiona set is seqable
07:24ivankhmm
07:25clgvI hate that `last` is not optimized for vectors - instead you need to use `peek` there to get O(1) access ...
07:27hyPiRionclgv: huh, do you use `last` often?
07:28clgvhyPiRion: not lately, but access to the last element is in my code base several times
07:28clgvhyPiRion: you need a it when constructing a vector and the next element is chosen dependent on the last one
07:28clgvone example ;)
07:29hyPiRionThat sounds like `iterate`
07:29hyPiRionor `reductions`
07:29hyPiRionI'm not disagreeing btw, I just found out that I rarely use last.
07:33clgvwell, only `iterate` would be an option only if performance was unimportant
07:33clgvI am far from data analysis and such in that project ;)
07:40mskoudTrying to build a Korma query, and the query works, but the code is not looking sound. Can anyone give me a hint? http://pastebin.com/HCZtYMVq
07:47TimMcclgv: And it's weirder because nth is O(n) time for seqs but not for vectors.
07:50clgvTimMc: yeah. it's weird that this optimization concept does not hold for all core functions
07:51clgvTimMc: count is also O(1) for the types that support it
07:52TimMcAt least it has a counted? predicate to help there.
07:53TimMc(Not that count's docstring mentions it...)
08:02hyPiRionOh, maybe I should file a JIRA issue for that and get it rejected
08:02spradnyeshis it possible to have something like "defvar" of common-lisp (http://stackoverflow.com/a/8928038) in clojure? better still, does something like that already exist?
08:03hyPiRionspradnyesh: defonce
08:03spradnyeshas far as i understand, def works like "defparameter" of common-lisp
08:03spradnyeshhyPiRion: ohh, i'll check that. thanks
08:04hyPiRion,(do (defone a 1) (defonce a 2) a)
08:04clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: defone in this context, compiling:(NO_SOURCE_PATH:0:0)>
08:04hyPiRion,(do (defonce a 1) (defonce a 2) a)
08:04clojurebot1
08:06clgv,(do (alter-var-root #'a (constantly 42)) a)
08:06clojurebot42
08:07hyPiRionclgv: or just (def a 42) – point is that defonce won't define a variable if it's already defined
08:07clgv,(def a 23)
08:07clojurebot#'sandbox/a
08:07clgv,a
08:07clojurebot23
08:07clgvah right there is no protection mechanism^^
08:08clgv$source defonce
08:08lazybotdefonce is http://is.gd/WSqiPr
08:08SagiCZ1(doc defonce)
08:08clojurebot"([name expr]); defs name to have the root value of the expr iff the named var has no root value, else expr is unevaluated"
08:09clgvhyPiRion: ever tried to implement an (do-once expr) or (do-times 10 ...) for debugging purpose?
08:10clgvhyPiRion: afaik you need to define some variable in the surrounding namespace to get it to work
08:11hyPiRionclgv: not entirely sure on the do-once or do-times
08:11hyPiRionclgv: the point of defonce is to not override contents after reloading changed source files
08:11hyPiRionor, at least that's one important use case
08:12clgvhyPiRion: yeah I did not want to set it in relation with defonce, I just remembered that scenario from debugging ;)
08:12hyPiRionah
08:13hyPiRionno, I don't think so. I tend to use delays or memoization to evaluate expressions once though
08:14SagiCZ1does it maek any sense to call def inside a function?
08:15SagiCZ1(#(def x 3))
08:15SagiCZ1,(#(def x 3))
08:15clojurebot#'sandbox/x
08:15SagiCZ1x
08:15SagiCZ1,x
08:15clojurebot3
08:16SagiCZ1so its a function with side-effect?
08:19TimMcAnd gone. Friggin' short-timers.
08:19clgvno, usually it does not make sense to use `def` within a function
08:19TimMcclgv: They already left the channel.
08:19clgvhe'll probably come back after he shot himself in the foot ;)
08:20TimMcMight take a couple weeks or months for that to play out.
08:29clgv~log
08:29clojurebotsee logs
08:29clgv~logs
08:29clojurebotlogs is http://clojure-log.n01se.net/
08:29clgv$logs
08:30clgv$log
08:30justin_smithclojurebot: those are some old ass logs
08:30clojurebotExcuse me?
08:31clgvlazybot is secretive about his logs ;)
08:31mskoud(let [b 1 b (when true 2)] ...) whats the right way?
08:32justin_smithmskoud: what are you trying to do?
08:33mskoudpastebin.com/HCZtYMVq
08:33clgv,(cond-> 5 odd? (* 2) even? dec)
08:33clojurebot9
08:33clgvmskoud: the above is an option but not when you want to return a constant value
08:34clgvmskoud: yeah, acccording to your example you want cond-> or cond->>
08:34mskoudok, ill try to check out cond->
08:35clgvthough you do not necessarily seem to return the "same" entity - so it might not work
08:36clgv,(cond-> {:a 1} (even? 2) (assoc :b 2) (odd? 5) (assoc :c 3))
08:36clojurebot{:c 3, :b 2, :a 1}
08:36clgvmskoud: a different example ^^
08:36mskoudthanks
08:48TimMcclgv: http://lazybot.org/logs/#clojure/2014-08-25
09:14bajabongoHi,
09:15bajabongoI'm browsing an Om source (https://github.com/swannodette/om/) and I stumbled upon cursors,
09:15bajabongoapart from them, I see they implement a lot of protocols, like IFn, ICounted, etc.,
09:16bajabongoI was looking at the ClojureDocs for more info about them, but I couldn't find anything,
09:16bajabongois there any documentation related to them?
09:16gnandrettabajabongo: have you seen the wiki page? https://github.com/swannodette/om/wiki/Cursors
09:17justin_smithreminds me of lenses kind of
09:17bajabongognadretta: yeah, I've looked at it but haven't digested it yet,
09:18bajabongognadretta: but apart from that, I'd like to get more info about "standard" Clojure protocols, like those above (IFn, ICollection, etc.),
09:18bajabongobut I failed to find anything,
09:18justin_smithI think IFn at least is a proper interface, rather than protocol
09:19bajabongojustin_smith: probably, but I wanted to play with a couple of them, just to try them out,
09:20justin_smithbajabongo: most of the core elements of clojure (functions, the basic datatypes) are defined in terms of these interfaces, which means that you can easily use your own custom classes with clojure, as long as you implement the relevant interfaces
09:20justin_smiththe best thing is probably to read the java source where these interfaces are defined
09:20bajabongojustin_smith: or, rather, I *could*, if I knew these interfaces definitions,
09:21justin_smithmost of them are right here https://github.com/clojure/clojure/tree/master/src/jvm/clojure/lang
09:21bajabongowhich I can't find (I did not look up the source - but isn't there anything about them in terms of any docs?)
09:22bajabongojustin_smith: thx, I thought there are any docs about them; I was probably wrong :>
09:23justin_smithfor each of the major interfaces - the name will start with I and the definition will be in that directory
09:23justin_smithbajabongo: I am looking, but not really finding anything - but the source is right there, and they are predictably named at least
09:27bajabongojustin_smith: thx; I was looking for it too before asking so no surprise you can't find anything; apart from that, no docs quite funnily corresponds to your statement above (about easiness of using one's own classes with Clojure),
09:27olliveraIn the code below, I got {:key nil}, however "key" should not exist if the value is nil.
09:27olliveraI have a document where the field should not be created if it is nil
09:27ollivera{assoc test :key (if-let [a nil] a nil)}
09:27bajabongoi.e. it *could* be easy as long as I even knew what interfaces are available *at all* :)
09:27gnandrettabajabongo: IIRC “Clojure porgramming” by Chas Emerick mentions a couple of them (as implementation details) and presents collections from the abstractions they can participate in
09:28gnandrettabajabongo: but I don’t think that’s what you’re looking for :(
09:28bajabongognadretta: I did look into this book, I have a copy,
09:29justin_smithbajabongo: well, clojure does provide the means to see what interfaces and protocols an object implements via reflection in the repl. But agreed that some real docs of the core interfaces, what types implement them, and which ones you should implement for your type would be helpful
09:30bajabongojusting_smith: you're right; generally no pun intended, I was just nitpicking a bit :)
09:30justin_smithbajabongo: via the doc and source functions you can figure out which interfaces you need to implement in order to be a valid arg to a given function
09:30justin_smithie. implement IFn to be the first arg of map, ISeq to be any of the others
09:31justin_smithILookup for get / assoc / dissoc
09:31bajabongojustin_smith: I rather wanted to know the opposite - what interfaces do I have to implement, to be able to use which fun (feature),
09:32justin_smith,(assoc [:a :b] 2 :c)
09:32clojurebot[:a :b :c]
09:32justin_smithbajabongo: how is that the opposite of what I said?
09:33justin_smithbajabongo: to use map, you need to implement IFn or ISeq, to use assoc you need to implement ILookup, to use deref you need to implement IDeref...
09:34bajabongojustin_smith: maybe not entirely opposite, but I *thought* there might be some kind of table (somewhere), where there are listed all interfaces and their methods, that's all,
09:34justin_smithbajabongo: don't call the interface methods, call standard clojure functions
09:34justin_smithand those are all made in terms of the appropriate interfaces
09:34justin_smithso call map, and you can use IFn and ISeq objects
09:35bajabongoofc I know I can look up every function, and that would roughly have the same result, but it's just somewhat different than what I thought before
09:35justin_smithcall assoc, and you can use IDeref
09:35justin_smithetc.
09:35justin_smithyou don't have to look them all up (any different than you would in writing normal code)
09:36justin_smithyou don't have to think about the interfaces much until you define new datatypes
09:37justin_smithand the clojure ecosystem is very rich with datatypes already, you shouldn't have to make new ones very often
09:37bajabongoas a last resort, I can always write code in a way it was *supposed* to work and just read the compiler error (about not implementing some protocol), anyway
09:37justin_smithyes, those errors will typically tell you exactly the interface or protocol you must implement
09:37justin_smithfoo cannot be cast to IBar
09:38bajabongojustin_smith: you're right, but it all started as I was (and still) lookin at the Om source,
09:38bajabongoI just wanted to know what I'm reading
09:38justin_smithright
09:38justin_smithwell, for that you don't want the clojure sources anyway, you would want the cljs sources
09:38justin_smithmy bad on that one
09:39bajabongono problem, as ClojureScript surely implements most of them, at least the basic ones,
09:40justin_smithiirc there are no protocols in cljs (though it does implement the basic interfaces)
09:40bajabongoI didn't add at the beginning, but I'm rather a Clojure(Script) noob, i.e. I can write sth in it but I want to know more
09:40bajabongojustin_smith: no protocols?
09:41bajabongojustin_smith: or just a (totally) different implementation?
09:41justin_smithnot in cljs
09:41justin_smithonly interfaces
09:41justin_smiththat directory I linked previously - no protocols, it was only interfaces
09:42justin_smiththe big difference being you can define protocols using normal clojure code, but for interfaces you must use interop
09:43bajabongoas far as I know, Clojure protocols are, actually, compiled to vanilla interfaces,
09:43justin_smithit's one of these things in clojure that would be simpler, except we want full access to the jvm level impl of things without a wrapper - so we have the non-wrapped version (interface) and the wrapped, clojure-friendly version (protocol)
09:43justin_smithbajabongo: sure, but protocols are only a subset of interfaces (the part you can sanely wrap from clj)
09:44justin_smithand iirc have some clojure specific stuff that aren't in interfaces too
09:44bajabongojustin_smith: but they are still interfaces, to be exact :)
09:44justin_smithscratch that, they definitely have clojure specific stuff (like putting protocol functions into a given namespace - the jvm knows nothing about our interfaces)
09:45justin_smithbajabongo: sure - it's because we want full and transperent usage of interfaces that we need the interface/protocol distinction
09:45justin_smithso we don't get trapped by our own wrapper
09:46bajabongojustin_smith: but there's one more thing that bothers me: you said there are no protocols in CLJS,
09:46bajabongoas far as I see, the docs says different: https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure
09:46justin_smithbajabongo: d'oh - I had the protocol / interface thing for cljs backward -they have protocols but not interfaces
09:46justin_smithsorry
09:46bajabongojustin_smith: not a problem, I was just trying to clarify :)
09:48justin_smithso the basic interfaces in clj become protocols in cljs, and since they don't have interfaces in cljs (the underlying js platform has no such concept, unlike the jvm), there is no runtime object corresponding to the protocol
09:49bajabongojustin_smith: exactly as you say
09:51bajabongojustin_smith: apart from that, do you have an idea where I could find some more info about these "cursor" thing?
09:52bajabongoI mean, I know there is some info in the Om docs, but David doesn't mention how the actually work, and that's what interests me most
09:52llasrambajabongo: I think they're a base React thing
09:52bajabongoofc I did look up the source, but with no success
09:52justin_smithI think the wiki link shared above was pretty clear, and the parts that are unclear may reveal which other parts of clojure you need to know to get it
09:52bajabongollasram: they're not,
09:52llasramwell nm
09:54bajabongothere is no such thing like "cursor" in the React ecosystem, and because of a fact that the Om's author has said a couple of times that the're "something like functional lenses", I'd like to get some more info,
09:54bajabongobut only info I found is about Haskell implementation, which does not help me much
09:56oskarthGetting a NullPointerException when I enter my username after being prompted by `lein deploy clojars`. Using lein 2.4.3 with java 1.8. Any ideas?
10:02justin_smithoskarth: does 2.4.2 behave better? try "lein upgrade 2.4.2" and see if it behaves any differently? (it should be obvious how to get back to 2.4.3 after that :))
10:04oskarthjustin_smith: it worked with some lein-clojars plugin I found and keyfile, but it seems to be deprecated so will give 2.4.2 a shot
10:05oskarthjustin_smith: nope, same error
10:05oskarthcould it have something to do with drip? seems to be a bit non-deterministic (sometimes it gives me a nullpointerexception before prompting for username)
10:07justin_smithoskarth: does drip really speed things up so much? I thought the main source of latency with clojure startup was the loading of clojure.core, not the jvm startup
10:09oskarthjustin_smith: when I installed it way back repl startup seemed to go a lot faster, but haven't done any serious benchmarking
10:11clgvjustin_smith: drip probably keeps jvms with loaded clojure.core around ;)
10:13oskarthyeah, that's my understanding too
10:14justin_smithclgv: ahh, that's the extra sauce I didn't realize
10:15justin_smithbut then you are commited to a specific clojure.core version
10:17dnolen_bajabongo: cursors just wrap collections and provide the collection API, the only difference is they track path information if you access a part of the collection. the implementation is almost entirely boilerplate.
10:19clgvjustin_smith: yeah, tradeoffs ;)
10:19gfredericksreiddraper: I take it back -- my test.check mods aren't entirely obviated by calling functions with failing examples directly
10:20gfredericksreiddraper: I think the biggest missing feature is being able to resume long-running shrinks
10:20bajabongodnolen_: o, nice to have a feedback from the author :), OK, but it's somehow still not quite clear how it all works,
10:20dnolen_bajabongo: for a list of protocols there's really not anything more definitive than the source https://github.com/clojure/clojurescript/blob/master/src/cljs/cljs/core.cljs#L201
10:21dnolen_bajabongo: a cursor is just a data structure + path information, what else are you missing?
10:21bajabongodnolen_: thanks, I'll look it up
10:22bajabongodnolen_: well, yes, but how is then made this "two-way binding" thing?
10:22jcrossley3gfredericks: nice use of "obviate" :)
10:22dnolen_bajabongo: that's orthogonal - but it's also simple.
10:22justin_smiththis gets me thinking, it would be really nice to have a definitive documentation of the core interfaces / protocols somewhere (even if they are just describing the implementation as of a certain specific version) -- unless that exists and we just aren't finding it
10:23dnolen_bajabongo: if you update a persistent data structure you will break equality checks along the path changed
10:23dnolen_bajabongo: that's all that's needed to drive React.shouldComponentUpdate
10:23gfredericksjcrossley3: I admit I googled it first to verify
10:24jcrossley3haha
10:24gfredericksbut in my defense I didn't know of another way to continue the sentence
10:24bajabongodnolen_: as you correctly noticed, the React's "shoudComponentUpdate" is what did bring me here with questions,
10:24justin_smithgfredericks: the availability of google obviates the self confidence and memory that having a large vocabulary once required
10:25bajabongodnolen_: could I have a question about the overall process of rendering that you did in Om?
10:25dnolen_bajabongo: sure if it's not already answered by what I just said :)
10:26bajabongoI mean, I see you've added some Om-specific props like "__om_shared", etc, and - while I see the source - I (still) don't have a clear overall mental view of how it actually works,
10:27bajabongodnolen_: but ofc I realize you may now want to answer it as it just "read f... the source" type of question,
10:27bajabongobut yet it's still not-that-clear for me :)
10:27gfredericksjustin_smith: only in some situations
10:28dnolen_bajabongo: it sounds like you want to understand the implementation - what I just described above is how it works
10:28bajabongoI'm actually towards using ClojureScript with React, and was looking for some bindings, found yours, and was happy about using it until I did try to read the source - and as I'm rather a Clojure novice (I have an Erlang exp, though), I just don't get it, and I like to know what am I using
10:30bajabongodnolen_: well, yes, the concept of a cursor seem to be clear, but I'd like to know how it works "in the big picture" (w.r.t Om),
10:30bajabongodnolen_: or maybe I could just drop you an email about that?
10:30dnolen_bajabongo: it's just a convenience so that some component can update a piece of global application state w/o details of it's location.
10:31dnolen_bajabongo: no, just direct questions here or #clojurescript or ask on the ClojureScript Google Group
10:31dnolen_bajabongo: lots of people use Om and now quite a few people understand how it works internally
10:33bajabongodnolen_: OK; so, if I understand correctly, when I change some path in the global app state, only that component connected with this path will update its view?
10:34bajabongodnolen_: "change path" -> change some object at this path, I meant
10:41tadniSo if I understand correctly, concurrency is not inherent to Clojure as you have to explicitly add it?
10:43justin_smithtadni: you have to explicitly use some construct that is concurrent
10:43justin_smithtadni: if that's what you mean
10:43justin_smithfutures, agents, core.async are all popular ways to do clojure concurrency
10:44scape_feel free to correct me; concurrency is a central theme with the persistent data structs in clojure, meaning you can use them in a thread-safe manner but since immutability is central to clojure that means you get thread-safety in an automatic manner
10:44justin_smithwhat is inherent is the ubiquity of immutible data, which makes concurrency just work once you pull that in
10:44tadnijustin_smith: Yeah, okay. I was just wondering why people were arguing this point not to learn Clj as an introductory lang.,
10:44scape_justin_smith, beat me to it hah
10:45justin_smithtadni: I would say that immutibility also makes things more clear to a learner
10:46justin_smithtadni: for example, when debugging, having certainty about the places you need to look in the code to know what happens with a given piece of data
10:46tadnijustin_smith: Was it you, who was telling me if my choices were Emacs Lisp and Clj, to side with Clojure?
10:46justin_smithtadni: yeah
10:47TimMcI think pretty much anyone will tell you that.
10:47justin_smith(here at least)
10:47TimMcelisp has *mutable strings* for god's sake
10:47justin_smithtadni: emacs is a great example of "where the heck did that binding of that value come from" type hell
10:48justin_smithlike - you can look up the key bindings / vars a given package offers, but you can't take a given var or binding and know which package last defined or altered it
10:48justin_smithor even in which scope these bindings hold
10:48tadniNow that Guilemacs seems like a viable option going onward, I see it more reasonable for me to go work with Clojure as a starter lang and move to Guile later and even later still, Emacs Lisp if I need to.
10:49justin_smithalso, trying to do things the clojure way in emacs will lead to better code, trying to do things the elisp way in clojure will bring pain and confusion
10:50bendlas`justin_smith: But C-h k takes you to the current definition of a binding, which is kind of the same thing, isn't it?
10:51TimMcIf you're still learning Clojure, I recommend sticking with your favorite editor.
10:52TimMcespecially if it has paredit :-)
10:52justin_smithbendlas`: I think I overstated the degree of uncertainty in emacs / elisp
10:55tadniNow to remember the location and name of that fairly general/introductory level CLJ intro ...
10:55justin_smith~intro
10:55clojurebotCool story bro.
10:56justin_smithtadni: I like this one http://aphyr.com/posts/301-clojure-from-the-ground-up-welcome
10:56tadnijustin_smith: Ah, I think that was it actually!
10:56tadnijustin_smith: Yeah it was, ty.
10:57justin_smiththis is not as good, but also popular http://www.braveclojure.com/
11:15sarcherI'm coming from an object oriented background to clojure and have a question about how to represent 'objects' or datastructures in clojure. A map would work fine with properties, etc., but what is the best way to create that structure given that clojure's data types are immutable?
11:15teslanickWhat's wrong with a map or vec?
11:16sarcherI'm parsing an xml document with data.xml and I get a nice map of the XML structure, but I'd like to transform that map to a more simple form, then pass that form to a function to do something with it.
11:16sarcherteslanick: nothing is wrong with maps and vectors.
11:16sarcherI'm asking a really basic question. What's the best way to go from map of xml, to map of the structure that I choose.
11:16justin_smithinstead of mutating the map, return a variation or derivative of it
11:17sarcherI'm probably overcomplicated this in my head.
11:17teslanickYou can use reduce, a walker, or a zipper to transform a data structure into another data structure.
11:17justin_smithwe have extensive facilities to make those derivations - update-in, assoc-in, clojure.walk/*
11:17TimMcsarcher: I predict a lot of clojure.core/for and clojure.core/into in your future.
11:17sarcherteslanick: thanks that's probably what i'm looking for.
11:19sarcherin java I would have a Map<String, Element> and would iterate over the elements, creating a Map<String, Contact> objects.
11:19justin_smithsarcher: you probably know this already, but any mutation can trivially be expressed in an immutible form where instead of transforming the input, you create some variation on it
11:19teslanickWhat's the value in expressing an object as a Contact rather than a map of keys->values?
11:19justin_smith(into {} (for [[string element] iput] [string (f element)]))
11:20justin_smithf being a function from element to contact, of course
11:20sarcherteslanick: the xml structure could change, so to support different versions of the xml, i'd like to transform it into a form that will be consistent for my real application functions.
11:21sarcheragain there may be a better approach, or this may not really be necessary.
11:21sarcherjust trying to think through it as i've done simlar things in java.
11:21teslanickYou could do the same thing with a clojure map. The XML changes, change your transformer to maintain consistency.
11:21sarcherteslanick: that's my plan to use a clojure map to represent a contact, i just need to transform the xml map to my clojure map.
11:22sarcherwas just asking for pointers on the best practice to do something like that.
11:22teslanickjustin_smith has the right approach, I think
11:22sarcherthanks justin_smith, i'll give that a try.
11:24teslanickI assume you've found clojure.xml/parse and xml-seq/xml-zip ?
11:24seangrovednolen_: Any chance of a retweet on the sfcljs tweet? I want to make sure we cover as much as possible while the designer is still fresh
11:25seangroveWe'll have him back in ~3 months or so to give an updated talk to see how things have progressed, but it'd be good to get as many questions as possible right now so people are aware of what a designer new to cljs/om thinks
11:27sarcherteslanick: i'm using clojure.data.xml and that piece is pretty awesome.
11:31bacon1989was wondering, if I have a folder ./foo, how can I create a lein project in it called 'foo'
11:32bacon1989it just seems to try and create the folder
11:33schmeewhat's the best way to go from ((0 1 2) (3 4 5) (6 7 8) (9 10 11)) to ((0 1 2 6 7 8) (3 4 5 9 10 11))?
11:33schmeeso the odd-indexed lists get merged into one list and the even-indexed into another
11:36llasramschmee: where {even,odd}-indexed means by first element?
11:37lvhis there any guarantee which order source files will get executed in
11:37lvh(I know I am not supposed to care; I am just out of ideas, so I added some global mutable state)
11:37lvhactually, maybe I should just get rid of it and do it the Hard(TM) but probably okay way :)
11:38justin_smithlvh: one form at a time, top to bottom
11:38lvhjustin_smith: Sorry, I mean order between different source files, not within a source file
11:39justin_smithtop to bottom in the require block, depth first, right?
11:39lvhjustin_smith: source file a.b.c modifies some global state in a.b.x at compile time, ...
11:39lvhoh
11:39lvhin that case it's actually easier without the global mutable state
11:39schmeellasram: no, I mean that the first list goes into the "even"-list, the second into the "odd"-list, and so on
11:40schmeeso based on their index in the outer list
11:40lvhjustin_smith: But if I do some defmethods in a clj file far, far away, I don't have to require the implementations to be able to use them, right
11:41justin_smithlvh: hmm - not sure about that detail, sorry
11:41justin_smithbut my instinct would be to require the ns that has the defmethod, and namespace qualify the method invocation
11:41dnolen_seangrove: done
11:42schmeellasram: actually I just realized that `keep-indexed` might be what I'm looking for
11:42cminusschmee: (->> '((0 1 2) (3 4 5) (6 7 8) (9 10 11)) (group-by #(even? (first %))) vals (map flatten))
11:42lvhjustin_smith: only one way to find out ; thanks!
11:42seangrovednolen_: Thanks! Should be a nice first step. Also, I believe CircleCI should have a big Om-related announcement tonight as well
11:42dnolen_seangrove: interesting!
11:43schmeecminus: awesome, thanks!
11:43schmee(inc cminus)
11:43lazybot⇒ 1
11:43llasramNoooo
11:43llasram(dec cminus)
11:43lazybot⇒ 0
11:43llasram~flatten
11:43clojurebotflatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with.
11:44llasramhash-map gives you no order
11:44llasram*and* it's doing even-odd by the first element
11:44llasramMaybe: ##(->> '((0 1 2) (3 4 5) (6 7 8) (9 10 11)) (map vector (cycle [0 1])) (reduce (fn [v [i x]] (update-in v [i] into x)) [[] []]))
11:44lazybot⇒ [[0 1 2 6 7 8] [3 4 5 9 10 11]]
11:44llasram(inc cminus) ;; here, have it back
11:44lazybotYou want me to leave karma the same? Fine, I will.
11:44llasramcminus: But just say no to `flatten` :-p
11:45cminusllasram: haha, ok. No flatten
11:45tenchillasram: Haha...you just helped me with a 4clojure problem. Thanks!
11:46TimMcschmee: See the clojurebot factoid for flatten ^
11:47justin_smithlvh: https://www.refheap.com/89452
11:48schmeeI like this solution: (flatten (keep-indexed #(if (even? %1) %2) '((0 1 2) (3 4 5) (6 7 8) (9 10 11))))
11:48schmeeany way to get rid of `flatten`?
11:48justin_smithschmee: apply concat
11:48justin_smithschmee: or turn keep-indexed into mapcat
11:49llasramschmee: Huh. I thought you said you wanted even/add alternation, and not even/odd by first element
11:49llasramOh, I see
11:49llasramindexed nm
11:51justin_smith,(apply concat (keep-indexed #(if (even? %1) %2) '((0 1 2) (3 4 5) (6 7 8) (9 10 11))))
11:51clojurebot(0 1 2 6 7 ...)
11:52tadni`clojurebot's name drives me crazy for some reason. cljbot has that 3 and 3 to it.
11:53schmeejustin_smith: I don't see how `apply concat` is any better than `flatten` if the result is exactly the same
11:53justin_smithschmee it's different when the elements are lists
11:54justin_smith,(apply concat (keep-indexed #(if (even? %1) %2) '(([0 0 0] [1 1 1] 2) (3 4 5) (6 7 8) (9 10 11))))
11:54clojurebot([0 0 0] [1 1 1] 2 6 7 ...)
11:54justin_smith,(flatten (keep-indexed #(if (even? %1) %2) '(([0 0 0] [1 1 1] 2) (3 4 5) (6 7 8) (9 10 11))))
11:54clojurebot(0 0 0 1 1 ...)
11:54justin_smith*when the elements are sequential
11:55justin_smithtadni`: sadly clojureautomata is 7/8
11:55justin_smithnot nearly as nice as 3/3
11:55justin_smithbut clojureandroid would work
11:55justin_smithor clojuremachine
11:56schmeejustin_smith: ahh, I see
11:56lvhif you have source files that are just about an interface (e.g. a protocol for a data store backend), would it typically be called "core"?
11:57justin_smithschmee: your code suddenly gets a big blindspot when you use flatten - sometimes that blind spot is worth it or even expected, but if you want to be general, apply concat or mapcat are much more reasonable in behavior
11:57clgvtadni`: OCD? ;)
11:59tadni`clgv: Not since "I was a kid", but yeah, little thinks like that sill irk me a bit. :^)
12:00schmeejustin_smith: yeah, good to know! also, when you say "turn keep-indexed into mapcat", you mean write my own version of `keep-indexed` with the correct behavior?
12:01schmeeor is there some magic that can be used
12:02justin_smithI mean something like ##(mapcat #(if (even? %1) %2) (range) '((0 1 2) (3 4 5) ( 7 8)))
12:02lazybot⇒ (0 1 2 7 8)
12:02justin_smithoops, missed a 6 there, sorry
12:02justin_smithbut I hope it is still clear
12:02justin_smiththough probably best to use apply concat
12:03lvhyeah, so I have to require the module to see the implementation :(
12:04schmeejustin_smith: aight, thanks for clearing that up!
12:04schmee(inc justin_smith)
12:04lazybot⇒ 66
12:07lvhgfredericks: eek
12:16clgvgfredericks: is there a verbose option to see that on the repl?
12:20gfredericksclgv: no, it's my fork
12:21gfredericksthe verbosity is crucial for my use case because the shrinking can take so long that I want to be able to stop & resume & etc
12:21right1so uhh, how many people in here going to the DC clojure meetup tomorrow?
12:25virmundiIs anyone in here willing to have a quick glance at ArangoDB driver I'm writin, specifically the travesedo.core file? I'm new to Clojure (figured a driver is a good learning tool). I need to know if I'm on the right path for configuration ideas.
12:30justin_smithvirmundi: got a link?
12:30virmundiYep. Let me push really quick
12:32virmundihere you
12:32virmundihttps://github.com/deusdat/travesedo/blob/master/src/travesedo/core.clj
12:33virmundiI'm trying to make a fluent way to build up a configuration. That I've got so far should add a database connection to a larger, general-configuration.
12:34clgvvirmundi: why not just use a clojure map that contains all configuration? it'll be much simpler and much easier to read
12:35virmundiI didn't want to expose all of the keys to the user. So I was thinking something like (tc/with-connection u (->> {} (tc/with-host "other") (tc/with-port 8332)))
12:35clgvvirmundi: encapsulating `assoc` is strange as well. and your calls to add-config pass the wrong number of arguments because of the vector
12:36clgvvirmundi: that way you'll have to write an essay to get a complete config
12:36justin_smithvirmundi: why not a factory that takes the config the user would be interested in, and returns the full config object? With immutibility, much of the justification for information hiding disappears.
12:37justin_smithvirmundi: or, even better, statically define a "default config" map, and let the user conj or assoc or merge as desired to get their working config
12:38virmundijustin_smith: I was going to have too assuming the default is for the localhost instance for the connection.
12:39virmundiis it common to provide all of the keys and structure to clients?
12:39virmundiFor example, in ArangoDB if I want to run a query, I need the connection information (which is what my core file is trying to do), plus the query information, like which collection or an AQL statement.
12:40justin_smithvirmundi: yeah, we don't do much information hiding - since our data structures are immutible, it suffices to document which parts are guaranteed and which parts may change in future verisons, and let a client make their own judgement on how painful they want upgrades to be
12:40justin_smithvirmundi: which is of course very different from the best practices in the java world
12:43virmundijustin_smith: would Clojure folk do this: tc/insert-document (config clojure-map) where config is a map like {conns: [{con info 1} {con info 2}]}
12:44justin_smithvirmundi: yeah, if you look at clojure.java.jdbc, the operations generally take a config map as their first arg
12:47virmundijustin_smith: should I put the possible keys in the ns doc section?
12:47justin_smithvirmundi: I'd put the keys that define your "api" in the doc of the ns or of the most relevant function
12:47justin_smith(or def)
12:48justin_smithvirmundi: and consider making a defrecord - where the official fields of the record are the public api, and other values can be associated ad-hoc but are known not to be "official", and only impl details
12:49clgvvirmundi: use them incrementally in the examples that document the usage of your library, as well
12:49clgvjustin_smith: I wouldnt recommend a defrecord until rcord features are really needed
12:51virmundiclvg: I hadn't gotten to defrecord yet :)
12:52clgvvirmundi: just go for a plain clojure map until you are really sure that you need more
12:53justin_smithclgv: I just saw an advantage in defrecord since it describes a set of canonical keys, while also being usable as a regular map with other keys
12:53virmundiclvg: though would they work for making a closable lazy-seq? I need that for part of the driver API. Querying gets a cursor from the server. I thought a lazy-seq would be useful. But I need a way to tell the server that the cursor is no longer needed. This is easy enough if the whole sequence is read, but I could figure out how to do it if the client just took 4
12:54justin_smithvirmundi: a common pattern is to define a block where any code inside the block can use the cursor, and once outside the scope of that block, the cursor will be closed
12:54clgvvirmundi: lazy-seqs and closeable resource dont work well together
12:54justin_smithso they can lazily ask for as much or little as they like inside that block
12:55clgvvirmundi: you could use explicit pagination and build something similar to chunked lazy-seqs where the resource is only used to realize a chunk
12:55justin_smithclgv: but I think that is exactly related to the feature he wants - you lazily access the elements the cursor can fetch, so as not to create more network traffic than needed
12:56virmundijustin_smith: how do I make that pattern? Is there a tutorial? I saw the with-close
12:57clgvjustin_smith: the problem is that you must realize as much of the lazy-seq as you need in something like a "with-open" and thus outside that scope you dont really have a lazy-seq anymore
12:57virmundiclgv: database's response will chunck as well. It returns a list of matching items, along with a cursor field to get the next batch. Default batch size is 5 documents.
12:57mikepencehi group, I am keen to finally learn clojure, and hope to get to use it my day job (LivingSocial) at some point
12:58mikepencewondering what the best path is to learning clojure, coming from a ruby and oop background
12:58justin_smithvirmundi: typically this is done with a macro having a & body argument that is inserted into something like `(try (open connection) ~@body (finally (close connection)))
12:58justin_smithclgv: absolutely - but the semantics of laziness and those of the cursor match up nicely inside that block which has the connection open
12:59clgvjustin_smith: if that's sufficient, then it certainly works...
13:00tadieciao
13:00tadie!list
13:00clgvmikepence: getting one of the recent books and reading through it and toying with the examples meanwhile
13:01virmundijustin_smith: my Clojure knowledge is lacking on this point. If I have a try/finally like you said, won't the whole stream have to be evaluated?
13:01clgvvirmundi: yes the lazy-seq must be evaluated in that try/finally block
13:01clgvvirmundi: that's what I was talking about ;)
13:01mikepence@clgv - thanks
13:02dnolen_mikepence: Clojure Programming from O'Reilly is a pretty good introduction to the language if you're coming from a mainstream OO background
13:02justin_smithvirmundi: any parts of the lazy-seq evaluated outside that block will throw an exception - which is exactly how clojure.java.jdbc operates
13:02justin_smithand I think it makes sense, personally
13:02mikepencethanks, that was the one that I was looking at
13:03virmundijustin_smith: I'll try looking at the code for clojure.java.jdbc more closely. Should be fun to learn.
13:03virmundiclgv and justin_smith: thanks for the comments. I'll work on refactoring the api now. Not too sure what to do with core. Maybe put the query operations in it.
13:06clgvvirmundi: there is no written law that you need a *.core namespace, so just delete it if you dont need it ;)
13:07justin_smithvirmundi: also, there is a blogpost from our own puredanger (who is often here, just not right now) with some stuff relevant to the differences between clojure and java best-practices http://tech.puredanger.com/2010/02/25/questioning-oo/
13:07justin_smith(inc clgv)
13:07lazybot⇒ 25
13:07clgvah puredanger is alexmiller? didnt know that yet
13:07justin_smithit seems like my-project.core is there because it is generic enough to be auto-generated, but it doesn't always need to exist
13:08sritchiednolen_: any chance I can get you to add om-bootstrap to the “reusable components” page?
13:08sritchiesection on the om page, rather
13:30technomancyjustin_smith: it's been on my list for ages to get lein new to stop using .core if someone gives a multi-segmented project name
13:30technomancylike my.project instead of my-project.core
13:30technomancy(also would avoid stupid dash/underscore problems)
13:30technomancythe whole .core thing is so dumb =(
13:32mdrogalistechnomancy: lein new core
13:32virmundiBut I learned it last week from lein ಠ_ಠ
13:32technomancy~guards
13:32clojurebotSEIZE HIM!
13:32justin_smithtechnomancy: that sounds awesome
13:33mdrogalislein new 0.1.0-SNAPSHOT
13:33mdrogalis-boom-
13:33justin_smithrofl
13:33justin_smithvirmundi: core is a placeholder that starts to act like a convention - but it isn't really needed at all
13:34joshuafcoleSee, that's the problem. Never name a placeholder something reasonable.
13:34joshuafcole:)
13:34technomancyit's totally a case of the tail wagging the dog
13:34justin_smithwe could always replace core with foo
13:34justin_smithpeople would be much less likely to leave foo
13:34virmundiand then foo would be the new core.
13:35mdrogalisThat's an awesome expression.
13:35technomancythe rules for regular namespaces are made more complicated just so the rules for AOT'd namespaces are simpler =(
13:35hiredmanfyi, if you give lein new a proper group-id like `lein new com.example/foo` you get src/com/example/foo.clj no core in site, it is great
13:36dnolen_sritchie: done
13:36justin_smithhow about rename-this - bonus, it would also demonstrate how to munge ns file-names given that its file would be rename_this.clj
13:36sritchiednolen_ nice, thanks man
13:37justin_smith(inc hiredman)
13:37lazybot⇒ 53
13:37justin_smiththat's awesome, I had no idea that worked
13:38hiredmansight
13:38mdrogalisjustin_smith: Thats actually a super good idea.
13:40technomancyjustin_smith: slightly annoying because you have two places to update; the filename and the ns name. I could see that being error-prone for people who are just getting started and have no idea how the tools work.
13:40virmundijustin_smith: entirely none lein related question. Why does (try (take 500000 (range)) (finally (println "finally"))) print finally and then the range?
13:40justin_smithlein rename-core core actual-name
13:41justin_smithvirmundi: because it returns the result after runnign the finally clause
13:41justin_smith*running
13:41virmundijustin_smith: well that was a stupid question. Read that questioning-oo post and tossed out my JVM knowledge.
13:42justin_smithif you had a print in the body, and then one in the finally, they would print in the right order
13:42justin_smithhah
13:46justin_smithvirmundi: another minutae of try/finally is that if you throw an exception in your body, the finally clause will be run before the caller sees the exception
13:48justin_smithran into that recently, editing someone's code where they were calling the same cleanup code in their catch and finally blocks (was able to prove it was redundant)
13:50virmundijustin_smith: makes sense
13:50justin_smithoh, the detail I left out there was that they were throwing in their catch block
14:09SagiCZ1hi
14:09SagiCZ1so is anyone here who has the whole today's channel history? could you look up my last question and pm me the answer to it?
14:11justin_smithyou could re-ask the question
14:11gfredericksSagiCZ1: the answer was "no"
14:11justin_smithI also think it got answered after you left though
14:11amalloySagiCZ1: http://logs.lazybot.org/irc.freenode.net/%23clojure/2014-08-25.txt
14:13justin_smithfor reference, SagiCZ1 asked if (#(def x 3)) made sense
14:15joshuafcoleWhether it makes sense depends on what you mean to do with the function, but the answer is almost certainly not. Also I think the example of the question may've been malformed since you didn't accept any parameters anyway.
14:15joshuafcoledef is a macro in clojure, which would execute on the forms prior to the function ever being called, rather than each time it was called
14:16amalloyjoshuafcole: def isn't a macro
14:16joshuafcoleReally? 0.o Oh man
14:16amalloyand it only half-executes when it's compiled: it creates the var immediately, but sets it every time you call SagiCZ1's function
14:16amalloyit's a special form
14:17joshuafcoleAh
14:17joshuafcolemy bad
14:17joshuafcoleI hadn't realized the distinction. Thanks for clarifying.
14:22stuartsierraI wish `def` were a macro that expanded to code calling `intern`
14:22stuartsierrabut… declarations and recursive calls
14:26SagiCZ1thank you guys!
14:27SagiCZ1sorry i had to leave channel without saying goodbay
14:27SagiCZ1someone stole a major part of our city's network
14:27SagiCZ1i wonder what could a criminal do with 600 m of optical cable
14:27Bronsastuartsierra: well, it could intern at compile time..
14:27SagiCZ1you cant scrap that
14:30llasramSagiCZ1: You mean.... physically stole the fiber?
14:32SagiCZ1llasram: yes
14:32llasramO_o
14:32technomancyllasram: happens all the time in some countries with copper
14:32SagiCZ1thats the thing.. they thought it was copper
14:32technomancybahaha
14:32llasramAh
14:32llasramThat makes more sense
14:32SagiCZ1so they left it in a parking lot
14:33SagiCZ1but cut it in different places
14:33SagiCZ1anyway.. two towns of about 200 000 people with no internet connection :]
14:33technomancySagiCZ1: wow. what city?=
14:33SagiCZ1https://en.wikipedia.org/wiki/Plze%C5%88
14:34technomancymy brother had that happen a few times when he lived in Manila
14:34caternthat should be punishable with death
14:34llasramcool story, bro
14:34SagiCZ1credit cards terminals also ceased to work.. couldnt even shop to kill time
14:35SagiCZ1i think we depend on the internet way too much nowadays
14:36caternnah we just need more cables
14:36SagiCZ1yeah
14:40csd_Hello-- why is this code generating a null pointer exception? http://pastebin.com/vLsG36Z7
14:41amalloycsd_: a stacktrace is invaluable in debugging exceptions
14:41amalloythat said, it happens that i can see what's going wrong: (rest args) never returns nil, so your loop continues going even past the end of the list; and (first ()) is nil, so you end up calling nil as a function
14:43csd_Thank you--
14:45SagiCZ1out of paredit.. do you use more than slurp, barf, raise, kill ?
14:47amalloySagiCZ1: i use wrap-round and backwards-up fairly often
14:48TimMcSagiCZ1: convolute-sexp
14:50SagiCZ1TimMc: what convolute sexp does?
14:52amalloyoh, that too
14:52TimMcSagiCZ1: Check the docs. It's a little hard to explain, but it basically allows you to change the nesting order of sexps.
14:52TimMcA day when I use paredit-convolute-sexp is a good day.
14:52amalloySagiCZ1: you can use it to turn (fn [x] (let [y 1] (+ x y))) into (let [y 1] (fn [x] (+ x y)))
14:53amalloyTimMc: it's truly a good day if you use C-2 M-x paredit-convolute-sexp
14:53TimMc*nod*
14:53TimMcI think I got to use a 3-level convolute once.
14:53amalloyi never quite know what will happen when i do that
14:53amalloycan anyone think of a clever way to find the first duplicate item in a seq, if any exists?
14:54technomancysounds like an interview question
14:54TimMcThe index of the first item that has already been seen?
14:54bbloomwhat is the opposite of `lein install` ?
14:54stuartsierrabbloom: rm -rf ~/.m2/repository
14:54TimMchahaha
14:54bbloomstuartsierra: i hate computers.
14:54amalloythat sounds about right actually
14:54amalloy(re stuartsierra's suggestion)
14:55stuartsierraMore specifically, rm -rf the directory of the thing you installed.
14:55Bronsa, (reduce (fn [s x] (if (contains? s x) (reduced x) (conj s x))) #{} '(1 2 3 3 4))
14:55clojurebot3
14:55bbloomstuartsierra: yeah, i gotcha
14:56TimMcBronsa: And if you wanted the index, you could return the size of the set. :-)
14:56amalloy, (reduce (fn [s x] (if (contains? s x) (reduced x) (conj s x))) #{} '(1 2 3 4))
14:56clojurebot#{1 4 3 2}
14:56amalloynot very useful if it still returns truthy with no dupes :P
14:56Bronsaclojurebot: ?
14:56clojurebotPardon?
14:56justin_smithtales of stupidity: once I was at a cafe and using their internet connection, and a bunch of deps were acting weird - so I hose my .m2 and try to get my deps from scratch, and still everything is misbehaving terribly
14:56SagiCZ1TimMc: thanks
14:57TimMcjustin_smith: Captive portal?
14:57justin_smithturns out each artifact I downloaded was the html of a "agree to our terms and services" page
14:57Bronsaamalloy: derp
14:57TimMcYeah...
14:57amalloyTimMc: why do you keep talking about the index? the original problem isn't interesting?
14:57justin_smithso I open a browser, agree to terms, and finally my deps work
14:57TimMcOffline (or near-offline) dev still sucks.
14:57TimMcamalloy: Well, you didn't clarify which one you wanted.
14:57TimMc(I asked.)
14:58justin_smithif only I had a picture of my face when I try to open the clojure.core jar file and see the contents of "click this box to agree to use our internet"
14:58amalloyTimMc: your asking looked like a (pretty bad) proposed solution: "easy, man, just look at the index of the first item that's already been seen"
14:58TimMcAh, whoops.
14:58TimMcjustin_smith: It turns out that blowing away m2 is usually a bad idea.
14:59justin_smithheh
14:59TimMcThe number of times I've ended up coding on the train and needed some dep that I needlessly blew away a week ago...
14:59justin_smithassuming that Internet != Web turns out to also be stupid, when not at home
15:00Bronsaamalloy: (try (reduce (fn [s x] (if (contains? s x) (throw (ex-info "" {:dup x})) (conj s x))) #{} '(1 2 3 3 4)) nil (catch clojure.lang.ExceptionInfo e (:dup (ex-data e))))
15:00Bronsa:P
15:00amalloyoh my gosh Bronsa what is wrong with you
15:01TimMcBronsa: No longer clever, might as well use loop/recur. :-)
15:01amalloyi was about to eat lunch and i have now lost my appetite
15:01SagiCZ1seems pretty sleek to me
15:01BronsaTimMc: yeah yeah, I was just being silly
15:01Bronsaamalloy: I mean, it works
15:04stuartsierrajustin_smith, TimMc: I run a local Nexus server as a secondary cache for just this situation.
15:04TimMcHey Midje users, do I need to have :aot listing every namespace with a :gen-class? Midje complains that it can't find namespaces that have :gen-class but are not listed for :aot in project.clj.
15:05TimMc(The :uberjar profile specifies it but the main project does not.)
15:07stuartsierraTimMc: Sounds you're trying to reload an AOT-compiled namespace with stale .class files on disk.
15:08TimMcNah, `lein do clean, midje` provokes this.
15:08TimMcLatest midje.
15:08stuartsierraThen I have no idea.
15:21SagiCZ1,(partition 2 (range 4))
15:21clojurebot((0 1) (2 3))
15:22SagiCZ1is there some predefined combination of apply map?
15:22SagiCZ1map apply?
15:22ro_sti know that (apply concat (map f coll)) is mapcat
15:23SagiCZ1i would like the partition to return multiple collections here (map <foo> (parition 2 (range 4))
15:24ro_stsritchie: howdy, robstuttaford here
15:24SegFaultAXSagiCZ1: What do you mean?
15:24borkdudeSagiCZ1 it does: (map count (partition 2 (range 4))) -> (2 2)
15:24sritchiero_st: hey!
15:24sritchiejust saw your tweet
15:25gfredericksSagiCZ1: if you're asking about multiple return values, that's not a concept clojure has
15:25SagiCZ1gfredericks: no, not that
15:25SagiCZ1hard to explain
15:26SagiCZ1i know i can use apply if i can turn collection into multiple arguments
15:26SagiCZ1but i dont know how to combine it with map
15:26TimMcSagiCZ1: YOu should start by describing an example input/output.
15:26AWizzArdbtw, apply is a “magic function” which you can’t implement yourself (without using apply).
15:26justin_smithSagiCZ1: (apply map f coll)
15:26SegFaultAXSagiCZ1: What do you mean you don't know how to combine it with map?
15:27SagiCZ1justin_smith: is that correct?
15:27SegFaultAX,(= (map + [1 2] [3 4]) (apply map + [[1 2] [3 4]]))
15:27clojurebottrue
15:27justin_smith,(apply map + (partition 2 (range 10)))
15:27clojurebot(20 25)
15:28SagiCZ1but apply only takes one function and one collection right?
15:28sdegutisbbloom: what's the story behind the mongodb tweet? I was considering it as an alternative to datomic for a simple web-store app
15:28justin_smithSagiCZ1: nope
15:28bbloomsdegutis: a client of mine uses it. it's awful
15:28justin_smithSagiCZ1: it takes as many args as you like, the collection is "unwrapped" in place and becomes the rest of the args
15:29justin_smithby collection I mean the last arg, of course
15:29sdegutisbbloom: what in particular? the only annoyance I had with it is that you have to turn atomicity on manually
15:29bbloomsdegutis: just use postgres/sqlite/data-files
15:29SagiCZ1justin_smith: i see
15:29TimMcSagiCZ1: ##(apply + 1 2 3 [4 5])
15:29lazybot⇒ 15
15:29bbloomsdegutis: it's not a database, it's an ORM for mmap
15:29SagiCZ1thats actualy more handy than i thought
15:29TimMcSagiCZ1: Which is the same as (+ 1 2 3 4 5)
15:29SagiCZ1thank you all
15:30sdegutisbbloom: Ah, I wondered why that sounded familiar:
15:30sdegutisbbloom: https://twitter.com/trptcolin/status/401586940786798592
15:30justin_smithclojurebot: mongodb |is| an ORM for mmap
15:30clojurebotc'est bon!
15:30justin_smith(inc bbloom)
15:30lazybot⇒ 40
15:30bbloomsdegutis: haha that must have been me :-P
15:30sdegutis:)
15:31justin_smith~mongodb
15:31clojurebotmongodb is an ORM for mmap
15:46SagiCZ1how do i kill whole expression before my cursor with paredit?
15:46SagiCZ1before: "(foo (foo2 (bar)))", after: ""
15:46SagiCZ1kill
15:46SagiCZ1sorry that was dumb.. its kill
15:47SegFaultAXSagiCZ1: Consider not being so violent, first of all. What did that sexp ever do to you?
15:48SagiCZ1he was completely out of line
15:48SagiCZ1barfed several times
16:32technomancybbloom: protip: don't actually use sqlite from the jvm
16:32technomancythe jdbc drivers are junk
16:32bbloomtechnomancy: noted.
16:32technomancyI mean I endorse the sentiment, but not the particulars
16:33bbloomthanks
16:54martinklepschis there a subset? for maps where (clojure.set/subset? {:a 1} {:b 2 :a 1}) would be true?
16:57gfredericksnot that I know of; I think I've written that before
16:58annapawlickaAnyone willing to help with a postwalk question? I need to remove all empty elements from a nested map. Code here: https://www.refheap.com/89463
16:59lodinIs there any way to use tools.analyzer(.jvm) to find undefined vars? I've managed to make a half-baked workaround by catching exceptions, adding forward declarations, and rerunning the analysis, but it won't work for vars in different namespaces. Any ideas?
17:00hiredmanlodin: that is sort like proving a negative
17:00hiredmanall vars that aren't defined are undefined
17:00arrdem_lodin: how are you structuring your analyzer?
17:01lodinarrdem, currently I'm just feeding it a form like '(def x y) which will croak when it sees y, so I first analyze '(def y) and then analyze '(def x y) which makes it happy.
17:02lodinarrdem, I don't do any other setup than that.
17:02arrdemlodin: ... okay, and the goal here is what?
17:03lodinarrdem, realize that x depends on y, if I have e.g. (def x y).
17:04arrdemkinda like this? https://github.com/oxlang/oxcart/blob/master/src/main/clojure/oxcart/passes/tree_shake.clj#L71
17:07lodinarrdem, Thank you! :-)
17:08arrdem:P
17:10sritchiednolen_: what version of clojurescript had that hashing bug for safari?
17:11dnolen_sritchie: http://dev.clojure.org/jira/browse/CLJS-839
17:13sritchiednolen_: I’m getting an intermittent error with the code used for advanced compilation in http://om-bootstrap.herokuapp.com on safari;
17:13dnolen_sritchie: yes look at the ticket
17:13sritchieclasses aren’t being applied in safari, and I’ve tracked it down to a Map[String, String] that won’t do lookups
17:13sritchieyup
17:13sritchiebut with strings for me, not keywords
17:13dnolen_sritchie: I don't think it matter what the type is
17:13sritchieokay
17:14dnolen_sritchie: and I'm petty sure it only affects older hardware and only appears when optimizations kick in
17:14dnolen_higher JS optimizations tiers in JavaScriptCore
17:14sritchiewell, I’m seeing it on safari 7.0.4
17:14dnolen_sritchie: the hardware matters
17:14dnolen_could not reproduce on my iPhone 5S
17:14dnolen_not once
17:15sritchieah, yeah, this is a late 2012 macbook pro, I guess that’s “old” by now
17:15sritchiednolen_: yeah, it does seem to be related to JIT; I’m printing out lookups on this one map, and I get a string of the proper result, and then nils on the second time around
17:15dnolen_sritchie: someone with hardware to tests needs to submit the patch
17:16dnolen_sritchie: I don't have a suitable machine
17:16sritchieso (get {“nav”, “nav”} “nav”) => nil
17:16dnolen_sritchie: we don't need to go over the problem, I understand it :)
17:16dnolen_sritchie: my immediate thought is that this is parsing problem with advanced compiled code of some kind
17:17dnolen_so an acceptable patch in my mind would be something that appends a plain JS imul to all CLJS output that we can use
17:17dnolen_in advanced compilation case
17:18dnolen_sritchie: a simpler option is to just ^:export cljs.core.imul and allow people to fix this themselves
17:18dnolen_it's a pretty insane JS bug
17:19sritchie:)
17:19sritchieseeing the comments in the ticket on the shim; I was on the version before that was added for safari
17:19sritchielet’s see if an upgrade touches this
17:20sritchie“All released versions of Safari 7 have a broken implementation of Math.imul”. love it.
17:27martinklepschannapawlicka: https://gist.github.com/mklappstuhl/2dcf28d2eaef25a4034c
17:28martinklepschthat was fun interesting
17:29annapawlickamartinklepsch: :-D thx! it still returns :roofs [{}]} (it shoudl not be there if it's empty) but it's way closer!
17:33amalloyannapawlicka, martinklepsch: just replace the two lines for dealing with maps with: (map? m) (not-empty (into {} (remove (comp nil? second) m)))
17:36annapawlickaamalloy: it still leaves :roofs [nil], while i want the whole :roofs key and its value to be removed if the value is empty
17:39hiredman[nil] is not empty though
17:39hiredmanit is a vector containing the element nil
17:40annapawlickahiredman: it was empty though. the solution suggested by amalloy repalced {} with nil
17:47mdrogalishiredman: I had a professor that explains that #{#{}} isn't empty because "it's taking an empty bag and putting it in an empty bag. The surrounding bag isnt empty anymore"
17:48mdrogalisSorta always stuck.
18:04AeroNotixmdrogalis: sounds like he was pretty high when he said that
18:05lodinarrdem, I don't see how I can use the oxcart function for incomplete forms, i.e. when a var can't be resolved.
18:07mdrogalisAeroNotix: He didn't start his sentence with "Yo dude" :P
18:09justin_smithhave you ever walked the leaves of a red-black tree... on weed?
18:11AeroNotixthis is your algorithm on drugs
18:15TEttingerAeroNotix: https://www.youtube.com/watch?v=jWyye9OneUM&amp;feature=youtu.be&amp;t=48m53s
18:16AeroNotixTEttinger: saw them in London
18:16AeroNotixTEttinger: mindblowing
18:35tuft_TEttinger: do you know who that is speaking in the vocal sample there? hear him sampled in a lot of psychedelic music. sometimes too far out, but sometimes some solid philosophy =)
18:35justin_smithtuft: terrence mckenna
18:35tuftcool thanks, justin_smith
18:36justin_smithhe had an interesting biography
18:36TEttingerit's interesting to me how programming often works better for me based on the task and what music I am listening to
18:37tufti pretty much totally depend on music to be productive
18:37tuftsometimes it takes a while to find the genre that fits my mood
18:37justin_smithsometimes it's a merzbow debugging day
18:39tufti like the terrence mckenna quote that goes something like "Thinking can be beautiful, thinking can be sublime. Pure, essence of creativity. But we must ask ourselves: Do we have our thoughts, or do our thoughts have us?"
18:39TEttingerlike when I was debugging complicated, extremely frustrating compatibility issues with Mono, it's angry angry metal for me. but for more of a simple thing like what I'm doing now that mixes art and code, shpongle is great. animals as leaders or other neoclassical metal (mixing classical music with guitar solos) is good when doing string stuff, since it has no lyrics
18:40TEttingerI also have my standby, the 12 hour chiptune mix
18:40tufthah that sounds awesome
18:40TEttingerhttps://www.youtube.com/watch?v=GH7eUlri4yM
18:41tuftyay childhood
18:41tuftcan i just eat cereal and play FF on the NES now? =)
18:42justin_smithsomeone needs to make a clojure lib called machine-elves
18:44AeroNotixtuft: This happens to me. I find that soma.fm's beatblender is generally good for me
18:44AeroNotixtuft: err, I was scrolled back. Replied to something a while abck
18:44AeroNotixback
18:44tuftAeroNotix: i got it =)
18:44tuftAeroNotix: i surf dublab.com's archives quite a bit too
18:44tuftthere're like 1200+ eclectic mixes in there
18:46AeroNotixtuft: will check it out
18:47AeroNotixTEttinger put me on a Shpongle run
19:01technomancyTEttinger: thanks for this link; sounds pretty good.
19:05TEttingertechnomancy, heh no prob. I'm sad I haven't been using clojure much lately, it would be nice to get processing some data again but none of my projects use much of that right now
19:07technomancysame
19:38danielcomptonFeeling like Leiningen surrounded by ants right now
19:39caternTEttinger: what are you using instead
19:41TEttingercatern, right now C#, I've also used Scala (and will likely revisit the project that uses it) but I'm not a fan of the type-obsessed academic fatalistic community
19:41technomancy"fatalistic" meaning "you can never know what's going to happen at runtime with a dynamic language; it will probably fail so why bother even trying"?
19:42TEttingeryes, they're basically that way
19:42TEttingeralso they're convinced scala will fail, and are reluctant to use it
19:42technomancyhuh
19:42technomancybecause it's not haskell?
19:42TEttingerthat's the impression I keep getting
19:42TEttingeryes
19:43TEttingerit would be hilarious to see how they try to "improve" haskell
19:44mdeboardrewrite it in python
19:44mdeboardpure, unadulerated python
19:44arrdemTEttinger: who's doing the improving?
19:44arrdemmdeboard: I'm actually pondering doing my oxlang prototype in python :P
19:45mdeboardgo for it
19:45TEttingerarrdem, I just anticipate if everyone in Scala switches over to haskell the doomsday cult ethos will kick in in a few years and they'll all start trying to jump ship
19:47arrdemmeh. scala has inheritance and traditional OO inheritance thoroughly hoses the only "sound" type systems which the research boys have invented to date. I think that there is merit in abandoning Scala as fundimentally type unsound... but just because it's unsound doesn't mean it isn't useful. It's arguably still better at some things than java .....
19:47arrdemI mean, we don't even have a type system let alone a sound one and we still get stuff done so
19:48technomancyarrdem: I think the impossibility of HM in Scala is more due to the JVM interop than any design decisions within Scala itself
19:49dbascharrdem: it depends on what you mean by “we.” I can’t imagine writing the 777 software in a dynamically typed language
19:49technomancyI mean... does it make any sense to design a type system on the JVM that doesn't support subtyping?
19:49technomancyor do you just have two type systems, one for interop and one for good code?
19:50arrdemtechnomancy: the later is an idea I've been playing with seriously
19:50technomancyarrdem: well there are two separate questions: 0) is it a good idea? and 1) would there be any chance of such a thing taking off?
19:51technomancynot that we can ever fully understand the factors making one language succeed where others fail, but a big part of clojure's success is the seamlessness of its interop
19:51technomancyespecially in the early days
19:53arrdemI think that the common case of proxy very much allows such a thing. Think, from little experience with hardcore JVM interop from Clojure.
19:53hiredmantechnomancy: hm isn't the be all to end all of type inference, haskell doesn't use it for example
19:54technomancyhiredman: yeah, that was more of arrdem's claim than mine
19:55arrdemdbasch: definitely true. maybe one day we'll get a truly general use language capable of spanning that entire range but I'm not holding my breath. I think that optional typing and checking systems are interesting because they let you potentially harden "dynamic" code until your entire system converges to a static design that is verifiable.
20:15amalloyi'm sad that my (is (successful? (clojure.test.check/quick-check 1000 ...))) produces the output "Ran 1 tests containing 1 assertions. 0 failures, 0 errors." would it be a crime to include something like (dotimes [_ 999] (is true))?
20:16amalloyfolks gotta know i really ran a thousand tests
20:23gfredericksamalloy: doesn't clojure.test.check.clojure-test/defspec do something like that?
20:24hiredmanit prints stuff out
20:25hiredmanwhich is actually kind of annoying, since you don't really want a test suite to output stuff unless there are errors
20:25gfredericksoh I guess amalloy is referring to the summary output
20:27gfredericksthis morning a wrote a "resume-shrink" function
20:59justin_smith (defn resume-shrink [resume job] "removes all unverifiable or irrelevant entries from a resume")
21:55beamsois there a particular pattern that i should be using if i'm attempting to use clojurescript + om for data input forms?
22:08TimMcamalloy_: In my johnny library, I make heavy use of nested loops to test various combinations of implementations. The result is something like "ran 18 tests containing 3267 assertions". It is *so damn satisfying*.
22:21sritchiebeamso: yeah, I have one -
22:21sritchiebeamso: I pass down a channel into each input component,
22:21sritchieand the passing component can map< that component to augment it will all path information you need to update your app state
22:21sritchiethen just have one core.async loop running to handle all those updates
22:24beamsoi tried nested components but i saw weird things
22:24beamsothe nested component wouldn't appear in the react dev tools in chrome
22:24beamsoor i locked out any modification of the form
22:44ben_vulpeshow do people running ring apps handle sessions across subdomains?
22:44ben_vulpesbehavior i'm facing: log in to www.my-thing.com, visit my-thing.com, no valid session
22:45beamsodo you have to adjust how you set the cookie on www.my-thing.com so that it's from my-thing.com?
22:45beamso*session cookie
22:49ben_vulpesdon't quite know what you're getting at beamso
22:51amalloyben_vulpes: the RFC is to use www.example.com, to avoid confusion about whether my-thing.com is a real thing or an example
22:52munderwoHi all. Having a bit of a problem with using Om and Secretary. I've got this https://www.refheap.com/89469
22:54ben_vulpesamalloy: implying that my app should simply not respond at my-thing.com, but 302 those requests to www.my-thing.com?
22:54ben_vulpes(or that that should be handled in dns?)
22:54munderwoIm trying to transition to a new page in om, so want to detach what is currently on the root and transition to another "om/root" . I think detach is the right way to got about it. But the let binding of root seems to not work? Any time I try to reference it (ie even logging it) I get the same Cannot read property "call" of undefined.
22:55amalloyhuh? no, i'm saying don't use my-thing.com as your "foo", but use example.com instead
22:57ben_vulpesah
22:58ben_vulpesbehavior that I'm facing: log into www.example.com, visit example.com, no valid session. amalloy - do you know anything about cross-subdomain ring cookie handling?
22:58amalloyi have no idea
22:58amalloyi'm just trying to make your question more clear
22:58ben_vulpesthanks. i've reworded it per RFC.
23:01beamsoin ring.middleware.session/wrap-session, have you tried setting/changing the :root option?
23:02jakecraigeWhat's the syntax for requiring an ns and including it's macros?
23:04munderwojakecraige: in the repl or in a file?
23:04jakecraigemunderwo: file
23:04jakecraigemunderwo: I've got [todos.rest :as r :include-macros true] right now, and i try to access the macro by it's name
23:04jakecraigeand i get a symbol error that it can't find it
23:05munderwohmm.. that seems about right. At least thats how you do it with om in clojurescript.
23:05munderwoyou can also :refer to a particular macro
23:05munderwoby doing [todos.rest :as r :include-macros true :refer [my-macro]]
23:06munderwoare you doing (:require [todos.rest :as r :include-macros true)
23:06munderwoie keyword require rather than function?
23:06ben_vulpesbeamso: root defaults to "/", right? could i set it to the domain instead?
23:06jakecraigemunderwo: yeah it's keyword require
23:07munderwohmm… not sure then. looks like you're doing everything right? Maybe the macro isnt declared correctly?
23:07jakecraigemunderwo: seems to work when I refer it, just not without it. thanks
23:08munderwooh glad I could help :) first clojure question I could answer :)
23:08beamsoben_vulpes: at a guess, yes. but you'll need to test it.
23:14ben_vulpesmy next curiosity is about how to specify multiple domains...
23:15ben_vulpessurely there's a better solution...
23:15beamsomultiple domains for?
23:16ben_vulpeswell i want sessions on example.com to be valid on www.example.com
23:17ben_vulpeswait i have misidentified the bug
23:17ben_vulpesproblem exists in programmer
23:19beamsoouch
23:30sarcherHi
23:31sarcherwhat does (->> do?
23:31sarcherthe google does not like searches for (->>
23:31sarcherhaha
23:31mdeboard,(doc thread-last)
23:31clojurebotexcusez-moi
23:31mdeboard,(doc ->>)
23:31clojurebot"([x & forms]); Threads the expr through the forms. Inserts x as the last item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the last item in second form, etc."
23:32sarcherah cool, didn't know you could do that in the repl. Thanks!
23:33Methodicalsarcher: If you haven't found it already http://clojure.org/cheatsheet
23:33sarcherMethodical: thanks, I have not seen that yet.
23:34sarcherI'm quite in over my head currently heh.
23:35sarcherI'm still trying to figure out how to transform one structure into a different structure.
23:38sarcherI'm parsing this XML with data.xml - https://gist.github.com/scarcher2/c582fe290f4295d98677 and trying to transform it from the XML structure into a more simple map [:id 1 :first-name "Joe" :last-name "Smith" :email-address "joe@example.com"]
23:39sarcherwould anyone be willing to help me learn how to do this? :-D
23:39sarcherhttps://gist.github.com/scarcher2/aa761ba50424cb91e46b
23:39sarcherso far I have the id in there, but now I need to iterate over the nested sequence and add content from them.
23:40justin_smithsarcher: why do you want [:key val :key2 val2] instead of {:key val :key2 val2} ?
23:40sarcherjustin_smith: I honestly don't know the difference at this point :)
23:41justin_smithsarcher: [] is associative by numeric index, {} is associative by key lookup
23:41sarcherjustin_smith: ok, so I definitely want {}
23:41justin_smithso the latter is usually the natural choice for key / value pairs
23:41justin_smithyeah
23:42justin_smithalso use :as is a bit weird - require :as is idiomatic
23:42justin_smithand that can be part of your ns declaration
23:43justin_smith(ns sample.core (:require [clojure.data.xml :as data.xml] ...))
23:44justin_smithother than that, it looks like you are on the right track
23:44sarcherjustin_smith: i made those two adjustments
23:44amalloyjustin_smith: use :as isn't just weird, it's pretty bad - it creates the ns that require does, but also refers everything like a refer :all
23:45sarcherthe problem i'm running into now is I don't know how to iterate over the sequence elements in contact and then set the value I get on my new map.
23:45justin_smithamalloy: OK - frankly I had no idea what it would do, just knew it was weird :)
23:45sarcheramalloy: so don't use :as?
23:45justin_smithsarcher: you are mapping over the :content tag - that should work
23:46justin_smithsarcher: don't use use
23:46justin_smith~use
23:46clojurebotOnly use :use with :only.
23:46amalloysarcher: require/:as is fine; use/:as is no good
23:46sarcheramalloy: thanks, I saw it the other way in some sample code.
23:47justin_smithsarcher: so what do you get from contact-seq, and what do you expect it to be doing?
23:47justin_smithis it not transforming each contact?
23:50sarcherjustin_smith: it is, but i'm trying to get the nested tag values out. It gives me a contact with attributes and a nested :content, but the nested :content is a sequence i believe, so I can't look it up like a map.
23:50sarcherwhich makes sense, since it comes from xml. it would be a list of elements.
23:51sarcherin java i would just have a nested for loop with access to add those values to my map.
23:51sarcherbut i'm not sure what the best or right way to do that in clojure is.
23:53justin_smithI get this from your code ([:id "1" :first-name nil :last-name nil :email-address nil] [:id "2" :first-name nil :last-name nil :email-address nil] [:id "3" :first-name nil :last-name nil :email-address nil])
23:53sarcherright, i get the id's fine because those are just a straight lookup from the contact
23:53justin_smithsarcher: it's a question of refining the functions that get the values out of the contact
23:53justin_smithyou are getting some thing, like the :id
23:54sarcherthe problem is the code is trying to access the last name, first name and email address like it's a map, but it's actualy a list of elements in the :content of the contact.
23:54justin_smithsarcher: so the first thing I did to figure this out was to add a new key to the value process-contact returns
23:55justin_smith:raw contact
23:55justin_smithso for each one I see the raw data we want to excavate
23:56sarcherjustin_smith: cool, I just did the same thing and I see the data and how it is structured.
23:57sarcherjustin_smith: by the way thanks for taking the time to look at this with me.
23:57justin_smiththen, in a repl, try using threading to narrow down how one accesses the nested structure
23:57justin_smith(-> (contact-seq (clojure.java.io/input-stream "/home/justin/big/Readings/data.xml")) first second :content)
23:58justin_smithnext - (->> (contact-seq (clojure.java.io/input-stream "/home/justin/big/Readings/data.xml")) first second :content (filter #(= :first (:tag %))))
23:59justin_smithI hope you can see the method here
23:59justin_smiththis probably isn't what you want the final code to look like at all, but helps get a much clearer view of how the whole thing is structured