#clojure log - Oct 03 2015

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

2:03 zhaoliangliu: hi guys..

2:04 anyone there?

2:04 hi?

2:27 * wasamasa hides

4:51 wombawomba: Why won't this work? (defmacro m [n] (let [as [myarg#]] `(defn ~n ~as (prn myarg#))))

4:51 And how do I fix it?

4:57 hiredman: # as an auto gensym only works inside syntax quote `

4:58 I dunno what you are trying to do with that let

4:58 oh

4:58 the arg list

4:58 anyway, you can manually gensym with the gensym function

4:59 or, 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

5:00 wombawomba: hiredman: I'm really trying to insert extra arguments when generating a function

5:00 expenseBot: Greetings! Send me a PM and I'll echo it back to you. If it contains the word 'die', I'll die as a bonus!

5:01 wombawomba: (defmacro m [n] (let [as [(gensym 'myarg)]] `(defn ~n ~as ~(prn myarg#)))) also doesn't seem to work

5:03 expenseBot: Greetings! Send me a PM and I'll echo it back to you. If it contains the word 'die', I'll die as a bonus!

5:04 Greetings! Send me a PM and I'll echo it back to you. If it contains the word 'die', I'll die as a bonus!

5:05 oddcully: ah /ignore-ance is bliss

5:07 jeaye: !ops

5:12 vish_: hello

5:13 expenseBot: Greetings! Send me a PM and I'll echo it back to you. If it contains the word 'die', I'll die as a bonus!

5:14 Greetings! Send me a PM and I'll echo it back to you. If it contains the word 'die', I'll die as a bonus!

5:16 Greetings! Send me a PM and I'll echo it back to you. If it contains the word 'die', I'll die as a bonus!

5:17 vish_: @expenseBot hi

5:53 expenseBot: Greetings! Send me a PM and I'll echo it back to you. If it contains the word 'die', I'll die as a bonus!

5:54 hyPiRion: amalloy: ^

5:55 amalloy: dangit now i gotta remember how to do it

5:55 well, i guess he isn't setup to autojoin

5:55 hyPiRion: (inc amalloy)

5:55 oh no, lazybot

5:55 =(

7:39 taylanub: I'm trying to package Clojure for GNU Guix. can it be built without Maven?

7:39 felipedvorak: Any insider info on when Clojure for the Brave will be updated?

7:50 triss: how can you fond the list of protocols a type satisfies?

8:01 noncom|2: taylanub: if you look here https://github.com/clojure/clojure it is all maven

8:01 taylanub: but you can do the same with ant, for example

8:02 taylanub: also there's maven plugin that creates an ant script from maven xml

8:02 triss: hey all I wan to dispatch a multimethod when input makes `sequential?` true

8:02 is there a Sequence type i can match on some how?

8:02 noncom|2: triss: on your first question: try (extends?) or (extenders)

8:03 triss: I know I can clojure.lang.IPersistantList but I want vectros too.

8:04 taylanub: noncom|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.

8:07 noncom|2: triss: why don\t you check for the exact type?

8:09 triss:

8:09 ,(instance? clojure.lang.PersistentList (list 1 2 3))

8:09 clojurebot: true

8:09 noncom|2: (instance? clojure.lang.PersistentVector (list 1 2 3))

8:09 ,(instance? clojure.lang.PersistentVector (list 1 2 3))

8:09 clojurebot: false

8:12 noncom|2: taylanub: 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

8:13 triss: r u still up to the music programming?

8:14 taylanub: 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

8:18 taylanub: yay, 1 hour into Clojure and I already found something to contribute :P https://github.com/clojuredocs/guides/pull/216

8:20 wink: taylanub: 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.

8:21 you need a jvm and lein

8:22 noncom|2: taylanub: cool :)

8:22 triss: noncom|2: yeah man. still all music related. making something for describing musical patterns in the same way SuperColider does today

8:22 I'd like to match on both vectors and lists

8:23 from a multimethod

8:23 noncom|2: triss: then make (or (inst? Vec.. ) (inst? List..) )

8:23 triss: will match both

8:23 (i wrote pseudocode)

8:24 triss: 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

8:24 could be quite an interesting experiment

8:25 triss: whats the "music guide"?

8:25 noncom|2: triss: this http://www.global-trance.com/misc/music_theory_tldr.pdf

8:26 triss: i thought the text is laid out perfectly to be translated to some computer knowledge system which then could manipulate it

8:26 triss: ah. yes... I think I'm dreaming of having db with that stuff in.... not even sure what I'd ask it yet though.

8:27 noncom|2: triss: you could give it some noise data (not musical noise) and ask to repair it using the laws

8:28 for example

8:28 triss: or give it some rule and ask to build a piece around it

8:28 triss: or give it a melody and ask to reformulate using the laws

8:28 and much and much more

8:29 yay, that's an itch! i'm gonna start laying it out as soon as i have some free time :D

8:29 triss: indeed. I'm sure it could be quite exciting...

8:30 does anyone know of any examples working with logic programming and muisc?

8:33 noncom|2: did not look for it

8:33 but saw many with neural nets

8:38 how do you think, can logic programming and music composition somehow work together?

8:54 triss: not sure yet... need o get in to logic programming...

9:38 irctc: Hi everyone.

9:39 I need some help configuring OAuth for Goodreads API.

9:39 I 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

9:40 Is there anyone who could help me with this?

10:03 Can anyone help me out with my question of stackoverflow? http://stackoverflow.com/questions/32920728/configuring-oauth-with-goodreads-in-clojure

10:03 *on

10:11 noncom|2: irctc: well, 401 means unauthorized

10:12 the error codes manual says that the response 401 should also contain header WWW-Authenticate which describes what you need to do to authenticate

10:12 you in returns should send a request containing header "Authorization" with the relevant data

10:13 or, as i understand, send a request with such a header in the first place, even before you get the 401

10:13 irctc: 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:13 irctc: Ok, but how do I do that? I am sorry but I am copmletely new to OAuth or API authorizaqtion in general.

10:14 noncom|2: irctc: well, you're getting 401 right? what if you print it?

10:15 irctc: ok, i'll try that out.

10:16 noncom|2: i'm not very familiar with oauth also, but just trying to apply some general http knowledge

10:16 irctc: What I get in my terminal is pretty cryptic and confusing. The only part I really recognize is the 401 error.

10:17 noncom|2: maybe you post the response to refheap?

10:17 irctc: What is refheap?

10:17 noncom|2: just google refheap

10:17 it's a pastebin

10:17 or another pastebin, not necessarily refheap :)

10:17 TMA: oauth is a complex beast

10:18 taylanub: (conj '(:a :b :c :d) :e) => '(:e :a :b :c :d) ;that was kinda unexpected...

10:18 (going through koans)

10:18 noncom|2: taylanub: that's what it should be

10:19 lists get conjed at the beginning

10:19 taylanub: what's the difference from consing?

10:19 noncom|2: well, if you come from other lisps - no difference except that afaik clojure lisks are not made of cons cells

10:19 TMA: irctc: it's better to read up some coherent tutorial on oauth first -- it's not easy to comprehend just by poking around

10:20 noncom|2: TMA: irctc: also agree with TMA

10:20 taylanub: I meant to ask, what's the difference from using cons in Clojure. just the argument order?

10:20 TMA: ,(conj ':e '(:a :b))

10:20 clojurebot: #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:21 TMA: ,(conj '(:e) '(:a :b))

10:21 clojurebot: ((:a :b) :e)

10:21 noncom|2: taylanub: cons will work like conj for vectors too

10:21 taylanub: i think it is provided for compliance with other lisps

10:23 irctc: Here is the response I get in my Terminal when I try to run lein ring server on my project: http://pastebin.com/gjLBHHCf

10:23 noncom|2: ,[(cons 1 [2 3]) (cons 1 '(2 3)) (conj [1 2] 3) (conj '(1 2) 3)]

10:23 clojurebot: [(1 2 3) (1 2 3) [1 2 3] (3 1 2)]

10:23 noncom|2: taylanub: ^ there's not much more to that

10:24 taylanub: also, if you do huge works on lists/vectors, the right choice might affect speed i think

10:24 taylanub: I just tried that too, and (conj '(1 2) 3) => (3 1 2) yet (conj [1 2] 3) => [1 2 3] seems quite nasty :\

10:24 I guess conjoin should be viewed as a "set" operation?

10:24 noncom|2: taylanub: correct. conj adds elements to the end of the [], but to the start of a ()

10:25 irctc: omg pastebin is blocked in my country! :D

10:25 clojurebot: In Ordnung

10:25 taylanub: pastebin.com is so bad it should be blocked everywhere :P

10:25 noncom|2: haha, maybe... but in my country we have some really strange things going on... :/

10:25 irctc: The other one just displays it all in one huge line.

10:25 noncom|2: taylanub: idk what is conjoin btw, there's no such function

10:25 taylanub: where is that? Turkey is also freaky like that, tho I'm in Germany now.

10:26 oh I meant conj with conjoin

10:26 noncom|2: i live in russia. stupid people in government things going on here.

10:27 taylanub: ah, I see.

10:27 irctc: Why is pastebin blocked in Russia?

10:28 noncom|2: many 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:28 however, usually there's even no such material or porn

10:28 it's just stupidity of people trying to justify their position in government

10:28 they don't even understand how inet works

10:28 irctc: Sorry to hear that.

10:28 taylanub: what's there not to understand, it's just a series of tubes :)

10:28 irctc: Hahaha, lol!

10:29 noncom|2: yes! :) but george did not do stupid things to it, as far as i know at least :D

10:30 so, there's that unblocking site.. i got through to your paste

10:30 here: "WWW-Authenticate" "OAuth realm=\"http://www.goodreads.com""

10:30 probably you're not setting the realm?

10:31 taylanub: Tor Browser Bundle also works pretty well these days

10:32 noncom|2: but as TMA said, a good oauth tutorial is a must-read i think...

10:32 yeah, there are people using tor too

10:32 irctc: I have no idea what a realm is though.

10:32 Where do you go about setting that up?

10:32 noncom|2: in your oauth request?

10:33 http://stackoverflow.com/questions/8577428/what-does-oauth-1-0-realm-stands-for

10:33 here's a good tutorial http://self-issued.info/docs/draft-ietf-oauth-v2-bearer.html

10:34 taylanub: did you work in other lisps?

10:35 taylanub: if not, take a look at this: http://www.gigamonkeys.com/book/they-called-it-lisp-for-a-reason-list-processing.html

10:36 it will explains why lists get appended at the beginning

10:36 irctc: Thanks. I need to take a closer look at the link you gave me. OAuth just seems so complicated.

10:37 noncom|2: irctc: 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:42 irctc: noncom|2, thanks for your help. I'm gona go study that tutorial.

10:42 Take care everyone and have a nice day! :)

10:42 noncom|2: thanks :)

10:47 hellofunk: triss: do you like Pink and Score?

10:49 triss: hellofunk: I've not seen pink and score!!!! another video to watch. thanks forthe heads up. have you played with it?

10:50 oh, blue. not thought about sound land for a longtime

10:51 oh man how have I missed this.

10:52 devn: hrm, I guess I never realized Peano arithmetic was turing complete...

11:01 hellofunk: triss: 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:02 wasamasa: pink?

11:02 never heard of it

11:03 hellofunk: wasamasa: it's a novel synth engine written in clojure

11:03 wasamasa: hellofunk: interesting, thanks!

11:04 hah, it's not 100% clojure

11:04 not sure why though

11:04 srsly: https://github.com/kunstmusik/pink/blob/d6fd11f9b3fad574f14f00bdd704e560c6eb8b74/src/main/pink/Utils.java

11:09 taylanub: noncom|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:09 hellofunk: wasamasa: well technically in clojure nothing is 100% clojure.

11:12 wasamasa: hellofunk: it's not about the implementation, it's about what language the projects is written in

11:12 noncom|2: taylanub: ah, yeah, it's special for clojure..

11:14 sdegutis: When 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:15 My 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:16 e.g. email service, database service, web router service

11:16 noncom|2: sdegutis: in my opinion, if you're writing your program using component, why not make everything component?

11:16 any namespace could be said to be a service

11:16 sdegutis: Whereas free-floating functionality that *uses* any of these services should just be functions that take parameters.

11:17 noncom|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:17 hellofunk: wasamasa: 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:18 noncom|2: sdegutis: hmmm, that reason sounds like an implementation detail.. but it has weight really

11:19 sdegutis: noncom|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:20 noncom|2: that's for sure

11:20 the living repl is the source of all life in this world :)

11:22 sdegutis: 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:23 devn: that's interesting

11:23 you've reminded me of it again. i guess i have to explore it finally

11:26 sdegutis: noncom|2: um, typo? I don't see devn here saying anything...?

11:26 justin_smith: what's your opinion on this component design?

11:40 noncom|2: sdegutis: he did, but before you have joined

11:40 sdegutis: he said that peano arithmetics is turing-complete

11:40 sdegutis: o

11:41 noncom|2: i did not even study that calculus indepth

11:41 i think i have to

11:41 seems rather interesting

11:42 justin_smith: it's used to establish that you can derive numbers and arithmetic from set theory

11:43 sdegutis: 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:43 sdegutis: justin_smith: meaning things that nothing else depends on?

11:44 justin_smith: right

11:45 sdegutis: justin_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:45 Of 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:45 Is this a common technique already?

11:46 monsta: Excusme, what "#=" keyword means?

11:46 justin_smith: sdegutis: 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:46 kind of a lazy-restart

11:46 sdegutis: monsta: Usually # begins a reader macro, but I have never heard of #= before

11:46 justin_smith: monsta: it forces eval inside string reading

11:46 monsta: and it is terrible

11:46 sdegutis: Oh, must be a new 1.7 thing

11:47 monsta: O.o

11:47 Thanks

11:47 justin_smith: sdegutis: no, it's old, and it sucks, and you should not use it

11:47 sdegutis: ,(read-string "#=(prn :lol)")

11:47 clojurebot: #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:47 monsta: what are the alternatives?

11:47 sdegutis: ,(binding [*read-eval* true] (read-string "#=(prn :lol)"))

11:47 clojurebot: :lol\n

11:48 justin_smith: monsta: reading and eval as distinct operations, no magic strings that cause themselves to be evaluated?

11:48 monsta: you can use clojure.edn/read-string instead of read-string

11:48 monsta: ok, thank you

11:49 sdegutis: justin_smith: the only difference that it doesn't respect *read-eval*?

11:50 justin_smith: sdegutis: it doesn't support the #= reader macro

11:50 sdegutis: there may be other differences I am forgetting

11:52 sdegutis: clojure.edn also makes it easier to use locally scoped first class readers

11:52 sdegutis: rather than installing them globally as you would for clojure.read

11:53 sdegutis: oh nice

11:54 justin_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:57 justin_smith: e.g. some people have written a partial-restart function like you just said

11:58 hellofunk: justin_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:58 justin_smith: hellofunk: it causes eval

11:59 ,(binding [*read-eval* true] (read-string "#=(+ 1 1)"))

11:59 hellofunk: wow, you know what? ya learn something new every day

11:59 clojurebot: 2

11:59 hellofunk: literally, every single day

11:59 justin_smith: hellofunk: 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:00 sdegutis: Like, if they're so useful and basically ought to be part of Component, then why aren't they?

12:01 Maybe 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:02 wasamasa: you're throwing these words around as if you were the one deciding in what direction things are headed

12:11 sdegutis: wasamasa: 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:12 wasamasa: 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:13 hellofunk: i'm sure there are good reasons why PRs for Component were rejected

12:32 sdegutis: hellofunk: ahh hmm

12:40 hellofunk: good point

12:40 roelof: Can I count a set with reduce because I cannot use count ?

12:40 justin_smith: roelof: you can count things with reduce, but are you sure you can't use count?

12:41 roelof: oh, is this a 4clojure thing?

12:41 roelof: justin_smith: yep

12:43 sdegutis: roelof: oh man I was just about to give away the solution in here (counting using reduce) until you said it was 4clojure

12:43 phew

12:43 justin_smith: roelof: there is also a version using apply, +, map, and constantly

12:43 roelof: o, i was already thinking about that solution so you do not give anything away

12:44 sdegutis: roelof: but to actually write it here and have clojurebot execute it is giving it away too much ;)

