#clojure logs

2015-10-03

02:03zhaoliangliuhi guys..
02:04zhaoliangliuanyone there?
02:04zhaoliangliuhi?
04:51wombawombaWhy won't this work? (defmacro m [n] (let [as [myarg#]] `(defn ~n ~as (prn myarg#))))
04:51wombawombaAnd how do I fix it?
04:57hiredman# as an auto gensym only works inside syntax quote `
04:58hiredmanI dunno what you are trying to do with that let
04:58hiredmanoh
04:58hiredmanthe arg list
04:58hiredmananyway, you can manually gensym with the gensym function
04:59hiredmanor, depending on what you are really doing, at least in your example you could rewrite it in such a way as to make autogensyming easier
05:00wombawombahiredman: I'm really trying to insert extra arguments when generating a function
05:00expenseBotGreetings! Send me a PM and I'll echo it back to you. If it contains the word 'die', I'll die as a bonus!
05:01wombawomba(defmacro m [n] (let [as [(gensym 'myarg)]] `(defn ~n ~as ~(prn myarg#)))) also doesn't seem to work
05:03expenseBotGreetings! Send me a PM and I'll echo it back to you. If it contains the word 'die', I'll die as a bonus!
05:04expenseBotGreetings! Send me a PM and I'll echo it back to you. If it contains the word 'die', I'll die as a bonus!
05:05oddcullyah /ignore-ance is bliss
05:07jeaye!ops
05:12vish_hello
05:13expenseBotGreetings! Send me a PM and I'll echo it back to you. If it contains the word 'die', I'll die as a bonus!
05:14expenseBotGreetings! Send me a PM and I'll echo it back to you. If it contains the word 'die', I'll die as a bonus!
05:16expenseBotGreetings! Send me a PM and I'll echo it back to you. If it contains the word 'die', I'll die as a bonus!
05:17vish_@expenseBot hi
05:53expenseBotGreetings! Send me a PM and I'll echo it back to you. If it contains the word 'die', I'll die as a bonus!
05:54hyPiRionamalloy: ^
05:55@amalloydangit now i gotta remember how to do it
05:55@amalloywell, i guess he isn't setup to autojoin
05:55hyPiRion(inc amalloy)
05:55hyPiRionoh no, lazybot
05:55hyPiRion=(
07:39taylanubI'm trying to package Clojure for GNU Guix. can it be built without Maven?
07:39felipedvorakAny insider info on when Clojure for the Brave will be updated?
07:50trisshow can you fond the list of protocols a type satisfies?
08:01noncom|2taylanub: if you look here https://github.com/clojure/clojure it is all maven
08:01noncom|2taylanub: but you can do the same with ant, for example
08:02noncom|2taylanub: also there's maven plugin that creates an ant script from maven xml
08:02trisshey all I wan to dispatch a multimethod when input makes `sequential?` true
08:02trissis there a Sequence type i can match on some how?
08:02noncom|2triss: on your first question: try (extends?) or (extenders)
08:03trissI know I can clojure.lang.IPersistantList but I want vectros too.
08:04taylanubnoncom|2: thanks for the help. I think I'll just use Leiningen for now and leave the Guix package for later; apparently Maven is a pathological case for Guix.
08:07noncom|2triss: why don\t you check for the exact type?
08:09noncom|2triss:
08:09noncom|2,(instance? clojure.lang.PersistentList (list 1 2 3))
08:09clojurebottrue
08:09noncom|2(instance? clojure.lang.PersistentVector (list 1 2 3))
08:09noncom|2,(instance? clojure.lang.PersistentVector (list 1 2 3))
08:09clojurebotfalse
08:12noncom|2taylanub: yeah, they're no big friends. i'd say that if you're into anything serious clojure, you're into using lein/maven anyway, since it'd be hell if you dont
08:13noncom|2triss: r u still up to the music programming?
08:14noncom|2taylanub: there's also boot - some other build tool, which also makes progress today, but i did not have a chance to look at it yet. however i think it is maven too
08:18taylanubyay, 1 hour into Clojure and I already found something to contribute :P https://github.com/clojuredocs/guides/pull/216
08:20winktaylanub: I think I've never seen anyone installing clojure via package manager anyway. Not saying it doesn't make sense to package it.. but, as you said.. it's more like with ruby and bundler.
08:21winkyou need a jvm and lein
08:22noncom|2taylanub: cool :)
08:22trissnoncom|2: yeah man. still all music related. making something for describing musical patterns in the same way SuperColider does today
08:22trissI'd like to match on both vectors and lists
08:23trissfrom a multimethod
08:23noncom|2triss: then make (or (inst? Vec.. ) (inst? List..) )
08:23noncom|2triss: will match both
08:23noncom|2(i wrote pseudocode)
08:24noncom|2triss: your question last time i was here - about representing musical laws with core.logic reminded me on how i once thought about putting all data from the "music guide. tl;dr" into a core logic program
08:24noncom|2could be quite an interesting experiment
08:25trisswhats the "music guide"?
08:25noncom|2triss: this http://www.global-trance.com/misc/music_theory_tldr.pdf
08:26noncom|2triss: i thought the text is laid out perfectly to be translated to some computer knowledge system which then could manipulate it
08:26trissah. yes... I think I'm dreaming of having db with that stuff in.... not even sure what I'd ask it yet though.
08:27noncom|2triss: you could give it some noise data (not musical noise) and ask to repair it using the laws
08:28noncom|2for example
08:28noncom|2triss: or give it some rule and ask to build a piece around it
08:28noncom|2triss: or give it a melody and ask to reformulate using the laws
08:28noncom|2and much and much more
08:29noncom|2yay, that's an itch! i'm gonna start laying it out as soon as i have some free time :D
08:29trissindeed. I'm sure it could be quite exciting...
08:30trissdoes anyone know of any examples working with logic programming and muisc?
08:33noncom|2did not look for it
08:33noncom|2but saw many with neural nets
08:38noncom|2how do you think, can logic programming and music composition somehow work together?
08:54trissnot sure yet... need o get in to logic programming...
09:38irctcHi everyone.
09:39irctcI need some help configuring OAuth for Goodreads API.
09:39irctcI have posted this question on stackoverflow explaining the problem but it still has no answers: http://stackoverflow.com/questions/32920728/configuring-oauth-with-goodreads-in-clojure
09:40irctcIs there anyone who could help me with this?
10:03irctcCan anyone help me out with my question of stackoverflow? http://stackoverflow.com/questions/32920728/configuring-oauth-with-goodreads-in-clojure
10:03irctc*on
10:11noncom|2irctc: well, 401 means unauthorized
10:12noncom|2the error codes manual says that the response 401 should also contain header WWW-Authenticate which describes what you need to do to authenticate
10:12noncom|2you in returns should send a request containing header "Authorization" with the relevant data
10:13noncom|2or, as i understand, send a request with such a header in the first place, even before you get the 401
10:13noncom|2irctc: so, in the end, you can try to see what else does the 401 response contain, print it out and look for the WWW-Authenticate field
10:13irctcOk, but how do I do that? I am sorry but I am copmletely new to OAuth or API authorizaqtion in general.
10:14noncom|2irctc: well, you're getting 401 right? what if you print it?
10:15irctcok, i'll try that out.
10:16noncom|2i'm not very familiar with oauth also, but just trying to apply some general http knowledge
10:16irctcWhat I get in my terminal is pretty cryptic and confusing. The only part I really recognize is the 401 error.
10:17noncom|2maybe you post the response to refheap?
10:17irctcWhat is refheap?
10:17noncom|2just google refheap
10:17noncom|2it's a pastebin
10:17noncom|2or another pastebin, not necessarily refheap :)
10:17TMAoauth is a complex beast
10:18taylanub(conj '(:a :b :c :d) :e) => '(:e :a :b :c :d) ;that was kinda unexpected...
10:18taylanub(going through koans)
10:18noncom|2taylanub: that's what it should be
10:19noncom|2lists get conjed at the beginning
10:19taylanubwhat's the difference from consing?
10:19noncom|2well, if you come from other lisps - no difference except that afaik clojure lisks are not made of cons cells
10:19TMAirctc: it's better to read up some coherent tutorial on oauth first -- it's not easy to comprehend just by poking around
10:20noncom|2TMA: irctc: also agree with TMA
10:20taylanubI meant to ask, what's the difference from using cons in Clojure. just the argument order?
10:20TMA,(conj ':e '(:a :b))
10:20clojurebot#error {\n :cause "clojure.lang.Keyword cannot be cast to clojure.lang.IPersistentCollection"\n :via\n [{:type java.lang.ClassCastException\n :message "clojure.lang.Keyword cannot be cast to clojure.lang.IPersistentCollection"\n :at [clojure.core$conj__4104 invokeStatic "core.clj" 82]}]\n :trace\n [[clojure.core$conj__4104 invokeStatic "core.clj" 82]\n [clojure.core$conj__4104 invoke "core.cl...
10:21TMA,(conj '(:e) '(:a :b))
10:21clojurebot((:a :b) :e)
10:21noncom|2taylanub: cons will work like conj for vectors too
10:21noncom|2taylanub: i think it is provided for compliance with other lisps
10:23irctcHere is the response I get in my Terminal when I try to run lein ring server on my project: http://pastebin.com/gjLBHHCf
10:23noncom|2,[(cons 1 [2 3]) (cons 1 '(2 3)) (conj [1 2] 3) (conj '(1 2) 3)]
10:23clojurebot[(1 2 3) (1 2 3) [1 2 3] (3 1 2)]
10:23noncom|2taylanub: ^ there's not much more to that
10:24noncom|2taylanub: also, if you do huge works on lists/vectors, the right choice might affect speed i think
10:24taylanubI just tried that too, and (conj '(1 2) 3) => (3 1 2) yet (conj [1 2] 3) => [1 2 3] seems quite nasty :\
10:24taylanubI guess conjoin should be viewed as a "set" operation?
10:24noncom|2taylanub: correct. conj adds elements to the end of the [], but to the start of a ()
10:25noncom|2irctc: omg pastebin is blocked in my country! :D
10:25clojurebotIn Ordnung
10:25taylanubpastebin.com is so bad it should be blocked everywhere :P
10:25noncom|2haha, maybe... but in my country we have some really strange things going on... :/
10:25irctcThe other one just displays it all in one huge line.
10:25noncom|2taylanub: idk what is conjoin btw, there's no such function
10:25taylanubwhere is that? Turkey is also freaky like that, tho I'm in Germany now.
10:26taylanuboh I meant conj with conjoin
10:26noncom|2i live in russia. stupid people in government things going on here.
10:27taylanubah, I see.
10:27irctcWhy is pastebin blocked in Russia?
10:28noncom|2many non-harmful sites get blocked in russia because they share IP or servers with some other sites that contain extremist material or child porn
10:28noncom|2however, usually there's even no such material or porn
10:28noncom|2it's just stupidity of people trying to justify their position in government
10:28noncom|2they don't even understand how inet works
10:28irctcSorry to hear that.
10:28taylanubwhat's there not to understand, it's just a series of tubes :)
10:28irctcHahaha, lol!
10:29noncom|2yes! :) but george did not do stupid things to it, as far as i know at least :D
10:30noncom|2so, there's that unblocking site.. i got through to your paste
10:30noncom|2here: "WWW-Authenticate" "OAuth realm=\"http://www.goodreads.com\""
10:30noncom|2probably you're not setting the realm?
10:31taylanubTor Browser Bundle also works pretty well these days
10:32noncom|2but as TMA said, a good oauth tutorial is a must-read i think...
10:32noncom|2yeah, there are people using tor too
10:32irctcI have no idea what a realm is though.
10:32irctcWhere do you go about setting that up?
10:32noncom|2in your oauth request?
10:33noncom|2http://stackoverflow.com/questions/8577428/what-does-oauth-1-0-realm-stands-for
10:33noncom|2here's a good tutorial http://self-issued.info/docs/draft-ietf-oauth-v2-bearer.html
10:34noncom|2taylanub: did you work in other lisps?
10:35noncom|2taylanub: if not, take a look at this: http://www.gigamonkeys.com/book/they-called-it-lisp-for-a-reason-list-processing.html
10:36noncom|2it will explains why lists get appended at the beginning
10:36irctcThanks. I need to take a closer look at the link you gave me. OAuth just seems so complicated.
10:37noncom|2irctc: yes, it is :/ i have to take a look at it too, when i get to implementing it since i am so noob in it
10:42irctcnoncom|2, thanks for your help. I'm gona go study that tutorial.
10:42irctcTake care everyone and have a nice day! :)
10:42noncom|2thanks :)
10:47hellofunktriss: do you like Pink and Score?
10:49trisshellofunk: I've not seen pink and score!!!! another video to watch. thanks forthe heads up. have you played with it?
10:50trissoh, blue. not thought about sound land for a longtime
10:51trissoh man how have I missed this.
10:52devnhrm, I guess I never realized Peano arithmetic was turing complete...
11:01hellofunktriss: pink is huge, and so is score, and both are written by a C-Sound developer. Pink is like SuperCollider but written entirely in Clojure, unlike overtone, which is just a Clojure wrapper around SuperCollider
11:02wasamasapink?
11:02wasamasanever heard of it
11:03hellofunkwasamasa: it's a novel synth engine written in clojure
11:03wasamasahellofunk: interesting, thanks!
11:04wasamasahah, it's not 100% clojure
11:04wasamasanot sure why though
11:04wasamasasrsly: https://github.com/kunstmusik/pink/blob/d6fd11f9b3fad574f14f00bdd704e560c6eb8b74/src/main/pink/Utils.java
11:09taylanubnoncom|2: I'd say I'm fairly advanced in Scheme and reasonably advanced in Elisp. I understand cons, but I don't know conj from any other lisp.
11:09hellofunkwasamasa: well technically in clojure nothing is 100% clojure.
11:12wasamasahellofunk: it's not about the implementation, it's about what language the projects is written in
11:12noncom|2taylanub: ah, yeah, it's special for clojure..
11:14sdegutisWhen should a thing be a Component with methods, vs just a group of functions with a common first parameter(s) in the same namespace?
11:15sdegutisMy current thinking is that it should be a Component if it's a service that (1) has a live-version and a test-version, AND (2) is a dependency of another such service
11:16sdegutise.g. email service, database service, web router service
11:16noncom|2sdegutis: in my opinion, if you're writing your program using component, why not make everything component?
11:16noncom|2any namespace could be said to be a service
11:16sdegutisWhereas free-floating functionality that *uses* any of these services should just be functions that take parameters.
11:17sdegutisnoncom|2: In the past I have preferred to make few things as possible Components so that it's more friendly to live-reloading of code definitions *without* needing to shutdown/restart the entire System component.
11:17hellofunkwasamasa: well, my point is that if you have a file that is clojure, but you make calls out to Java a lot with interop, then it is not 100% clojure in my opinion, and this is typical in a lot of clojure programs that rely on lower level stuff, like Pink with audio processing. in his case, he has just written some of the files in java directly
11:18noncom|2sdegutis: hmmm, that reason sounds like an implementation detail.. but it has weight really
11:19sdegutisnoncom|2: well I really like repl-driven development and find it incredibly fast, so that I can redefine a function while my system is running live, re-run the tests for that function (which creates a test-system and uses that against my new function definition), and not have to shut down the system if possible
11:20noncom|2that's for sure
11:20noncom|2the living repl is the source of all life in this world :)
11:22noncom|2sdegutis: well, actually i doubt anyone can tell you when something is worth making a component... from the theoretical point of view, i guess it's coming to "everything is a component", but from the practical one, as you have already mentioned, that's not always feasible
11:23noncom|2devn: that's interesting
11:23noncom|2you've reminded me of it again. i guess i have to explore it finally
11:26sdegutisnoncom|2: um, typo? I don't see devn here saying anything...?
11:26sdegutisjustin_smith: what's your opinion on this component design?
11:40noncom|2sdegutis: he did, but before you have joined
11:40noncom|2sdegutis: he said that peano arithmetics is turing-complete
11:40sdegutiso
11:41noncom|2i did not even study that calculus indepth
11:41noncom|2i think i have to
11:41noncom|2seems rather interesting
11:42justin_smithit's used to establish that you can derive numbers and arithmetic from set theory
11:43justin_smithsdegutis: the point of a system is that the components are interdependent, if you have parts that can be restarted on their own, without restarting the rest, they are either "leaf nodes" downstream of all other dependencies, or they are not part of the same system
11:43sdegutisjustin_smith: meaning things that nothing else depends on?
11:44justin_smithright
11:45sdegutisjustin_smith: I'm experimenting with the concept of a quicker deployment whereby we simply redefine parts of the running system in production (via a secure REPL of course) and restart the live System component after redefinition. But I'm looking for ways to avoid that last step.
11:45sdegutisOf course, the danger of redefining just one part of a system is that if anything else depends on it or uses it, they need to see this new change. Usually Clojure vars are bound late enough that this works. But not always. That's the messy part I'm trying to figure out.
11:45sdegutisIs this a common technique already?
11:46monstaExcusme, what "#=" keyword means?
11:46justin_smithsdegutis: you could extend component so that along with its current dependency tree definition, you could figure out for a given tree of components, give that components d, f, g are changed, but no others, how to restart only the ones needed to propagate those changes
11:46justin_smithkind of a lazy-restart
11:46sdegutismonsta: Usually # begins a reader macro, but I have never heard of #= before
11:46justin_smithmonsta: it forces eval inside string reading
11:46justin_smithmonsta: and it is terrible
11:46sdegutisOh, must be a new 1.7 thing
11:47monstaO.o
11:47monstaThanks
11:47justin_smithsdegutis: no, it's old, and it sucks, and you should not use it
11:47sdegutis,(read-string "#=(prn :lol)")
11:47clojurebot#error {\n :cause "EvalReader not allowed when *read-eval* is false."\n :via\n [{:type java.lang.RuntimeException\n :message "EvalReader not allowed when *read-eval* is false."\n :at [clojure.lang.Util runtimeException "Util.java" 221]}]\n :trace\n [[clojure.lang.Util runtimeException "Util.java" 221]\n [clojure.lang.LispReader$EvalReader invoke "LispReader.java" 1100]\n [clojure.lang.LispRe...
11:47monstawhat are the alternatives?
11:47sdegutis,(binding [*read-eval* true] (read-string "#=(prn :lol)"))
11:47clojurebot:lol\n
11:48justin_smithmonsta: reading and eval as distinct operations, no magic strings that cause themselves to be evaluated?
11:48justin_smithmonsta: you can use clojure.edn/read-string instead of read-string
11:48monstaok, thank you
11:49sdegutisjustin_smith: the only difference that it doesn't respect *read-eval*?
11:50justin_smithsdegutis: it doesn't support the #= reader macro
11:50justin_smithsdegutis: there may be other differences I am forgetting
11:52justin_smithsdegutis: clojure.edn also makes it easier to use locally scoped first class readers
11:52justin_smithsdegutis: rather than installing them globally as you would for clojure.read
11:53sdegutisoh nice
11:54sdegutisjustin_smith: i like stuartsierra's Component and it shows a lot of promise, but it makes me a bit nervous how many unofficial forks there are that people claim are so helpful that you rarely have any reason not to use them, yet they've all been rejected as PRs
11:57sdegutisjustin_smith: e.g. some people have written a partial-restart function like you just said
11:58hellofunkjustin_smith: what is the #= reader macro? i don't recall ever seeing that before. it's not here: http://clojure.org/reader#The%20Reader--Macro%20characters
11:58justin_smithhellofunk: it causes eval
11:59justin_smith,(binding [*read-eval* true] (read-string "#=(+ 1 1)"))
11:59hellofunkwow, you know what? ya learn something new every day
11:59clojurebot2
11:59hellofunkliterally, every single day
11:59justin_smithhellofunk: the only thing you need to know about #= is it is terrible, and you can use clojure.edn/read-string to avoid it :P
12:00sdegutisLike, if they're so useful and basically ought to be part of Component, then why aren't they?
12:01sdegutisMaybe one of the existing forks of Component is the one that should become canonical, if the original is going to reject things that ought to be part of it?
12:02wasamasayou're throwing these words around as if you were the one deciding in what direction things are headed
12:11sdegutiswasamasa: oops sorry let me clarify, I'm just expressing my concern about jumping on a bandwagon that sounds really good in theory but I'm worried about causing more work down the road than it saves
12:12sdegutiswasamasa: It's not possible for my opinion to influence anyone in the Clojure community, so it's pretty safe for me to express my concerns straightforwardly
12:13hellofunki'm sure there are good reasons why PRs for Component were rejected
12:32sdegutishellofunk: ahh hmm
12:40sdegutishellofunk: good point
12:40roelofCan I count a set with reduce because I cannot use count ?
12:40justin_smithroelof: you can count things with reduce, but are you sure you can't use count?
12:41justin_smithroelof: oh, is this a 4clojure thing?
12:41roelofjustin_smith: yep
12:43sdegutisroelof: oh man I was just about to give away the solution in here (counting using reduce) until you said it was 4clojure
12:43sdegutisphew
12:43justin_smithroelof: there is also a version using apply, +, map, and constantly
12:43roelofo, i was already thinking about that solution so you do not give anything away
12:44sdegutisroelof: but to actually write it here and have clojurebot execute it is giving it away too much ;)
12:44roelofjustin_smith: then its time to experiment how I can count with reduce
12:44roelofsdegutis: yep, then you are right. I want to discover it myself , then im learning more then just copy/paste someone solution
12:45sdegutis:)
12:45sdegutisjust solved it, oh wow that was a lot shorter than i thought itd be
12:46hellofunkroelof: you can also count with a recursive loop
12:47roelofhellofunk: thanks for the solution
12:50roelofall thanks for the help, Enought to explorer for the next few hours/days
12:51sdegutisokay we found like 3 solutions
12:51sdegutisjustin_smith's is by far the coolest
13:13ionthasHei everyone!
13:13ionthasI have the following piece of code. (map #(+ % (* 3 (- (rand) (rand)))) [1 2 3 4])
13:13ionthasI would like to apply the same function instead of into the vector [1 2 3 4] to a vector like [[1 2] [3 4]].
13:14ionthasThere is some idiomatic way to do that or I need to iterate over the vectors of the vector?
13:16taylanubionthas: consider naming intermediate functions to make the code more readable
13:16taylanub(but that's mostly irrelevant to your concern I guess...)
13:17taylanubionthas: I'm a Clojure novice but unless there's a "deep map" or "tree map" in the standard library you'll probably have to implement that yourself, or use a one-off that goes only two nested vectors deep
13:19ionthasI already have that implemented, just wondering if there was a neater way to do it. ;) Thanks for your help!
13:19taylanub(map #(map your-func %) two-level-vec)
13:20oddcully,(clojure.walk/postwalk #(if (number? %) (+ % (* 3 (- (rand) (rand)))) %) [[1 2] [3 4]])
13:20clojurebot#error {\n :cause "clojure.walk"\n :via\n [{:type java.lang.ClassNotFoundException\n :message "clojure.walk"\n :at [java.net.URLClassLoader$1 run "URLClassLoader.java" 366]}]\n :trace\n [[java.net.URLClassLoader$1 run "URLClassLoader.java" 366]\n [java.net.URLClassLoader$1 run "URLClassLoader.java" 355]\n [java.security.AccessController doPrivileged "AccessController.java" -2]\n [java.net.U...
13:21ionthasoddcully: I will check on the clojure.walk library
13:21taylanub,(let [func (fn [x] (+ x (* 3 (- (rand) (rand)))))] (map #(map func %) [[1 2] [3 4]]))
13:21clojurebot((-0.4187152559669012 4.0223175926993715) (2.5732410429187538 5.3999494532085075))
13:22ionthas,(let [func (fn [x] (+ x (* 3 (- (rand) (rand)))))] (map #(map func %) [[1 2] [3 4]]))
13:22clojurebot((3.3449172521383645 3.263821849965249) (3.197445887461697 4.426748480427572))
13:22ionthasthats it taylanub thanks!
13:22taylanubhth :)
13:23taylanublooks like there's also 'flatten' in the stdlib
13:23ionthasI will also check 'flatten' then
13:23oddcullymy assumption was, that you want to keep this vectors
13:24taylanubyeah, was just sayin', if you want the result to be a flat list of the numbers
13:24ionthasyes oddcully that's right
13:24oddcullyionthas: postwalk will keep your structure
13:25justin_smithit will if used properly at least
13:25justin_smithit can transform structures too, quite easily :)
13:26ionthasnice tool to have in my pocket then :P
13:26oddcullyyeah, depends what you return. the example above returns any non-number as-is
13:26expez,(partition 2 (map #(+ % (* 3 (- (rand) (rand)))) (flatten [[1 2] [3 4]])))
13:26clojurebot((-1.5506148351397617 2.9634706105943183) (2.3380856015620304 5.703991983435822))
13:27justin_smith,(flatten flatten)
13:27clojurebot()
13:34taylanubso, I'm through the Koans. I feel it would be beneficial to have some tutorial show me the ropes re. library and project boilerplate, development tools, etc. ... though I use Emacs with CIDER already and lein is like magic.
13:39hellofunktaylanub: not a lot of boilerplate for a project in clojure, since you don't have to worry about a big OO tree getting setup just to get started. just start writing functions, that's all the project boilerplate there is. for libraries, it just depends on what you need. put them in your project.clj, refer the headers in your source files that need them, and that's done too.
13:40taylanubneat
13:44lxsameerhey guys, what tool do you use for benchmarking a piece of code
13:44wasamasataylanub: let lein set up a project for you (it even supports community-made templates)
13:45wasamasataylanub: the rest is just coding away, frameworks aren't as common in clojure
13:46wasamasataylanub: for example if you were to do a web application, you'd start out with ring (an abstraction over an application server), compojure (routing) and hiccup (html generation)
13:51hellofunkwasamasa: taylanub: for what it's worth, enlive is a great html generation library as well that goes a bit further in flexibility to hiccup. i've come to prefer it now for everything (recent versions of enlive extended it to offer hiccup-like tooling)
13:55ionthaslxsameer: you can use criterium
13:55lxsameerthanks
13:55ionthasnp ;)
13:57ionthasregarding my the question I had about the vectors. I'm doing tests with clojure.walk/postwalk and I don't know what I'm doing wrong but it doesn't work. Can anyone take a look and tell me what I'm doing wrong using postwalk? https://gist.github.com/d177ab27ce82887a2c16 Thanks!
14:00ionthas'(postwalk-demo [[1 2] [3 4]])
14:00ionthas,(postwalk-demo [[1 2] [3 4]])
14:00clojurebot#error {\n :cause "Unable to resolve symbol: postwalk-demo in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: postwalk-demo in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6704]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbo...
14:01ionthas,(use 'clojure.walk)
14:01clojurebotnil
14:01ionthas,(postwalk-demo [[1 2] [3 4]])
14:01clojurebotWalked: 1\nWalked: 2\nWalked: [1 2]\nWalked: 3\nWalked: 4\nWalked: [3 4]\nWalked: [[1 2] [3 4]]\n[[1 2] [3 4]]
14:01oddcullypostwalk calls the fn for everything in that structure. for the vectors, for the numbers
14:01ionthasI see oddcully, that's the problem
14:01oddcullyat first glance your current code looks like mixing the (map (map)) version and the walk version
14:02GlenjaminHi all, does anyone know where i can find a good link that discusses treating data-structure-as-API vs hiding behind getters?
14:03wasamasasounds like a thing rich hickey has held a talk about
14:03justin_smithGlenjamin: I'm vaguely recalling a chas emerick or stuartsierra blog post on this (also, immutability changes everything in regard to this topic)
14:03ionthasmmmm... ok I will try to use only one of the methods oddcully. Thanks to check my code! :)
14:04oddcullyionthas: without trying it, i'd say that swaping postwalk with map should already fix it
14:04Glenjamini'm seeing people wrap complex immutable data in helpers to ease refactoring (in JS/React land), and i'm looking for some clojure posts on why that is/isn't a good idea
14:08justin_smithhow do the helpers ease refactoring? by providing a consistent view of the data even as its shape changes?
14:09ionthasoddcully: that's right, now it's working. I will try to implement also the postwalk method just to learn to use it.
14:09Glenjaminjustin_smith: thats the idea, yes
14:16Jabberzany clojure + heroku users out there? If so, is there a compelling reason to choose a clojure uberjar versus a lein trampoline run command?
14:18hellofunkJabberz: fair amount of explanation here: https://devcenter.heroku.com/articles/clojure-support
14:19justin_smithJabberz: I've only used heroku a little, but in general an uberjar is lower overhead at runtime, faster startup, and more reproducible. But it's also slightly more inconvenient I guess.
14:20Jabberzthanks, reason I ask is that I'm trying to get newrelic to work with a pretty standard ring/compojure app, and came across this: https://gist.github.com/espeed/8159198
14:20justin_smithoh never mind, both of those run on heroku? they do that whole git based deployment thing I guess
14:21Jabberzyeah heroku will build your whatever, and then run it with whatever command - so you can do a regular java -jar myuber.jar, or a lein command (or whatever)
14:22justin_smithfor an uberjar, instead of following the lein setup, you'd use the same setup you would use to include new-relic with a java project I think?
14:23Jabberzwell , i'm trying to get that :java-agents part of the lein invoked so I don't have to put the newrelic jar directly in the git repo
14:23hellofunkJabberz: fwiw heroku offers a free new relic add-on independent of your app that lets you monitor stuff in their dashboard
14:24justin_smithJabberz: looks like it suffices to specify a -javaagent arg to the java command line https://docs.newrelic.com/docs/agents/java-agent/installation/java-agent-manual-installation
14:24justin_smithhellofunk: oh, cool
14:24hellofunkJabberz: justin_smith: https://addons.heroku.com/newrelic
14:25hellofunkyeah heroku are definitely taking "platform as service" seriously, to minimize developer time on setting a lot of stuff up
14:25Jabberzso far it's working out great
14:25hellofunkJabberz: i'm pretty happy with heroku, though giving then all the source code feels a tad weird
14:27Jabberzhellofunk: yeah I agree
14:28hellofunkJabberz: for what they do, they are unique and excellent and their tech support is fantastic
14:50devnHello all, anyone know of other options in Clojure beyond Clara for rules engines? I found a couple of things like https://github.com/hraberg/mimir and https://github.com/rururu/rete4frames
14:51devnI'm curious if anyone knows of other options, whether they're "under development", "a toy implementation", "a sketch", etc.
14:52devnso far, clara looks to be the only one I would consider "polished enough for production use"
14:52devnpartly because, well, to my knowledge, it's being used in production
14:55Jabberzdevn: you could use something like Stardog, it gives you the entity/attribute/value graph model, and the logic reasoning is full OWL 2, so pretty much most advanced mechanism to express a rule
14:55Jabberzdevn: there's a clojure API, you query it with sparql (datalog)
15:01xcvHey guys, I've been looking into which web server to choose for a new project, which is expected to have to handle a lot of traffic so a good async story is a big plus. I noticed that luminus moved from HTTP Kit to Immutant Web as the default.
15:01xcvIs Pedestal not an option there primarily because it's too different from the others conceptually, or is it more of a niche option in general?
15:02wasamasaI thought pedestal is some framework?
15:02justin_smithwasamasa: right, but it doesn't use ring
15:02xcvGood websockets support may turn out to be a big plus, and it does look like Immutant has a good story there.
15:02xcvYeah.
15:02xcvI realize luminus is intended as a collection of good defaults.
15:03justin_smithiirc immutant uses ring
15:03xcvPedestal is more of a specific choice, it seems. I've read through the docs and it does look interesting.
15:04justin_smithit's an odd one out in the clojure world because just about everything else for web servers is built on ring
15:05justin_smithxcv: for example with the immutant vs. http-kit thing, both have ring adapters, so switching between them is straightforward
15:05justin_smithas opposed to switching to a completely different API for web handlers
15:06xcvjustin_smith: Yeah. It looks like one of the big reasons luminus moved to Immutant as the default is that it's got more support/development weight behind it than HTTP Kit.
15:06xcvThe interceptor concept that Pedestal is based on is quite interesting.
15:07xcvI was a little disappointed when I saw that it doesn't easily support Websockets (only Server Sent Events) at this point, but I think that may change soon.
15:07xcvBut yeah, writing the app using interceptors is a different style.
15:08xcvI'm leaning toward Immutant now.
15:08xcvHave heard people say good things about Pedestal though.
15:20taylanubfor what are prefixed keys, like :a/b ?
15:24wasamasasure they did start with a colon?
15:24wasamasaif it weren't for the colon, my guess would be namespaced symbols
15:24justin_smithtaylanub: namespaced keywords
15:24justin_smith,::a
15:25clojurebot:sandbox/a
15:25justin_smith,(require '[clojure.string :as s])
15:25clojurebotnil
15:25justin_smith,:s/a
15:25clojurebot:s/a
15:25justin_smith,::s/a
15:25clojurebot:clojure.string/a
15:26justin_smithtaylanub: wasamasa: namespaced keywords are a popular choice for map keys that only code in your particular lib would care about, that might otherwise conflict with other keys in a hash map / metadata map
15:27wasamasajustin_smith: interesting, did just know about the ::foo thing
15:27justin_smith,(= ::a :sandbox/a)
15:27clojurebottrue
15:28taylanubinteresting...
15:41sdegutisI'm having trouble figuring out how to model my app's primary functionality (i.e. "business logic") as Components.
15:42sdegutisComponents seem like a blog's categories: a blog post may only belong in one; whereas blog posts often have many tags, and functions may exist to serve many different functionalities.
15:43justin_smithdon't model logic with components, use components to manage state that needs initialization. You can do the modeling with functions, you don't need to create a stateful object to model a stateful process.
15:43sdegutisAhhh, nice.
15:43clojurebotGabh mo leithscéal?
15:44sdegutisjustin_smith: thanks, That's a great guideline for finding the line between components and functions
15:44sdegutisjustin_smith: or wait, no.., I think I'm misunderstanding you
15:58roelofhello, my first try to make a function which counts the items in a list. My code :(reduce (fn [counter] (inc counter)) [1,2,3]) but now I see this error message : clojure.lang.ArityException: Wrong number of args (2) passed to: core/eval6254/fn--6255
15:58roelofwhat do I do wrong ?
16:00Musclor,(count [1 2 3])
16:00clojurebot3
16:00roelofMusclor: Im not allow to use count
16:01xcv_The reducing function needs be a function of two arguments.
16:02xcv_For counting this way, you'll need to pass the initial value of the reduction in as well.
16:02xcv_Does that clarify?
16:03roelofxcv_: correct , as far as I can see I have 2 arguments. 1 is the function and one is the list [1 2 3]
16:03roelofoke, and where do I put the initial value ?
16:04xcv_The function you pass (the reducing function) has to take two argument (your example takes one argument). The initial value comes after the reducing function and before the collection.
16:04xcv_https://clojuredocs.org/clojure.core/reduce
16:04xcv_*two arguments
16:05justin_smith,((fn silly-last [coll] (reduce (fn [_ e] e) nil coll)) [:a :b :c]) ; roelof
16:05clojurebot:c
16:05roelofoke, so one of the ) is on the wrong place
16:07Musclor(fn [counter] (inc counter)) is a function of one argument
16:08roelofcorrect
16:08justin_smithalso, (fn [counter] (inc counter)) is a really verbose way to write inc
16:08justin_smithroelof: the function used by reduce must take two arguments
16:09xcv_It can ignore the second argument in this case, but the arity has to match.
16:10roelofjustin_smith: I understand.What I try to write is a function which counts as 1 argument and the list as second
16:10justin_smithroelof: but the function argument to reduce will not get the list as an argument
16:10justin_smithroelof: it will get one item each time it is called
16:10Musclor,(reduce (fn [counter _] (inc counter)) [1 2 3])
16:10clojurebot3
16:10xcv_It takes the reduction up to that point, and the next value.
16:11xcv_That's why this works
16:11xcv_,(reduce + [1 2 3])
16:11clojurebot6
16:11justin_smithMusclor: that can only count things if their first element is 1
16:11Musclorright
16:12xcv_,(reduce (fn [count _] (inc count)) 0 [1,2,3])
16:12clojurebot3
16:13xcv_It needs the zero as the initial value, unlike the sum.
16:13roelofoke, I see that this works, What is the second argument of counter which is a do not care variable
16:13xcv_The next value in the vector.
16:13justin_smithroelof: it is an element of the input
16:13justin_smithfor counting, the values are irrelevant, so you can ignore them
16:13roelofoke, so the _ will be first 1 then 2 and then 3
16:14xcv_Yep.
16:14justin_smithif eg. you were only counting inputs if they were keywords, or only counting even numbers, then you could check the value
16:14roelofaha,that was the part I did not think of
16:14justin_smithroelof: yeah, that's how my "silly-last" reduce worked
16:14justin_smithit ignored the accumulator, and always returned the item
16:15justin_smith,((fn silly-last [coll] (reduce (fn [_ e] e) nil coll)) [:a :b :c]) ; roelof
16:15clojurebot:c
16:15roelofoke, there you did not use the list ?
16:16justin_smithroelof: there I did not use the accumulator
16:16justin_smithroelof: the accumulator being whatever is returned from the previous step - since last only cares about the last value, it can throw away all preceding values and ignores them
16:16xcv_roleof: The collection itself is never passed to the reducing function. Just each element in turn.
16:16roelofoke, I still find this confusing. I hope by doing more exercixes I will be more clear to me
16:16xcv_The optional initial value is like the "-1th" element of the collection in this way.
16:17justin_smith,(reduce println :start [:a :b :c]) ; roelof
16:17xcv_Well, not quite. Forget that.
16:17clojurebot:start :a\nnil :b\nnil :c\n
16:17roelofoke, like you do (reduce + [ 1 2 3] you forget the answer to 1+ 2 at the first run
16:17justin_smithso the first args are start :a, then nil :b, then finally nil :c (since println returns nil)
16:18justin_smithroelof: no, you use it
16:18justin_smith+ does not throw away any args
16:18roelofoke, stupid example
16:18justin_smith,(reduce (fn [a b] (println a b) (+ a b)) [1 2 3 4])
16:18clojurebot1 2\n3 3\n6 4\n10
16:19justin_smithmaybe that helps?
16:19justin_smithso it gets 1 2, then 3 3, then 6 4, and finally returns 10
16:20justin_smithalways two items, an accumulator and a new input
16:20justin_smiththe accumulator is whatever type you return, the input is whatever type is in the collection
16:20roelofexactly but when you use a _ the 3 and the 6 are trown away, that is what I trying to say
16:20justin_smithOK
16:21roeloftime for me to sleep and think if I can improve the function,
16:21justin_smithbut of course the 6 would never even happen :) it is only constructed because you build from the previous input
16:21xcv_http://pastie.org/10458951
16:21xcv_roleof:
16:21xcv_This is what's going on, in JS.
16:21roelofjustin_smith: correct
16:22roelofeveryone thanks and have a nice day or I hope a good night sleep
16:22justin_smithyou too!
16:22xcv_good night
16:23zxcHello! How can I get dependencies in Light Table? Last time I've saved project.clj, evaluated a project several times, finally deleted a connection and created a new one
16:24zxcIs there a better way of doing that?
16:24taylanub.oO( should I be a bit of an ass and say "just use Emacs"? )
16:25justin_smithzxc: one option is to add pallet/alembic to your deps and then you can use alembic.still/load-project to add all deps that are in your project.clj without restarting clojure
16:25justin_smiththis works even without an editor
16:26justin_smithjust naked repl
16:26zxctaylanub: Emacs is too weird for me, vim has some nice and fast navigation, Light Table has instarepl, Emacs just has.. weirdness
16:27zxcjustin_smith: Will not use that, but thank you
16:30taylanubI have to absolutely agree that Emacs is full of weirdness. :D it's very powerful though. as they say, whatever floats your goat.
16:30justin_smithzxc: the editor cannot change the classpath of a running clojure project, the alembic.still lib can
16:31zxctaylanub: It's the weirdest proverb I've ever heard
16:31justin_smithzxc: your options are a clojure library that knows how to find, download and load deps (alembic being the easiest to use) or restarting clojure
16:31taylanubzxc: I might have modified it just a bit. (boat -> goat)
16:32zxcjustin_smith: I'm just doing a course in Clojure, so it's not *that* important now :)
16:33zxctaylanub: What emacs plugins do you have?
16:33justin_smithzxc: emacs doesn't have plugins, it has source code - 80% or more of emacs itself is elisp, just like all the extensions are
16:34justin_smithin fact, emacs without the elisp it comes with isn't even capable of editing files
16:34justin_smithwhich is just more proof emacs is weird, of course
16:34taylanubzxc: I installed clojure-mode and CIDER from 'M-x list packages' (having MELPA-stable and Marmalade as my package repositories)
16:34taylanuband Paredit of course, without which any Lisp would be a pain
16:35zxcjustin_smith: Light Table is kinda written in Clojure, I felt more safe using it
16:36zxctaylanub: Sounds like my config from a month ago, I've used Spacemacs though
16:36justin_smithlight table is also super weird, but it's well designed for learning clojure
16:36taylanubof course, I also use Emacs for IRC, email, and file management :)
16:37justin_smithbut few people stick with it past the learning stage
16:37zxcjustin_smith: Why?
16:37zxctaylanub: Can you be my Emacs friend, please
16:38taylanubzxc: you can have a ton of Emacs friends over at #emacs :)
16:38taylanubme included
16:38justin_smithzxc: it is an incomplete project that is no longer being developed, and the features at which it excells become less useful as you gain expertise with the language
16:40oddcullyzxc: there is vim-fireplace
16:40oddcullysomebody here had to stand up
16:40zxctaylanub: People were unhelpful last time, told me to go to #spacemacs :(
16:40justin_smithI use clojure but not cider, right now my biggest annoyance with cider is that my coworkers who use it find it difficult to use newer clojure features, because everything breaks when they try to update, so their editors can't handle cljc files for example.
16:40zxcjustin_smith: Oh, that's sad
16:40zxcjustin_smith: How are you using repl then? Lein repl?
16:41justin_smithor just java -cp ...
16:41taylanubzxc: oh, I guess there's some frustration with / hostility against users of things like spacemacs, prelude, etc. :\
16:41justin_smithbut yeah, one of those
16:42zxcoddcully: How's working with vim? Have you had any problems with it?
16:42taylanubzxc: it sometimes makes helping harder since such packages add layers of complexity, though I think some people in #emacs like to exaggerate the situation
16:42justin_smithtaylanub: well, they change keybindings, and most of the questions are going to be about keybindings in some way
16:42zxctaylanub: They wanted to help me, but when heard I was using spacemacs, they went into "get out of here" mode
16:42zxcjustin_smith: Sounds painful
16:43justin_smithtaylanub: for example, I was trying to help someone use cider with custom lein args, and their customization (which they did not understand) broke C-u M-x
16:43oddcullyzxc: i have vim-fireplace, paredit, vim-sexpr (with the paredit stuff disabled) installed for clojure. works like a charm. needed some fiddling to make it go with figwheel
16:44zxcoddcully: Is nvim worth downloading? Or just use vim?
16:44oddcullyzxc: never used neo. can't comment
16:45zxcoddcully: Too bad, I was so excited about that :(
16:48zxcBy the way, thank you all, you're the most helpful community available
16:48zxcI'll bake you a cake someday
16:51oddcullyvodka cake!
16:52zxcjustin_smith: I've got no alcohol to share, I'm just seventeen :(
17:21mungojellyi got confused yesterday by map's laziness, is there some better way to say "do this to all these for the side effects" than "(doall (map"?
17:21justin_smithmungojelly: run!
17:22justin_smith,(run! println (range 10))
17:22clojurebot0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n
17:22mungojellyoh "run" is what i should use? for half a second i thought i had come upon something dangerous and you were actually telling me to run
17:22justin_smithnot run, run!
17:22justin_smithhah
17:23TEttinger(doc run!)
17:23clojurebot"([proc coll]); Runs the supplied procedure (via reduce), for purposes of side effects, on successive items in the collection. Returns nil"
17:24justin_smithtoo bad it's not varargs like map is so it could be a drop-in
17:24mungojelly"run!" is *really* hard to google, geez :/
17:24justin_smithhah
17:26emautonDriving through a county here the other day, big signs saying "THIS IS CAVAN!" followed directly by "GET READY TO RUN!"
17:27TEttingeremauton: is it... like, some territorial group's turf? like how neonazis used to cluster in northern idaho?
17:28emautonNah, I think there's just some charitable event on, but it was pretty funny.
17:28TEttingerhaha
21:05justin_smithodd issue on SO - does anyone know why the compilar complains about java/lang/Foo. here? http://stackoverflow.com/questions/32928909/clojure-deftype-referencing-other-type
21:09justin_smithalso I don't think the guy gets the concept of "type hints"
21:09amalloymost of the hints there actually do something
21:10amalloythe only irrelevant hint is the last one
21:11justin_smithbut none of the other hints on Bar effect the question either way
21:11amalloywell, no
21:34justin_smithI bet Bronsa would know what is going on in that question
23:08python476hello there
23:09python476Using emacs/cider, I'd love to know a way to stop stuck code (unresponsive networking code) in cider repl. Without restarting cider entirely.
23:11amalloytry C-c C-c
23:11amalloywhen that doesn't work i generally give up
23:18python476then I'm in the same boat
23:18python476I need a tiny emacs helper to smooth out the bump