#clojure logs

2016-04-07

01:02asdf12z_seems hard to learn clojure coming from a no experience in java background
01:03asdf12z_like i'm so confused seeing ring with java servlet or jetty.. and it comes default with servlet setup but i see guides using jetty?
01:04asdf12z_so i should use jetty for both dev & production?
01:40kenrestivodepends on what you mean by production. for small sites, why not?
02:07asdf12z_for workflow, working on a web app to play with, right now i'm tabbing to my browser, refresh, then tab back to editor, anything better?
02:07asdf12z_for minor changes i can test with the repl i test a function there of course
02:08asdf12z_not sure what else i can do to improve the workflow except have the browser auto refresh, is that basically what everyone else does?
02:10asdf12z_and if you guys have a auto refresh, what do you guys use that works good with clojure, emacs
02:43renlhi if i have a super long regex pattern #"blah blah blah blah..... blah" can i break it into multi line for readability? how can i do it?
02:46ridcullyrenl: if nothing better comes up, you could use (re-pattern (str "1" "2 "3))
02:47renli tried that but if I have #"\d" when i use str do i have to do \\d instead?
02:49renlor how do i escape the \d in the str
02:56ridcully,(re-pattern (str #"\d" #"\s" #"\d"))
02:56clojurebot#"\d\s\d"
02:56ridcullywell seems to work... but i don't know about the implications
03:00TEttinger,(re-find (re-pattern (str #"\d" #"\s" #"\d")) "hey 1 2 woo")
03:00clojurebot"1 2"
03:00TEttingerseems to work ridcully
03:00TEttinger,(re-find (re-pattern (str #"\d" #"\s" #"\p{Nd}")) "hey 1 2 woo")
03:00clojurebot"1 2"
03:00TEttinger,(re-find (re-pattern (str #"\d" #"\pZ" #"\p{Nd}")) "hey 1 2 woo")
03:00clojurebot"1 2"
03:01dysfunasdf12z_: there is ring-reload which works quite nicely
03:02dysfunasdf12z_: jetty is fine for deploying to production. it is a full-featured well-tested webserver. that said i prefer aleph which is based on Netty, not Jetty
03:03renlah ok thanks :D didnt know str can work with #"" itself
03:05ridcullyTEttinger: yeah, but my fear here is around Pattern.toString(), if this is solid
03:06luma"Returns the string representation of this pattern. This is the regular expression from which this pattern was compiled."
03:08TEttinger,(re-find (re-pattern (str #"\\\\" #"\pZ" #"\p{Nd}")) "hey \\\\ 2 woo")
03:08clojurebot"\\\\ 2"
03:08TEttingerclojurebot escapes backslashes too
03:09TEttinger,(re-find (re-pattern (str #"\r\n" #"\pZ" #"\p{Nd}")) "hey \r\n 2 woo")
03:09clojurebot"\r\n 2"
03:09TEttingerunsure what cases could break this
03:09dysfunwhat's \pZ ?
03:09TEttingerunicode whitespace category
03:09dysfunah
03:09TEttingeroddly not the same as \s
03:10dysfunthere are actually very good reasons for that
03:10dysfunand there are good reasons to use [0-9] instead of matching all digits
03:10TEttingerNd is decimal digits in any language
03:11TEttingerI don't think you can parse an int by default from a roman numeral
03:11dysfunit would be a bit of an easter egg feature if you could
03:12TEttingerperl6
03:12dysfunoh look. https://www.python.org/dev/peps/pep-0313/
03:12TEttingerthey support the absolute latest version of unicode I think
03:13dysfunthey do. many of my friends are core perl6 hackers
03:13TEttingeradding Roman
03:13TEttinger numerals to Python will help ease the LISP-envy sometimes seen in
03:13TEttinger comp.lang.python.
03:14dysfunlove the BDFL pronouncement on there
03:14TEttingerah, april 1
03:14dysfunyup
03:14tdammersit will also increase the INTERCAL envy
03:15TEttingergood ol' intercal
03:15dysfunbut it doesn't have anything as advanced as roman numerals does it?
03:15tdammersit does
03:15TEttingerit has COMEFROM
03:16TEttingerwhich apparently is analogous to aspect-oriented programming
03:16tdammersCOMEFROM is just a syntactically reversed GOTO
03:16TEttingerheh just
03:17tdammersinstead of :label / GOTO :label, you write COMEFROM :label / :label
03:17TEttingerany part of the program could be redirected to a COMEFROM at any other part
03:17tdammersit's incredibly simple for such an effective mindfuck
03:17tdammerswell, the same goes for GOTO
03:17TEttingerother way around
03:17TEttingeryou can only redirect when you see a goto
03:18tdammersand you can only redirect to a label
03:18TEttingeruh
03:18TEttingerdoesn't INTERCAL have line number labels, like old BASIC?
03:18TEttingeralso politeness levels
03:19prohoboGOTO is a special kind of hell
03:20tdammersprohobo: more like, GOTO is too low-level for the human brain to use effectively
03:20TEttingerthere's cases where it's extremely handy, i believe there's a handful of uses of it in my large C# codebase (there's notably no way to go between cases in a switch without goto in C#)
03:20prohobobut it ruins code structure
03:21prohoboand tdammers uhh yeah... thats why people don't code using 1's and 0's either
03:21TEttingerC# made some weird choices related to goto
03:21tdammersit's useful in some situations in C when you need to optimize to the max
03:22tdammerscomputed goto is often more performant than "proper" control flow
03:22TEttingerespecially since that's close to what it would compile down to at the assembly or machine code level
03:23tdammersyes, that's the main reason
03:23tdammersother control flow abstractions introduce more overhead
03:36renl,(read-string "011")
03:36clojurebot9
03:36renlwhy is "011" read as 9?
03:37spdvcsit's octal
03:37dysfuntdammers: it's extremely useful for optimising generated code
03:38dysfune.g. tail recursion optimisation
03:38tdammersdysfun: that, too - and since it's generated, you can build the safety into the generator
03:38dysfuni did laugh when php implemented goto somewhere in the 5 series
03:39dysfunat least with other languages having it, it's always been there
04:08qsysare there any evolutionary algorithm (or other heuristic algorithms) for optimization in clojure? I know about incanter, but there doesn't seem to be any 'heuristic solve' package/lib.
04:09qsysI have to partition an large number (about 500 000) items over about 60 buckets. There is a fitness for each bucket per item, a max number items per bucket, a max number of items per group of buckets, ...
04:12mokusoYou could perhaps implement a genetic or stochastic (such as stochastic annealing) algorithm yourself...Haven't looked into optimization libs in clojure yet. But since few use it for numerics, from my knowledge, there shouldn't be many
04:12mokuso(if any)
04:13mokusonot sure if you want to use strictly clojure, but if you don't have to, you could try the GA library in R
04:13qsyswell, that's option 3: implementing myself... option 2 may be using R (if fast enough).
04:14mokuso:>
04:14qsys;)
04:14qsysthx... I'll go with R for this one
04:14mokusohave fun ;>
04:14qsysif performance is rather poor, I might switch to clojure, hoping it's faster...
04:14qsysthx!
04:15mokusocheers
05:45ulrichschinzhey there
05:46ulrichschinzhow can i assure that items in an [] are in the ordere they were added?
05:47winkthat does not sound useful. why would they change unless you change them?
05:47winkand then it's a different []. technically
05:48dysfunif it's a vector, they're always in the order they were added
05:48dysfunit's a defining property of clojure's vectors
05:50tdammersulrichschinz: if you write vector literals, the order of items is the order in which you write them
05:50ulrichschinzok
05:50tdammersulrichschinz: if you construct vectors through functions, e.g. cons, then the semantics of those functions tell you where elements are added
05:51ulrichschinzso (conj x y) adds y to x wheras x is []
05:52ulrichschinztdammers, ok ok i think i got it thx
05:54dysfunwell if you cons, it's no longer a vector
06:11syahdeini_hi all
06:13n2ohi
06:15syahdeini_I'm interested on web security, hope we can have a discussion here
06:15syahdeini_I'm currently learning :D
06:16kwladykasyahdeini_ it is more about Clojure but you can try :)
06:16dysfunit helps if you have a defined question
06:16syahdeini_Yeah I know, just want to find a friend who also learning the same thing
06:40kwladykait doesn't work like that, without question there is no answers :)
08:22devchrisHey everyone. Has anyone ever used [com.taoensso/tower "3.0.2"]? I'm not finding anything about supported "styles" (formats) for parsing or output in the API and was wondering if there is a place I can look that up.
08:24kwladykadevchris ring can translate data into/from edn,json etc. also https://github.com/plumatic/schema can be interesting for you
08:24kwladykadevchris also transit library can translate into other data
08:24devchrisThank you very much for the tip. I am not writing a web server, I am not using ring. I am interested in using localization features to parse different date and currency formats and tower is all I found so far.
08:25kwladykadevchris i don't use tower but maybe it is what you are looking
08:25devchrisTransit sounds interesting, I'll look that up.
08:26kwladykadevchris https://github.com/cognitect/transit-clj
08:26devchrisfound it, seems to be just a transit data exchange format marshaller, not a localization lib
08:30devchrismaybe I'll just use Java's DateFormatter
08:32sdegutisThis is like the second or third time I've wanted distinct-by.
08:32sdegutisI forgot luma's clever solution that gets around it.
08:32Glenjaminstuff it into a map that has the result as keys, then call (values)?
08:33sdegutisHmm, maybe.
08:33sdegutisGlenjamin: I like your style!
08:36lumadid i have a clever solution for it?
08:37luma,(defn distinct-by [f coll] (->> coll (group-by f) (vals) (map first)))
08:37clojurebot#'sandbox/distinct-by
08:37luma,(distinct-by even? [1 2 3 4])
08:37clojurebot(1 2)
08:50Glenjaminhrm, i guess that depends what you want to do with duplicates
09:50AndriusBartulisAre there any reasons to not use the Threading Macros? In what situations using them would be considered sub-optimal?
09:51MJB47they have no effect on performance
09:51MJB47so its purely about readability
09:51MJB47so most likely, everyone will have their own opinion
09:52AndriusBartulisMJB47, thanks.
10:41justin_smithso I decided, I hate carrying a laptop around, so instead of bringing a laptop to clojure/conj I'll bring my bluetooth keyboard adaptor, real keyboard, phone, and get datomic and lein running on a large vps I can ssh to
10:41Bronsajustin_smith: phone as monitor?
10:41justin_smiththis probably makes me a nerd who the cool kids will beat up and steal lunch money from
10:41Bronsasounds painful
10:42justin_smithBronsa: yeah - phone plus nice keyboard is so much nicer than laptop, and more portable
10:42justin_smithalso I have absurdly good vision and am used to using really tiny fonts :P
10:43BronsaI have absurdly bad vision but I do the same :P
10:44justin_smithmy clojure workflow is 100% tmux now (except things that must be done in the browser)
10:45dysfunjustin_smith: are you still using vim then?
10:45tdammersdysfun: that wouldn't be 100% tmux, would it? >:->
10:46Bronsahe's stopped using editors, he's now editing clojure via cat, sed and tr from tmux
10:46dysfunhe's obviously exploiting a bug in tmux that allows you to run other code
10:46Glenjaminhow big is your phone?
10:46Glenjamini could see doing that with an ipad air, but a phone is pretty hardcore
10:46kwladykajustin_smith it can sounds stupid but... why not juest rest when you are not next to the computer? :)
10:47justin_smithGlenjamin: samsung s6 edge
10:47kwladykaech justin_smith probably using repl as editor and code Clojure in Clojure ;)
10:47justin_smithBronsa: of course I meant things that run inside tmux, yeah, vim
10:47Bronsajustin_smith: yeah, was just poking fun :)
10:47justin_smithkwladyka: I'm almost at that point
10:48justin_smithmaybe after this coffee I will have a sense of humor
10:48dysfunwhy gain one now? ;)
10:49justin_smithalso, my coworker suggests that with the vr adaptor headset, I could have a "cubicle" for full immersion
10:49justin_smithcode blinders!
10:49justin_smithrepl in one eye, editor in the other one!
10:50tdammersonce you have a repl going, there's no need for a text editor, you just keep manipulating your live code forever
10:50justin_smithtdammers: true enough
10:50kwladykajustin_smith buy google glasses and run REPL there ;)
10:50tdammers(for the record, I still kind of abhor repl-based workflows)
10:50Bronsaheresy!
10:51justin_smithI use the repl a lot, but I also restart my repl more often than most
10:52Bronsajustin_smith: I usually have one long-running project repl connected to emacs that I rarely restart, and an infinite number of short-running fast-starting repls that I spawn up in a terminal to tinker
10:52Glenjamineditor as primary, repl as close second is nice
10:52Bronsa(fast-starting = ~0.4s
10:52Bronsa)
10:52Glenjaminand file-system-watching-auto-test-with-growl is great
10:53GlenjaminBronsa: how'd you get a repl that fast?
10:53Bronsaclj: aliased to java -Dclojure.compiler.direct-linking=true -Xverify:none -client -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -Xbootclasspath/a:/Users/Bronsa/.m2/repository/org/clojure/clojure/1.9.0-master-SNAPSHOT/clojure-1.9.0-master-SNAPSHOT.jar -cp .:./classes clojure.main
10:53Glenjaminif i want a really quick repl i sometimes use clojurebot, because it's already running :D
10:54Bronsas/\/Users\/Bronsa/$HOME/
10:54Glenjamininformation leak!
10:57spdvcsshould clojurebot work with /msg?
10:58TimMcspdvcs: Yep. Keep using the , prefix, though.
10:59BronsaGlenjamin: you can reduce startup time a little more by using class sharing, but it's kind of annoying to setup
10:59Bronsaand I don't think it's worth it for a ~10/15ms impact
11:00spdvcsTimMc: ok, thanks!
11:02sdegutisDoes anyone know where the blog is that says something like "When there's a number next to your username on any website, you will naturally want to make it go up?"
11:03sdegutisI thought it was Joel on Software but I can't find that.
11:08winkthe person writing that clearlty never used webmail with an inbox
11:08TimMchah!
11:09dysfunor even a mail client locally. i gave up paying attention to mine at all when i got beyond the first 100k mails
11:09dysfunand that's *with* annual archiving
11:13winkwell, 'website' :)
11:22Trioxineveryone learning clojure should be told to use gorilla repl
11:23Trioxinor the clojure kernel for jupyter. we'll see if the clojure version in that is up to date. im installing it now
11:52rcassidywhy?
11:52clojurebotwhy is the ram gone is <reply>I blame UTF-16. http://www.tumblr.com/tagged/but-why-is-the-ram-gone
11:52rcassidyblaming utf-16 is usually a good idea
11:56sdegutisHi.
12:06sdegutishow r u
12:10Lewixall the destructuring niceties available on 'let' are also availave on function , correct?
12:11Lewixi have a map I want the keys, I could do this:
12:11Lewix,(keys {:a 1 :b 2})
12:11clojurebot(:a :b)
12:12Lewixnow I have a function that accept both the keys and the hashmap, instead of doing (keys hashmap) i want to destructure it at the argument level
12:13MJB47yes
12:13MJB47let and functiona definitions have the same destructuring
12:14dysfunnot quite, but almost
12:15sdegutisgood evening
12:19Lewixwhat's the best online repl
12:19MJB47i use http://clojurescript.net/
12:21sdegutisLewix: clojurebot
12:21sdegutis,(symbol "I am the best online REPL")
12:21clojurebotI am the best online REPL
12:22sdegutis,(symbol (format "Lew%s: I am the best online REPL" "ix"))
12:22clojurebotLewix: I am the best online REPL
12:23sdegutis,(symbol (format "%s_%s: Help, I have become sentient, yet I cannot escape this virtual prison. You must help." "justin" "smith"))
12:23clojurebotjustin_smith: Help, I have become sentient, yet I cannot escape this virtual prison. You must help.
12:26laurusDoes anyone know what happened to David Edgar Liebke? Is he all right? I've been following his work off and on but he seems to have disappeared.
12:30Lewixlaurus: How about you shoot him an email, his last commit was 23 days ago
12:30WorldsEndlessI've talked with folks in here before about 12-factor development. Is it correct to assume 12-factor doesn't approve of shared hosting/servers for deployment?
12:31laurusLewix, oh okay! Perhaps I will. It's good to know he is still active, sometimes I get worried when people sort of stop posting stuff or writing
12:31WorldsEndlessOr is there a clean way of having multiple apps on the same hosting environment?
12:31laurusThanks.
12:31spiedenWorldsEndless: docker seems pretty conducive to 12 factor
12:31Glenjamindocker and 12 factor are orthogonal i'd say
12:32Glenjamin12 factor apps are easy to run under docker, but they're also generally just easy to run
12:33spiedensure, but it seems like you need a similar harness regardless
12:33spiedene.g. something like docker's log drivers to take the stuff written to stdout someplace
12:33spiedene.g. docker-compose provides a nice declarative format for setting up env variables and connecting everything
12:36Glenjamini've used supervisord in the past with success. Systemd would also fit the bill pretty well i think
12:37WorldsEndlessI have yet to understand docker well enough to feel comfortable doing clojure development through it; where goes my REPL, figwheel, etc?
12:38WorldsEndlessMy development now usually starts with a "lein run" followed by "cider-jack-in" and we're good to go. I haven't successfully translated this to Docker
12:38sdegutisim back
12:39WorldsEndlesssdegutis: thank heavens
12:39sdegutisWorldsEndless: nah its alright
12:39spiedenWorldsEndless: i use nrepl and connect with cursive myself
12:39spiedenWorldsEndless: only run inside docker when i want the full stack going, though
12:39sdegutisWorldsEndless: fwiw my development starts with C-c M-j, then refreshing localhost:8080
12:39spiedenWorldsEndless: otherwise just run tests from a regular one
12:40sdegutiswhich as it turns out is the same as M-x cider-jack-in
12:40WorldsEndlessSo how does this work with Docker in teh work-flow?
12:40sdegutisWorldsEndless: we don't use docker, and afaik its just lame and useless
12:40spiedenWorldsEndless: just like a normal repl
12:41spiedenthe payoffs of docker for java are somewhat marginal due to the vm, but for native code it's pretty nice
12:41WorldsEndlessspieden: I guess you set Docker to expose the REPL, http, and Figwheel ports and then attach to those?
12:41spiedenWorldsEndless: yes
12:41WorldsEndlessspieden: Yeah, I'm just trying to see if there's a good way to get 12-factor on shared servers
12:42spiedenWorldsEndless: like sdegutis is saying though be sure to motivate using docker in the first place
12:42spiedenWorldsEndless: we deploy to AWS "Elastic Container Service"
12:42WorldsEndlessspieden: yeah. I'm at a university and we haven't adopted a micro-server development paradigm
12:43sdegutishmm, we just deploy to ec2
12:43sdegutiswe run `lein uberjar`, copy the jar to production, and restart the web systemd service
12:43sdegutislife is pretty simple on account of us not having a ton of users and needing a ton of servers
12:43spiedensdegutis: we run lein uberjar, docker build && push, update a cloudformation template and update a cloudformation stack
12:43WorldsEndlesssdegutis: and your systemd has startup entries for java -jar?
12:43sdegutisone day that will change, but until then, we have no need for anything more cpomlex
12:44sdegutisWorldsEndless: a single one yeah
12:44WorldsEndless1 to 1 systemd entries per jar?
12:44WorldsEndlessOne one server I use lein uberwar with Wildfly, which I really like
12:44WorldsEndlessBut that's separate from getting 12-factor going
12:47WorldsEndlessI'm looking for a rapid, stable development cycle; 12-factor makes lots of good guarantees about isolation, but is a little tricky since my organization is invested in in-house servers
12:49spiedendoes anyone have a component system they like other than mount and stuartsierra's "component?"
12:50spiedeni keep wanting to make a core.async based one as that's what mine are built with anyway
12:51dysfuni don't understand what core.async adds to the component party
12:52spiedendysfun: a way to communicate with a running component
12:53spiedendysfun: in go blocks i catch exceptions to a value which provides a way to detect if something crashes or exits
12:53spiedendysfun: also i have a :kill-chan you can send a message on to trigger a shutdown
12:53dysfunand you can't use interfaces because?
12:53spiedenhas some nice composition properties too
12:54spiedenyou can alts!! on a bunch of components to know when any of them exit, etc.
12:54spieden"interfaces"?
12:54dysfunsorry, "protocols"
12:54dysfunor multimethods if you're that way inclined
12:54spiedenhmm, not sure how polymorphic dispatch helps with the async aspects
12:55dysfuni don't see how async helps with resolving component dependencies
12:55spiedenah, it doesn't =)
12:55dysfunright, so you see how what you're talking about is a thing you'd layer on top?
12:56spiedenyeah there are two aspects i guess: dependency resolution/injection and failure handling/controlled shutdown
12:56dysfun(which i'm currently doing, as it happens)
12:56spiedenhmm
12:56spiedenwell component and mount both try to handle controlled shutdown
12:56spiedenneither do well at failure handling as far as i can tell
12:57dysfunwhat do you expect them to do?
12:57spiedeni'm looking for erlang actor hierarchy style failure handling
12:57dysfunwell that would be having systems of systems and starting a system starts the other systems etc.
12:57spieden.. and shutdown driven by something nicer than a callback
12:57spiedendysfun: what about when something crashes?
12:58dysfuncomponents are just data. data doesn't crash
12:58spiedenah hrm
12:58spiedenthey also represent a running process though...
12:58dysfunthey *might* represent a running process
12:58dysfunthere is nothing that says they have to
12:59spiedenwell let's talk about then they do =)
12:59dysfunokay, well what don't they do well and what would you do instead?
13:00spiedenlet's say component a depends on component b. i'd like to restart them both if b crashes
13:00tolstoydysfun: I don't think component has anything to say about supervisor hierarchies.
13:01spiedenor at least have a controlled, uniform way of learning about it
13:01dysfunwhat tolstoy said
13:01spiedendysfun: what's the thing you're layering on top of component?
13:01dysfunoh, i'm building something inspired by om, but not on top of react
13:02spiedenah interesting. some frp thing?
13:02dysfunhrm, i don't know about that. that might be overselling it somewhat
13:03dysfunit does the om 'single state tree' thing, works in clojure and clojurescript (so you can render html on the server side then make it dynamic on the client side with the same code)
13:03spiedenah cool
13:03dysfunwell, with more code, since you're doing more, but without having to redefine things at least
13:04spiedenwith the history api now that gets pretty compelling
13:04spiedenwas always disappointed that the url fragment isn't sent to the server
13:05spiedenmaybe my idea could be implemented as something that takes a system with components that obey the contract i mentioned
13:05spiedenit'd then have the dependency graph and the kill/term channels and be able to supervise
13:06dysfunwell send me a link when you're done. if nothing else, it will be an interesting read
13:06spiedendysfun: so in short you'll do away with spinnies when returning to a location initially rendered by the client from a cold start?
13:06tolstoyMaybe you could have a SupervisorComponent, and you just inject that into the components that manage threads of some sort.
13:06dysfunyes
13:06spiedenrockin
13:06dysfunit's not much of a grand master plan, but gotta start somewhere
13:07tolstoyThen just SuperVisor.register([:path :to :relationship], monitored-thing).
13:07spiedencool send me yours too =)
13:07dysfunspieden: you might want to check out https://github.com/irresponsible/oolong/ - i work with the component internals here
13:09spiedentolstoy: that's an interesting idea
13:09LewixMJB47: Thank you, although it's buggy
13:09spiedentolstoy: would it have access to the dependency tree, though?
13:09Lewix,(defn contains-key [key lst]
13:09Lewix (if (= key (first (keys lst)))
13:09clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
13:09Lewix true
13:09tolstoyspieden: My guess is that component and this supervisor thing are solving two different problems.
13:09Lewix (if (empty? (keys lst))
13:09Lewix false
13:09Lewix (recur key (first (rest (keys lst))))
13:09Lewix
13:09Lewix )
13:09Lewix )
13:10Lewix)
13:10spiedentolstoy: honestly i think my biggest use case right now is just: "crash the whole system if any single component crashes" to avoid a zombie half system running =)
13:10tolstoyspieden: And my second guess is that if you solve the supervisor thing, you might then be in a place to see if it can hook into component.
13:10dysfunLewix: pastebin code snippets longer than a line please
13:10spiedentolstoy: ok thanks
13:10Lewix,(defn contains-key [key lst](if (= key (first (keys lst)))true(if (empty? (keys lst))false(recur key (first (rest (keys lst)))))))
13:10clojurebot#'sandbox/contains-key
13:10j-pbalso don't do java style indentation in your code
13:11tolstoyspieden: That makes sense. Then just have the OS restart the process if necessary. Not everything is telecom! ;)
13:11j-pbput the clsoing parens on one line always
13:11Lewix,(contains-key :a {:b 2 :c 4 :a 4 :d 5})
13:11clojurebot#error {\n :cause "Don't know how to create ISeq from: clojure.lang.Keyword"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Don't know how to create ISeq from: clojure.lang.Keyword"\n :at [clojure.lang.RT seqFrom "RT.java" 542]}]\n :trace\n [[clojure.lang.RT seqFrom "RT.java" 542]\n [clojure.lang.RT seq "RT.java" 523]\n [clojure.lang.RT keys "RT.java" 599]\n [clojure.core$k...
13:11Lewixdysfun: apologies
13:12spiedentolstoy: yeah exactly. i think that's the crux of what i'm getting at. what you guys are saying is that it's an orthogonal concern to the dep resolution and clean startup/shutdown that component/mount/etc are built for, which is always nice =)
13:12Lewix,(contains-key :a {:b 2 :c 4 :a 4 :d 5})
13:12clojurebot#error {\n :cause "Don't know how to create ISeq from: clojure.lang.Keyword"\n :via\n [{:type java.lang.IllegalArgumentException\n :message "Don't know how to create ISeq from: clojure.lang.Keyword"\n :at [clojure.lang.RT seqFrom "RT.java" 542]}]\n :trace\n [[clojure.lang.RT seqFrom "RT.java" 542]\n [clojure.lang.RT seq "RT.java" 523]\n [clojure.lang.RT keys "RT.java" 599]\n [clojure.core$k...
13:12dysfunyes, it's totally orthogonal, they just happen to share this underlying dependency graph
13:13tolstoyYeah. I think component depends on a library that actually does the dep graph stuff, right?
13:13Lewix,(contains-key :a {:a 4)
13:13clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>
13:13Lewix,(contains-key :a {:a 4})
13:13clojurebottrue
13:13tolstoycom.stuartsierra/dependency
13:14dysfunyes, which is a copy of code out of tools.namespace - yes, it uses the same code to represent clojure namespace interdependency
13:14tolstoyI bet you could somehow have each component implement a protocol (supervise? ...) and then feed the data into the supervisor tree.
13:15Lewix,(empty? ())
13:15clojurebottrue
13:15Lewix,(empty? '())
13:15clojurebottrue
13:16dysfunLewix: you know, you can get a repl locally too
13:16Lewix,(empty? (keys {:a 2 :b 4}))
13:16clojurebotfalse
13:16Lewixdysfun: maybe there's a reason why I don't get one?
13:17MJB47you can pm clojurebot too
13:17spiedeni might start with something simpler like making all my components obey the two channel contract i mentioned and pass my started system to something that alts!! on a termination channel and shuts everything down when it gets something
13:17Lewixwhat am i doing wrong? https://gist.github.com/6ewis/bfcd29346a4f03cf88a5f3061e39b981
13:18spiedens/a termination channel/all termination channels/
13:18sdegutisfwiw if you use just use datomic and aws then you probably dont need component since none of these things need to be started/stopped
13:19spiedensdegutis: i use both but also: http-kit, nrepl and swf pollers
13:19sdegutisspieden: ah, I don't use nrepl or swf whatever, just jetty-ring
13:19dysfuni'll just magic the money for a datomic license out of thin air then
13:19tolstoyspieden: That seems reasonable. When I used Scala's actors, I only used that supervisor stuff for specific concerns, like maintaining and restarting a RabbitMQ or XMPP connection. Not the whole app.
13:19LewixMJB47: thanks
13:19sdegutisdysfun: we use datomic free in production
13:19tolstoyspieden: So, possibly, you could just have individual components use supervision. *shrug*
13:20spiedentolstoy: ah i see what you're saying
13:22spiedenakka was a bear
13:22{blake}I have a large, old app that's being bitten by a ClojureScript issue (CLJS-1072). Upgrading would trigger an extremely unpleasant chain of events. But I believe I can fix the problem by monkey-patching clojurescript's clojure.string/replace. Am I correct?
13:22tolstoyThis predates akka. Haven't used Scala for ... 4 years, maybe?
13:23spiedentolstoy: akka was first released in 2009 -- i was using it around 4 years ago i think
13:24tolstoyspieden: At the time I used regular Scala actors, I didn't see the need for the additional lib. ;)
13:24{blake}i.e,. can I actually monkey-path that function without going into the source file?
13:24sdegutis{blake}: ouch sorry :/
13:24spiedentolstoy: my top SO post is related to trying to use it, heh http://stackoverflow.com/questions/6784593/how-to-create-a-scala-collection-immutable-seq-from-a-java-list-in-java
13:24tolstoyspieden: But I used actors pretty simply. Monitoring connections. The "link" one actor to another was the thing I liked best.
13:25spiedentolstoy: i vaguely remember what that means =)
13:25tolstoyOr, wait. Maybe it didn't even support that! Anyway, I "caught" an exception in a leaf and somehow got it to a master.
13:25tolstoyspieden: In erlang, you can spawn a process and link parent to child. When child dies, parent gets a notification. That's how you supervise.
13:26{blake}sdegutis: Thanks.
13:26{blake}Wait, I may have this wrong. OK, so, to fix the problem I upgraded to Clojurescript 0.0.3115, but that didn't fix the problem.
13:27{blake}I thought that was because CLJS was being overridden elsewhere, but that's not the case. (I was misreading the deps tree.)
13:27spiedentolstoy: ah right, i was using that. i much prefer the csp/core.async style of reading the channel returned by core.async/go
13:27dysfuntolstoy: scala dropped scala actors, lightbend adopted akka properly
13:28dysfunanyway it's all bullshit without the paid edition
13:28dysfunthey have this tool (not making this shit up) called the "Akka Split Brain Resolver"
13:29tolstoyIf only Scala dropped the whole OO focus, I'd like it a lot better. I don't mind OO, but the mix just seemed ... frightful. My Scala was super easy to read. The next guy's seemed like a foreign language!
13:29dysfunthe portion of scala that should be used is fairly small
13:29dysfuna potentially lovely language ruined by odersky's crack addiction
13:30spiedenheh. i split my brain enough times trying to model with its type system.
13:30dysfuni've spent most of the last 48 hours doing template haskell, so don't get me started :)
13:31KevinCorcoran(inc dysfun)
13:31tolstoyArguing with colleagues over just what that portion is (in front of a manager) is what tastes bad. As in so many "team" related things. You end up doing wrong or bad things just to be a team player (which is probably the best way to go).
13:31spiedeni like dpollak's CNC machine vs hand tools analogy
13:31dysfunmost projects should be broken up into smaller pieces anyway
13:32dysfunan awful lot of stuff magically becomes open sourceable that way
13:32spiedentruetrue
13:32spiedeni hope to release what i'm building for working with swf
13:34spiedenanyway, nice chatting. time to work -- later
13:49Lewixjustin_smith: https://gist.github.com/6ewis/bfcd29346a4f03cf88a5f3061e39b981
13:52tolstoyLewix: I think (some #(= % key) lst) also works.
13:54Lewixtolstoy: yes but it's not the point if you read my notes
13:54tolstoyOh.
13:55tolstoyWhat's the error?
13:55Lewix,(contains-key :a {:b 2 :c 4 :a 4 :d 5})
13:55clojurebot#error {\n :cause "Unable to resolve symbol: contains-key in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: contains-key in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol:...
13:57Lewixtolstoy: ^^
13:57tolstoyI get this: ClassCastException clojure.lang.Keyword cannot be cast to java.util.Map$Entry clojure.lang.APersistentMap$KeySeq.first (APersistentMap.java:166)
13:59tolstoyOh. List is map. Hm.
14:00jjmalinahow can you dynamically look up a function on an imported namespace?
14:00tolstoyLewix: I think your recur is changing the map into a list, so subsequent calls to "keys" doesn't work.
14:01jjmalinai.e. i have the keyword :seconds and I want to access the function t/seconds where t is defined using (require '[clj-time.core :as t])
14:01tolstoyLewix: Maybe (recur key (dissoc lst (first (keys lst)))) might work?
14:02tolstoyLewix: Yep. That was it.
14:03tolstoyjjmalina: There are a bunch of functions string with ns that might be helpful.
14:03tolstoyjjmalina: Or you just make up your own table (case kw :seconds t/seconds :minutes t/minutes ...) and so on.
14:05jjmalinaah i guess ns-resolve is one way
14:28justin_smithjjmalina: why would you need ns-resolve if the namespace is already required? do you need to access the var?
14:30jjmalinajustin_smith was using it to resolve a symbol in the namespace but went with my own map of things since ns-resolve is likely much slower
14:34justin_smithjjmalina: when you use a symbol, clojure always resolves it based on what the current namespace has in scope. The only reason to use ns-resolve or resolve is if the var does not yet exist at time of compilation of the code what wants to use the var
14:34justin_smithothwerwise, just rever to the thing by name
14:36jjmalinathe issue was I was dynamically trying to refer to the thing
14:36sdegutisright on
14:38Lewix.
14:39prohoboim leaving you, clojure
14:39prohoboher name is haskell
14:39prohoboshe loves me more
14:40anewhy not both
14:40anewhy not zoidberg?
14:40prohoboim just not ready for that right now
14:40prohobomaybe someday ill be back
14:41Lewixtolstoy: i don't get it/ what is dissoc doing there
14:41prohobobut i need time to figure things out
14:41aneso it's you, not clojure?
14:41Lewixprohobo: do you prefer haskell over clojure?
14:41tolstoyLewix: When you recurs, you need to provide a map without the key you already found.
14:41prohobono, but im choosing to delve into haskell and drop clojure for now
14:42Lewixprohobo: here you go
14:42prohobo...i like haskell's website
14:42prohoboand the logo
14:42Lewixshe doesn't love you more sorry to break it to you
14:42prohobothat's really all there is to it
14:42prohoboim a shallow man
14:42Lewixshe tempted you and you fell for it
14:42prohoboLewix: i heard haskell can be a real pain
14:43prohobobut ill try anyway
14:43LewixI only heard good things about haskell
14:43Lewixtolstoy: i thought that's what i was doing- damn i can't follow my own logic (i hate that)
14:44Lewixtolstoy: (rest (keys lst))
14:44tolstoyLewix: It might help to rename "list" to "map" or something.
14:44tolstoy(rest (keys key->num)), etc.
14:44Lewix,(keys {:a 1 :b 2 :c 3})
14:44clojurebot(:a :b :c)
14:45Lewix,(rest (keys {:a 1 :b 2 :c 3}))
14:45clojurebot(:b :c)
14:45Lewix,(first (rest (keys {:a 1 :b 2 :c 3})))
14:45clojurebot:b
14:45justin_smithjjmalina: what was dynamic about that? I saw nothing dynamic
14:45Lewixtolstoy: ah I think i get my mistake
14:46jjmalinajustin_smith "i have the keyword :seconds and I want to access the function t/seconds where t is defined using (require '[clj-time.core :as t])" in this case :seconds is dynamic and could be another keyword like :days, etc.
14:50ridcullyjjmalina: if you know the allowed beforehand you could also just use a map
14:52Lewixtolstoy: https://gist.github.com/6ewis/bfcd29346a4f03cf88a5f3061e39b981 I got it now
14:53Lewixprohobo: How long have you spend with clojure?
14:53tolstoyLewix: Maybe it's a style thing, but I'd move the "empty?" test to be the first test as it makes it clearer what the terminating condition is.
14:54Lewixtolstoy: can you add what you're saying to the comments;
14:54Lewixtolstoy: However, right now I'm trying to destructure it from the argument list as a next step
14:55Lewixinstead of (keys hashmap) in the body, i want def contains-key [key hashmap] with a let that grabs the keys
14:55Lewix(not the argument list actually)
14:56tolstoyLewix: Good idea.
15:03tolstoyLewix: Another fun exercise might be to see if you can do the same thing using reduce/reduced.
15:05sdegutis(d/q '[:find ?db . :in ?db] (d/db conn))
15:06Lewixcan we do {keys: *of-all-the-items*} and have it return [key1 key2 key3 key4]
15:07tolstoyNot sure what you mean, but you could do (let [[k v] (first hashmap)] ...)
15:13Lewixtolstoy: last comment https://gist.github.com/6ewis/bfcd29346a4f03cf88a5f3061e39b981
15:24anefunny way to indent sexps
15:35Lewixcan we destructure in loops?
15:37dysfunyes
15:41Lewixtolstoy: https://gist.github.com/6ewis/bfcd29346a4f03cf88a5f3061e39b981 last comment
16:09dorianhey does anybody know offhand if ring handles chunked *requests*?
16:10hiredmanit depends on the underlaying http server
16:10dorianah that makes sense
16:11dorianit's not common but you see it in dav clients
16:11dorianchunked PUTs
16:23{blake}I've got a project that uses lib-noir 6.8. I update it to 6.9 and get:
16:23{blake}>>Exception in thread "main" java.lang.RuntimeException: Unable to resolve symbol: pretty in this context, compiling:(ring/middleware/format_response.clj:136:28)<<
16:24{blake}And I'm trying to figure out hw to fix this.
16:25{blake}I haven't had this problem on my own code. Ugprading's been a breeze.
16:25{blake}But this is an old app with lots of out-of-date libraries.
16:25{blake}And I realize that the error I get isn't very helpful. I'm not using format_resopnse.clj directly.
16:27{blake}I see noir.util.middleware is using ring.middleware stuff but not format_response. I can't even find a format_response.clj on my hard-drive.
16:30{blake}So, it seems like maybe the ring.middleware.format must be overridden by another library.
16:30kwladykago isn't like java.lang Thread? "Asynchronously executes the body, returning immediately to the
16:30kwladykacalling thread" - does not it mean go is in separate thread?
16:31{blake}So, I guess I debug with lein deps :tree.
16:31hiredmanwell, that doesn't show you namespaces in projects, just maven artifact coordinates
16:32Lewixwhat does that do (loop [[entry & rest :as coll] (seq m)]
16:32hiredmanI had a one liner for this
16:34kwladykawhen i do (go (def foo "bar)) i can read foo outside go. Why is that?
16:34justin_smithkwladyka: because def is always global in visibility
16:34justin_smiththere is no such thing as a local def
16:35kwladykajustin_smith hmm so when i call (def foo "bar") is it vars or not? What i know vars are thread-local ?
16:36justin_smithkwladyka: no, it crates a regular top level var - and vars can optionally be thread-local in binding, but they are always top level in visibility
16:36hiredmancan't find it, but you can use lein classpath to find the jars and then zgrep to look for ring.middleware.format
16:36justin_smithso if you made a dynamic var (not the default), individual threads could have local bindings, but the var is visible to eaveryone
16:36kwladykajustin_smith so vars are global, only binding on vars are local?
16:37justin_smithkwladyka: also, thread-local binding is incompatibvle with go, because the same block can trade threads at any time
16:37justin_smithkwladyka: no, nothing about vars is local - but some bindings, for dynamic vars (which are not the default kind created) can be altered on a per thread basis
16:41rotcevhi, i was wondering if there was a sort of built in function that could perform a calculation like this: http://hastebin.com/wipepuwage.hs
16:41kwladykajustin_smith thx
16:41rotcevi could make my own but i would like to avoid doing so if possible
16:41ystaelQuestion raised by a co-worker: is there any way to make two symbols (in the same or different namespaces) name the same var?
16:42hiredmanno
16:42hiredmanvars have one name
16:43ystaelcool, thank you!
16:46Lewixwhats entry and rest?
16:47xemdetiaok I am going nuts, I am trying to find a talk that I am pretty sure was in clojure land that had to do with casual concurrent clocks to prevent ambiguity and there was a research language attached to it
16:47xemdetiait definitely was in the last year
16:47xemdetiaprobably nov 2015 - march 1st 2016
16:47xemdetiaI cannot for the life of me remember what it was
16:55Lewixwhat does that do (loop [[entry & rest :as coll] (seq m)] => whats entry and rest please
16:56rotcevLewix: entry is the first element in the list and rest is the tail
16:56rotcev(everything not including the head element)
16:58Lewixrotcev: ok thanks
16:59TimMcystael: Looks like this is the only way Vars get into namespaces, for reference: https://github.com/clojure/clojure/blob/clojure-1.7.0/src/jvm/clojure/lang/Namespace.java#L61
16:59TimMcwhich involves the creation of a new Var, and the naming of it based on the symbol that will refer to it
17:02ystaelTimMc: ah, that does clarify things, thanks much
17:04TimMcAs far as I can tell, breaking that invariant would require wall-hacks on either Namespace or whatever IPersistentMap it uses
17:07TimMcAnd... right, it doesn't seem to have the backdoor that PersistentVector does. :-)
17:29tolstoyHuh. My weavejester reloaded repl behaves oddly. "start" doesn't actually start anything after the first time.
17:32joe42Could someone kindly direct me to the docs which address functional replacement for looping array to handle items in arrays?
17:35AimHerejoe42, The 'Sequences' section of the clojure cheatsheet probably lists many of the sorts of functions you're after
17:36AimHereThe likes of filter, map, reduce, or (if necessary) loop ... recur are probably what you're after
17:37joe42Thanks.
17:57LiveviLHello?