12:44 roelof: justin_smith: then its time to experiment how I can count with reduce

12:44 sdegutis: yep, then you are right. I want to discover it myself , then im learning more then just copy/paste someone solution

12:45 sdegutis: :)

12:45 just solved it, oh wow that was a lot shorter than i thought itd be

12:46 hellofunk: roelof: you can also count with a recursive loop

12:47 roelof: hellofunk: thanks for the solution

12:48 * roelof time to hit the books about reduce one more time

12:50 * roelof but first time for dinner

12:50 roelof: all thanks for the help, Enought to explorer for the next few hours/days

12:51 sdegutis: okay we found like 3 solutions

12:51 justin_smith's is by far the coolest

13:13 ionthas: Hei everyone!

13:13 I have the following piece of code. (map #(+ % (* 3 (- (rand) (rand)))) [1 2 3 4])

13:13 I 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:14 There is some idiomatic way to do that or I need to iterate over the vectors of the vector?

13:16 taylanub: ionthas: consider naming intermediate functions to make the code more readable

13:16 (but that's mostly irrelevant to your concern I guess...)

13:17 ionthas: 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:19 ionthas: I already have that implemented, just wondering if there was a neater way to do it. ;) Thanks for your help!

13:19 taylanub: (map #(map your-func %) two-level-vec)

13:20 oddcully: ,(clojure.walk/postwalk #(if (number? %) (+ % (* 3 (- (rand) (rand)))) %) [[1 2] [3 4]])

13:20 clojurebot: #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:21 ionthas: oddcully: I will check on the clojure.walk library

13:21 taylanub: ,(let [func (fn [x] (+ x (* 3 (- (rand) (rand)))))] (map #(map func %) [[1 2] [3 4]]))

13:21 clojurebot: ((-0.4187152559669012 4.0223175926993715) (2.5732410429187538 5.3999494532085075))

13:22 ionthas: ,(let [func (fn [x] (+ x (* 3 (- (rand) (rand)))))] (map #(map func %) [[1 2] [3 4]]))

13:22 clojurebot: ((3.3449172521383645 3.263821849965249) (3.197445887461697 4.426748480427572))

13:22 ionthas: thats it taylanub thanks!

13:22 taylanub: hth :)

13:23 looks like there's also 'flatten' in the stdlib

13:23 ionthas: I will also check 'flatten' then

13:23 oddcully: my assumption was, that you want to keep this vectors

13:24 taylanub: yeah, was just sayin', if you want the result to be a flat list of the numbers

13:24 ionthas: yes oddcully that's right

13:24 oddcully: ionthas: postwalk will keep your structure

13:25 justin_smith: it will if used properly at least

13:25 it can transform structures too, quite easily :)

13:26 ionthas: nice tool to have in my pocket then :P

13:26 oddcully: yeah, depends what you return. the example above returns any non-number as-is

13:26 expez: ,(partition 2 (map #(+ % (* 3 (- (rand) (rand)))) (flatten [[1 2] [3 4]])))

13:26 clojurebot: ((-1.5506148351397617 2.9634706105943183) (2.3380856015620304 5.703991983435822))

13:27 justin_smith: ,(flatten flatten)

13:27 clojurebot: ()

13:34 taylanub: so, 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:39 hellofunk: taylanub: 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:40 taylanub: neat

13:44 lxsameer: hey guys, what tool do you use for benchmarking a piece of code

13:44 wasamasa: taylanub: let lein set up a project for you (it even supports community-made templates)

13:45 taylanub: the rest is just coding away, frameworks aren't as common in clojure

13:46 taylanub: 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:51 hellofunk: wasamasa: 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:55 ionthas: lxsameer: you can use criterium

13:55 lxsameer: thanks

13:55 ionthas: np ;)

13:57 regarding 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:00 '(postwalk-demo [[1 2] [3 4]])

14:00 ,(postwalk-demo [[1 2] [3 4]])

14:00 clojurebot: #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:01 ionthas: ,(use 'clojure.walk)

14:01 clojurebot: nil

14:01 ionthas: ,(postwalk-demo [[1 2] [3 4]])

14:01 clojurebot: Walked: 1\nWalked: 2\nWalked: [1 2]\nWalked: 3\nWalked: 4\nWalked: [3 4]\nWalked: [[1 2] [3 4]]\n[[1 2] [3 4]]

14:01 oddcully: postwalk calls the fn for everything in that structure. for the vectors, for the numbers

14:01 ionthas: I see oddcully, that's the problem

14:01 oddcully: at first glance your current code looks like mixing the (map (map)) version and the walk version

14:02 Glenjamin: Hi all, does anyone know where i can find a good link that discusses treating data-structure-as-API vs hiding behind getters?

14:03 wasamasa: sounds like a thing rich hickey has held a talk about

14:03 justin_smith: Glenjamin: I'm vaguely recalling a chas emerick or stuartsierra blog post on this (also, immutability changes everything in regard to this topic)

14:03 ionthas: mmmm... ok I will try to use only one of the methods oddcully. Thanks to check my code! :)

14:04 oddcully: ionthas: without trying it, i'd say that swaping postwalk with map should already fix it

14:04 Glenjamin: i'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:08 justin_smith: how do the helpers ease refactoring? by providing a consistent view of the data even as its shape changes?

14:09 ionthas: oddcully: that's right, now it's working. I will try to implement also the postwalk method just to learn to use it.

14:09 Glenjamin: justin_smith: thats the idea, yes

14:16 Jabberz: any clojure + heroku users out there? If so, is there a compelling reason to choose a clojure uberjar versus a lein trampoline run command?

14:18 hellofunk: Jabberz: fair amount of explanation here: https://devcenter.heroku.com/articles/clojure-support

14:19 justin_smith: Jabberz: 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:20 Jabberz: thanks, 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:20 justin_smith: oh never mind, both of those run on heroku? they do that whole git based deployment thing I guess

14:21 Jabberz: yeah 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:22 justin_smith: for 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:23 Jabberz: well , 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:23 hellofunk: Jabberz: fwiw heroku offers a free new relic add-on independent of your app that lets you monitor stuff in their dashboard

14:24 justin_smith: Jabberz: 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:24 hellofunk: oh, cool

14:24 hellofunk: Jabberz: justin_smith: https://addons.heroku.com/newrelic

14:25 yeah heroku are definitely taking "platform as service" seriously, to minimize developer time on setting a lot of stuff up

14:25 Jabberz: so far it's working out great

14:25 hellofunk: Jabberz: i'm pretty happy with heroku, though giving then all the source code feels a tad weird

14:27 Jabberz: hellofunk: yeah I agree

14:28 hellofunk: Jabberz: for what they do, they are unique and excellent and their tech support is fantastic

14:50 devn: Hello 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:51 I'm curious if anyone knows of other options, whether they're "under development", "a toy implementation", "a sketch", etc.

14:52 so far, clara looks to be the only one I would consider "polished enough for production use"

14:52 partly because, well, to my knowledge, it's being used in production

14:55 Jabberz: devn: 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:55 devn: there's a clojure API, you query it with sparql (datalog)

15:01 xcv: Hey 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:01 Is 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:02 wasamasa: I thought pedestal is some framework?

15:02 justin_smith: wasamasa: right, but it doesn't use ring

15:02 xcv: Good websockets support may turn out to be a big plus, and it does look like Immutant has a good story there.

15:02 Yeah.

15:02 I realize luminus is intended as a collection of good defaults.

15:03 justin_smith: iirc immutant uses ring

15:03 xcv: Pedestal is more of a specific choice, it seems. I've read through the docs and it does look interesting.

15:04 justin_smith: it's an odd one out in the clojure world because just about everything else for web servers is built on ring

15:05 xcv: for example with the immutant vs. http-kit thing, both have ring adapters, so switching between them is straightforward

15:05 as opposed to switching to a completely different API for web handlers

15:06 xcv: justin_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:06 The interceptor concept that Pedestal is based on is quite interesting.

15:07 I 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:07 But yeah, writing the app using interceptors is a different style.

15:08 I'm leaning toward Immutant now.

15:08 Have heard people say good things about Pedestal though.

15:20 taylanub: for what are prefixed keys, like :a/b ?

15:24 wasamasa: sure they did start with a colon?

15:24 if it weren't for the colon, my guess would be namespaced symbols

15:24 justin_smith: taylanub: namespaced keywords

15:24 ,::a

15:25 clojurebot: :sandbox/a

15:25 justin_smith: ,(require '[clojure.string :as s])

15:25 clojurebot: nil

15:25 justin_smith: ,:s/a

15:25 clojurebot: :s/a

15:25 justin_smith: ,::s/a

15:25 clojurebot: :clojure.string/a

15:26 justin_smith: taylanub: 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:27 wasamasa: justin_smith: interesting, did just know about the ::foo thing

15:27 justin_smith: ,(= ::a :sandbox/a)

15:27 clojurebot: true

15:28 taylanub: interesting...

15:41 sdegutis: I'm having trouble figuring out how to model my app's primary functionality (i.e. "business logic") as Components.

15:42 Components 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:43 justin_smith: don'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:43 sdegutis: Ahhh, nice.

15:43 clojurebot: Gabh mo leithscéal?

15:44 sdegutis: justin_smith: thanks, That's a great guideline for finding the line between components and functions

15:44 justin_smith: or wait, no.., I think I'm misunderstanding you

15:58 roelof: hello, 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:58 what do I do wrong ?

16:00 Musclor: ,(count [1 2 3])

16:00 clojurebot: 3

16:00 roelof: Musclor: Im not allow to use count

16:01 xcv_: The reducing function needs be a function of two arguments.

16:02 For counting this way, you'll need to pass the initial value of the reduction in as well.

16:02 Does that clarify?

16:03 roelof: xcv_: correct , as far as I can see I have 2 arguments. 1 is the function and one is the list [1 2 3]

16:03 oke, and where do I put the initial value ?

16:04 xcv_: 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:04 https://clojuredocs.org/clojure.core/reduce

16:04 *two arguments

16:05 justin_smith: ,((fn silly-last [coll] (reduce (fn [_ e] e) nil coll)) [:a :b :c]) ; roelof

16:05 clojurebot: :c

16:05 roelof: oke, so one of the ) is on the wrong place

16:07 Musclor: (fn [counter] (inc counter)) is a function of one argument

16:08 roelof: correct

16:08 justin_smith: also, (fn [counter] (inc counter)) is a really verbose way to write inc

16:08 roelof: the function used by reduce must take two arguments

16:09 xcv_: It can ignore the second argument in this case, but the arity has to match.

16:10 roelof: justin_smith: I understand.What I try to write is a function which counts as 1 argument and the list as second

16:10 justin_smith: roelof: but the function argument to reduce will not get the list as an argument

16:10 roelof: it will get one item each time it is called

16:10 Musclor: ,(reduce (fn [counter _] (inc counter)) [1 2 3])

16:10 clojurebot: 3

16:10 xcv_: It takes the reduction up to that point, and the next value.

16:11 That's why this works

16:11 ,(reduce + [1 2 3])

16:11 clojurebot: 6

16:11 justin_smith: Musclor: that can only count things if their first element is 1

16:11 Musclor: right

16:12 xcv_: ,(reduce (fn [count _] (inc count)) 0 [1,2,3])

16:12 clojurebot: 3

16:13 xcv_: It needs the zero as the initial value, unlike the sum.

16:13 roelof: oke, I see that this works, What is the second argument of counter which is a do not care variable

16:13 xcv_: The next value in the vector.

16:13 justin_smith: roelof: it is an element of the input

16:13 for counting, the values are irrelevant, so you can ignore them

16:13 roelof: oke, so the _ will be first 1 then 2 and then 3

16:14 xcv_: Yep.

16:14 justin_smith: if eg. you were only counting inputs if they were keywords, or only counting even numbers, then you could check the value

16:14 roelof: aha,that was the part I did not think of

16:14 justin_smith: roelof: yeah, that's how my "silly-last" reduce worked

16:14 it ignored the accumulator, and always returned the item

16:15 ,((fn silly-last [coll] (reduce (fn [_ e] e) nil coll)) [:a :b :c]) ; roelof

16:15 clojurebot: :c

16:15 roelof: oke, there you did not use the list ?

16:16 justin_smith: roelof: there I did not use the accumulator

16:16 roelof: 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:16 xcv_: roleof: The collection itself is never passed to the reducing function. Just each element in turn.

16:16 roelof: oke, I still find this confusing. I hope by doing more exercixes I will be more clear to me

16:16 xcv_: The optional initial value is like the "-1th" element of the collection in this way.

16:17 justin_smith: ,(reduce println :start [:a :b :c]) ; roelof

16:17 xcv_: Well, not quite. Forget that.

16:17 clojurebot: :start :a\nnil :b\nnil :c\n

16:17 roelof: oke, like you do (reduce + [ 1 2 3] you forget the answer to 1+ 2 at the first run

16:17 justin_smith: so the first args are start :a, then nil :b, then finally nil :c (since println returns nil)

16:18 roelof: no, you use it

16:18 + does not throw away any args

16:18 roelof: oke, stupid example

16:18 justin_smith: ,(reduce (fn [a b] (println a b) (+ a b)) [1 2 3 4])

16:18 clojurebot: 1 2\n3 3\n6 4\n10

16:19 justin_smith: maybe that helps?

16:19 so it gets 1 2, then 3 3, then 6 4, and finally returns 10

16:20 always two items, an accumulator and a new input

16:20 the accumulator is whatever type you return, the input is whatever type is in the collection

16:20 roelof: exactly but when you use a _ the 3 and the 6 are trown away, that is what I trying to say

16:20 justin_smith: OK

16:21 roelof: time for me to sleep and think if I can improve the function,

16:21 justin_smith: but of course the 6 would never even happen :) it is only constructed because you build from the previous input

16:21 xcv_: http://pastie.org/10458951

16:21 roleof:

16:21 This is what's going on, in JS.

16:21 roelof: justin_smith: correct

16:22 everyone thanks and have a nice day or I hope a good night sleep

16:22 justin_smith: you too!

16:22 xcv_: good night

16:23 zxc: Hello! 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:24 Is there a better way of doing that?

16:24 taylanub: .oO( should I be a bit of an ass and say "just use Emacs"? )

16:25 justin_smith: zxc: 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:25 this works even without an editor

16:26 just naked repl

16:26 zxc: taylanub: Emacs is too weird for me, vim has some nice and fast navigation, Light Table has instarepl, Emacs just has.. weirdness

16:27 justin_smith: Will not use that, but thank you

16:30 taylanub: I have to absolutely agree that Emacs is full of weirdness. :D it's very powerful though. as they say, whatever floats your goat.

16:30 justin_smith: zxc: the editor cannot change the classpath of a running clojure project, the alembic.still lib can

16:31 zxc: taylanub: It's the weirdest proverb I've ever heard

16:31 justin_smith: zxc: 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:31 taylanub: zxc: I might have modified it just a bit. (boat -> goat)

16:32 zxc: justin_smith: I'm just doing a course in Clojure, so it's not *that* important now :)

16:33 taylanub: What emacs plugins do you have?

16:33 justin_smith: zxc: emacs doesn't have plugins, it has source code - 80% or more of emacs itself is elisp, just like all the extensions are

16:34 in fact, emacs without the elisp it comes with isn't even capable of editing files

16:34 which is just more proof emacs is weird, of course

16:34 taylanub: zxc: I installed clojure-mode and CIDER from 'M-x list packages' (having MELPA-stable and Marmalade as my package repositories)

16:34 and Paredit of course, without which any Lisp would be a pain

16:35 zxc: justin_smith: Light Table is kinda written in Clojure, I felt more safe using it

16:36 taylanub: Sounds like my config from a month ago, I've used Spacemacs though

16:36 justin_smith: light table is also super weird, but it's well designed for learning clojure

16:36 taylanub: of course, I also use Emacs for IRC, email, and file management :)

16:37 justin_smith: but few people stick with it past the learning stage

16:37 zxc: justin_smith: Why?

16:37 taylanub: Can you be my Emacs friend, please

16:38 taylanub: zxc: you can have a ton of Emacs friends over at #emacs :)

16:38 me included

16:38 justin_smith: zxc: 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:40 oddcully: zxc: there is vim-fireplace

16:40 somebody here had to stand up

16:40 zxc: taylanub: People were unhelpful last time, told me to go to #spacemacs :(

16:40 justin_smith: I 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:40 zxc: justin_smith: Oh, that's sad

16:40 justin_smith: How are you using repl then? Lein repl?

16:41 justin_smith: or just java -cp ...

16:41 taylanub: zxc: oh, I guess there's some frustration with / hostility against users of things like spacemacs, prelude, etc. :\

16:41 justin_smith: but yeah, one of those

16:42 zxc: oddcully: How's working with vim? Have you had any problems with it?

16:42 taylanub: zxc: 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:42 justin_smith: taylanub: well, they change keybindings, and most of the questions are going to be about keybindings in some way

16:42 zxc: taylanub: They wanted to help me, but when heard I was using spacemacs, they went into "get out of here" mode

16:42 justin_smith: Sounds painful

16:43 justin_smith: taylanub: 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:43 oddcully: zxc: 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:44 zxc: oddcully: Is nvim worth downloading? Or just use vim?

16:44 oddcully: zxc: never used neo. can't comment

16:45 zxc: oddcully: Too bad, I was so excited about that :(

16:48 By the way, thank you all, you're the most helpful community available

16:48 I'll bake you a cake someday

16:50 * justin_smith checks the cake->vodka exchange rate

16:51 oddcully: vodka cake!

16:52 zxc: justin_smith: I've got no alcohol to share, I'm just seventeen :(

17:21 mungojelly: i 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:21 justin_smith: mungojelly: run!

17:22 ,(run! println (range 10))

17:22 clojurebot: 0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n

17:22 mungojelly: oh "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:22 justin_smith: not run, run!

17:22 hah

17:23 TEttinger: (doc run!)

17:23 clojurebot: "([proc coll]); Runs the supplied procedure (via reduce), for purposes of side effects, on successive items in the collection. Returns nil"

17:24 justin_smith: too bad it's not varargs like map is so it could be a drop-in

17:24 mungojelly: "run!" is *really* hard to google, geez :/

17:24 justin_smith: hah

17:26 emauton: Driving through a county here the other day, big signs saying "THIS IS CAVAN!" followed directly by "GET READY TO RUN!"

17:27 TEttinger: emauton: is it... like, some territorial group's turf? like how neonazis used to cluster in northern idaho?

17:28 emauton: Nah, I think there's just some charitable event on, but it was pretty funny.

17:28 TEttinger: haha

21:05 justin_smith: odd 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:09 also I don't think the guy gets the concept of "type hints"

21:09 amalloy: most of the hints there actually do something

21:10 the only irrelevant hint is the last one

21:11 justin_smith: but none of the other hints on Bar effect the question either way

21:11 amalloy: well, no

21:34 justin_smith: I bet Bronsa would know what is going on in that question

23:08 python476: hello there

23:09 Using emacs/cider, I'd love to know a way to stop stuck code (unresponsive networking code) in cider repl. Without restarting cider entirely.

23:11 amalloy: try C-c C-c

23:11 when that doesn't work i generally give up

23:18 python476: then I'm in the same boat

23:18 I need a tiny emacs helper to smooth out the bump

Logging service provided by n01se.net