#clojure logs

2014-03-13

00:00seangrovemr-foobar: Well, with that approach, you get state-serialization, user-playback, etc. for free
00:00seangroveAnd the code stays tiny, your state-transitions are forced through once choke-point so it's manageable, etc.
00:00seangroveLots of nice things just fall out.
00:01danielszmulewiczseangrove mr-foobar : and that's the way to go.
00:01danielszmulewicz:-)
00:03mr-foobarseangrove, you should definitely add this in the om wiki. shall I add it now ?
00:03seangrovemr-foobar: Add what?
00:04mr-foobarseangrove link to omchaya
00:04seangroveOh, sure. Sounds like a good idea.
00:05brainproxyworking w/ a seq abstraction over read-line
00:05brainproxyin cider repl
00:06brainproxystuck ... how can I close stdin
00:06brainproxywithout killing the whole thing
00:08loneworlfhey guys - i am reading "Clojure Programming" from Oreilly and i have a question about one of the examples
00:09loneworlfhere is the example
00:09sdegutisloneworlf: refheap.com
00:09loneworlf(require '[clojure.string :as str]) (def camel->keyword (comp keyword str/join (partial interpose \-) (partial map str/lower-case) #(str/split % #"(?<=[a-z])(?=[A-Z])")))
00:10muhooi'm confused by the purpose of secretary. why would you need routing on the client side?
00:10muhoois it even possible for js browser clients to receive incoming http connections?
00:10bob2because in that world you're writing JS that redraws the whole page based on actions
00:10loneworlfmy question is i understand that comp is combing functions together - i dont know what keyword is referring to - is it just the parameter name ?
00:10bob2it's not about incoming http
00:11amalloy&(doc keyword)
00:11lazybot⇒ "([name] [ns name]); Returns a Keyword with the given namespace and name. Do not use : in the keyword strings, it will be added automatically."
00:11bob2loneworlf, the name of the variable is literally "camel->keyword"
00:11bob2oh, in comp, sorry
00:11muhoobob2: what is it for then?
00:11loneworlfbob2 - yeah in comp
00:13akhudekmuhoo: it's to handle # urls in single page apps
00:14muhooakhudek: oh, cool, thanks. that makes sense
00:14mheldwhy would something work in a repl but not in lein run?
00:15loneworlfbob2, is the keyword in comp a "self" reference to the outer function ? (the camel->keyword function we are defining in the example)
00:15muhooloneworlf: i have a threading-macro fetish, so i'd do it as https://www.refheap.com/57613
00:16muhooactually, sorry https://www.refheap.com/57614
00:16mheldlet in clojure is lexically scoped?
00:17loneworlfmuhoo, yeah they mention that you can do it as a threading-macro - that site you linked is cool - in your example what is the meaning of the keyword at the end of your macro ?
00:17mheldso I can do (let [x 1 y x] y) and it'd evaulate to 1, yes?
00:17muhooloneworlf: that thing amalloy doc'ed you to
00:17muhoo,(doc keyword)
00:17clojurebot"([name] [ns name]); Returns a Keyword with the given namespace and name. Do not use : in the keyword strings, it will be added automatically."
00:18amalloymheld: yes, although it's not clear what lexical scope vs some other scope has to do with that
00:19mheldamalloy: non-globally scoped
00:19bob2loneworlf, keyword is a function in clojure.core
00:19loneworlfmuhoo, clojurebot, amalloy - thanks i didnt know there was a keyword "keyword" and i was slow to grok the doc command - with you know much appreciated
00:20loneworlfbob2, thanks i got it know :)
00:20loneworlfbob2 - correction now ;)
00:20muhoonp. and, just for accuracy: https://www.refheap.com/57615
00:22Raynesmheld: LETsically scoped. ;)
00:23muhoobahaha
00:23muhooreally wish there was an as->> macro :-/
00:23mheldRaynes: heh
00:24seangrovemuhoo: Write one, put it in your personal 'useful ns. I have (comp first filter) as ffilter in mine, for example
00:24muhoo'cause most of the time most of the stuff is ->>, and like one or two is ->. so it'd be neat to have (->> foo (bar baz) (as->> x (quux x blah)) (bleah yeah huh))
00:25muhooseangrove: good point. i do have one of those misc-libraries
00:25pdkwhat would as->> do
00:25muhoopdk: let you accomodate the rogue function that takes the arg you want as its FIRST argument :-)
00:25seangrovemuhoo: Doesn't as-> do that already though?
00:26muhoonot afaict.
00:26muhooactually, not last i tried. hmm, maybe i shoudl try again
00:27muhooseangrove: nope, unsupported binding form
00:27seangrovemuhoo: refheap?
00:27amalloymuhoo: i don't really love any of these definitions of camel->keyword, but yours starting with ->> is particularly silly. you could much more legibly write (-> camel (str/split #"...") (->> ...))
00:27muhooseangrove: https://www.refheap.com/57616
00:28muhooamalloy: nest threading macros?
00:28amalloyof course?
00:29seangrovemuhoo: https://www.refheap.com/57619
00:29muhoohuh, and so it goes. provided everything in the back end of the chain is ->> otherwise i could be going back and forth between ->> and ->
00:30Raynesmuhoo: Also remember that you do not have to chain everything.
00:30Raynes:p
00:30muhooseangrove: yeah, but all those x's are annoying.
00:30amalloymuhoo: you don't even have to go back and forth. (-> x (f 1) (->> (g 2) (h 3)) (q 4))
00:30muhooRaynes: what! of course i do. :-P
00:30seangrovemuhoo: Not that big a deal, but I understand if you're seeking perfection
00:30muhoonaw, it's not even perfection, it's just a tic
00:31muhooor, a fetish really, for threading
00:32Raynesmuhoo: Not appropriate for HQ, man. Not appropriate for HQ.
00:32amalloyi think that function reads better with no threading at all, personally
00:32muhoowith the partials and comps? hmm.
00:32amalloyalso the interpose \- should obviously be lumped together with the join, for (join "_')
00:32amalloyugh, no
00:32amalloythose are even worse
00:32amalloyjust nested sexps
00:33muhoooh, old-skool lisp. yeah, there's that
00:34amalloy(keyword (join "-" (map lower-case (-> camel (s/split #"(?<=[a-z])(?=[A-Z])")))))
00:34amalloyso i guess a little threading
00:35muhoo (keyword (str/join (map str/lower-case (str/join "-" (str/split camel #"(?<=[a-z])(?=[A-Z])")))))
00:35amalloystr/join twice??
00:35lazybotamalloy: What are you, crazy? Of course not!
00:36muhoololbot
00:36muhooyeah, an extra one snuck in there
00:37muhoobut your point stands: plain ol' sexps is actually clearer for this
01:07sdegutisclojurebot: !help
01:07clojurebotTitim gan éirí ort.
01:07sdegutisclojurebot: english?
01:07clojurebotexcusez-moi
01:07escherizehaha
01:10muhoo~help
01:10clojurebotNobody can help with "X doesn't work". Please provide context: what you did, what you hoped would happen, and what happened instead. A stack trace is especially helpful, if applicable.
01:11muhoo~english
01:11clojurebotHuh?
01:11muhoo~english do you speak it
01:11clojurebotIt's greek to me.
01:11muhoohaha
01:12escherizei have a question actually
01:12muhoo~ask
01:12clojurebotThe Ask To Ask protocol wastes more bandwidth than any version of the Ask protocol, so just ask your question.
01:12escherizei have a function defintion like (defn f [arg] ["stuff..." arg "stuff"])
01:12escherizeactually it's more like
01:13escherizei have a function defintion like (defn f [arg] [1 2 3 (- arg 30)])
01:13escherizeis there a way to take f itself and get the fact that it's using (- arg 30) instead of -25 or whatever
01:14ddellacostaescherize: what do you mean, look into the function itself?
01:15escherizegiven the fn, i'm trying to get the names of the arguments, and how the args are used
01:16ddellacostaescherize: well, metadata may help somewhat
01:16ddellacosta,(defn foo [a b] (+ a b))
01:16clojurebot#'sandbox/foo
01:16ddellacosta,(meta #"foo)
01:16clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading regex>
01:16ddellacostawhoops
01:16ddellacosta,(meta #'foo)
01:16clojurebot{:arglists ([a b]), :ns #<Namespace sandbox>, :name foo, :column 0, :line 0, ...}
01:17ddellacostaescherize: as far as how the args are used, I suspect you'd have to write a macro to do that, but maybe other folks know better...
01:17escherizemm, i was afraid of that
01:18escherizebut that's actually useful too. thanks ddellacosta
01:18ddellacostaescherize: np, glad I could help
01:43amalloyescherize: given a plain function, your goal is unachievable: the information simply doesn't exist
01:43amalloybut you can write a macro (defn-introspectable [a b c] (do-whatever a b c)) that saves that information for later
01:43escherizeamalloy: what if it's not evaluated
01:43escherizei see.
02:43dissipate,(slurp 'http://www.fourmilab.ch/cgi-bin/Hotbits?nbytes=128&amp;fmt=hex&amp;npass=1&amp;lpass=8&amp;pwtype=3')
02:43clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Cannot open <http://www.fourmilab.ch/cgi-bin/Hotbits?nbytes=128&amp;fmt=hex&amp;npass=1&amp;lpass=8&amp;pwtype=3'> as an InputStream.>
02:45dissipate,(slurp "http://www.fourmilab.ch/cgi-bin/Hotbits?nbytes=128&amp;fmt=hex&amp;npass=1&amp;lpass=8&amp;pwtype=3&quot;)
02:45clojurebot#<SecurityException java.lang.SecurityException: denied>
02:45dissipate,(slurp)
02:45clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core/slurp>
02:59Amnesiou_I noticed that native queues are mentioned in ClojureDocs, but I can't seem to find any relevant syntax token; are they deprecated?
03:37alewAmnesiou_: are you talking about PersistentQueue?
03:37Amnesiou_alew: Yes
03:37alewAmnesiou_: http://stackoverflow.com/a/2495105/1432017
03:37alewAmnesiou_: there is no reader syntax for them
03:37Amnesiou_Any particular reason why?
03:38alewAmnesiou_: Not that I know of.
03:40alewAmnesiou_: http://dev.clojure.org/jira/browse/CLJ-976
03:42Amnesiou_Thanks
03:45Amnesiou_Ah, I see it's not in cljs yet. Too bad.
03:48Amnesiou_…It actually is, as it seems. I had forgotten about the nomenclature differences in namespaces.
04:06dsrxis ##(assoc-in {:foo "bar"} [:foo] "baz") as good as I'm gonna get for idiomatic "add or replace" on a hashmap?
04:06lazybot⇒ {:foo "baz"}
04:06dsrxactually... that really isn't that bad
04:07beamso##(assoc {:foo "bar"} :foo "baz")
04:07lazybot⇒ {:foo "baz"}
04:07dsrxbeamso: yeah... i tried that and then it turns out i completel misread what the repl said
04:09beamso##(conj {:foo "bar"} [:foo "baz"])
04:09lazybot⇒ {:foo "baz"}
04:09dsrxdanger of using "bar" and "baz" as test strings, they look too similar
04:09beamsoi think that will work with a map as the second argument as well
04:09beamso##(conj {:foo "bar"} {:foo "quux"})
04:09lazybot⇒ {:foo "quux"}
04:10dsrxnice nice. i dunno how i forgot assoc and conj would do that, i blame spending too much time with ruby this week
04:11beamsoi think you just have to check clojuredocs for the examples to see the examples
04:11beamsoor try in a repl
04:24chareok guys
04:24charesuppose I wanted to make something like reddit where you have comments and stuff
04:24charehow do I make that web app with clojure
04:25scottjchare: that's way too broad of a question
04:25charescottj what pieces do I use
04:25charecome on you gotta know this
04:26charewith ruby I would like use rails and other stuff right?
04:27scottjchare: there are tons of web libraries you can choose from. compojure is the most common web server library.
04:28scottjchare: http://www.clojure-toolbox.com/
04:28scottjchare: specifically the Web Frameworks section
04:30chareneed more guidance than that
04:30jballancchare: Rails is a framework, in general the Clojure community favors libraries over frameworks
04:30scottjchare: be more specific than that
04:31chareso i'm going to need to store comments and stuff like reddit does. So i use something like postgresql db
04:31charehow do I interact with postgres
04:31charedo i got some ORM with compojure?
04:31charei know that rails got the activerecord stuff for postgres
04:31jballancchare: there's a number of libraries for working with DBs
04:31jballancsome are more towards the ORM side of things, others are just ways to run queries
04:32charei don't like the vague answers
04:32chareneed concrete stuff
04:32jballancSQLKorma is probably one of the more popular toward the ORM side of things
04:32cmdrdatschare: compojure is purely a routing library
04:32cmdrdatshas nothing to do with db
04:32scottjchare: there is a book written specifically for you
04:32jballancchare: apologies for being vague...but you have to understand that if you expect a 1-to-1 translation of Rails concepts to Clojure, you're going to have a bad time
04:32cmdrdatshttp://www.clojure-toolbox.com/
04:32scottjhttp://pragprog.com/book/dswdcloj/web-development-with-clojure
04:33chareomg another pots of the toolbox
04:33chareoh wtf you post a book that costs money
04:33cmdrdatslol chare
04:33cmdrdatsmoving along then
04:34scottjchare: fine, you need clojure, leiningen, a computer, compojure, a web browser, clojure/java.jdbc
04:34scottjchare: anything else?
04:34jballancscottj: emacs?
04:34jballanc;-)
04:34cmdrdatsemacs! and an elisp book
04:35scottjit's free though
04:35cmdrdatsscottj: a computer isn't though
04:36charecmdrdats, so you got a pdf of the book that you can link to?
04:37scottjchare: he only mentioned the elisp one, as a joke.
04:37cmdrdatssure - http://www.gnu.org/software/emacs/manual/pdf/eintr.pdf
04:37xsynWhy does Clojuredocs only have 1.2.0 and 1.3.0?
04:37charecmdrdats WRONG BOOK I MEAN THE WEB ONE
04:37scottjxsyn: something about the way it was built made it hard to upgrade. there have been discussions about it on the mailing list
04:38scottjchare: I mentioned that book. No, sorry.
04:38jballancxsyn: there's also http://clojure-doc.org
04:38jballanca bit of a different direction though
04:38jballancbut not covered by the CA, so more open to outside contributors
04:38charescottj please buy me a copy of the book
04:39scottjchare: sure, what's your mailing address?
04:39scottjif it's in the first world though, no. buy it yourself.
04:40scottjchare: there are TONS of blogs and docs on compojure and java.jdbc
04:40xsynscottj: I'm in Africa?
04:41xsyn(which is not a country)
04:42chareso you guys think that clojure with compojure, etc. is better than ruby on rails?
04:42cmdrdatschare: no, it's way worse
04:42chareyou being sarcastic?
04:43scottjchare: compojure is better than rails like a bicycle is better than a car
04:43cmdrdatslol, not at all :P 'better' is completely a matter of perspective
04:44chareyou guys are not giving me straight answers
04:44scottjyou asked what he thinks. he thinks rails is better.
04:45chareWRONG ANSWER
04:47cmdrdatsif you know ruby and not clojure, and you have 10 minutes to bash out a throwaway prototype of something
04:47chareI refuse to use imperative programming
04:48chareI only use clojure, erlang, haskell, etc...
04:48scottjchare: congrats
04:49xsyn*chuckle*
04:50charewhat is so funny?
04:50cmdrdatschare: anyhow - it's been a fun conversation, thank you, but if you want to chat more about it - chat me directly and I'll be happy to assist.
04:51chareuh no I don't do private cyber sex chat if that is what you're asking
04:52scottjyou private chatted me, so just be honest with cmdrdats, tell him he's not your type
04:53scottjyou can't be with someone who likes rails :)
04:54cmdrdatshey, I never said I liked rails
04:55charescottj are there other web clojure books out there
04:55charethat don't cost money
04:56scottjhttp://clojure-doc.org/articles/tutorials/basic_web_development.html
04:58cmdrdatsscottj: nice link
04:58jballanccmdrdats: yeah, the clojure-doc articles can be hit or miss, but they've been steadily improving
04:59chareok team
04:59chareour next task
05:00cmdrdatsjballanc: I'm very impressed!
05:00chareis to kill ruby on rails and python django
05:00chareclojure MUST WIN
05:00dissipatehi
05:00jballanccmdrdats: which reminds me that I've been meaning to write up something for them on core.logic, just haven't had the time
05:00dissipatechare, i'm trying to get away from ruby and python, but clojure jobs are slim
05:01clojurenoobhey guys, how do I remove instances of a backslash character from a string ? I've failed with all sorts of different attempts
05:01dissipatechare, BTW, hasn't clojure already won?
05:01cmdrdats,(.replaceAll "test/test.clj" "[/]" "")
05:02clojurebot"testtest.clj"
05:02cmdrdatsoh, lol - backslash...
05:02dissipatechare, i don't want rubyistas and pythonistas coming over to clojure
05:02clojurenoobyeah cmdrdats :-)
05:02cmdrdats,(.replaceAll "test\\test.clj" "[\\]" "")
05:02clojurebot#<ExceptionInInitializerError java.lang.ExceptionInInitializerError>
05:03cmdrdatsdissipate: there's no competition in which to win.. :P
05:03clojurenoobcmdrdats that last example fails for me
05:03clojurenoobregex.Pattern.error
05:04dissipatecmdrdats, well, the competition is jobs. more jobs for clojure, the better.
05:04cmdrdatshmm, one sec
05:04scottj,(clojure.string/replace "foo\\bar" "\\" "")
05:04clojurebot"foobar"
05:04cmdrdatsclojurenoob: that'll teach me for clojurebot'ting off the cuff
05:05clojurenoobcmdrdats: no worries :-)
05:06cmdrdatsdissipate: perhaps - but while it's a good thing to have a higher demand, it also means that there's more people on board for the wrong reasons (ie. money and software craftsmanship)
05:06cmdrdatssorry
05:06bob2clojurenoob, how did backslashes get in the string?
05:06cmdrdatslol
05:06cmdrdatsmoney instead of software craftsmanship
05:07dissipatecmdrdats, that's why people are in ruby and python, right?
05:07clojurenoobbob2: clj-json 'generate-string' put them in there
05:07clojurenoobbob2: it generates something like : {\"k2\":\"blurb\",\"k1\":\"blurb\"}
05:07dissipatecmdrdats, i think clojure might be in a sweet spot now. it's big enough to get a job if you really hustle, but not big enough to draw in the money grubbers
05:07clojurenooband I want to remove the backslashes
05:08bob2clojurenoob, nope
05:08bob2clojurenoob, that's just what the repr is
05:08cmdrdatsdissipate: hmm, I'm not exactly qualified to speak for the Ruby camp, but I think they go there for the productivity gains.
05:08bob2clojurenoob, ie it has no backslashes in it, that's just how it prints out strings that have " in them
05:08bob2clojurenoob, this is a common XY problem in python too
05:09clojurenoobbob2: I'm throwing that in a string and outing it on stdout so people can copy the string and run it (does that make sense? )
05:09dissipatecmdrdats, there are some smart people in the ruby community, but i keep seeing sites like: 'learn ruby on rails in 5 nanoseconds'
05:09clojurenoobso while it may just be a repr... I kind of need to remove them in the rep
05:09bob2clojurenoob, nope
05:09clojurenoob(hopes this makes sense :-) )
05:10bob2clojurenoob, how do you think you enter strings that have " in them into the repl?
05:10clojurenoobbob2: I'm not tackling this in the REPL, its part of a cli
05:11clojurenoobso I think you are right, it is the repr that contains these chars
05:11bob2user=> (count "\"")
05:11bob21
05:11clojurenoobbut... I need to remove them or anyone copying the command output from the cli will not be able to run it because of the chars
05:11bob2you don't
05:11bob2the format for /displaying/ strings that have " in them is the same as the format for /entering/ strings that have " in them
05:12dissipateclojurebot, is clojure your first programming language?
05:12clojurebotexcusez-moi
05:13dissipateoops. :P
05:13clojurenoobbob2: I'm trying to output a string like... "curl -v -H 'Content-type: blah' --data '{"k2":"blurb","k1":"blurb"}' ..."
05:14dissipateclojurenoob, is clojure your first programming language?
05:14clojurenoobso it can be copied from stdout , pasted into terminal and run
05:14bob2then don't do that
05:14clojurenoobdissipate: yes
05:14clojurenoobbob2: what can I do instead ?
05:14bob2generate --data "{\"bong\": \"hits\"}"
05:15clojurenoobI'll give it a go
05:15clojurenoobthanks
05:15dissipatehmm, interesting. i thought people learning clojure as their first language was a rarity.
05:16dissipatei thought we were all C++, Java, Python, Ruby and perhaps .NET burn outs and refugees
05:16clojurenoobdissipate: it looks cool, I like the idea of prefix notation and consistency etc
05:16clojurenoobI don't want to be mentally scrambled by the other stuff :-)
05:16dissipateclojurenoob, keep up the good work. you are on a good path. :D
05:17clojurenoobI had a look at Scala, but its a bit crazy :-)
05:17dissipateclojurenoob, i keep seeing talks on Clojure by people who had done Java for 15 years. don't be that guy.
05:17clojurenoobhaha
05:18dissipateclojurenoob, yeah, OOP is actually bad for solving most problems. the vast majority of OOP code in the corporate world is just a complete mess. the 'reusabillity' of OOP was a false promise. :(
05:19clojurenoobseems clojure breaks things apart to make things simple... I need it simple because I'm simple :-)
05:22dissipateclojurenoob, yeah, working with data structures directly is great. however, i have seen some pretty 'intense' clojure code. but it's intense because it is doing a lot in a short amount of space. idiomatic clojure is extremely clever IMO. just have to wrap the brain around it.
05:22clojurenoobyep, I'm just doing simple stuff atm
05:22clojurenoobeven failing on string manipulation :-)
05:23dissipateclojurenoob, that's because it's your first language. but you are lucky because your brain won't be clouded with bad habits and idioms from other languages.
05:26chareso guys how do you architect a gameloop in functional style with clojure
05:26chareall the tutorials are all imperative languages for game architecture
05:27clojurenoobbob2: I tried your suggestion, but unfortunately : --data "{\"bong\": \"hits\"}" is part of a larger string, so it ends up being : --data \"{\"bong\": \"hits\"}\"
05:27clojurenoobunsure how to proceed
05:28clojurenoobI kind of need a way to format one big string
05:31dissipatechare, what kind of game?
05:31chareANY
05:32cmdrdatsnice article on functional game design: http://clojurefun.wordpress.com/2013/03/21/game-development-in-clojure-alchemy-7drl-post-mortem/
05:32noidi_chare, https://github.com/ztellman/penumbra/blob/master/test/example/game/asteroids.clj
05:33dissipatechare, i was actually thinking about a game design that used a rule engine
05:33noidi_http://stevelosh.com/blog/2012/07/caves-of-clojure-01/
05:34dissipatechare, well, a rule engine with events
05:34cmdrdatsI recently read this very interesting series as well: http://prog21.dadgum.com/23.html
05:35dissipatechare, imagine events occur and then the rule engine updates the rule database using backward and forward chaining techniques and then the current 'rule database' at any given moment is rendered on the screen
05:36charelike i was thinking your typical game that uses oop has a type hierarchy so it can shove everything into a CObject container which allows iterating over it to do whatever physics or whatever entity interactions
05:37chareso in functional languages you do what instead
05:38dissipatechare, replace that with data structures passed through pure functions
05:40dissipatechare, entity interactions would be done via async calls
05:42noidi_chare, in Clojure you could use protocols for polymorphism
05:43noidi_say you want to update things in your game loop, but each type of thing needs to be updated differently. just define a protocol containing an update function that takes a thing and returns an updated thing.
05:44noidi_(defprotocol Thing (update [thing])))
05:44clojurenooboh... my problems were because I was using 'prn' instead of 'println'.. better go read up on those two
05:44dissipatenoidi_, and particle collisions?
05:45clgvclojurenoob: println is for output. prn is for serialization of datastructures to text
05:45noidi_dissipate, I've never written a particle system, but I'd assume it would be a function from a set of particles to a new set of particles
05:45clojurenoobclgv: due to ignorance, I kind of thought prn was just an alias :-)
05:45clojurenoobwhoops
05:46dissipatenoidi_, sure, but you need to detect the collision somehow
05:46clgv,(let [s "Hello World"] (println s) (prn s))
05:46clojurebotHello World\n"Hello World"\n
05:46pyrtsapr ≈ print readably, prn ≈ print readably with newline
05:47clgvpyrtsa: thoufh that naming is confusing - readably for whom? ;) in this case it is for the clojure reader
05:47clgv*though
05:47pyrtsaYeah.
05:48pyrtsaAgreed.
05:48clojurenoobnow I'm reading the docs I'm doing better :-)
05:48clojurenoobusually read the manual as a last resort
05:48clgvclojurenoob: you got one of the clojure books?
05:48clojurenoobdid not help here
05:48dissipate,(doc prn)
05:48clojurebot"([& more]); Same as pr followed by (newline). Observes *flush-on-newline*"
05:48dissipate,(doc pr)
05:48clojurebot"([] [x] [x & more]); Prints the object(s) to the output stream that is the current value of *out*. Prints the object(s), separated by spaces if there is more than one. By default, pr and prn print in a way that objects can be read by the reader"
05:48pyrtsaprintln is bad for printing data structures though. It removes quotes around strings nested in data structures as well:
05:48pyrtsa,(let [xs [1 "foo" {:a "bar"}]] (println xs) (prn xs))
05:48clojurenoobclgv: I like the thought of Joy of Clojure, but its a bit advanced for me
05:48clojurebot[1 foo {:a bar}]\n[1 "foo" {:a "bar"}]\n
05:48clojurebotPardon?
05:49dissipateclojurenoob, have you tried brave clojure?
05:49clojurenoobdissipate: not heard of that
05:49clgvclojurenoob: yeah. start with "Clojure Programming" or "Programming Clojure" (Rev 2)
05:49dissipateclojurebot, free online book: http://www.braveclojure.com/
05:49clojurebotI don't understand.
05:49dissipateclojurenoob, http://www.braveclojure.com/
05:50noidi_dissipate, I'm not familiar with collision detection either, but again, I'd assume you'd compose a function that updates each particle's position according to its velocity with another that resolves collisions, updating each particle's position and velocity
05:50clojurenoobthx for the recommendation
05:50dissipateclgv, what about brave clojure?
05:50clgvdissipate: didnt read it yet
05:50noidi_(comp resolve move) :)
05:51dissipatenoidi_, and would you update those in a transaction?
05:52noidi_you don't need a transaction unless you want to update different parts of the world at different rates
05:53dissipatenoidi_, would it be possible to model the game world using a rule engine?
05:53noidi_your game loop can be (loop [state initial-state] (recur (comp render update) state))
05:54dissipatenoidi_, er, not just possible, but effective as well
05:55noidi_no idea :)
05:55dissipatenoidi_, i'm thinking of a 3 layer architecture
05:56noidi_here's a little "game loop" using a tiny wrapper I wrote for quil https://www.refheap.com/57666
05:57dissipatenoidi_, event emitters (these add facts to the rule engine in real time from external events like a player hitting a button), the rule engine itself which uses backwards and forwards chaining techniques to generate new facts that represent state in the game world, and the rendering engine which takes snapshots of the current rule set and renders the game world on screen
05:58noidi_(the only reason the previous state is kept in that example is that I was showing someone how simple it would be to add an undo feature to a purely functional drawing program)
05:59dissipatethe interesting thing is you could write event emitters that queried the rule set and injected random events based on the rule set at that time
06:00dissipatecollisions would be handled entirely by the rule engine
06:01noidisound interesting. write a blog post about it if you ever give it a try :)
06:03noidi*sounds
07:09Pate_Is it possible to write a macro/function that overrides a function with an implementation that calls the original implementation, but returns something else? Like if you wanted println to return the arguments passed to it.
07:11ddellacostaPate_: if you can wrap stuff easily you can do that with with-redefs pretty easily
07:12hyPiRionPate_: already exists, sort of. (alter-var-root #'println (fn [f] (fn [& args] (apply f args) args)))
07:12Pate_thx hyPiRion
07:14noidiPate_, check out the with-redefs function and https://github.com/technomancy/robert-hooke/
07:15Pate_what is this data type? #'examine
07:15Pate_is it a reader macro?
07:15josephwilkvar
07:16josephwilk(var4 (
07:16josephwilk(var examine(
07:16josephwilkExcuse me, wrong channel
07:16Pate_oh, I was really confused for a second :)
07:24bob2Pate_, var quote
07:25bob2ie #'foo <- always the 'var' foo, ignoring any shadowing bindings
08:07clgv,(read-string "#'inc")
08:07clojurebot(var inc)
08:23k3nytest..
08:24k3ny1
08:24thorn2
08:28fredyr2
08:28fredyr3
08:34nightfly4
08:35clgv42
08:36isaacbwso #' has a different meaning from CL?
08:36k3nytest..
08:36isaacbwk3ny: stop :(
08:37isaacbwI was confused about why clojure had #', since it's a lisp 1
08:44llasramisaacbw: Yes
08:46dnolen_isaacbw: unrelated to #' in CL. #' gives you the var, mostly useful for meta programming, but also enables live development in some cases like Ring.
09:22isaacbwis there a decent workflow loading a namespace just for the repl, so that I don't have to write a bunch of (use ...) and (require ...) every time I open the repl?
09:22isaacbw*for
09:25winkisaacbw: define it in a file, in a ns and use (in-ns?
09:25winkor am I missing somethign?
09:26isaacbwso I guess what I'm asking is if lein has a way to set a file as not part of the project code itself, but as something to autoload when the repl starts
09:27winkah, no clue, sorry. I would just use a bogus file and then (in-ns 'bogus) :P
09:32joegalloisaacbw: you can use :repl-options {:init ...} to load arbitrary code
09:32joegalloyou'd put that in ~/.lein/profiles.clj in your :user profile.
09:32isaacbwjoegallo: so no way to do it per-project?
09:33joegalloah, let me see if i understand your question:
09:34joegalloare you saying "oh, hey, all the nses in my project are requiring x, y, z, etc, and i want to just say that once and be done with it"?
09:34isaacbwlet me give a concrete example. I don't need ring.mock.request in my actual server code, but I like to have it in my repl. So I do (use 'ring.mock.request) every time I open the repl
09:34joegalloah, i see
09:34joegallowell, there's two ways i see to do that
09:34isaacbwI'm just imagining how much of a pita that workflow will be when I have more "repl libraries" I want to include
09:35joegalloon is to have something like your-project/test/repl.clj and you could just require and in-ns to there (which was suggested already)
09:35joegallonext, i believe user.clj is loaded when you are placed in a repl
09:36joegalloso you could just drop some forms into user.clj and then you'll have those forms in your repl when you load it, because, well, you're in the user namespace.
09:36joegalloi'm not 100% positive that works, but i'm like 95% :)
09:36joegalloand lastly, i'm pretty sure you could also use :repl-options {:init ...} from inside project.clj, i don't *think* it has to just be in a profile...
09:37joegalloso there's three possible ways you could do it
09:38hyPiRionthere should be a `distinct-by`.
09:38pjstadigi think user.clj would be loaded even in production, but you could drop it in your test directory so it is only available in your dev environment
09:38pjstadigbut i think the third option is probably the best (using a :repl-option in your project.clj)
09:39joegallopjstadig: agreed
09:39joegallothat is, agreed re:test/user.clj, and separately, also agreed re: :repl-option (as that seems the most discoverable to me, user.clj seems like magic...)
09:41joegalloand confirmed that both options work, and further that they work happily together, so you could even mix and match if you have a criminal mind
09:42clgvisaacbw: if your repl supports backward search you can do it without config. just type "(use" and activate backward search, usually you will have the use-command you want in 3-4 keypressed
09:44isaacbwcool, thanks all
09:44isaacbwI'll try my options
11:10jjttjjwhat's the simplest way to output what is captured by tools.logging?
11:11joegallocat some.log
11:13joegalloif you're asking for the sake of like, "oh i want to see that xyz is being output to the logs during a test", then you might look at using with-redefs on clojure.tools.logging/log*
11:16jjttjjhmm you mean things should automatically be written to some.log? it doesn't seem to be the case. Just using a library that seems to be acting wierd sometimes and it has a ton of :debug logging in the code that will probably be useful
11:18joegalloi see, so you're using a library that's using clojure.tools.logging, but you're not seeing any logging.
11:18jjttjjexactly
11:18joegallohow about you configure c.t.l. to use log4j for logging, and then it'll log to wherever you tell it to log
11:18stuartsierraTime to spend some quality time with the Logback (or Log4j) & SLF4J manuals.
11:19joegalloeh, there's a sample log4j.properties in the c.t.l. readme (https://github.com/clojure/tools.logging/blob/master/README.md)
11:19jjttjjok cool thanks
11:20joegalloyou're welcome
11:57yediseangrove: omchaya is pretty sexy -- how did you come up with the architecture / did you look into other methods for organizing client side applications?
11:58seangroveyedi: It's how we built our production apps - it grew out of that. A lot of the patterns emerged from growing, refactoring, growing, etc.
11:59seangroveyedi: Definitely open to other ways of organizing SPA though. This is the best we've found so far, but if there's something even better, that's fantastic
11:59seangroveNeed to come up with a catchy name for the pattern though, and also blog about it. Both of those would help
12:00shep-werkseangrove: +1 blogpost. I like to learn
12:03yedihaving all the app events handled synchronously in one place seems perfect for dealing with spaghetti code
12:03yediseangrove: do you have any plans for omchaya (the app), seems like cool stuff
12:05seangroveyedi: I'd like to continue building it out as a large, best-of-breed reference app
12:05seangroveThings like integrating prismatic's Schema + cljx (like we do in our app) to verify data structure/shape between server/client, fuller testing, server-agnostic clients, etc.
12:11seangroveOh, and actual layout managers, reusable components, etc. That's the stuff I've been hammering on recently, but I've been going a roundabout way.
12:14yediseangrove: not interested in actually getting ppl to use omchaya the app, and not just use it as a reference
12:14seangroveyedi: Well, that would be cool, but it would fall out of it just being a good app
12:14seangroveyedi: Certainly not interested in running a business on top of it
12:15seangroveThough making it multitenant is on my todo list
12:16ystaelI'm having trouble using prismatic/schema's coercion support to define a coercion into an s/defrecord type
12:17ystaelI think I need to define a coercion matcher that applies map->MyRecordType to a raw map, but it's not clear to me where to attach it
12:17ystaelIs there an example of this anywhere?
13:09chris-free
13:10isaacbwwould something like contrib.nlp make sense? (it would be a common API like JDBC, but for NLP libraries)
13:10isaacbwthe thing I'm not sure makes sense is the contrib.*, but it would be cool
13:17mpenetisaacbw: you are building on another lib (open-nlp, stanford, etc)?
13:18isaacbwmpenet: well, it would be an abstraction layer with pluggable drivers for standard, clearnlp, opennlp, nltk, etc
13:19mpenetThat'd be nice. That said, I'd just do it as a regular lib first. There's actually little gain from doing a contrib lib imho
13:20isaacbwexcept I would feel super cool :D
13:20mpenetThey have boring names most of the time, not cool :)
13:21mpenetto be serious, nothing prevent you to make it a contrib later
13:21mpenetprevents*
13:22sdegutisAll I'm saying is, I just think libraries shouldn't be so lax with what their inputs may be. It just leads to confusion when an argument is allowed to be either a string or a map.
13:22jaccarmacHi!
13:23isaacbwsdegutis: I agree completely
13:23isaacbweveryone clojure developer should spend time with haskell on the side
13:23isaacbwteaches good habits
13:23jaccarmacsdegutis: What is that complaint's context?
13:23isaacbw*every
13:23jaccarmacisaacbw: Teaches you to think. Even when you have no idea what's going on...
13:24isaacbwlol
13:24isaacbwI finally figured out the point of monads
13:24isaacbwit's so simple once it makes sense, but so difficult until it does
13:24sdegutisjaccarmac: I found a function in my code which takes a `response` argument and leaves it along if it's a map, but if it's a string, it wraps it like `{:body response :status 200}`
13:25sdegutisisaacbw: I tried to learn Haskell but I had no motivation so I played Starcraft 2 instead that day.
13:25jaccarmacisaacbw: Pretty much.
13:25jaccarmacsdegutis: Hmmm... Yeah, doesn't seem very idiomatic. But polymorphism is useful in some cases i.e. map, reduce, and friends.
13:26locksI think this channel talks more about haskell than the haskell channel :P
13:26sdegutislocks: cuz #haskell is talking about Clojure?
13:27technomancyclojure was mentioned in the erlang factory keynote as having a significantly better getting started story than erlang
13:27technomancyI loled
13:27lockssdegutis: they are? that's nice
13:27Raynestechnomancy: Well, we kinda do
13:27sdegutisno, just making a joke
13:28Raynestechnomancy: "install leiningen"
13:28sdegutissorry, I need practice making jokes
13:28bbloomtechnomancy: you should have shouted "YOU'RE WELCOME!"
13:28sdegutisRaynes: erlang's leiningen is elixir no?
13:28Raynessdegutis: Erlang's leiningen is Elixir's build tool, mix.
13:28hyPiRionsdegutis: no, that's another language on top of erl
13:28technomancyRaynes: I agree, but it just shows how crazy things are in erlang land
13:28Raynessdegutis: Because I made it that way :P
13:29RaynesI purposely wrote the beginnings of the tool before anyone else got to it so that I could inject leiningen into it as quickly as possible.
13:29sdegutisRaynes: so elixir:clojure, erlang:java, mix:lein?
13:29RaynesI couldn't bear the thought of Elixir having anything less. :(
13:29RaynesSure.
13:29RaynesIf we need to make those comparisons.
13:29sdegutiswhich we do
13:30hyPiRion(inc Raynes) ;; for taking one for the team
13:30lazybot⇒ 43
13:30sdegutisoh sorry, im getting a bit off topic here
13:30sdegutisill take it back in the offtopic version of this channel
13:31TimMcsdegutis: And where would that be?
13:31sdegutis#clojure-social
13:32sdegutisBut yeah, I think those kinds of uses of value introspection are really abuses.
13:33sdegutisThe sole purpose is convenience, but in the long run it really hurts convenience, since you no longer have confidence in what types the functions take in, and so you have to check the docs for that function(s) every time.
13:38sdegutisclojurebot: who owns you?
13:38clojurebotPardon?
13:39sdegutis$seen Pardon?
13:39lazybotI have never seen Pardon?.
13:40isaacbwsdegutis: it's hangedman or osmething like that
13:41joegalloit's hiredman :)
13:41isaacbwoh rigfht
13:41isaacbwdammit, so many typos today
13:41isaacbwI look a fool
13:41joegalloi've been having a week of typos, so i'm totally sympathetic
13:52jaccarmacClojure on Glass, anyone?
14:00amalloyisaacbw: you finally figured them out, eh? i think the next step is one or two crises of faith, and *then* actually remembering what you learned when you figured them out
14:01locksLOL
14:09arrdemso pardon the heresy, but what Haskell books (if any) would you lot suggest?
14:09TimMc"Baby's First Monad"
14:10systemfaultarrdem: LYAH
14:10patchworkI second LYAH
14:10arrdemsystemfault: really? I didn't find it terribly illuminating on my first pass, although I did read it without a GHCI instance to hand
14:10patchwork(except for the fonzie bit, blech)
14:11patchworkarrdem: You have to type everything in and experiment with concepts to make it stick
14:11arrdempatchwork: :P this sounds familiar...
14:11systemfaultarrdem: I bought both LYAH and RWH... RWH can be a hard read if you're starting.
14:11patchworkWe are working through it in a workshop and it is good to have a group of people to talk through it with and do experiments with the concepts etc
14:12patchworkYou don't read it like a novel, it is a guide for your own explorations really
14:12arrdemgotcha
14:13justin_smithso kind of like Finnegans Wake
14:14patchworkFinnegans Wake just open in the middle and start reading, so… a little different
14:14justin_smithriverrun, past Eve and Adam's, from swerve of shore to bend of bay,
14:14justin_smithbrings us by a commodius vicus of Functors and IO Monads to Sir Tristram, violer d'amores, fr'over the short sea, had passencore rearrived from static type checking.
14:15steeriois it possible to do the equivalent of execv() in the jvm?
14:15steerioreplacing the process image with that of another to be started
14:19patchworkHaven't seen bitemyapp around here for awhile… or did he just change his nick?
14:20patchworkThe channel has been oddly… civil
14:20TEttingersteerio: http://docs.oracle.com/javase/7/docs/api/java/lang/ProcessBuilder.html it does not look like it
14:21justin_smiththis could be because process clone and exec isn't portable to various jvm targets?
14:21TEttingersteerio, what I've found so far has not been encouraging... Runtime/exec always starts a separate process, and ProcessBuilder/start always starts a new one too
14:21steerioyep
14:22TEttingerjustin_smith, yeah, the docs even mention it being non-portable for all cases
14:22TEttinger(like dos processes starting on win32)
14:22steerioanyway, i'll probably work around this easily
14:22steeriothx
14:23amalloypatchwork: he moved to austin and to #haskell
14:23justin_smithdepending on compatibility needs, you could just use the libc function or directly use the linux system call
14:24arrdempatchwork: can confirm. had dinner with him a couple of times... doubt he'll be back in here ever :c
14:28tbaldridgearrdem: well that was kindof his own fault.
14:28tbaldridgeone of these days I should go to #erlang and start convincing them to use shared memory STM. I'd probably have about as much success.
14:30arrdemtbaldridge: yeah you're entirely correct and more's the pitty.
14:31arrdemaaanyway.
14:31tbaldridgelol
14:34circ-user-hmcDtHello using a new irc client and seems to be acting can someone respond if they receive this message?
14:34arrdemcirc-user-hmcDt: pong
14:35Ravi__thanks
14:35arrdemRavi__: if you ping clojurebot it'll pong for you too.
14:36AeroNotixclojurebot: ping
14:36clojurebotPONG!
14:36Ravi__ah perfect thank you
15:00stuartsierraAny more feedback on the new G.Closure lib package? https://groups.google.com/d/topic/clojure/Ekd_ptNY8Jc/discussion
15:01seangrovestuartsierra: I can give it a try on a couple of projects if that helps. Anything I should look out for specifically?
15:02stuartsierraseangrove: Mostly just make sure all the goog.* stuff works, especially things in or dependent on the G.Closure third-party extensions.
15:19seangrovestuartsierra: Our test suites are pretty small, but they all pass
15:21stuartsierraseangrove: Good, thanks.
15:54abakeris there a way to tell lein to prefer local m2 over maven central?
15:55joegallowhy do you think you need to do that?
15:56abakerlocal patches on third party jars, in fact general ordering of repos would be good where different repo servers may be preferred
15:56technomancyabaker: it always prefers cached jars
15:56abakerah there we go
15:56abakerthanks
15:57hyPiRionabaker: if you need to depend on a patched third party, you should probably deploy the patched jar instead
15:57abakerand the :repositories configuration, that'll just traverse the vector till it finds one?
15:57technomancynp
15:57technomancyabaker: more or less
15:58abakerhypirion: yeah in the process of doing that, but the patched jars still exist for now
15:58hyPiRionah
16:00TimMcabaker: You should use different maven coordinates for your patched version.
16:00katratxohi all, is there are way to debug (print) the classpath used by the `javac` task in lein ? i'm trying to debug `lein protobuf` compilation issue
16:01abakerTimMc: yeah, dropping them in custom group id's is the work in progress
16:01cbpkatratxo: not the answer to your question but lein protobuf doesn't work on windows if you're using it
16:02katratxocbp: not really, i'm on archlinux ;)
16:03TimMcabaker: This should be your first priority when maintaining a forked version -- it's otherwise very easy to get mixed up and have major dev and maintenance problems.
16:03hyPiRionkatratxo: `DEBUG='y' lein protobuf` probably
16:03cbpkatratxo: lein protobuf uses a bash script so you can just check that
16:03hyPiRion/s/probably//
16:04abakerTimMc: yep, I know
16:05katratxohyPiRion: yes i tried that checking lein code (when/debug ...) but didn't print too much
16:05katratxocbp: thanks, will check that
16:08katratxocbp: the code gets generated but the `lein javac` part is the failing one, any hints? https://dpaste.de/LWJE/raw
16:09phaoHi.
16:09loliveiraAny LightTable user around? I can't make log4j log to LightTable's console.
16:09cbpkatratxo: I think you might have an error on your protobuf file
16:10cbpor files
16:10katratxocbp: https://dpaste.de/gV1J/raw
16:11katratxothe example one
16:13cbpkatratxo: I found this https://code.google.com/p/protobuf/issues/detail?id=493
16:13cbpI'm trying to find the actual damn github repo but failing miserably
16:13cbpAll I'm finding is an ancient 0.1 version
16:14cbpAh nevermind they just didnt update the readme
16:36cbpkatratxo: heh sorry for not being of help. I tried reproducing and got a different error. Protobuffers are no fun :-(
16:43katratxocbp: hehe, thanks anyway :)
16:45dacckatratxo: i had some good success with thrift+clojure+lein
16:47llasramcbp: What are you using protobufs for?
16:48katratxodacc: using http://xsc.github.io/thrift-clj/ ?
16:48cbpllasram: The clojure driver for rethinkdb uses protobufs
16:48llasramah
16:48llasramSo can't be helped
16:48dacckatratxo: yes, also lein-thriftc
16:56katratxocbp: now that you mentioned, the lein protobuf plugin 0.3.1 works fine https://github.com/bitemyapp/revise/blob/master/project.clj#L7
16:57cbpkatratxo: good t kno
16:57cbper
16:57cbpgood to know
16:58cbpthat reminds me i really need to maintain that project :(
17:08arrdem`cbp: good news is that it's a pretty solid project, not too much work needed :P
17:35`cbparrdem: thanks :)
17:38mheldanybody here use dropwizard with clojure
17:39technomancymheld: I don't think so. I'm tempted because the name is so good though.
17:40mheldtechnomancy: https://twitter.com/stevelosh/status/355160052333678592
17:40technomancymheld: haha nice
17:41sjlmheld: we use dropwizard, and clojure, but not together
17:41technomancyclojurebot: dropwizard is http://gunshowcomic.com/316
17:41sjlalso yes that ^^
17:41clojurebotIk begrijp
17:41mheldsjl: boo
17:41mheldsjl: also, who's we?
17:41mheld(if you don't mind me asking)
17:41sjlmheld: simple.com
17:41mheldI'm a fan!
17:41sjlthanks
17:41mheldcongrats on the recent news :-)
17:42sjlclojure<->scala interop is pretty much nutbags most of the time
17:42sjlso we don't really try
17:42arrdemtechnomancy: <3
17:42sjlthanks
18:16Anderkent,(binding [*print-meta*] (macroexpand-1 '(NewThing. ^long (long 0))))
18:16clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: binding requires an even number of forms in binding vector in sandbox:>
18:16Anderkent,(binding [*print-meta* true] (macroexpand-1 '(NewThing. ^long (long 0))))
18:16clojurebot(new NewThing (long 0))
18:16AnderkentAm I right in thinking macroexpand ate the type hint?
18:17arrdemAnderkent: no... the reader should eat it before macroexpand happens
18:19Anderkentah, right, I'm not printing it under the binding
18:19Anderkentstupid mistake
18:21amalloyAnderkent: try, though, (.length ^String (doto "x" identity))
18:21amalloyin that case the typehint does get eaten during macroexpansion
18:23arrdem,(meta (second '(.length ^String (doto "x" identity))))
18:23clojurebot{:tag String}
18:24arrdem,(meta (second (macroexpand '(.length ^String (doto "x" identity)))))
18:24clojurebot{:tag String}
18:24arrdemamalloy: lil help here?
18:25amalloyarrdem: you're not macroexpanding the doto
18:25arrdemyeah I was worried about that..
18:25danielszmulewicz(:require [libpath.libname :as name]) is good in both Clojure and Clojurescript, but (:require (libpath [libname :as namee]), while perfectly fine in Clojure, won't compile in Clojurescript. Aargh.
18:25arrdemok.
18:26amalloyin a repl, try: (set! *warn-on-reflection* true) and then eval it
18:27dnolen_danielszmulewicz: the second one just seems like an abomination
18:27stuartsierraI really wish prefix-lists for namespaces had never been included.
18:27danielszmulewiczdnolen_: the second one is handy when you have a lot of libnames under the same libpath, wouldn't you think?
18:27dnolen_danielszmulewicz: no
18:28dnolen_the ns form is an abomination
18:28danielszmulewiczdnolen_: so no prefix-lists for namespaces?
18:28danielszmulewiczstuartsierra: what's the alernative?
18:28dnolen_danielszmulewicz: CLJS is closer to how the ns form should work but still makes too many concessions
18:29stuartsierradanielszmulewicz: Writing out the full namespace name.
18:29stuartsierra If you have too many namespaces, that's a design problem.
18:30danielszmulewiczdnolen_ stuartsierra: your opinion interests me because it seems counterintuitive. The prefix lists saves us from repetition. This seems to be the rationale, right? So I am interested in why you reject it...
18:30danielszmulewiczdnolen_: should according to whom/what? Like in Common Lisp?
18:30technomancydnolen_: I'm curious what the concessions are
18:31bbloomnamespaces != classes in java or whatever. you can put a few thousand lines of code in a single file/namespace and it's no big deal design-wise really
18:31arrdemThrow me on the curious list too.
18:31stuartsierradanielszmulewicz: You can't grep for it. It's harder to parse, both visually and programatically.
18:31stuartsierraAnd it makes it more convenient to create many small namespaces, which I believe is unnecessary.
18:32danielszmulewiczdnolen_: I meant to ask how should the ns form look like in your opinion? What model do you have in mind?
18:32Bronsawell.. I moved to prefix lists for tools.analyzer.jvm since this https://github.com/clojure/tools.analyzer.jvm/blob/930ddbb6bc6e663f4fcaef54455b605fb41679e2/src/main/clojure/clojure/tools/analyzer/jvm.clj#L16-L40 was really too much :/
18:32danielszmulewiczstuartsierra: OK
18:32bbloomdnolen_: it's kinda a shame how bad the ns form is given it's prominence at the top of each file
18:32bbloomBronsa: see now that's a design problem ... of clojure :-P
18:32danielszmulewiczbbloom: it is, right. I always have to look up the docs to remind myself how to work with it.
18:32stuartsierraI almost long for the days when literally the only loading option was "load-file"
18:33danielszmulewiczstuartsierra: but that's even more interesting: why are many small namespaces unnecessary?
18:34bbloomstuartsierra: bronsa's example is a place where i want something "export" like, where everything is not necessarily private, but i only really have ONE or a few api functions to expose
18:34stuartsierradanielszmulewicz: Because namespaces have no semantic meaning. If your symbol names don't clash, you don't need more namespaces.
18:34arrdemstuartsierra: except that you bring in more symbols for both the programmer and the compiler to handle than are strictly required
18:34danielszmulewiczstuartsierra: can I split a namespace in two files?
18:34arrdemstuartsierra: if I can throw an entire API in a single set of four functions and stash it away somewhere, why shouldn't I do so?
18:34bbloomdanielszmulewicz: and if your names are clashing too frequently, than you have to simplify and/or invent some new names
18:35arrdemstuartsierra: no need for it to get inlined into some other larger ns..
18:35stuartsierraYes, you can split a namespace into several files with `load`, although I've never felt the need to do so.
18:35AnderkentI kinda like small namespaces, they're a natural way of separating concerns. Makes tracking things easier
18:35technomancydon't use load =(
18:35arrdemit's done in a couple of places in clojure core...
18:36arrdemdon't do it please.
18:36stuartsierra:)
18:36bbloomarrdem: the fundamental issue is that namespaces/files/vars/etc complect the issues of avoiding name collisions, organizing subsystems, exposing APIs, etc
18:36danielszmulewiczstuartsierra: I want files with little text in them for my sanity. So I would agree with one namespace only if I can spread over many files.
18:36stuartsierraI never intended to say you can only have one namespace. But most projects I see have too many, in my opinion.
18:36bbloomdanielszmulewicz: unfortunately, you're better off just getting used to more text in each file
18:37danielszmulewiczstuartsierra: sorry, didn't mean literally one.
18:37bbloomdanielszmulewicz: it's not ideal, but it's better than working against the grain
18:38danielszmulewiczbbloom: very interesting opinion and different than how I use to think.
18:38stuartsierraSummary of my take: Think of namespaces more like Java packages and less like classes.
18:38bbloom(inc stuartsierra) ; that's a good summary
18:38lazybot⇒ 6
18:40danielszmulewiczGood people, here's a scenario: Suppose we're writing a client-side clojurescript application with ten Om components, I would naturally put each component in its own namespace in its own file. I gather that you would find this a terrible idea, right?
18:40stuartsierraAs usual, I have an old blog post about it http://stuartsierra.com/2011/08/08/clojure-namespaces
18:41danielszmulewiczTo me, I wouldn't mind put all these ten components in the same namespace (as far as names don't collide), but I would mind having eaverything in one giant file....
18:42beamsoi'd have no issues with 10 files if subsets of them were included on each webpage
18:43beamsoif all 10 were included on each webpage :/
18:43Morgawrhow can I check in an if statement if a namespace is included/required/imported in a clojure script?
18:44bbloombeamso: that's not relevant b/c the compiler does tree shaking (ie dead code removal)
18:44MorgawrI mean, this is just for comfort's sake, I'm using LightTable + browser live editing and if I re-evaluate everything it keeps throwing a (harmless) exception about the namespace at the top being already required in the page
18:44`cbpMorgawr: I think you can just eval the namespace name and check if it's not nil?
18:44bbloomdanielszmulewicz: your components are what? 3 to 10 lines each?
18:44bbloomdanielszmulewicz: seems fine to have them in one file...
18:44AnderkentHm, I still don't get what the problem with small namespaces is. I'd rather thing of directories as packages and namespaces as kinda class-like objects
18:45danielszmulewiczbbloom: More likely 25 lines each.
18:45Morgawr`cbp: how do I do that? with eval?
18:45bbloomdanielszmulewicz: step one: write smaller components :-)
18:46bbloomdanielszmulewicz: eh, nevermind. 25 is reasonable for om b/c of the verbosity of the html building forms
18:46bbloomand the overhead of the various signatures for mounting, etc
18:47danielszmulewiczOf course.
18:47bbloomstill, i blame browsers :-P
18:47danielszmulewiczbbloom: So that's a file with 250 lines.
18:47danielszmulewiczstuartsierra: you really work with huge source files?
18:48bbloomdanielszmulewicz: that's a tiny file
18:48stuartsierraWhat's "huge"? My Clojure source files are typically between 250 and 3000 lines.
18:48hyPiRion250 lines is not that much. If you have search functionality, that should be fine
18:49technomancyleiningen has 5 namespaces over 300 loc
18:49technomancyonly one of them is outside leiningen-core (the pom task)
18:49hyPiRion(I'm guessing project.clj is the largest)
18:50technomancyhyPiRion: nearly by a factor of 2
18:51`cbpMorgawr: sorry, actually just check if it's undefined
18:51danielszmulewiczI'm an Emacs user like most here, I suppose. We all have search functionality.
18:51hyPiRionoh wow
18:51technomancydanielszmulewicz: M-x imenu is great for that
18:51`cbpMorgawr: since a cljs namespace is just a js object afaik
18:51danielszmulewiczBut it's a cognitive habit.
18:51technomancyespecially with ido
18:52Anderkentit's less about search and more about reducing the amount of context you have to keep; and with jump-to-declaration I don't see how having code split across multiple files is a problem
18:52danielszmulewicztechnomancy: Ah, so that's your secret sauce!
18:52`cbpMorgawr: actually that may not work with imports
18:52amalloytechnomancy: that's pretty neat. i didn't know about imenu. how would i turn on ido for imenu?
18:53`cbpMorgawr: sorry no clue :(
18:53technomancyhttp://p.hagelb.org/lein-line-count.html
18:53`cbpMorgawr: to answer your how to question though, (nil? my-ns)
18:53technomancyamalloy: ido-ubiquitous does it
18:53alewborg
18:54`cbpMorgawr: there may be a google closure function somewhere that you could use
18:54justin_smithI use outline-mode's hide-sublevels command to turn the buffer into the menu
18:54justin_smiththen I go to the line I want, and re-expand
18:54arrdemtechnomancy: ooh scpaste... do like
18:54danielszmulewiczjustin_smith: Cool.
18:54Morgawr`cbp: heh, thanks for the help, it's probably more hassle than anything, I'll live with the harmless exception (or just comment out the line when I'm doing live editing)
18:55justin_smithshow-all expands it all again
18:55danielszmulewiczstuartsierra: How do you navigate a 3000 loc file?
18:55technomancyarrdem: those counts include blanks and comments fwiw
18:55justin_smithhide-sublevels and show-all are in default emacs
18:55arrdemtechnomancy: ofc
18:56stuartsierradanielszmulewicz: search
18:56stuartsierrahide-show-mode
18:57stuartsierraM-.
18:57danielszmulewiczstuartsierra: Oh, that's interesting. Sound and simple.
18:57danielszmulewiczstuartsierra: Ah, OK.
19:13SegFaultAXIs there a succinct way to describe reduce/fold to someone who doesn't already understand it?
19:13SegFaultAXClojure doc sucks and Haskell's is too long winded.
19:13SegFaultAX,(doc reduce)
19:13clojurebot"([f coll] [f val coll]); f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val i...
19:14arrdemSegFaultAX: why not just explain it in terms of an accumulator loop?
19:14SegFaultAXarrdem: That's what I have right now.
19:14rasmustoyeah, do a looprecur and then its reduce equivalent
19:14SegFaultAXarrdem: But I'm trying to come up with a prose description as well.
19:16amalloySegFaultAX: you can also use something like ##(reduce (partial list '+) 0 (range 5)) as a visual aid
19:16lazybot⇒ (+ (+ (+ (+ (+ 0 0) 1) 2) 3) 4)
19:16SegFaultAXNot necessarily for clj people.
19:16amalloy,(reduce (partial list '+) 0 (range 5))
19:16clojurebot(+ (+ (+ (+ (+ 0 0) 1) 2) 3) 4)
19:16SegFaultAXAgain, I'm trying to distill the essence of a reduce or fold.
19:17amalloySegFaultAX: i'm arguing that's what this is. it's the expression tree that reduce evaluates
19:18technomancy"making changes to a single accumulator value for each element in a collection"
19:18SegFaultAXamalloy: But that's not prose.
19:18SegFaultAXtechnomancy: Closer!
19:18amalloywell you didn't ask for prose until this very second
19:18SegFaultAXUh, yes I did.
19:18SegFaultAX16:13 < SegFaultAX> arrdem: But I'm trying to come up with a prose description as well.
19:18amalloyoh, i guess you did in the middle of a discussion with arrdem. i didn't notice it
19:18SegFaultAXNp
19:18brehautSegFaultAX: an abstraction of primative recursion
19:19arrdemSegFaultAX: someone's on irssi...
19:19SegFaultAXarrdem: ;)
19:19SegFaultAXbrehaut: I started with a technical definition (more like Haskell's) but I want something more easily parsed.
19:20SegFaultAX3 of the 5 words you named might require additional description.
19:20brehautSegFaultAX: i think its like monads: you can come up with simpler explainations but they miss the full details.
19:21brehautits hard to explain because its a pretty general operation with a sort of mathematical basis
19:21SegFaultAXbrehaut: I know. The weird thing is map and filter are trivial to describe. Reduce is only moderately more complex, and considerably harder to describe.
19:21brehautSegFaultAX: the code is only moderaly more complex but the operation is vastly more general
19:21SegFaultAXbrehaut: True.
19:21SegFaultAXMaybe a more technical definition is warranted then.
19:22charewtf is going on with MH370?
19:22beamsochare: it's a mystery
19:30isaacbwhow do libraries become contrib?
19:30arrdemisaacbw: they are invited to become so
19:31dnolen_isaacbw: arrdem: people can also propose them on clojure-dev and see what people think.
19:45SegFaultAXSo here's why I'm asking about describing reduce: I want to see if implementing map, filter, and reduce make for good phone screening material.
19:47SegFaultAXThe questions I usually ask are pretty algorithmic and potentially time consuming, and I want to see if using these basic algorithms as a lead in to tougher questions is a good weeder.
19:47daccSegFaultAX: how about "implement map in terms of reduce"? =)
19:47SegFaultAXdacc: That'd be a bonus question, yea.
19:48technomancySegFaultAX: in a specific language, or up to the interviewee?
19:48SegFaultAXHow do people feel about using map/filter/reduce as tech screening questions?
19:48SegFaultAXtechnomancy: Up to the interviewee.
19:48SegFaultAXI'm giving reference impls in Python, Ruby, and JS, but that's just for the interviewer.
19:48`cbpI remember implementing map, and the variadic argument one version pretty tough
19:48`cbpwas*
19:49SegFaultAX`cbp: Depends on if your language already has a sane notion of iterators. :)
19:49`cbpSegFaultAX: I was doing it with just car cdr and stuff
19:49`cbpI mean first rest and stuff ;)
19:49arrdemif you're screening people who have written or who claim to have written functional code it seems entirely reasonable.
19:49beamso_for me it seems weird to ask phone/tech screening questions of something that you'd never do
19:49SegFaultAXBut yea, I'd be asking for the simple version, not the zip-style Clojure has.
19:49technomancySegFaultAX: I might be worried if someone who couldn't implement map in terms of reduce actually made it as far as a coding interview
19:49SegFaultAXtechnomancy: That's why I want to use it as a weeder question.
19:49arrdemSegFaultAX: I think that particular example is a fair weeder question.
19:50SegFaultAXMy thinking is have them do map and filter normally to warm up.
19:51SegFaultAXThen reduce, then re-implement map and filter in terms of reduce.
19:51technomancySegFaultAX: yeah, it'd be good to ask early on, big red flag if it's not a quick warm-up
19:51SegFaultAXBut I'll a/b test my approach to see if I get better results.
19:51SegFaultAXtechnomancy: Yup, these are purely tech screen questions.
19:51arrdemseems reasonable to me...
19:51arrdembut I think about 80% of the kids I go to school with would get hammered by that
19:51SegFaultAXAs in, if you can't answer these without much help, then you don't make it beyond phase 1.
19:51arrdemjust by dint of not recognizing the names.
19:51arrdemthe idea they could probably get given a reference imp'l.
19:51SegFaultAXarrdem: That's why I have a prose explanation.
19:51amalloy`cbp: what's hard about the vararg case?
19:52amalloySegFaultAX: you really want to do coding questions over the phone? how does that even work logistically?
19:52SegFaultAXamalloy: coderpad.io or stypi.com
19:52`cbpIm unsure if amalloy is just dissing me :P
19:52arrdemamalloy: either of those actually work out pretty well... used coderpad yesterday for IBM coding interview.
19:52`cbpI cant quite remember I need to look at the source
19:53SegFaultAXYup.
19:53arrdem`cbp: if you did it in C that's reason enough :P
19:53SegFaultAXI used to use collabedit, but it feels significantly worse lately.
19:53arrdemI think that 10gen used collabedit but that was a long time ago.
19:54SegFaultAXcoderpad is soo much better. You can run the code inline.
19:54SegFaultAXAnd they support quite a large number of languages by now.
19:54`cbpamalloy: you don't go from a 1 coll to many collections in a straightforward way
19:54arrdemwell except that a bunch of the "coding screen" questions I've seen are self-answering if you can just run the mother...
19:54novocharWhat is the difference between node's streams and the core.async library?
19:54SegFaultAX`cbp: Unless you handle them all the same way.
19:55`cbpSegFaultAX: I mean from the obvious implementation of handling 1 coll to implementing handling many colls
19:55amalloycoderpad looks pretty decent. neat
19:55SegFaultAXamalloy: It supports Clojure now!
19:55amalloyyes, i saw that
19:56`cbpI mean it's not earth shattering hard but when I was trying to live code it to some people I was like.. yeah I need to do this calmly on my own
19:57`cbphttps://www.refheap.com/58038
19:58gfredericksthat's the second time at least I've been baffled by clojure catching FileNotFound and assuming it's a namespace typo
19:58sdegutisjballanc: same jballanc from #macruby?
19:58SegFaultAX`cbp: Well that's because clojure.core/map is doing extra stuff
19:58amalloy`cbp: that's hardly fair. it contains the chunking nonsense and also the variadic unroll. https://www.refheap.com/58039 would be a more normal implementation
19:58SegFaultAXLike chunked seqs
19:58sdegutisoops, i could have just checked, sorry for the noise
19:58SegFaultAXBut you don't have to do that.
19:58hiredmangfredericks: huh?
19:59hiredmangfredericks: did that patch land?
20:02amalloySegFaultAX: i found it pretty hard to write only the [f & colls] version, without special-casing only-one-collection
20:02amalloysince you end up wanting to use the single-arity version to map first & rest over the input sequences
20:02gfrederickshiredman: patch? this could even be leiningen's fault, I dunno
20:02amalloyif you have a good example of "handling them all the same way" i'd love to see it
20:02gfredericksit's happening with `lein run` in particular
20:02hiredmangfredericks: oh, yeah, that is lein's fault
20:02gfrederickssounds haxy to fix
20:02hiredmangfredericks: but there is a jira ticket for getting better error messages from clojure when you use - instead of _ in file names
20:02hiredmanwhich is what I assumed you were talking about
20:02dacci think collabedit is defunct
20:02`cbpamalloy: That's not valid code =P
20:02daccor was a couple weeks ago when i tried to use it
20:03amalloyoh, fine fine. https://www.refheap.com/58040 then
20:04gfrederickshiredman: oh no; this is any program that crashes with a FNFE for any reason
20:04amalloyi always forget the compiler won't let you do that
20:04gfrederickslein reports it as a namespace typo
20:05hiredmangfredericks: because lein doesn't set your hair on fire or something
20:05gfredericksyep current lein too
20:05gfrederickshiredman: aw snap
20:06gfredericksI should file an issue mentioning my hair on fire in the title
20:12hiredman"dear philip, I am penning you this missive because your apparatus has caused my coiffure to alight like dry kindling, rather upsetting those in the local environs. Be a good chap and see what you can do about it. -- YT &etc"
20:15amalloynorth, sir? everyone knows that the only thing north is the mad scientist leiningen! i'll need more than a ha'penny for that task
20:19hiredmanwell, like, canada is up there too
20:19cbpamalloy: oh well :-P
20:19gfredericks(inc hiredman)
20:19lazybot⇒ 38
20:19gfredericks&'where-are-you
20:19lazybot⇒ where-are-you
20:19gfredericksso much internet money being lost by lazybot's absence
20:19hiredman"the mad scientist leiningen‽ he'll grind me up and use my bones for building keyboards!"
20:19arrdemgfredericks: idk what you're talking about... fido is working fine for dogetips :P
20:19arrdem"Good job you go now then son, he just finished his last 'board and it'll be a while yet before inspiration strikes him again"
20:19hiredmanI really should stop
20:19hiredmanI could spend all day implying that technomancy is a mad scientist living in a steampunk world
20:19arrdemas long as they have 64 piston adding machines..
20:19gfredericksclojurebot: I could spend all day implying that technomancy is a mad scientist living in a steampunk world
20:19clojurebotIk begrijp
20:20gfredericksMy Hobby: teaching clojurebot anything that contains "is" somewhere in it
20:20arrdem~technomancy
20:20cbpwhat the hell?
20:20gfredericksclojurebot: technomancy?
20:20clojurebottechnomancy codes while wearing gravity boots to increase the blood flow to the face transplant he got after discovering the world does not treat build tool creators kindly
20:20hiredmanalso he codes using his keyboard pants while hanging upside down to increase the blood flow to his face translate that he got after going in to the witness protection program because he created a build tool
20:20hiredmantransplant
20:21cbp(I had hoped that would trigger clojurebot)
20:21arrdemoooh man this is gold
20:21arrdemtechnomancy: please tell me you're a tea man
20:28gfredericksyou know I might have written this code myself
20:28gfredericksoh and it's even fixable without {refactor,hax}ing
20:31danielszmulewiczSo many options for websockets <-> cljs/core-async communication! Too many! Sente or Chord? Or Http-kit alone? Suggestions welcome...
20:49amalloyi guess the easy-mode definition of map is just (defn map [f & colls] (apply mapcat (comp list f) colls), SegFaultAX. i hope an interviewee tries that at some point
21:03SegFaultAXHas anyone ever used nginx-clojure?
21:28gfrederickshiredman: I put out my own hair-fire: https://github.com/technomancy/leiningen/pull/1470
21:29sdegutiswelp
21:29sed-utilser, welp
21:36mlb-Is there any nice Clojure-y way to read in a subset of a file given a byte offset and a length of bytes?
21:37joegallofile or inputstream?
21:37gfredericksnothing I know of besides the RandomAccessFile class
21:37gfredericksi.e., same as in java
21:40joegallogfredericks: agreed, if it's a file, then RandomAccessFile, if it's an inputstream, then you could .skip and wrap it in a commons-io CountingInputStream, but yeah, that's all just the same as in java
21:40gfrederickshe did say file
21:40mlb-yeah, I'm currently dealing with a file
21:40gfrederickss/he/the-person/
21:41mlb-reading JavaDocs
21:41mlb-thanks, gfredericks, joegallo
21:41gfredericksnp
21:41mlb-for the moment, I want to effectively grep the first 500MB of a file for a string's existence or not
21:42mlb-I could shell out and just: head -c$((500*1024))K filename | grep -m1 my_string
21:44mlb-but I'd like to try and be a bit less hackish about the whole thing
22:22isaacbw,(. java.util.UUID randomUUID)
22:22clojurebot#uuid "cccb4ca3-fa4b-42bd-a58a-372a2ae09316"
22:23sed-utils,(java.util.UUID/randomUUID)
22:23clojurebot#uuid "9c35e6c9-7624-409e-9ea6-c3a600b76a91"
22:23isaacbwoh
22:23isaacbw:D
22:28sed-utilsxD
22:29isaacbwis there a proposal layout guide for clojure?
22:29sed-utilswhat should that mean?
22:30isaacbwer, GSoC
22:31sed-utilsshrug
22:32TravisDAnyone here live in Ann Arbor? I'm visiting the University of Michigan, and if you're on campus tomorrow it might be fun to have a chat
23:00sed-utilsnot i
23:17nopromptmacros are bananas
23:17seangroveB-A-N-A-N-A-S
23:18seangrovenoprompt: Do you have a plain css parser in clojure?
23:18nopromptseangrove: thorn can do it.
23:18nopromptwell almost, media-queries aren't finished.
23:18seangrove$google clojure thorn
23:19nopromptit'll emit (scss->edn "path/to/yo.css")
23:19seangroveOh, that's fantastic
23:19nopromptsass' media-query stuff is a bit weird and i haven't worked up the energy to finish emitting proper tags.
23:20seangroveOh, I just need a property parser
23:20nopromptoh, well the cool thing is, once you have parsed the css in to edn
23:20nopromptyou can just call (filter-tag (tag= :declaration) edn-tree))
23:21seangrovenoprompt: What about a cljs version? Looks like there's some pretty crazy stuff in the project
23:21noprompti haven't pushed it to clojars yet cause i'm still working on it, but nothing is stopping you from cloning it
23:21nopromptcrazy?
23:21dnolen_isaacbw: there's a proposal, I would follow the examples you find there
23:21nopromptnah it's actually stupid simpl.
23:21seangrovenoprompt: zweikopf in particular ;)
23:21dnolen_isaacbw: er GSoC proposal page
23:21nopromptseangrove: oh that's not a big deal.
23:21noprompttakes like 5 seconds.
23:22nopromptonce it's loaded it's reasonably fast.
23:22seangrovenoprompt: Oh, the app I'm working on is entirely in-the-browser cljs at the moment. Will add a server component later, but the more I can do in the browser, the better
23:23nopromptseangrove: well one thing you can do is use the CSSOM
23:23nopromptseangrove: if the CSS is already loaded as a stylesheet in the browser you can use goog.cssom's utilities to fetch properties.
23:24seangrovenoprompt: No worries, will work on it later anyway
23:26nopromptthis macro is wacky https://gist.github.com/noprompt/9541611
23:26nopromptdnolen_: i'm not sure of a better way to implement it.
23:28nopromptthat is if it's easy to tell from the example what it's doing
23:28iwilcoxamalloy_: I like keywordize in utils.
23:28nopromptseangrove: that's the style of selector i'm working on. :-)
23:29nopromptit's kind of a trip.
23:33iwilcoxamalloy_: (Obviously it should be keywordise, but I'll let you off the heterography.)