#clojure logs

2014-04-15

00:04cddrclojurebot: How do I add a fact?
00:17zspencer@kidpollo aloha :)
00:17zspencerSo, I've got a string "foo" and I want to turn it into a vector ["f" "o" "o"]
00:18zspencersplit #"" gives me too many ("" "f" "" "o" "" "o")
00:18zspencer(clojure.string/split "foo" #"")
00:18beamso(seq "foo")
00:18beamso,(seq "foo")
00:18clojurebot(\f \o \o)
00:18zspencerderp
00:18zspencerI'm an idiot
00:18zspencerthis is what happens when I come at it from my ruby programmer mentality
00:19beamsoyou asked when it seemed wrong. so that isn't idiotic.
00:22amalloyderek_c: you can't, in general, make anything "'return more than one thing", so [1 2 3 (something ...)] will always have exactly four elements
00:24amalloybut you can write, for example, (apply vector 1 2 3 (something ...)), or (concat [1 2 3] (something ...)), or `[1 2 3 ~@(something ...)]. any of those are ways to splice lists together
00:24derek_camalloy: I see, thanks!
00:33zspencerok one more question: I've got two hashmaps who (with visual inspection) seem to be the exact same
00:33zspencerhowever test-unit is saying they are not
00:34gvickerswhat's in them?
00:34zspencermore hash-maps
00:34zspencerand a vector
00:34zspencerit's a representation of a dungeon
00:35zspencerehhh, let me put it in a gist
00:35zspencerhttps://gist.github.com/zspencer/357332c3f6ca7ecdc978
00:36TravisDGiven any imperative algorithm that modifies state, we can construct a pure functional equivalent that consists of some state transformers that sequentially update persistent data structures. Are there any dangerous gotchas with this transformation?
00:36zspencerIt's very possible that I am a touch past the ballmer peak
00:37trap_exitis there a builtin library for parsing urls in clojurescript?
00:37trap_exiti.e. I want the params of a url
00:37trap_exitsomething like foo.com/?username=blah&id=blah
00:37trap_exitI wnat the username=blah, id=blah part
00:37trap_exitperferably as a map
00:37zspencerI think ring has something like that
00:38trap_exitsorry, I want to do this _clojurescript_
00:38zspencerbut I don't think it's independent of the framework
00:38trap_exitnot clojure
00:38zspencercould probably extract that into cljx but I don't know of something offhand
00:38amalloyTravisD: well, if any of that state lives in the outside world, like console input, it's a little tricky
00:39amalloybut in general i am aware of no theoretical dangers
00:39TravisDamalloy: Ah, yeah. Some state doesn't come to you in a persistent form
00:39TravisDamalloy: Do you know if there are some situations where the pure version has substantially worse running time?
00:40amalloyi think we have data structures good enough to get within a log-factor on just about anything
00:41amalloybut that's asymptotic, of course - for small data persistence is relatively more expensive (and that matters relatively less, since it's small)
00:41TravisDThat's pretty cool. Is there a good place to read about the functional data structures? I have a copy of Chris Okasaki's book, but I haven't looked much at it
00:41amalloythat book is amazing, but too hard for me :P
00:41amalloy$google understanding persistent vector
00:41gvickerszspencer: in the second map :health and :10 are keys
00:41lazybot[polymatheia - Understanding Clojure's Persistent Vector, pt. 1] http://hypirion.com/musings/understanding-persistent-vector-pt-1
00:41gvickerszspencer: or the first one rather
00:42amalloyi think that's a decent article
00:42TravisDAh, I saw some links to these blog posts before, but didn't look closely either :P I have a problem with choosing what to read
00:42amalloyi gtg though, enjoy
00:42zspencergvickers: this... this is my life
00:42TravisDThanks! Talk later
00:43zspencergvickers: huge thanks. I was certain that hashmaps should be equivalent
00:43gvickerszspencer: hahaha I feel that. It helps sometimes to def both and pprint them next to each other
00:43zspencerahhh pprint
00:43gvickerszspencer: maintains the order
00:43zspencerthat would have been smarter
00:45zspencerand yay programming: https://github.com/zspencer/clj-warrior
00:49gvickerszspencer: looks interesting
00:51devnI'm reading a slide deck about core.async. It says "goroutines don't map 1-1 to threads. They get their own thread pool (number of cores + 2) in clojure. The runtime takes care of multiplexing them."
00:51devn"number of cores + 2" -- is that &(.availableProcessors (Runtime/getRuntime))
00:52devn,(.availableProcessors (Runtime/getRuntime))
00:52clojurebot#<CompilerException java.lang.SecurityException: Reference To Runtime is not allowed, compiling:(NO_SOURCE_PATH:0:0)>
00:52devn+ 2?
00:52devnin my case, because of hyperthreading, I would have 10
00:52devn(thread pools I mean)
00:53gvickersdevn: https://github.com/clojure/core.async/blob/72509d0b97372fd51b271a9662f67107642783e2/src/main/clojure/clojure/core/async/impl/concurrent.clj
00:54devnbadda bing! thanks gvickers
00:54gvickersLooks like it, hyperthreading doesent count as an extra processor
00:55devngvickers: my macbook pro has 4 cores, but .availableProcessors returns 8
00:55devnbecause of hyperthreading
00:55devn(inc gvickers)
00:55lazybot⇒ 1
00:56gvickersdevn: oh I just assumed since mine returned 4, hyperthreading didnt count. Hmm, I have an i7 macbook and only see 4 processors.
00:57dbellis there a way to see all the protocols a type implements?
00:57devngvickers: I have an i7 -- 2.3GHz, number of processors = 1, number of cores = 4
00:57dbell(off the top of collective heads, i'm on google pass #2 but it's not a big deal yet)
00:58devndbell: extenders?
00:58dbellhmm, extenders looks awesome, i have the mirror problem though
00:59dbell(inc devn)
00:59lazybot⇒ 16
01:00devndbell: do you know the protocols you want to check for the type?
01:01dbellerr, you are severely overestimating how hacky this is
01:01TravisDI've got an interview for an internship coming up in the next few weeks and I'm hoping to refresh my algorithms background. Can anyone recommend a book that is shorter than CLRS and maybe more appropriate for a quick review?
01:01devndbell: heh
01:01devndbell: well, help me out
01:01dbellthis is more of a throwaway b/c i don't want to look that up, ha
01:01dbellreally what i'm trying to do is get a to-str string from basic functions
01:02devndbell: what about using ns-publics and protocol? or something?
01:02dbellso, say, (mystery-fn +) -> "+"
01:02devn,(filter #(-> @(val %) protocol?) (ns-publics *ns*))
01:02clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: protocol? in this context, compiling:(NO_SOURCE_PATH:0:0)>
01:02devnerr sorry
01:02TravisDI find your names very hard to distinguish
01:03gvickersTravisD: check this out http://bigocheatsheet.com/
01:03devn,(filter #(boolean (:on-interface @(val %)) (ns-publics *ns*))
01:03clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
01:03devngah
01:03dbellsmiled
01:04devn,(filter #(boolean (:on-interface @(val %))) (ns-publics *ns*))
01:04clojurebot()
01:04TravisDgvickers: thanks
01:04dbelldevn: checked out an equivalent in my repl, looks promising
01:05devndbell: you can then filter again across that for #(satisfies? @(val %) t)
01:07dbelldevn: https://www.youtube.com/watch?v=WVpe4lOAcjc
01:07dbellthanks, solved my problem
01:11devnsweet
01:11devn,(defn protocols [ns] (filter #(boolean (:on-interface @(val %))) (ns-publics ns)))
01:11clojurebot#'sandbox/protocols
01:11devn,(defn implementers [x] (filter #(satisfies? @(val %) x) (all-protocols)))
01:11clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: all-protocols in this context, compiling:(NO_SOURCE_PATH:0:0)>
01:11devnerr
01:11devn,(defn implementers [x] (filter #(satisfies? @(val %) x) (protocols)))
01:11clojurebot#'sandbox/implementers
01:12devn,(defprotocol Foo (bar [x] "bar method"))
01:12clojurebotFoo
01:12devn,(deftype Bar [x] Foo (bar [this] "bar bar method"))
01:12clojurebotsandbox.Bar
01:12devn,(implementers (Bar. 1))
01:12clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: sandbox/protocols>
01:12devnsigh
01:12devn,(defn implementers [x] (filter #(satisfies? @(val %) x) (protocols *ns*)))
01:12clojurebot#'sandbox/implementers
01:12devn,(implementers (Bar. 1))
01:12clojurebot([Foo #'sandbox/Foo])
01:14devnhackish for sure
01:36dbaschderek_c: what’s the difference between (mymacro 1 2 3) and (list 1 2 3) ?
01:41bob2what do you mean?
02:51sm0kehow safe/idiomatic is it use metadata to classify some data as special?
02:55llasramWhat do you mean?
03:03sm0kehurmm not sure
03:04sm0keso i have an api, to which i want to add some other functionality without adding more functions
03:05sm0kei guess i can always use a map which is stripped by the functions
03:05sm0kemoreover i read, that meta is not preserved by clojure functions
03:05sm0kenot all
03:12llasramThat's unfortunately a bit vague to provide suggestions about... Any more specific?
04:32YwenHello, guys. When you need to access a REST WS exposing a WADL (with a succinct API), do you use wadl2java to generate classes that you'll use with Clojure or do you make the HTTP query/response parsing (through Xpath) yourself?
04:56sandbagsHi folks. I'm missing something about transitive dependencies. I built a library that depends (ironically enough) on Stuart Sierra's "dependency" library. When I include my library in my app 'dependency' is not picked up as a transitive dependency and the code won't load. I've googled but can't see what I am missing. Shouldn't transitive deps be picked up?
04:57TEttingerall the project.clj config is as it should be?
04:57sandbagsTEttinger: my library has com.stuartsierra/dependency as a dependency in project.clj and my app has my library as it's dependency
04:58sandbagsi'm not sure if that is the same as "as it should be" :)
04:58TEttingerthere's a command to check...
04:58TEttingerlein deps tree
04:58TEttingermight be it
04:58sandbagsright so i ran that on both
04:58sm0ke:tree
04:58sandbagsand my lib shows "dependency" as a dependency
04:59sandbagsbut my app shows only my library as a dependency, no transitive deps
04:59sandbagsi'm wondering if there's something specific you need to do to have this happen? it's not come up for me before
04:59TEttingercould it be using an older version of your lib?
04:59sandbagsthe app depends on the current version
05:00TEttingertry lein install of the latest lib
05:01sandbagsokay so a potential wrinkle is that this library is installed locally using mvn instalL:install-file
05:01sandbagscould that have some bearing?
05:01sandbagsthe lib isn't in clojars
05:01TEttingerthat's what I suspected
05:01TEttingerunless you keep installing as you change deps, it won't know in the app?
05:02sandbagsi don't think i changed deps since i last installed it but i'll try installing it again to be sure
05:03sandbagsthat doesn't appear to have made any difference
05:03TEttingergah
05:03TEttingerno idea
05:03TEttingerwait for technomancy
05:03TEttingerI best sleep
05:03sandbagsfor reference i install it using https://gist.githubusercontent.com/anonymous/da74f82b8040100495bc/raw/31a3133b65ae8f2e85d5ce7ee5d718cea6dd73b2/gistfile1.sh
05:03nathan7Ahoy humans — is there an opposite to conj?
05:04Ywennathan7: what do you mean? putting to the end of a list or reading the first element?
05:04nathan7Like, (= x (f (conj l x)))
05:04sandbagsTEttinger: okay, thanks for your help
05:05nathan7equivalent to last for a vector, equivalent to first for a list
05:05Ywennathan7: try pop
05:05Ywennathan7: sorry, peek
05:05nathan7Ywen: <3
05:06Ywennathan7: you're welcome ;)
05:10olliveraHi, I am learning Clojure and I tried to write a sql query to insert the result in a mongoDb collection but I got a Null Point exception.
05:10olliverasee sample https://www.refheap.com/76295
05:11apumHi, does anyone know the way to find in which namespace (of the loaded ones) is a function defined (by fn's name)?
05:13sm0ke`inc
05:13sm0ke,`in
05:13clojurebotsandbox/in
05:13vijaykiranapum: try #'fn name
05:13sm0ke,`odd?
05:13clojurebotclojure.core/odd?
05:13vijaykiranapum: in repl
05:13vijaykiranor ` as sm0ke said
05:17apumsm0ke, vijaykiran - thanks! gonna read what's really happening under the hood...
05:19olliveraanyone knows what's wrong on that code?
05:21apumollivera: don't know, but I would check where exactly NPE is thrown
05:26Ywenollivera: Can you try to execute portions of the code to narrow down the source of the exception?
05:29olliveraapum, it happens when I try to insert in MongoDB
05:30apumollivera: can you print whole stacktrace?
05:31noidiollivera, println returns nil
05:32olliveraapum, https://www.refheap.com/76299
05:32olliveranoidi, no, it prints the results
05:33olliveranoidi, something like .. {:cid 2037} ...
05:35noidiit prints to *out* and returns nil
05:35apumollivera: have you created "documents" collection?
05:35noidiso mapping with println gives you a sequence of nil
05:35noidi,(map println [1 2 3])
05:35clojurebot(1\n2\n3\nnil nil nil)
05:38olliveraapum, yes
05:38olliveranoidi, okay .. so what should I do?
05:44noidi(let [results ...] (dorun (map println results)) results)
05:45olliveranoidi, I will try it
05:57sm0kehello
05:57sm0kei am getting really weird exception with no way to make sense of it
05:57sm0kehttps://www.refheap.com/76304
05:57sm0keseems like an clojure glitch?
06:04pjstadigsm0ke: maybe. it depends on what you're trying to do
06:05pjstadiglooks like either a very deeply nested data structure that is getting printed, or somehow there's a loop in the print method or data structure that is getting printed
06:06sm0kehmm
06:06pjstadigyour concurrent hash map has a self reference?
06:07sm0kei am not sure which part of code is causng this
06:08pjstadigsm0ke: i'm not sure if this is when something is being printed at the repl or if you are explicitly trying to print something, but binding *print-length* and *print-level* might help
06:12sm0keidentified the part
06:12sm0kehmm weird
06:17pjstadigsm0ke: what was it?
06:18sm0kepjstadig: one sec, i am not sure yet but i think tools.logging has a bug with printing maps
06:18sm0ketrying to reproduce
06:23sm0keoh shite!
06:24sm0kepjstadig: i had a record MyReco [state], state is a (atom {}) to which i had assoc! a :another-record other
06:24sm0kethe other is like MyOtherReco [state]
06:24sm0keto which i was passing this record's whole state
06:24sm0keget it?
06:24sm0keclojure while prining deeply prints the records as maps
06:25sm0kehmm wtf!
06:27sm0kealthough this is very ugly code, but still very undesirable behaviour imo
06:40sm0keso here is the gist
06:40sm0ke(defprotocol MyPro (foo [this]))
06:40sm0ke,(defprotocol MyPro (foo [this]))
06:40clojurebotMyPro
06:40sm0ke,(defrecord MyRec [f] MyPro (foo [this] (swap! f :foo (MyRec. f))))
06:40clojurebotsandbox.MyRec
06:40sm0ke,(.foo (MyRec. (atom {})))
06:40clojurebot#sandbox.MyRec{:f #<Atom@f7f18e: #sandbox.MyRec{:f #<Atom@f7f18e: #sandbox.MyRec{:f #<Atom@f7f18e: #sandbox.MyRec{:f #<Atom@f7f18e: #sandbox.MyRec{:f #<Atom@f7f18e: #sandbox.MyRec#>}>}>}>}>}
06:40sm0kewhat!
06:41sm0keno stackoverflow :(
06:42sm0ke,*print-level*
06:42clojurebot10
06:43sm0ke,(def *print-level* nil)
06:43clojurebot#<CompilerException java.lang.SecurityException: denied, compiling:(NO_SOURCE_PATH:0:0)>
06:55turbopapeHi guys, how can I set my default clojure version to 1.6.0 when creating a new project with "lein new?"
06:59Ywenturbopape: not sure it's possible, but it is quite easy to fix it in the project.clj file
07:00vijaykiranturbopape: I think it uses https://github.com/technomancy/leiningen/blob/master/resources/leiningen/new/default/project.clj
07:00turbopapeyeah Ywen , just feeling lazy :)
07:00Ywenturbopape: you'll have to edit it anyway ^^
07:01turbopapeyep Ywen :P
07:01vijaykiranturbopape: may be you can have a local leiningen template for your projects
07:01turbopapethx vijaykiran !
07:01turbopapeI'll have to master the ways of the leiningen templates !
07:03vijaykiranturbopape: its just one click away - https://github.com/technomancy/leiningen/blob/stable/doc/TEMPLATES.md :)
07:04turbopapeoh vijaykiran , thanks for helping the lazy noob out !
07:10olliveranoidi, your suggestion worked. I just need to convert the lazy-seq in a vector ...
07:10olliveranoidi, https://www.refheap.com/76316
07:12olliveranoidi, what should I chance if I decide to insert line by line as the table may have thousand of lines ...
07:17sm0keso how do i define records in clojure with a child parent relationship without blowing stack?
07:28persesis there anybody had checked the clojure's performance relative to other languages?
07:29scottjperses: http://www.techempower.com/benchmarks/
07:31llasramsm0ke: Instead of having recursive references, add a layer of indirection. For example, two maps: one of numeric ids to objects, and one of numeric ids to a list of the numeric ids of their children
07:31llasramThis approach can represent loops in a graph without any need for mutability
07:34sm0kellasram: makes sense thanks
07:41perseswhat is the best way to do this: if i have a list like this ("clojure" "is" "good"), how can i get [["clojure" "is"] ["is" "good"]] ?
07:42pyrtsa,(partition 2 1 '("clojure" "is" "good"))
07:42clojurebot(("clojure" "is") ("is" "good"))
07:46mercwithamouthdoes anyone here have any apps that use mongodb by chance?
07:46geckodru1yes
07:46mercwithamouthon github?
07:46geckodru1mercwithamouth: they're not
07:47mercwithamouthhmm i just wanted to take a look at see you go about modeling
07:47geckodru1mercwithamouth: you mostly looking for sample code?
07:48mercwithamouthyeah for the most part...is it even worth making a schema.clj file...or just coding loosely?
07:49geckodru1mercwithamouth: with mongo, there was a definite set of fields that could be in a collection...but not all docs had the fields...
07:50Ywenmercwithamouth: schema.clj? You mean like from https://github.com/runa-dev/clj-schema ??
07:50lazybotYwen: Uh, no. Why would you even ask?
07:50geckodru1mercwithamouth: from code, we didn't define a schema
07:52geckodru1anyone here interview with Runa?
07:54mercwithamouthgeckodru1: easy enough... =P
07:55ssqqHow to input repeat the code in repl? just like use up-narrow or down-narrow in command line.
07:55geckodru1ssqq: depends on where your repl is
07:55mercwithamouthYwen: hrmm not quite...i was just being hesitant before diving in as i should...
07:55geckodru1ssqq: emacs you click on line and hit <return>
07:56wunkiis there a fn which prints a value and returns the same value instead of `nil`? Would be very useful for debugging `->` or `->>`
07:56ssqqI used git shell on windows
07:56geckodru1ssqq: terminal, it usually <up> <down>
07:57ssqqgeckodru1: Could I use terminal on windows?
07:58geckodru1wunki: #(do (println %) %)
07:58Ywenmercwithamouth: looks like both are not correlated, you can start by putting loose data in your mongo collections & then afterwards write schemas when you know the shape of your data
07:59wunkigeckodru1: thanks, also just found https://github.com/dgrnbrg/spyscope
08:01geckodru1wunki: you should also checkout https://github.com/clojure/tools.trace
08:03wunkigeckodru1: will do, thanks
08:11oskarthping dakrone
09:15igorHi all, can anybody help me? I have a question about emacs/cider/lein
09:15teslanickJust ask the question.
09:16igorOk, thank you
09:16igorThe question is here: http://stackoverflow.com/questions/23081797/how-do-i-correctly-use-lein-try-in-cider
09:17igorI have a lein repl in Emacs+Cider, and the question is how I use lein try in this case?
09:25igorBack to my question about lein-try+cider: may be someone could give me some tips?
09:26igorI can't believe that I'm the only one who wants to use lein-try with emacs/cider
09:27ssqqHow to change a node value of complex data structure?
09:27dnolen_ssqq: update-in, assoc-in
09:32ssqqdnolen_: thanks very much.
09:34clgvigor: when you have a repl running just use the pomegranade library to get the dependencies you want to try
09:51igorclgv: thank you very much, I will try it
09:52igorthe dependecies are then automatically downloaded?
09:55clgvigor: yes
09:55igorok, it works, thank you once again! And what is the point of lein try then if I can do it so easily with pomegranade?
09:56clgvigor: it's the library leiningen uses ;)
09:57clgvigor: the point is to get the deps and a repl where you can use these. otherwise this would be multiple steps
09:59igorwell, I mean if I fire up a lein repl and then just do (add-dependencies ... ), for what is lein try good?
10:04clgvigor: convenience - one good reason for a plugin if you need that task repeatedly
10:05clgvigor: and you do not need to know how that implementation works ;)
10:13igorclgv: ok, thank you very much
10:19igoranother question: is it possible that pomegranate does not honor http_proxy/https_proxy variable?
10:20igorI see that after I started add-dependencies there were no new entries in my proxy's access.log
10:21igorand the add-dependencies just hangs in the repl
10:22igorcan it be that it just tries to access the servers direct (I don't think so), but anyway, that is strange that there are no new log entries in the proxy's log
10:23akazloudoes mock testing is common in Clojure? What if I want to test my ring app, what is the best approach to start with? I found with-redef which can be used together with clojure.test?
10:23igorand when I do lein try everything just works
10:28clgvigor: hmm it's possible. but then you can find out what leiningen does to honor proxies...
10:28igorleiningen just uses http_proxy/https_proxy and -Dhttp.proxy if you have it
10:29clgvigor: I meant implementation wise
10:29igorok, I see already that pomegranate just ignores this settings ( https://github.com/cemerick/pomegranate/issues/15 )
10:30igorthese settings are just ignored (probably)
10:31llasramWell, Leiningen uses pomegranate to do dependency resolution, so...
10:31clgvigor: my point is that leiningen supports proxies and ass llasram stated leiningen uses pomegranate so it adds something to use proxies ;)
10:32llasramclgv: No need to throw around insults! ;-/
10:32llasramEr, ;-)
10:32clgvllasram: huh? what?
10:32dakroneoskarth: pong
10:32llasramigor: To throw more fuel on the fire, there is also https://github.com/pallet/alembic which loads a full instance of Leiningen in your REPL process
10:33llasramclgv: Your typo s,ass,as,
10:33clgvllasram: roflmao
10:34clgvigor: seems as if add-dependencies supports a :proxy parameter https://github.com/technomancy/leiningen/blob/5c6db48efa8b81e0a0348f8fdac9a249f966aa82/leiningen-core/src/leiningen/core/classpath.clj#L170
10:36igorthat's right, but get-proxy-settings just takes http_proxy from the environment
10:36clgvigor: I meant you can manually specify the proxy via the named parameter :proxy
10:36clgvigor: or build a wrapper that get http_proxy from the environment
10:41igorok, that is a good idea, but anyway, as you can see in the code, the function must use the environment variable automatically and that it strange that this doesn't work
10:42igorthank you very much once again, I will check it
10:44perseshow can i convert ([(1 2) (12 34)] [(3 4) (5 6)]) to ([[1 2] [12 34]] [[3 4] [5 6]]), i can implement it with nested maps but nested % not allowed, so what do you suggest guys?
10:45persesand also how can i get ([1 2] [12 34] [3 4] [5 6]), this will be clean
10:46llasram,(->> '([(1 2) (12 34)] [(3 4) (5 6)]) (mapcat (partial map vector)))
10:46clojurebot([(1 2)] [(12 34)] [(3 4)] [(5 6)])
10:46llasramEr
10:46llasramheh
10:46llasram,(->> '([(1 2) (12 34)] [(3 4) (5 6)]) (mapcat (partial map vec)))
10:46clojurebot([1 2] [12 34] [3 4] [5 6])
10:46llasramThere we go
10:48persesllasram: thanks
10:50clgvigor: that code I linked to is the implementation leiningen uses not the implementation of pomegranate
10:50jonathanjmreowr
11:04sritchieanyone here using sente for websockest?
11:04sritchiewebsockets*?
11:06sritchiedanoyoung: how'd the prez go?
11:08danoyoung@sritchie personally I think it went well, although the only thing that everyone seemed to focus on was how hard they thought the syntax was to read….
11:08sritchie:)
11:08sritchieoperation, inputs, outputs
11:08sritchieboom
11:08sritchiethat's it
11:09danoyoung@sritchie yea, but they like their java, calsses, objects,etc...
11:10danoyoung@sritchie the combo of the REPL + TDD kinda blew a few folks away I think.
11:14agarman@sritchie + @danoyoung folks at my current work place are having the same struggles with s-exp ... it's just a familiarity thing
11:14sritchieyup
11:21danoyoungi'm hoping to slid in some small cascalog work….see if I can get some traction….
11:22sritchiedanoyoung: you'll just code so much faster that you should just use it for stuff
11:22sritchieand blow everyone's minds
11:23rundll32 what is the best clojure ide?
11:26coventryI hear good things about cursive and light table is probably the future, but I use emacs.
11:27BobSchacklighttable is very good if you are just starting to learn clojure imho
11:28rundll32 allright
11:28locksas a clojure noob, LT was the easiest way to start
11:29andyfThis might be a bad idea for reasons I don't know yet, but has anyone tried to make a tool/library/etc that helps avoid Clojure lib conflicts by "auto renaming" a library. E.g. Core.memoize gets renamed core.memoized.myversion, and you can require that without manually editing source code of core.memoized ?
11:30agarman@rundll32 here people use a mix of LaClojure, LightTable & Emacs
11:30Ywenrundll32: I'm coding Clojure & doing IRC via Emacs right now.
11:31stuartsierraandyf: At the Java bytecode level, "JarJar"
11:31agarman@rundll32 + @Ywen: same here...emacs daemon mode is just too much awesome for me to even try other options.
11:32Ywenagarman: I also tried light table but find it was lacking some of the cool features that were shown in the "commercials" ^^
11:32rundll32 i am going to play with all of them and decide which suites me best.
11:33andyfStuartsierra: thanks for pointer. Will check it out. Trying to avoid lib conflicts between libs used by Eastwood & those used by projects being linted
11:33Ywenagarman: like the possibility to forget the files and open function one next to another. Plus I experienced some bugs, like live interpreter stopping to work
11:34agarman@rundll32 if you're new to emacs...use emacs live...it's pretty good starting env
11:34stuartsierraandyf: I think somebody (technomancy?) made an experimental renamer for Clojure.
11:35agarman@ywen: I tried LightTable for January...it didn't have anything on emacs if you already know emacs
11:43andyfStuartsierra: maybe metaverse ?
11:51nzhow to delay macro expansion so that it happens after aot compilation. I am trying to make an uberjar, but macros expand when uberjar is build, not when app (from uberjar) is executed
11:51andyfYep. Found Google group thread from May 2013 on util libs discussing the issue. Thanks
11:53devnwhat do people use for escaping SQL?
11:56devni wish sean was here :)
11:58andyfBad joke answer: use a NoSQL db instead?
11:59BobSchackWorse joke answer: http://us1.php.net/mysql_real_escape_string
12:00llasramnz: Don't use AOT?
12:01llasramdevn: Doesn't the positional-parameter JDBC query foo handle escaping inserted parameter values?
12:09gtrakI know that immutant does runtime-isolation, but are there ill-effects of running multiple versions of clojure, say multiple uberwars, on a tomcat?
12:12seangroveAhk, I want something between protocols and multimethods - is there a way to tell if a multimethod has an implementation for a given input? Something like (satisfies? multi-method [some input])
12:12jcrossley3gtrak: uberwars containing any clojure version older than 1.6.0 will likely result in permgen leaks
12:12bbloomseangrove: i've got you covered: https://github.com/brandonbloom/dispatch-map
12:13gtrakah, interesting.
12:13llasrambbloom: Slick
12:15seangrovebbloom: Looks fantastic. Think it'll work in ClojureScript?
12:16bbloomseangrove: you'd have to substitute the various java interfaces for cljs protocols
12:16bbloomseangrove: but it should be a straightforward port
12:16jcrossley3gtrak: those leaks only occur when you redeploy, though.
12:16gtrakyea, I've just been looking at the JIRA issue, seems reasonable.
12:17seangrovebbloom: I'll circle back to that, it's a nice to have, but I can deal with it a different way for now. Definitely looks a lot more like what I wish Clojure's multimethods were
12:18gtrakI've got no problem using 1.6, just don't want to mess up someone else's deployment at an arbitrary time in the future :-)
12:19gtrakI've seen permgen leaks with regular java on jboss, so I guess it's not _that_ unusual anyway.
12:20jcrossley3gtrak: it's a common risk, yes. any libs that don't release thread locals will cause leaks.
13:05clgvclojure.test.check question: how do I create a generator that chooses from a set of given constants?
13:07reiddraperclgv: gen/elements
13:07reiddraperclgv: (gen/sample (gen/elements [1 2 :three 4 '5]))
13:07clgvreiddraper: great, thanks. I suspected one-of but learned differently from the docs ;)
13:09gfredericks,(require '[clojure.string :as s'])
13:09clojurebotnil
13:09gfredericks,s'/split
13:09clojurebot#<string$split clojure.string$split@11416b3>
13:10pbostromreiddraper: I noticed the new test.check README does not have a link to the API docs, is this intentional?
13:10reiddraperpbostrom: nope, just forgot to add the link back once i created the github page
13:13gfredericksreiddraper: any guesses what'll happen with TCHECK-15? I was going to start a utility lib but was waiting on that first
13:14reiddrapergfredericks: i haven't had time to dig in with a lot of detail yet. but assuming there are no semantic issues found, i'd like to have it included.
13:15reiddrapergfredericks: my biggest worry is that it doesn't make users consider the difference between _values_ and _generators_, which is seemingly already confusing in choosing between gen/elements and gen/one-of, and gen/fmap and gen/bind
13:15gfredericksreiddraper: cool, that's all I was wondering; thanks
13:15clgvreiddraper: (gen/sample (gen/nat)) => ArityException Wrong number of args (0) passed to: PersistentArrayMap clojure.lang.AFn.throwArity
13:15reiddraperclgv: gen/nat is not a function
13:15reiddraperclgv: (gen/sample gen/nat)
13:15clgvoh ok
13:16nzllasram: does uberjar work without aot?
13:16gfredericksreiddraper: I feel like it should be intuitive for anybody familiar with clojure.core/for
13:16gfrederickswhich requires you to consider the difference between lists and elements
13:16reiddrapergfredericks: so which does gen/for expect you to return, a value or a generator?
13:16jcromartiehow do you reduce redundant boilerplate code when rendering templates with Enlive?
13:16gfredericksreiddraper: the body is a value, just like in c.c/for
13:17reiddrapergfredericks: so it takes the place of fmap, not bind?
13:17gfredericksreiddraper: a single-clause for is like fmap; but with multiple clauses they are combined via bind
13:18reiddrapergfredericks: ah ok, so bind is only used within the bindings, _not_ for the body you provide
13:18jcromartiewe currently have a one HTML file with a <section> per page, but in the HTML template file itself, those <section> elements have duplicate headers/structure etc/
13:18gfredericksreiddraper: right; I believe this covers all use cases of fmap & bind though
13:19reiddrapergfredericks: so a 'gotcha' would be not using multiple bindings when the generators are _not_ dependent on each other. since it would use bind unnesecarily, which affects shrinking
13:20gfredericksyeah that sounds fair
13:20gfredericksprobably not feasible to do dependency analysis
13:20reiddrapergfredericks: cool, so yeah, i'm definitely leaning toward this being included in test.check proper
13:20reiddraperif you find it useful, i'm sure others will
13:21gfredericksreiddraper: should I add a docstring note about independence?
13:21gfrederickspresumably suggesting tuple
13:21reiddrapergfredericks: yes i do think that would be useful
13:21reiddraperand yes, tuple is the most likely way to combine independent generators
13:21gfredericks(gen/for [[a b] (gen/tuple gen-a gen-b) ...] ...)
13:21reiddraperexactly
13:23gfredericksso when using bind-as-tuple ("degenerate bind"), does the shrinking involve a lot more redundancy? Is that the main downside?
13:23nzusing lein-otf instead of aot seems to work. startup is slower but doesn't matter too much
13:25reiddrapergfredericks: the main downside of using bind when you don't need the value from the previous generator is that the generators don't shrink 'in parallel', they shrink in series. the outer one shrinks first
13:27reiddrapergfredericks: if you're into the monadic/applicative explanation, its like the difference between monad and applicative.
13:29gfredericksthe tuple shrinks the first one as far as it can before starting on the second one
13:29coventrynz: Why do your macros need to expand at runtime?
13:31reiddrapergfredericks: hm, i'll need to take a look, that could be improved it sounds like
13:32nzexpanding macro puts stuff to global state (atom) and other macros read stuff from that state. when uberjar starts up, the global state is empty
13:34nz
13:35hiredmannz: macros shouldn't have side effects, they should expand in to code that has side effects
13:36nzhiredman: i know, but that is what the lib is doing
13:37nzbut anyways, not using aot solves the problem, so would delaying macro expansion, i think
13:39hiredmannz: don't use the library
13:40nztoo much good stuff in it
13:40justin_smithwhat lib?
13:41nzhttps://github.com/metosin/compojure-api-examples
13:42hiredmannz: I doubt that
13:43justin_smithwhere does compojure-api do the macro magic?
13:43hiredmanugh
13:43hiredmanit includes it's own version of the clojure.walk namespace, without changing the namespace
13:43hiredmanthis compure-api library is terrible
13:44nzhttps://github.com/metosin/compojure-api/blob/master/src/compojure/api/swagger.clj#L17 https://github.com/metosin/compojure-api/blob/master/src/compojure/api/swagger.clj#L208 https://github.com/metosin/compojure-api/blob/master/src/compojure/api/swagger.clj#L195
13:45llasramWow
13:45hiredmannz: I believe in you, you can write something better in an afternoon
13:45justin_smithSWAG
13:46justin_smithbonus points if the replacement lib has a YOLO function
13:46llasramI've got an idea -- let's all agree to pretend to people new to Clojure that macros don't actually exist
13:46justin_smith(inc llasram)
13:46lazybot⇒ 22
13:46coventryAw, I had so much fun with macros.
13:46llasramOnce they've earned some trust, we can let them in on the secret
13:47llasramcoventry: Yeah, but I know that one reason I picked up Clojure in the first place was because MACROS ARE AWESOME WOOO
13:47llasramAnd I was right, but also oh so wrong
13:48llasramI get the sense that macro over-exuberance is a common problem for recent arrivals to the Clojuresphere
13:48technomancyllasram: have you been drinking scala water recently? http://www.scala-lang.org/old/node/8610
13:48hiredmanllasram: how just not using libraries written by people who barely know clojure?
13:48gfredericksreiddraper: that was my best guess after looking at the output of (gen/call-gen (gen/tuple gen/nat gen/nat) (java.util.Random. 42) 7)
13:48technomancypattern matching as an "intermediate" feature =(
13:48llasramtechnomancy: Wow... Finely classify all the things
13:48hiredmanllasram: if you don't know/use the language you have no бизнес packaging up your junk for others
13:49RickInAtlantallasram: for anyone like me who came to clojure after reading "beating the averages" macros were the one thing I most wanted to learn about. I haven't had occasion to use them yet.
13:49llasramhiredman: Yeah, but -- believe it or not -- I'm trying to avoid that level of elitism
13:49llasramIn the formal sense
13:50technomancyhiredman: are you sure it's intended for others though?
13:50justin_smithllasram: macros are for two groups - those just learning the language and trying to figure them out (their macros should never go in a library), and people who have some mastery of the language, implementing extensions to it (their macros can go in libraries, but only half as many as they think they need)
13:50llasramhiredman: Er, well, or whatever sense means that I'm not trying to insult you for elitism :-)
13:51llasramjustin_smith: Yeah, I can buy that. You do need to get some actual experience with them to internalize the correct level of exuberance
13:52hiredmantechnomancy: dunno, I'll open an issue asking that they put a big "this is not for others to use" disclaimer on it
13:52justin_smithllasram: simiarly re: inheritance in OO, function pointers in procedural...
13:53llasramRickInAtlanta: see -- appropriately tuning exuberance
13:53llasram:-)
13:53technomancyhiredman: maybe a candidate for the default readme in `lein new` =)
13:53technomancyit checks to see if you have a user profile defined, if not, you're probably a newb, so it adds a disclaimer
13:54justin_smithwhat if we made the syntax for defining macros so bizarre and boroque that any newcomer is appropriately scared of using them?
13:54justin_smith(half joking)
13:55hiredmanjustin_smith: that is just silly
13:55clojurebotAck. Ack.
13:55llasramAnd *now* who's been drinking the Scala-water?
13:55technomancyone thing that has worked well for me is not using code written by people who are learning the language.
13:55coventry(defmacro js-defmacro [& args] `(defmacro ~@(reverse args)))
13:55RickInAtlantallasram: lol
13:55hiredmanit is an education problem, for some reason people feel like they have to use these terrible libraries
13:55hiredmantechnomancy: exactly
13:56hiredmanif a library is terrible, don't use it!
13:56technomancyunfortunately the most effective way to find out if a library is terrible is to ask on IRC, and that doesn't really scale
13:57amalloyjustin_smith: that's how scheme/racket macros feel to me
13:57hiredmantechnomancy: oh, it is pretty simple, switch your default library evaluator from "this seems ok" to "this is terrible"
13:58technomancyguilty until proven innocent; I see
13:58hiredmancode is terrible until proven otherwise somehow
13:58technomancyworks for me
13:58nztechnomancy: i wish i had done that when i started. tried too many macro-dsl things
14:00sdegutisHello.
14:03Jaoodso macros in libraries are usually frowned upon in Clojure?
14:03hiredmanno
14:03coventrynz: If you're going to keep using compojure-api, you probably want to rewrite the swaggered macro so that it does the swap! at runtime. He says he takes PRs. :-)
14:03hiredmanJaood: they are fine
14:03mdrogalisJaood: That's kind of a loaded question for this environment.
14:04hiredmanJaood: the problem is they are using side effects at macro expansion time instead of runtime
14:05Jaoodmdrogalis: ;)
14:05justin_smithtechnomancy: hiredman: the issue is that the people who will mistakenly use code made by people learning the language, are themselves new to the language
14:05hiredmanwhich means if you compile to bytecode and then run that bytecode in a different jvm, or on a different machine, the macros have all disapeared (been expanded out before the bytecode was generated) so the side effects won't happen in the new runtime environment
14:05justin_smithit is like a self-feeding vortex of ill-informed decisions
14:05technomancyjustin_smith: the only solution is a certification program.
14:05Jaoodhiredman: K, I'll keep that in mind when getting to the macros part on the book
14:05technomancyI'll get clojurebot right on that
14:05sdegutisJaood: Macros used for things that a function could handle are frowned upon.
14:06nzdoesn't korma (http://sqlkorma.com/) have similar problems?
14:07hiredmannz: dunno, I've never used korma, and can't say I particularly care for it either
14:07coventryjustin_smith: Perhaps the solution is a robot which runs eastwood on clojure libraries and reports problems to the authors of clojure code which depends on those libraries. :-)
14:07sdegutisjustin_smith: isn't that true in any language?
14:07ikitomminz hi
14:08nzhi
14:08coventrynz: I'm not aware of a similar runtime/compile-time problem in korma. The macros do make extensibility a bit hard, though.
14:08hiredmannz: I sort of suspect korma expands in to code with side effects instead of having side effects in the macros
14:08ikitommithe compojure-api global state, that's bad
14:08technomancycoventry: that would just make it harder to tell at a glance that a lib is from someone who doesn't know what they're doing though
14:08justin_smithsdegutis: sure, maybe there is a language-agnostic solution to the "newcomers find badly designed stuff and try to use it" situation
14:08oskartheastwood has keyword-typos detection? nice, I've been looking for that :)
14:09justin_smithhanging ) on a line by itself = never use said code
14:09ikitommithe whole idea in c-api was to collect the routes at compile-time
14:10gtrakikitommi: one issue I noticed was it prevents use of building dynamic compojure handlers by calling a function. I understand that's kind of hard to get around.
14:10coventrynz: e.g. of extensibility issue https://www.refheap.com/76356
14:11ikitommithe atom can be removed as a var so that the collection would be done more locally, but still in a macro
14:11hiredmanikitommi: I don't think you are understanding the issue
14:11gtrakikitommi: that use-case is enough to make me consider implementing my own ring-swagger adapter and ditching compojure.
14:12justin_smithgtrak: it is hard to get higher order with compojure in general, in my experience, we ended up making our own thing that is mostly vanilla data structures and pure functions
14:12gtrakjustin_smith: yea, I considered just gutting the pedestal routes
14:12gtrakso at least I'm not reinventing stuff
14:12Jaoodjustin_smith: does compojure has to much macro magic?
14:12justin_smithJaood: it mostly macros
14:13justin_smithJaood: it is well made!
14:13hiredmanikitommi: macro expansion happens before compilation, after compilation you just have the emitted byte code
14:13justin_smithI just wanted something that was more functional
14:13ikitommigrtak - I agree, the route resolution is kind of hacky, would be better to do same for bidi for example
14:13justin_smithhttps://github.com/caribou/polaris
14:13gtrakit's just a shortcoming of compojure, not your fault.
14:13gtrakdata as code, unfortunately.
14:13justin_smithpolaris was the lib we made based on vanilla datastructures and function composition (still in progress mind you, but I think it is a good starting point for a more function oriented approach)
14:13hiredmanikitommi: if you aot compile clojure, all you get is the emitted bytecode, so when you run the aot'ed code, there is no macroexpansion -> compilation -> run bytecode, it just runs the bytecode
14:14hiredmanikitommi: which means https://github.com/metosin/compojure-api/blob/master/src/compojure/api/swagger.clj#L208 never gets run in that case
14:14oskarthHm. Is it bad from to have tests which check if the correct exceptions are being raised? eastwood wouldn't run with it.
14:15amalloyJaood: compojure, mostly macros??? the only ones that have functionality you can't easily get from functions are like GET, POST, and so on, as far as i'm aware
14:15amalloyer, meant to address justin_smith
14:15ikitommihiredman - that's true. do you know how the routes shoud be collected
14:15ikitommiwithout aot it "works", but is wrong.
14:16justin_smithamalloy: "mostly macros" was overstated - but once you start using functions instead, you don't end up using much of compojure's code actually
14:16hiredmanikitommi: use a richer abstraction than function composition
14:16justin_smithamalloy: the real dealbreaker was wanting to define routes based on db data at runtime
14:16ikitommibut to have static routes, one could persist the routes elsewhere, into a file? (still macro doing side effects)
14:16hiredmanikitommi: compojure defines routes via function composition, but you want function composition + extra information
14:17coventryamalloy: Thanks for the +' tip.
14:17gtrakthe function composition isn't necessary, I'd rip out the routing and keep the destructuring.
14:18amalloycoventry: you're welcome. i've edited the question to suggest it
14:18gtrakplus there's some rendering on the result, but whatever.
14:18ikitommihiredman: asked from weavejester about setting the meta-data to the compojure functions, but that's also hard as all functions in the route tree should be meta-data aware
14:19gtrakit was a nice interface to start with, but we're already hitting the limits.
14:19hiredmanikitommi: oh, no, don't use compojure
14:19hiredmanikitommi: metadata on functions sucks, I really recommend avoiding it
14:20justin_smithamalloy: I am double checking the compojure code - if you are not using the route-defining macros, there is not much else offered. It is well designed, but for dynamic generation of routes it is more hinderance than help.
14:21gtrakjustin_smith: there's the render-response protocol.. I've abused that a couple times. (reminds me of our conversation from yesterday)
14:21justin_smithgtrak: about protocols for carrying status / varieties of error?
14:21gtrakyea, for instance, I extended it to numbers for just a quick '200' or something.
14:22amalloyfor dynamic generation of routes, sure, that's probably true. i don't think it wants you do to that
14:22gtrakit's janky around maps, b/c ring is maps.
14:22hiredmanikitommi: there are other routing libraries that may provide something richer (maybe pedestals, or something else)
14:22ikitommihiredman: ok, but someone should do a good web route/endpoint lib for clojure then. I have liked Compojure as it's not in the way
14:23ikitommihiredman: should be trivial to resolve routes from bidi ;)
14:23agarman@amalloy et al: we're pulling compojure out of our code because we no longer using its route generators
14:23ikitommihttps://github.com/juxt/bidi that is
14:23gtrakagarman: what are you using instead?
14:23agarmangtrak: ring + httpkit
14:24gtrakah. I'd like to investigate ripping out the pedestal routes.. didn't seem like it would be impossible.
14:25amalloyoh man. i've always wanted to be part of an et al
14:25amalloyi've finally made it as a grown-up
14:25ikitommi.. but for the compojure-api limitations. I agree they are there and should be fixed, but the AOT-problem is listed in the readme.
14:25gtrakikitommi: fwiw, it's impressive to me the deep-walking works for static routes :-)
14:26ikitommiI guess the only clen solution would be to have a leiningen plugin etc. to peel the routes. not the macro. but would be extra step in developing it
14:26ikitommigtrak: thanks!
14:26agarman@gtrak we're also considering bidi or gudu
14:27ikitommi.. and the macros on top of compojure-route-macros get peeled currently twice, once in peeling and another time with the real expansion.
14:28justin_smithagarman: bidi looks pretty cool, and many common elements to what we are trying to do with polaris
14:30justin_smithoh, oops, ^ above was for ikitommi
14:30ikitommihiderman: and the "custom clojure.walk" is the vanilla one from 1.6, which supports records.
14:30whodidthispolaris would be cool for cljs too
14:30justin_smithwhodidthis: I should double check, but I think it should run under cljs
14:31ikitommijustiin_smith: polaris looks cool too.
14:31whodidthisi dont think theres clout for cljs yet
14:32coventryikitommi: I think the problem with your inclusion of clojure.walk that you didn't change the ns for it, so it's going to blow away or be blown away by the one which ships with clojure.
14:33justin_smithwhodidthis: hmm... if you want to make an issue on polaris requesting cljs compat - I may just find time to integrate that
14:33ikitommicoventy: true, will change that.
14:34justin_smithwhodidthis: looking at clout, it is small (I like this about weavejester's stuff, it is small while providing good functionality), so adapting or replacing it for cljs should be straightforward
14:34whodidthisoh, cool
14:35sdegutisClojure is great, but when it comes down to needing to manipulate deeply nested complex types, wouldn't mutability and imperativity be more suited to the task?
14:35justin_smithsdegutis: clojure can do those things when you need them
14:35justin_smiththey just aren't the default
14:36coventrysdegutis: https://www.refheap.com/76363 :-)
14:36sdegutisjustin_smith: Ah good point. Although having compile-time type errors also dramatically helps in this area, which isn't built into Clojure.
14:36sdegutiscoventry: touché
14:36gtraknested atoms is not going to be the thing you want :-)
14:36justin_smithsdegutis: well, when you move the goal post, it will be hard to score a point
14:37sdegutisjustin_smith: Thank you for the analogy I have not heard it before.
14:37gtrakI think zippers is supposed to address this?
14:37justin_smithsdegutis: really? it is a term of the art in rhetoric
14:37sdegutisI am not very cultured.
14:37sdegutisAlthough my yogurt is.
14:38amalloyzippers...zippers are a fantastic and exotic data structure, and they sound super-sexy, but in practice you need them so rarely
14:38justin_smithsdegutis: https://www.google.com/search?q=moving+the+goalposts&amp;oq=moving+the+goalposts
14:39gtrakfor really deep structures, is there a better alternative? (I haven't had to use those, but I've written a couple of recursive algorithms instead that I think my coworkers hate me for :-)
14:40amalloyrecursion. like, "really" deep doesn't matter at all. a tree of depth 100 is not fundamentally any different from a tree of depth 5
14:40coventrygtrak: Just use a deeply nested map in an atom, and do (swap! a update-in [:path :into :it] manipulation-function).
14:40gtrakessentially an update-in that branches through arrays.
14:40gtrakarrays in this case being seqs/vectors..
14:40sdegutisgtrak: maybe atoms with update-in?
14:40Jaoodisn't it more of a performance issue?
14:41coventrygtrak: update-in's path argument can take an index into a seq/vector.
14:41sdegutisgtrak: but I don't know what you're trying to do here, so maybe atoms with update-in won't be suitable for your needs. Sorry.
14:41gtrakcoventry: that sucks :-)
14:41gtrak{:a [{:b :c} {:d :e} {:f :g}]} you don't know the size ahead of time.
14:42gtraksure, you could use map/update-in.. whatever.
14:42gtrakI don't think that helps.
14:42sdegutisgtrak: update-in with atoms would be better
14:42justin_smithcoventry: index into seq?
14:42amalloy(update-in deep-map [:a] update-each update-in [:x] inc), where update-each is a function you write that's basically map with reordered args
14:43gtrakmy approach just takes a path and branches appropriately. just the initial data has to be the correct shape.
14:43gtrakcorrect in terms of your data model.. the algo doesn't care.
14:43gtrakbut still, the code's a bit hard to read :-)
14:44ikitommijustin_smith: there is a demo of ring-swagger with fnhouse, should be quire similar for polaris - https://github.com/metosin/fnhouse-swagger , without any macro-hackery.
14:44gtraknot sure if cascading update-in/map calls is any better.
14:44justin_smith,(do (println (update-in {:a [0 1 2]} [:a 1] inc)) (println (update-in {:a (list 0 1 2)} [:a 1] inc))) ; coventry
14:44clojurebot{:a [0 2 2]}\n#<NullPointerException java.lang.NullPointerException>
14:44amalloyjustin_smith: seqs don't act like indexed structures
14:45justin_smithamalloy: that was regarding coventry's claim that update-in could index a seq
14:45gtrakthen I also wrote nest and unnest, which assembles/disassembles these things.
14:45coventryjustin_smith: Oops, you're right.
14:46justin_smithikitommi: wow, I had not seen fnhouse either, so many ways to skin this cat!
15:11brunovHrm. Avout (https://github.com/liebke/avout) looks very enticing, but it doesn't seem to be actively maintained.
15:11justin_smithit is cool, but watches don't work
15:11brunovAnyone here have used it and can vouch for it?
15:12justin_smithif you don't need add-watch, I can recommend it
15:12justin_smithie. if your semantics can work as pull as opposed to push
15:12justin_smithor if you can split off a separate non-avout push layer
15:13benkay`has anyone else run into "could not locate leiningen/exec__init.class" errors when using lein-exec to run clojure scripts?
15:13devthbrunov: can't vouch but looks interesting. also seems pretty legit
15:14brunovjustin_smith, devth: Thanks. I think I can do without watchers. I was basically worried about two of its unattended bug reports.
15:15brunovone about watchers, the other about atoms...
15:16justin_smithbrunov: I used it successfully to share coordinated state between hosts
15:16justin_smithbrunov: I would not have seen the atom issue, because if no other host is running, the first one creates the state
15:16justin_smithand the others reference it
15:17justin_smithI would not use avout for persistence between runs, only coordination between servers that are running
15:17brunovjustin_smith: I see. I'm thinking of a similar use case, so that's good news.
15:17justin_smithbecause we have things like sql for long term state, that is not avout's thing
15:18brunovRight. I'm also thinking of using it for coordination between running hosts, not for persistent state
15:18justin_smiththen yeah, avout is cool, I recommend it
15:18brunovgreat, thanks justin_smith
15:18justin_smithnp
15:21seangroveWhat's the best way of integrating other git repos as sub-repos? gitmodules? Are those dead now?
15:26gtrakgithub can handle that, I remember a project using it somewhere
15:29sdegutisLook let's just take a vote of what the best way to define a new type in Clojure is, and agree to discontinue all the others.
15:29gfrederickssdegutis: definitely gen-class
15:30llasramouch
15:30coventryDon't you define them in scala and then import them?
15:30coventryIt has types, after all.
15:30sdegutiscoventry: you mean jruby?
15:30gfredericksclass Clojure::Base; end
15:31gtraktypes are just keys in a global map. let's reify the JVM instead.
15:31gtrakdesign by decoupling and all that
15:33sdegutisgfredericks: heh, class Clojure::Controller::Base; end
15:34gtrakif by interop you mean we modify your bytecode.
15:34gfredericksclass ClojureScript::Base < Clojure::Controller::Base
15:35gtrakany class that calls into clojure gets modified, because they probably didn't think through their design enough.
15:36sdegutisgfredericks: just wow
15:36sdegutisgfredericks: so accurate
15:37ikitomminz, hiredman. quick patch to support the AOT: https://github.com/metosin/compojure-api/commit/47b896b4b808e29fc9c3129d14a9a3741659e411
15:38ikitommiwill clean up the surroundings with better time.
15:39ikitomminz: ping me, if there's some more weird stuff. will try to fix 'em all :)
15:39nzikitommi: thanks
15:40ikitommiI'll push that to clojars, no tests for the AOT-uberjarring, but works now fine locally. and the clojure.walk has been renamed.
15:40coventryikitommi: That (do) will return the last entry in body. Is that how it's supposed to work?
15:40nzthere where some issues with multilevel schemas {:foo {: bar 1 :baz 2}} kind. for example subschemas do not keep order
15:41coventryikitommi: Maybe (routes body) or (concat routes body)? Not sure what routes is.
15:42ikitommicoventry: true.
15:43nzikitommi: i'll try to make issues to github about them tomorrow
15:43ikitomminz: thanks
15:46oskarthFrom Joy of Clojure on reference types. "Retriable indicates that the work done to update a reference's value is speculative and may have to be repeated" - what does this mean exactly?
15:47nzoskarth: new value for reference may be calculated several times
15:47mdrogalisoskarth: It means transactions can be aborted and tried again.
15:47mdrogalisnz's wording is better.
15:48oskarthbut it will still happen, no?
15:48oskarthjust that the update has to be idempotent
15:48nzyes
15:48gtrakoskarth: generally they say 'no side-effects'
15:48nzdoesn't have to be idempotent
15:48mdrogalisoskarth: Little experiment you can do - have a handful of threads try to update a ref, and put a println inside the transaction.
15:49oskarthI see
15:49oskarthmakes more sense then, thanks :)
15:49gtrakidempotent might not be quite right, generally if there's a retry it's because the input has changed.
15:49nzor atleast side-effects shouldn't cause problems if they are executed several times
15:50gtrakie a transaction completes, changing the ref's value, which changes the input to further transactions.
15:50oskarthI think it's the word "speculative" which confused me
15:50gtrakref-set! won't have this issue.
15:50oskarthseemed to indicate that it might not happen to me
15:50gtrakerr wait, is ref-set! a thing?
15:50oskarth,(doc ref-set!)
15:51clojurebotNo entiendo
15:51gtraknope.. sorry :-)
15:51amalloyref-set
15:51oskarth,(doc ref-set)
15:51clojurebot"([ref val]); Must be called in a transaction. Sets the value of ref. Returns val."
15:51ikitomminz: 0.10.3 now at clojars
15:51bbloomdnolen_: elm debugger is looking pretty cool http://debug.elm-lang.org/
15:52nzoskarth: work/calculations will happen at every update attempt, but ref may not get updated at that attempt, thats the speculative part
15:53oskarthI see
15:56ToBeReplacedhow would i create a ComponentSet? i want that when i start {:dep foo :items #{(using {} [:dep])} that i get {:dep foo :items #{{:dep foo}}}
16:00coventryToBeReplaced: How could (using) know about foo?
16:00blake__Is there anything like this for Clojure? http://debug.elm-lang.org/
16:00nzikitommi: i tried 0.10.3, works for me with aot
16:02ToBeReplacedcoventry: it couldn't, unless i manipulated the metadata on the set, maybe
16:03ToBeReplacedcoventry: probably stupid idea... i'm just dreading changing a bunch of code to direct calling; i'm sure i'll be happier in the end if i do that anyway
16:03dnolen_bbloom: yup checked that out earlier today
16:07technomancythis is good stuff http://artyom.me/learning-racket-1
16:07technomancywould be interesting to see that stream-of-consciousness type treatment for clojure
16:10blake__I could do that, but I'm a few months into learning already.
16:11blake__I could probably still do it usefully.
16:11technomancyI like how this guy doesn't get more than a few pages in before complaining about lack of egal =)
16:12technomancyblake__: or something more specific, like compojure or lein
16:14blake__technomancy: That's not a bad idea. So far, I'm deliriously happy with lein (coming from rvm/rbenv) but I need to tackle compojure, too.
16:14technomancyblake__: glad to hear it. the lein bug tracker is always open for usability suggestions too though =)
16:15seangroveCSS and JS, there's just so many things wrong
16:16bbloomseangrove: what's wrong now?
16:16bbloomalso, seangrove, where's my time traveling debugger?
16:16blake__technomancy: I'll keep that in mind. Prior to Ruby, I was doing Delphi, Smalltalk and Python, which are all different beasts as far as reusing code.
16:16bbloomthe elm guy has it. aren't you finished yet?
16:16seangrovebbloom: It's on the way, on the way. Just solving the other 3 fundamental problems with frontend dev first
16:17seangroveThe ocean's almost boiled...
16:17blake__bbloom, seangrove: Oh, you guys had seen the elm thing already? =P
16:17bbloomseangrove: ok, well when you do finish, travel back in time to now so i dont ahve to wait for it
16:18bbloomseangrove: i'm curious what nonsense you've run in to now thanks to our friends at the W3C
16:20seangrovebbloom: Remind me to tell you whenever we chat later. I thought of a hack, but basically it comes down to the fact that CSS/JS are separate, but not really, and I can't import CSS into a CSS 'namespace'
16:20bbloomheh ok
16:20seangroveI have to pre-process the thing somewhere else to get the textual representation right before loading it in the browser :P
16:21devnwow. claypoole is so awesome.
16:24gfredericksreiddraper: any known gotchas with writing a gen-double? I'm thinking of doing it
16:25`szxseangrove: saw your tweet on gridstylesheets.org (first match for "reactjs gss" =D), have you had a chance to give it a try yet?
16:25reiddrapergfredericks: just the question of how floats should shrink
16:26reiddrapergfredericks: see: https://github.com/reiddraper/simple-check/issues/36
16:27gfredericksreiddraper: oh nice thanks
16:27reiddrapernp
16:29wunkiI'm trying out the component library by Stuart Sierra, anyone know how to call `stop` when you press CTRL-C?
16:29sandbagstechnomancy: do you have time for a Q about transitive dependencies and locally installed jars?
16:31technomancysandbags: sure
16:31sandbagstechnomancy: thanks. so i have a lib i made that is installed locally (rather than say clojars) that has a dependency on com.stuartsierra/dependency (ironically enough)
16:32sandbagstechnomancy: in an app i made a dependency on my library, but the transitive dependency doesn't seem to be made
16:32sandbagslein deps :tree on the app doesn't show "depdendency" as a dependency and the code fails because it can't find Stuarts lib
16:32sandbagsi'm assuming this should work fine, any ideas why it might not?
16:33sandbagsthe workaround is to dep on the dependency lib in my app as well
16:33technomancyit must be that you're depending on a version that doesn't have the com.stuartsierra/dependency dep declared
16:33technomancylocal/remote makes no difference unless it's a snapshot
16:33gtrakwunki: what's CTRL-C in this context? you can add a shutdownhook: http://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#addShutdownHook(java.lang.Thread)
16:33sandbagstechnomancy: i don't think so, i rejarred and reinstalled and i still have the problem
16:33sandbagstechnomancy: however, i'll make a new version to be absolutely sure
16:34technomancyyou can always peek at the pom inside ~/.m2
16:35wunkigtrak: yes, the shutdown hook indeed. Just found my problem, need to run `lein trampoline run` instead of `lein run`
16:35sandbagstechnomancy: dependencies should be inside the pom?
16:36technomancysandbags: yeah, that's the canonical place
16:36sandbagsif so then that's my problem... i just made a new version and the dep isn't in there
16:37sandbagsi'm using "lein jar" is that a problem?
16:37sandbagsi assumed that i didn't need uberjar as I don't want the dependencies packaged *in* my lib
16:37sandbagsor maybe i've misunderstood what uberjar does
16:38technomancysandbags: you should be running `lein install` on your lib if that's what you mean
16:38technomancyor do you mean for the app?
16:39sandbagsokay so in my lib, i am using "lein jar" to create a jar of the lib, and then "mvn install:install-file" to install it locally
16:39sandbagsi cobbled that procedure together from google
16:39technomancyok, that won't work
16:39sandbagscheck
16:39technomancylein install is the way to go
16:39technomancycurious why you went that route?
16:40sandbagstechnomancy: like i say, i googled for how to install a lib locally and that's the only thing i found
16:40sandbagspossibly a google operator fail ;-)
16:40technomancyhm... I guess there's not much we can do about that if google is giving crap results
16:41sandbagsi must get in touch with ryan thingammy so my approach doesn't go into the Clojure cookbook!
16:42technomancyhehe yeah
16:42technomancyor if it's a blog that recommended mvn install:install-file you could leave a comment or something
16:48gfrederickswhat does {:aot :all} do exactly?
16:49gfredericksoh nevermind my problem is unrelated
17:28bbloomi'm manually converting some code from continuation passing-style to direct-style... i'm having javascript flashbacks
17:36bbloomor should i say callbacks...
17:37gfredericksany guesses why future would throw a java.util.concurrent.RejectedExecutionException?
17:38gfrederickslooks like the thread pool executor might have 0 thread? o_O
17:38justin_smithstackoverflow.com/questions/19003430/what-are-the-possible-reason-for-a-java-util-concurrent-rejectedexecutionexcepti
17:38justin_smitherr
17:38justin_smithhttp://stackoverflow.com/questions/19003430/what-are-the-possible-reason-for-a-java-util-concurrent-rejectedexecutionexcepti
17:39justin_smithgoogle-chrome-beta just changed it's X11 select / middle-click behavior
17:40gfredericksoh I prollably shutdown the agents didn't I.
17:40gfredericksyes I most certainly did.
17:44technomancyhttp://p.hagelb.org/shutdown-agents.jpg
18:05guest234245yogthos: just want to say thanks for making cljs-ajax
18:06prasincsis there an easy way to throttle/batch http connections on client side with clj-http?
18:08brunovprasincs: I wrote this just for that purpose: https://github.com/brunoV/throttler
18:09se_Any tricks for speeding up jvm startup on the raspberrypi? just running time lein help takes 2.5 minutes.. (running java 1.8.0)
18:09brunovse_: take a look at drip
18:09justin_smithse_: you could make an uberjar on a more powerful machine
18:10brunovse_: https://github.com/ninjudd/drip
18:10justin_smithbrunov: the jvm won't be the issue here though, clojure has expensive startup
18:10brunovjustin_smith: uhm, true
18:11se_brunov, justin_smith: thanks, will give it a try, if it's clojure that takes the most time, then i'll test out the uberjab route first.
18:12justin_smithse_: I've seen amazing differences in startup time when using uberjars, even on full powered desktop machines
18:16hiredmanjustin_smith: uberjars or aot?
18:16se_justin_smith: yeah, you're right, now we're talking 28 seconds, not several minutes..
18:16justin_smithhiredman: good point, this was an aot'd uberjar
18:16justin_smithse_: cool
18:17justin_smithse_: is this with aot?
18:18se_without (default is without, right?), will try aot now
18:18justin_smithse_: unless you have :aot in your project.clj or gen-class I think without is default, yeah
18:24justin_smithbrunov: that throttler lib is cool
18:24brunovjustin_smith: woot!
18:25akhudekhmm, I see now why dnolen_ didn’t make an om set cursor, state doesn’t work quite right with it :-(
18:26justin_smithbrunov: about the deps, does it really need criterium outside the dev profile?
18:26brunovjustin_smith: shoot, good catch. It doesn't!
18:27justin_smithalso, seems funny to have c.math.numeric-tower as a dep when all you need is round
18:28brunovwould you have just reimplemented/inlined round?
18:28brunovI could do that.
18:28justin_smith,(Math/round 1.5)
18:28clojurebot2
18:29brunovhahaha
18:29justin_smithjava can do that - unless you need the numeric tower support
18:29brunovno, you're right
18:29brunovhead, meet desk
18:29justin_smithanyway, original point stands, great idea for a lib
18:30brunovthanks :) I'll incorporate your suggestions now, thanks for taking a look
18:30justin_smithand looks good - I just have these projects that are way too huge so I always have default "how to remove deps" glasses on
18:31brunovthat's a good default to have IMO
18:31brunovjar bloat is a real thing
18:31justin_smith,(Math/round (/ 7 3)) ; the gotcha to look out for with the jvm round
18:31clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: round>
18:32justin_smith,(Math/round (double (/ 7 3)))
18:32clojurebot2
18:32brunovaah
18:32justin_smithbut since you are rounding anyway, the double coersion should be harmless
18:32brunovwould type hints also help in this case?
18:33justin_smithno, needs the coercion I think
18:33brunovI see
18:33justin_smith(defn round [n] (Math/round (double n)))
18:33justin_smitheasy as that really
19:01frozenlo`Anyone else getting errors with postal/mailer? IllegalArgumentException No implementation of method: :eval-part of protocol: #'postal.message/PartEval found for class: nil clojure.core/-cache-protocol-fn (core_deftype.clj:541)
19:16justin_smithfrozenlo`: looks like the input to the function was misformatted - do you have a full stack trace?
19:18frozenlo`Sure... I just have to remember how to enable it in Cider. Brb
19:18justin_smithclojure.repl/pst will show the stack for the most recent uncaught exception
19:19justin_smiththen you can share it via refheap or a github gist or whatever
19:21frozenlo`justin_smith: https://www.refheap.com/76421
19:32timsgHey all, I’d like to write an implementation of a bare-bones REPL using clojure.main, but I’m having trouble finding minimal examples or instructions on how to do so. Does anyone know of such resources?
19:33justin_smithtimsg: clojure.core/read clojure.core/eval and clojure.core/print should be the important bits. Are you doing this as a learning exercise I assume?
19:37hiredmanprn
19:38timsgjustin_smith: I’m working on embedding a Clojure repl in Unity. I’d also like to improve an old Mathematica-Clojure interop library I’ve been using. Evaluating forms is straightforward, but error handling and some other things (eg in-ns) seem to require more robust support. Clojure.main looks like the way to , and I can figure out how to use it through trial and error, but it would save a lot of time there were a small existing exampl
19:38timsgits use.
19:41justin_smithtimsg: I don't know of a tutorial or example, but I'd assume the code to clojure.tools.nrepl would be very informative
19:41justin_smithhttps://github.com/clojure/tools.nrepl
19:41justin_smithyou may even want to build on nrepl
19:45timsgjustin_smith: yeah, maybe I should just spelunk nrepl. looking through it now
21:15seangrove`szx: Sorry for the delay, GSS + react work well together. GSS is a bit finicky in that it's like Apple's constraint system - a low api surface area, but conceptually takes some effort
21:22`szxseangrove: i guess that's to be expected since it's the same algorithm
21:22`szxany idea what the performance is like? particularly on mobile?
21:23seangrove`szx: Yeah, but a lot of people in the iOS/etc world don't get that :P
21:23seangrove`szx: No idea on mobile. Perf. like you'd expect on desktop: good, not amazing
21:23seangroveThere aren't the right hooks to do it properly in the browser like there are on other platforms
21:24`szxright
21:25`szxwell, i've just about had it with CSS so i think i'll give it a shot and see for myself
21:25seangrove`szx: Oh, sorry, actually it's fine. I'm specifically talking about resize events
21:25seangrove`szx: Yeah, just about to take on porting a layout system over, it's the next big project on the list
21:26seangroveI think we've just about 'solved' the component problem, along with event propagation (up) and property synth (down)
21:26seangroveI take credit for all ideas, as usual. Amazing inspiration and invention.
21:26`szxhaha
21:26`szxlooking forward to seeing it
21:27bbloomseangrove: i'm happy to get an honorable mention as long as i don't have to do all the work :-)
21:31seangrovebbloom: You could meet me half-way and port Auckland to cljs so I don't have to, and I could just, ya know, use it.
21:31bbloomseangrove: do you have a good cljs interface for a constraint solver?
21:31bbloomseangrove: or do i need to implement a constraint solver too? :-P
21:32bbloomnot that i have bandwidth for either of those tasks...
21:32seangrovebbloom: Hoping (hoping) that I can piggieback off of some js lib
21:32bbloomseangrove: i couldn't find a sane linear constraint solver for js when i looked
21:33bbloomseangrove: mutable cluster fuckery, to say the least
21:33jcromartielinear constraints seem like a great candidate for persistent data strucutres no?
21:33seangroveI'll get upset about it when I come to it, it's next on the list
21:33bbloomjcromartie: yes.
21:33jcromartiesounds like fun
21:34bbloomjcromartie: although the "cassowary" algorithm is only really fleshed out in a mutable variant. i dunno if there is a good persistent version of the algorithm, although one could probably invent it w/o much difficulty from the original paper
21:34bbloombut ugh. the least bad impls i saw were like OOP nightmares
21:35bbloomthe core of the algorithm w/ extra features is a few hundred lines of code tops... yet there's thousands of lines of getters and setters
21:35bbloominsane
21:35bbloomported from java, i believe
21:39seangrove"ALM is currently implemented for .NET, Java and Haiku. We will port it to other platforms if there is a popular demand."
21:39seangroveOne of those platforms is not like the other.
21:39bbloomhaha
21:40bbloomi was referring to the cassowary backend
21:40base698seangrove: alm?
21:40bbloomyou don't want the ALM code anyway, it's not interesting to us at all
21:40base698I worked on something called alm many moons ago
21:40seangrovebbloom: Oh, yes, but I was just taking a look at the code, thought it was time to feed my subconscious with more than the high-level ideas
21:40bbloomseangrove: the important part is the ideas; you really don't want their addRow addColumn OOP api
21:40bbloomyou just need the backing solver
21:41seangrovebase698: Layout manager?
21:41bbloombut even that you can punt on it
21:41base698nah project management tool
21:41bbloomjust start with fixed size grid cells & go with that for now. add the solver later
21:41bbloomsupport like N pixels, M percent, and fill-remaining
21:41bbloomhack that in, and move back about your day :-P
21:42seangrovebbloom: Interesting. Probably ready to talk to you about this soon, everything else is in place, and the components are in an excellent data structure to have layout dictated from above
21:42seangroveThen I can remove layout from the components, and components will be finally reusable
21:43bbloomlookless components == awesome :_)
21:43seangroveStructure, layout, texture, state, behavior, all separate
22:05lannycan someone look at my project.clj and tell me why lein profiles hate me: http://pastebin.com/d51YNNT8
22:05technomancylanny: you have :profiles in there twice
22:06technomancyhttps://github.com/technomancy/leiningen/issues/1471
22:06lannywow, embarrassing, but thanks!
22:06rplacaQuestion: is there a way to interrupt running clojure code such that it throws an exception and generates a stack trace? I'm under cider, but I don't need to be.
22:06technomancynp
22:08ivanrplaca: C-c C-c or C-c C-b
22:09rplacaivan: that interrupts it, but it doesn't give me a stack trace
22:09rplacaI'm trying to find out what a big pile of libraries is waiting for
22:10ivanyou can (pst) or do something different if you want to see a CIDER stacktrace buffer
22:10ivanor does that not include the hanging thing?
22:11rplacaivan: yeah, there was no exception thown, so no stack trace
22:11rplaca*thrown
22:11rplacaI'm trying to get it to inject an exception so I can do the (pst) :)
22:11ivanoh I see
22:13ivanrplaca: you might try using visualvm and hitting the thread dump button
22:14rplacawell, I tried throwing it a segv, but that just crashed. I'll eat my dinner and try some other sigs after dinner
22:14rplacaivan: oh, good idea, I'll try that. Thanks!
22:33amalloyrplaca: there are tools in the jdk for that. jvisualvm, or jstack
22:35hiredmanif you have a repl you can get stacktraces for all threads from a static method on Thread
23:00rplacahiredman, amalloy: thanks!
23:23zRecursiveIs clojure based on Common Lisp or Scheme ?
23:24zRecursivenoob question :)
23:24scottjzRecursive: http://clojure.org/lisps
23:24zRecursivescottj: thanks
23:29zRecursiveso many differences, it is better to regard it a new language :)
23:29arrdemzRecursive: probably...
23:32derek_chow do you simulate condition variables in clojure? I need a thread (future) to wait until a certain condition becomes true