#clojure logs

2015-10-08

00:50nXqd!help
00:50nXqd,(def a "something")
00:50clojurebot#'sandbox/a
00:51nXqda bit offtopic, how is this clojurebot created ? it's pretty neat
00:51justin_smithnXqd: it's a repl with a whitelist and sandbox, the source is easy to find on github
00:52justin_smithnXqd: made by hiredman
04:27sm0keis there something like doseq which returns list instead of side effect?
04:28wmealingdorun ?
04:28schmirsm0ke: doall
04:28sm0ke,(for [x (range 10)] (inc x))
04:28wmealingisnt what is returned.. what you want ?
04:28clojurebot(1 2 3 4 5 ...)
04:28sm0kei guess i can use `for`
04:29sm0kei always seem to forget about `for` in clojure
04:30sm0keits such an underrated expression in clojure tbh
04:33patrkris/part/part
04:33borkdudesm0ke for, or map
04:34borkdudesm0ke but for is more similar to doseq, with a fancy binding and :let, :when
04:34borkdudesm0ke possibly multiple bindings yielding a cartesian product
04:37sm0keyes multiple bindings is also unique about `for` compared to a map
04:38sm0kea single map in short can be an equivalent of chains of map filter
04:38muhuksuppose (unique? [1 2 3]) => true & (unique? [:x :x]) => false, what should (unique? nil) or (unique? []) do?
04:38borkdudeI never realized that doseq also supports multiple bindings until now
04:39sm0ke,(doseq [x [1 2] y 3] (prn (str x "," y)))
04:39clojurebot#error {\n :cause "Don't know how to create ISeq from: java.lang.Long"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Don't know how to create ISeq from: java.lang.Long"\n :at [clojure.lang.RT seqFrom "RT.java" 535]}]\n :trace\n [[clojure.lang.RT seqFrom "RT.java" 535]\n [clojure.lang.RT seq "RT.java" 516]\n [clojure.core$seq__4116 invokeStatic "core.clj" 137]\n [clojure.co...
04:39sm0ke,(doseq [x [1 2] y [3]] (prn (str x "," y)))
04:39borkdudesm0ke 3 should be [3] there
04:39clojurebot"1,3"\n"2,3"\n
04:39sm0kenice i didnt knew this either
04:40sm0kedoes it also supports :when ?
04:40sm0keheh
04:40borkdudehmm
04:40sm0keoh it does
04:40sm0ke"with bindings and filtering as provided by "for""
04:41borkdudeyes, it does!
04:41borkdudewow
04:41sm0ke,(doseq [x [1 2] y [1 3]] (prn (str x "," y)) :when (= x y))
04:41clojurebot"1,1"\n"1,3"\n"2,1"\n"2,3"\n
04:42sm0kehuh
05:18TEttinger,(doseq [x [1 2] y [1 3] :when (= x y)] (prn (str x "," y)))
05:18clojurebot"1,1"\n
05:18TEttingersm0ke: ^
05:19sm0keheh thanks TEttinger
05:19TEttingerno prob, those :when and :while etc. are handy
07:51bordeltabernacleHi! I'm new to Clojure (and IRC!) and just thought I'd introduce myself and "join in the conversation" y'know.
07:53dstocktonhey bordeltabernacle
07:53dstocktonwelcome
07:53bordeltabernacleHi dstockton, thanks.
07:53bordeltabernaclefeel kinda high school goofy!
07:55dstocktonthings seem quiet today
07:56snowellWelcome, bordeltabernacle!
07:57bordeltabernacleThanks, snowell!
08:07noncomwhat's the most idiomatic way to update all values in a {} by a function? (except for reduce, if possible)
08:07noncomor is reduce the most idiomatic one?
08:08dstocktoni'd say its fine noncom, or you can (into {} (for [kv] ...
08:08dstocktonthere is also https://clojure.github.io/algo.generic/clojure.algo.generic.functor-api.html#clojure.algo.generic.functor/fmap
08:08dstocktonuser=> (fmap inc {:a 1 :b 3 :c 5})
08:08dstockton{:a 2, :b 4, :c 6}
08:09noncomoh wow
08:09dstocktonthis uses the into (empty m) version
08:09noncomright
08:09noncominteresting!
08:09dstocktonhttps://github.com/clojure/algo.generic/blob/aa028f7467d193a5cfad0626b324f4c682b91c15/src/main/clojure/clojure/algo/generic/functor.clj#L29
08:10dstocktonthere was a whole load of discussion here yesterday about it
08:11noncomgotta read that from the archive
08:11noncomdstockton: is it going to be in the core sometimes?
08:12dstocktondon't know, actually i didn't catch all of the discussion yesterday either
08:13noncomwell, good that the bots are taking care of logs
08:16dstocktonmost of it was about type systems and haskell
08:21noncomdstockton: yes, i already found it! just yesterday me and a friend of mine were talking about the same thing, also mentioning haskell, but we did not see it here. what a synchronicity!
08:36taharqaHi there !
08:36taharqaI'm new to Clojure as well, what can I say to someone that told me "Clojure is not a Lisp" ?
08:39MasseRtaharqa: what was his reasoning?
08:42taharqaMasseR: « a lisp should be a langage built on top of functions that are primitives (atom, quote, eq, car, cdr, cons, cond, lambda, apply, etc ) and should rely entirely on this primitives »
08:44opqdonutwell clojure is built on top of the primitives
08:44opqdonutlisted on http://clojure.org/special_forms
08:45opqdonutand what does it matter what some guy thinks
08:45opqdonutclojure certainly isn't a very traditional lisp
08:45opqdonutmaybe you can settle on calling it lisp-like :)
08:45MasseRBesides, that's the first I've heard of that kind of condition for being a lisp
08:46taharqaopqdonut: the guy in my opinion mix the language and the platform
08:47taharqaopqdonut: the fact that Clojure share with java may seems to them that those are not primitives
08:47opqdonutMasseR: it's quite widely repeated, see e.g. http://steve-yegge.blogspot.fi/2006/04/lisp-is-not-acceptable-lisp.html
08:48taharqaMasseR: yes strange, he points me to http://axisofeval.blogspot.fr/2010/04/why-i-ignore-clojure.html
08:48opqdonutor http://stackoverflow.com/questions/3482389/how-many-primitives-does-it-take-to-build-a-lisp-machine-ten-seven-or-five
08:48taharqaopqdonut: excellent ^^
08:49opqdonuteven axisofeval ends with
08:49opqdonut> Now, go ahead and have fun using Clojure if it floats your boat, but stop whining about how it's a more modern or better Lisp. That doesn't make the slightest bit of sense.
08:51noncomtaharqa: clojure is a lisp because it is a list processing language and it is homoiconic. it is not the grahams lisp, however, and it is not scheme and it is not common lisp. it is clojure...
08:52noncomtaharqa: it has some jvm interop which may frighten pure lisp people, but this is the reality of jvm and actually a bliss
10:51gfredericksapparently the 4clojure test suite has been broken (uncompileable) for over two years
10:53gfredericksit's made it through six or so commits without anybody noticeing
11:07sobelis there a prettier way to say this: (merge-with (fn [_ s] s) default-config file-config)
11:07sobelspecifically the (fn [_ s] s)
11:10michaniskin(comp peek vector)
11:11lumasobel, isn't that just using the value from the second map, so the same as (merge default-config file-config)
11:12tdavisis there any way to expand to a symbol's full namespace a-la syntax quote when inside a quoted list? as in, '(reify SomeClass (foo [bar baz] ...)) i need 'SomeClass' to be 'com.ns.SomeClass' because it's being used in a macro expansion.
11:15sobelluma: thx
11:35justin_smithtdavis: syntax-quote does namespace expansion, not class-name, I think...
11:35justin_smith,`String
11:36clojurebotjava.lang.String
11:36justin_smithoh, never mind :)
11:40justin_smith,'String
11:40clojurebotString
11:51tdavishas anybody ever gotten "NullPointerException clojure.lang.Reflector.invokeNoArgInstanceMember" just trying to call macroexpand on something?
11:52justin_smithtdavis: no, but if a macro is buggy, it can npe while expanding
11:52tdavisis there any way to debug it?
11:53tdavisi wrote a macro, it works fine, but calling it in a loop from a function is NPE'ing despite the fact that i've confirmed none of the arguments are nil.
11:53tdavisand for whatever reason i can't even expand the call to see what could be wrong
11:54justin_smithmaybe try expanding the surrounding loop form?
11:54tdavisi pulled it out of the loop entirely, same result.
11:57tdavisprogress, maybe! ClassCastException clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol clojure.core/ns-resolve (core.clj:4216)
11:57justin_smithsobel: michaniskin: I benchmarked a few variants, #(do %2) was the fastest shorthand, (comp second list) was slowest, (comp peek vector) did OK https://www.refheap.com/110425
11:59justin_smithyeah, that sounds like a macro that is either broken, or being used improperly
12:00justin_smithsorry, beyond expanding things I don't have any good macro writing / macro debugging tips
12:00justin_smithI'm not so great at macros myself, maybe someone else can help
12:01tdavisjustin_smith: yeah... once i eliminated all the other macros involved (i forgot, e.g., `let') i'm getting more of a stack trace. might be something to do with (to-array) usage... Constructor.newInstance() usage is convoluted from clojure.
12:11tdavisinteresting! i am passing a macro a argument of type java.lang.Class but inside the macro the type is clojure.lang.PersistentList
12:15justin_smith,(type ''foo)
12:15clojurebotclojure.lang.PersistentList
12:15justin_smithcould it be an extraneous quoting / not enough evaluation issue?
12:16tdavisthe macro isn't receiving the value just the raw list which i guess makes sense since it's being expanded prior to the calling function being evaluated
12:20justin_smithwell, the idea with macros is you want them to get the raw form, and need to explicitly do any level of evaluation needed to get the compile time value they need
12:32clgvHello, is there an option to set the timeout for an aleph tcp client connection attempt?
12:41clgvok :bootstrap-transform and setting CONNECT_TIMEOUT_MILLIS is the solution
14:39boxedis there a way to make a macro expand into two forms? in my case I want to output both a defn and another macro from a macro
14:43justin_smithboxed: `(do ...)
14:44boxedah crap, that was obvious in hind sight, thanks :P
14:44boxedbut I guess this only works for outputting two things that are side effect-y right?
14:45boxed(for my case fine, but I’m thinking about the general case)
14:45snowellFor multiple return values you can just return a vector
14:45justin_smithboxed: otherise, output a collection containing both results
14:46justin_smithright
14:46boxedwell, that doesn’t work in reagent when I want to output say two [:td]s at some point
14:46justin_smithboxed: in that case I use into
14:47snowellYou'd return a [:div] with the two [:td]s in it :)
14:47justin_smith(into [:div] (thing-returning-tow-tds))
14:47boxedsnowell: you can’t have a a div randomly inside a tr
14:47snowellEr…what he said
14:47snowellNot with that attitude
14:47justin_smithhaha
14:47boxedhah, yea, “works” is a bad attitude
14:48boxedseriously though, I’ll take this as “nope"
14:48snowellI'd take what justin_smith said
14:48justin_smithboxed: I have had good luck using into (or occasionally just conj) to combine stuff in reagent
14:48justin_smiththough my literal suggestion above is not correct for that case
14:49snowell,(into [:div] [[:td :first] [:td :second]])
14:49clojurebot[:div [:td :first] [:td :second]]
14:49boxedjustin: problem with that is that the code ends up really ugly because the internal behavior of the component leaks out.. in that you have to (into) it
14:50boxedsnowell: that produces an invalid DOM
14:50justin_smithboxed: that's true, and I wish there were a better solution, maybe using om :P
14:51boxedjustin_smith: yep, at least I’m doing the right thing currently :P pity, I would want clojure macros to be just a tiiiny bit more powerful :P
14:51justin_smithboxed: essentially for your case you would need the ability to modify the containing form, and that is just --- eww
14:52skeuomorfHow do people do DTLS in Clojure land?
14:53skeuomorfPlease don't tell me bouncy castle :(
14:53boxedjustin_smith: nah, just the ability for a macro to output several forms. Like C macros can :P
14:55justin_smithboxed: that's a modification of the parent form
14:55justin_smithc macros don't even have a concept of "form", and can clearly modify parent forms at will
14:55justin_smithreified concept of form that is, of course
14:56boxedjustin_smith: I don’t see what you’re saying. Changing the contents of the parent form is all that macros do. A macro that can’t modify the parent form isn’t a macro, it’s just a literal
14:57justin_smithno, there is a difference between your form (args to a macro) and the parent form (the thing containing the macro), one aspect of the parent form, which you would be altering, is the argument count
14:58boxedjustin_smith: another aspect is the contents.. I really don’t see the big difference
14:58justin_smithit's all the difference
14:58boxedyea, in my case between nice code and eeeeww :P
14:59boxedbetween useful and not so much
14:59justin_smithboxed: it would mean a much messier compiler
15:00boxedjustin_smith: don’t buy that. Instead of “append x” you could do “append x, append y”
15:00boxed“much messier” seems like an exaggeration
15:02justin_smithboxed: I would not be surprised if it doubled the line count - because it makes a bunch of shitty things possible that are not possible in the current design.
15:02boxed“shitty”? didn’t you just above say it would be much nicer?
15:03boxedsimplicity of the compiler should not be confused by simplicity of the user code
15:05boxedI guess the big problem is that reagent templating is done in clojure native forms, which just can’t express things cleanly for these cases
15:06boxedoh yea, and another problem is that HTML is shite of course, but that almost goes withouth saying :P
15:29daniel__1if i write code for someone with no contact and hand it over, do i have any rights over said code?
15:30daniel__1contract*
15:31hiredmanhttp://copyright.gov/help/faq/faq-general.html#mywork
15:38daniel__1thanks hiredman
15:48Cr8in future though, don't do that -- copyright isn't magic, they can't redistribute or make derivative works of the code, but you also can't force them to delete it/not run it
15:49boxedis there some tool that makes developing macros somewhat non-horrible?
16:00TMAdaniel__1: even in the common law you do have a contract; however as it is not a written one it is hard to tell what are its terms
16:03daniel__1im actually not concerned with giving up rights to what i produce, im concerned with contracts i dont fully understand taking rights from things i havent yet but might produce
16:03daniel__1i think im talking about simple transfer of copyright
16:10sobelactually unless you give them permission to run your code, you can assert copy rights to make them stop using it
16:10sobelit's tricky to prove your copyright if you don't register it properly but that's how the law reads
16:10Frozenlo`sobel: Don't they get the copyright if they hired you to write the code?
16:11sobelit depends on how the employment is arranged
16:11daniel__1and how complicated does this contract have to be
16:11sobelif the person is hired to do some work, the work product (code) belongs to the employer
16:12sobele.g. code written as a coder on the clock or on salary
16:12sobelit's different if someone contracts a solution you might dig out of your toolbox of existing solutions, which may be your copyrighted material
16:12daniel__1i actually meant to start this discussion in another channel, heh
16:12daniel__1just realised it was clojure
16:13daniel__1and getting helpful responses anyway
16:13sobelrelevant here though
16:13daniel__1basically, i got given a contract which scares me a bit because its long and i dont understand it
16:14sobeluse a real atty if it matters
16:14sobeland beware of giant contracts
16:14daniel__1yeah, im not sure it does matter that much
16:14TMAfor example, there is a special work-for-hire provision in our copyright law that takes precedence over any terms agreed between the parties; however if you are a corporation instead of a naural person, these need not apply
16:15daniel__1anyone ever worked for two competing business simultaneously?
16:15daniel__1and how do you handle that
16:16sobelusually the employer has wanted my exclusive service
16:16TMAdaniel__1: tricky. you might need the first employer's permission to work for the second
16:17daniel__1yep, i've been open with both
16:17skoudeI make a get request to a web service that returns json document, and I use clj-http.client get function for that.. The problem is that how can I read it to vector in clojure? I I try to use parse-string function in chesire, I get error: PersistenMap cannot be cast to java.lang.String..
16:17daniel__1but its still tricky, i don't want to get into conflicts with any contractual obligations
16:17hiredmansoftware engineers are basically the worst people to ask about law and ip
16:17daniel__1heh hiredman, im sure thats true
16:18anewill and evaluate all its forms or stop at the first falsey?
16:18daniel__1but maybe it is a case of over-thinking
16:18TMAdaniel__1: there is a reason for the lawyers being paid handsomely :)
16:18anee.g. (and false (expensive-computation)) will it short-circuit
16:18justin_smithskoude: likely clj-http.client is giving you a hash map describing the entire result of the request (including headers), and the :body key will have the actual contents that you can parse or whatever
16:18snowellane: It will stop at the first falsey
16:18snowell,(doc and)
16:18daniel__1TMA: i know, law is incredibly boring
16:18clojurebot"([] [x] [x & next]); Evaluates exprs one at a time, from left to right. If a form returns logical false (nil or false), and returns that value and doesn't evaluate any of the other expressions, otherwise it returns the value of the last expr. (and) returns true."
16:18daniel__1i don't envy anyone who has to learn it all
16:19TMAane: it will stop
16:19skoudejustin_smith: thanks.. I will check that..
16:19justin_smith,(and false (prinln "expensive$$$$")
16:19clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
16:19justin_smith,(and false (prinln "expensive$$$$"))
16:19clojurebot#error {\n :cause "Unable to resolve symbol: prinln in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: prinln in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: prinln in t...
16:19irctcHiya. I'd like to be able to execute a function multiple times in parallel and return the results in a list. Like this: (pmap (fn [_] (myfunc)) (range 10)). Is there a standard function that can do this without the use of range and an underscore parameter?
16:19justin_smithergh
16:19anesnowell: ok thanks
16:20justin_smithirctc: dotimes
16:20justin_smithwell, you would need to create the futures in the dotimes body, so never mind, there isn't a fully pre-baked solution
16:21justin_smith~pmap
16:21clojurebotpmap is not what you want
16:21justin_smith(also)
16:21aneis there any way of making this a bit simpler (if (and (= @data []) (realized? my-future)) @data @data) i.e. i want it to return @data immediately otherwise wait for my-future to finish (which modifies data)
16:21ane(if data is [])
16:21irctcpmap seemed to have worked but not sure if there is something more straightforward.
16:21justin_smithane: (do @my-future @data)
16:21justin_smiththat returns @data, but only after my-future is done
16:23irctcDoes dotimes run in parallel?
16:23justin_smithno, that's why I decided it wasn't a replacement
16:25irctcSo I guess the easiest way is the way I already have it then. Can I simplify (fn [_] (myfunc)) ? I tried (constantly #(myfunc)) but it only calls myfunc once and repeats the result.
16:25hiredmanane: that is all a big race condition
16:26hiredmanalso (if x y y) is y
16:26aneyes, i just want to execute the future if (= @data []) is t
16:27aneotherwise use the currently committed value
16:27justin_smithmore like (do x y) - x has a side effect here
16:27hiredmanfutures are executed when they are created
16:27hlolliIm using lein droid for the first time, and I connect to my android device repl trough port 9999, but changing something in emacs and evaluating does not change my running app on my device. Is this expected behaviour, do you need to do lein droid doall to see every change?
16:27anehiredman: yeah, i've defined it earlier, but i want the function to block until it's finished if it's empty
16:28hiredmanane: futures have a great built in way to do that called deref
16:28justin_smithso, like I said above, (do @my-future @data)
16:29anewould that block even if @data has something in it?
16:30justin_smith(or (not-empty @data) (do @my-future @data))
16:30hiredmanane: so other things are writing to data?
16:30aneno, just the future
16:30justin_smithbut yeah, still messy
16:30hiredmanso why would it have something in it unless the future has a value to produce?
16:31justin_smithwait, are you sure you couldn't just deref the future and get its result and skip the atom?
16:31hiredmanyou almost certainly want one of the j.u.c queues and not an atom
16:33anewell i'm periodically fetching some data and storing it inside a ref. but i want the actual fetching only to happen every n calls to the function
16:35anesigh. i've designed this all ass-backwards
16:35hiredmanyou want to queue up calls
16:38anewhat would be the best method for doing that? agents?
16:39hiredmanhttp://docs.oracle.com/javase/7/docs/api/java/util/concurrent/SynchronousQueue.html or core.async channels
16:40anewhat about just using add-watch on the counter ref? when it's at every N steps run something in the background
16:41justin_smithane: when did you switch from atom to ref?
16:41justin_smithor are you using one of these terms "generically" - because they are two different htings
16:41hiredmancreate a queue, spin up a thread/future/process of some kind that consumes N messages from the queue and then executes the bulk request, and then each message in the queue has another queue or promise that the response can be multiplexed to
16:41hiredmanane: no
16:42hiredmancore.async may even have some machinery that would do this already
16:43anejustin_smith: oh i don't think i mentioned atoms, but maybe
16:44justin_smithane: sorry, poor reading comprehension on my part
16:44justin_smithyou didn't mention atoms
16:46anehiredman: sounds a bit more complicated, but infinitely smarter
16:47hiredmanno way
16:47hiredmanthe STM is way more complicated and you are way more likely to screw up using it
16:47anehiredman: i just can't figure out what the queue contents actually are at this point
16:47hiredmanI do not recommend using refs
16:48Jabberzdo folks use visualVM for clojure app memory profiling, or something else?
16:48hiredmanane: the queue contents are the arguments to the function you are batching up (and if you care about getting results back a promise for the results)
16:49hiredmanthen you have a thread that loops around consuming from the queue and once it has consumed N items, it takes those items and executes a batch, then takes the results from executing that batch and debatches them out to the promises (if you need the results)
16:50aneah, now i see. well i have no arguments to pass to the function, and i just need the result to be stored elsewhere, not to be returned, like a database or an in-memory ref
16:51hiredmanJabberz: I've used visualvm, there are nicer profiles for the jvm with all kinds of features but you'll have to shell out money for licenses
16:53hiredmanane: in that case you might actually consider an agent or an executor
16:54hiredmanif your value can be the value in an agent, you can store a "last-updated" in the value and if a refresh request is sent, ignore it if last-updated is less than whatever time frame
16:55hiredmanbut in that case you really might just want to consider unconditionally refreshing every time period, and never have explicit refresh requests
16:56hiredmanyou have an atom containing some value, and a scheduled executor refreshes the value of the atom every time period and clients just deref the atom
16:56aneyeah, that's actually what i was going to implement, using a java timer or some such
16:57anethought it'd be simpler to initially prototype using just a global variable and simple cache
16:59hiredmana looping future and an atom are very straight forward
17:00hiredmanbut in your initial discussion you mentioned waiting for the future to be realized, which you wouldn't do
17:00aneindeed
17:25hlolliStill having problem with lein droid and cider. No matter how I change the profiles.clj I always get this error ONLY with droid: WARNING: The following required nREPL ops are not supported:
17:25hlolliclasspath format-code format-edn refresh
17:25hlolliPlease, install (or update) cider-nrepl 0.9.1 and restart CIDER
17:42WorldsEndlessHow do I use :rename in my ns declaration? e.g:
17:42WorldsEndless
17:42WorldsEndless(ns mine.styles
17:42WorldsEndless (:require [garden.color :as c :refer [{:rename '{hex->rgb hr}}]])) ;; doesn't work
17:42WorldsEndlessI've tried several variation on it
17:42justin_smithdon't use ' inside the ns form
17:42justin_smithand I don't think :rename should go inside :refer...
17:43WorldsEndlessI can't seem to find any examples, other than the main docs that say :rename can go SOMEWHERE...
17:45justin_smith,(require '[clojure.string :as s :refer [split] :rename {split schmoop})
17:45clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>
17:45justin_smith,(require '[clojure.string :as s :refer [split] :rename {split schmoop}])
17:45clojurebotnil
17:45justin_smith,(schoop "hello world" #" ")
17:45clojurebot#error {\n :cause "Unable to resolve symbol: schoop in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: schoop in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: schoop in t...
17:45justin_smith,(schmoop "hello world" #" ")
17:45clojurebot["hello" "world"]
17:45WorldsEndlessSay, that clojurebot is pretty cool!
17:45justin_smithWorldsEndless: ^ see above, but without the leading ' before the vector in the ns form
17:46justin_smithWorldsEndless: yes, it's a nice feature
17:47justin_smiththat's a slightly unintuitive mix when you have refer and rename together, to be sure
17:48WorldsEndlessSo, It compiles but doesn't work for me
17:48WorldsEndless(ns turbo-tenure.styles
17:48WorldsEndless (:require [garden.color :rename {hex->rgb hr}]))
17:48justin_smithwell, you aren't using refer there
17:48WorldsEndlessYeah, took it out for clarity
17:48justin_smithOK
17:48justin_smithso hex->rgb works, but hr does not?
17:48WorldsEndlessI'm just trying to rename the ugly function, but hr does not work
17:49WorldsEndless"unable to resolve symbol"
17:49WorldsEndlessI guess if I have to I can use "require" outside of the ns declaration, but I was hoping I wouldn't need to do that
17:49justin_smithWorldsEndless: note that it should be :refer [hex->rgb] :rename {:hex->rgb hr}
17:49justin_smith:require runs the same code, so you don't need to do that
17:50WorldsEndlessAh! Beautiful
17:50WorldsEndlessGetting the right combo of refer and rename was what I was missing
17:50justin_smithWorldsEndless: that's what I meant about it being unintuitive
17:50justin_smithyou ask to refer to the un-renamed version, and you get the renamed
17:50WorldsEndlessThanks, justin_smith (thought you were referring to my code with that)
17:51sdegutisWhat's the best way to handle text fields in Reagent?
17:53WorldsEndlesssdegutis: what are you trying to do?
17:53sdegutisJust create normal forms that can be submitted via AJAX.
17:55WorldsEndlessI'm pretty new to reagent myself, but I would think you'd just handle them in the normal DOM way (i.e. give them an id, refer to them)
17:55WorldsEndless^ sdegutis
17:56justin_smithsdegutis: in reagent, I tie the state of the form elements to some part of an ratom, and read the ratom on submit to build the ajax request
17:56sdegutisI was under the impression that any text you type into it gets squashed as soon as you type if you try to store it in an atom or anything?
17:56justin_smithsquashed?
17:57sdegutisLike, the field is tied to ratom, ratom is empty, field is empty, you click the field, type "f", and since the change isn't propagated back to the ratom, it asks the ratom what to display, which is nothing, and the field says ""
17:57justin_smithsdegutis: more specifically, an on-change that modifies the ratom
17:57sdegutisMainly because during onchange event (or whatever), it --- ooh, so you specifically change the ratom during onchange.
17:57justin_smithsdegutis: I'm not talking about the ratom that renders the component
17:58sdegutisOkay that makes sense. But then how do you handle the cursor always going to the end of the field?
17:58justin_smithsomething is making redraws happen because you are watching data for rendering that you modify while typing
17:58justin_smithdon't do that, and that behavior stops
17:59justin_smithor at least, watch it in a different component, not the same one accepting the input
17:59sdegutisSo another component should be responsible for input validation than the input itself?
17:59sdegutisAh maybe a higher level component, I guess, one that sees both the input and the error field which it should show upon error...
17:59justin_smithsdegutis: insanely simplified version of the problem: you tell joe to follow bob, you tell bob to follow joe, nobody does anything interesting and they walk in circles
17:59justin_smithso don't do that
18:00sdegutisright
18:00sdegutisThanks, I think I understand enough to solve this now.
18:46skeuomorfIs there a way to write multiline docstrings for functions inside a protocol? e.g. (defprotocol MyProtocol "A protocol which represents an entity." (my-function [this] "multiline docstring here!!"))
18:48skeuomorfargh, had an unescaped `\` in the docstring
18:48skeuomorfwhich is weird, that I have to escape characters inside the docstring
18:52justin_smithskeuomorf: \ inside strings needs escaping, because \c for most characters c is not valid
18:53skeuomorfah
18:54justin_smithbeing the escape string itself, it needs escaping (mind you this is all invalid inside the crazy world of regex)
18:54justin_smith,#"\a"
18:54clojurebot#"\a"
18:55skeuomorfYeah, ofc
18:56justin_smith,"\a"
18:56clojurebot#<RuntimeException java.lang.RuntimeException: Unsupported escape character: \a>
20:24skeuomorflet's say I have a record R which has two "properties", x and y, x is an atom holding a map and y is an int. Let's say we have two instance (def r1 (->R (atom {}) 2)) and (def r2 (->R (atom {:my-key r1}) 3)). Now, what I want to do is change the value of y which is inside r1 which is inside x which is inside r2, what would be the cleanest way to do that?
20:27skeuomorffor the sake argument, assuming "properties" inside records weren't private, what I would want to change is (y (:my-key @(x r2))
20:28skeuomorfs/sake/sake\ of/
20:28wmealingwell, i've started using specter for that kind of manipulation.
20:28wmealingi'm by no means cool though
20:28wmealingso i'm probablly doing things all kinds of wrong
20:29skeuomorfI'd prefer to use it without external libs though, I could define that y field as mutable but that seems dirty
20:32skeuomorfwmealing: A quick glimpse, I think spectre doesn't work with records? If I were using a regular map, I would've just made a new version with the new value out of the old one, but records' members are private
21:01skeuomorfScrew it, did it with getter/setter :)
21:07wmealingskeuomorf: sorry man had to bail , i had a meeting
21:10skeuomorfwmealing: No worries :)
21:51justin_smithskeuomorf is gone, but he should know you can do everything you can do with maps to record
21:51justin_smiths
21:51htmldrumAnyone got some material on setting up a Ring application on AWS? I'm used to preparing hosts via cloudformation or a provisioning tool like Puppet/Chef but am looking for resources on where to start as a newbie to Clojure/Java web services.
21:52justin_smithhtmldrum: it's a lot easier to use elasticbeanstalk
21:52justin_smithyou can use lein ring to make an uberwar, hand the uberwar to elasticbeanstalk, and that's it
21:53htmldrumjustin_smith: Thank you :)
23:16TimMcjustin_smith: Except for call empty or (sometimes) dissoc on them, because then you get a map again. :-P
23:16justin_smithTimMc: you can do those things though!
23:17TimMcTrue!
23:17justin_smithyou just get a different data type back