#clojure log - Jul 19 2014

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

0:15 bryanmaass: So, I'm trying the cider 0.7.0-snapshot kool aid

0:15 when I start a repl via cider-jack-in (on emacs 24) I get this message:

0:15 ; CIDER 0.7.0-snapshot (Java 1.7.0_51, Clojure 1.5.1, nREPL 0.2.3, cider-nrepl 0.7.0-snapshot)

0:15 WARNING: The following required nREPL ops are not supported:

0:15 macroexpand macroexpand-1 macroexpand-all resource

0:15 Please, install (or update) cider-nrepl 0.7.0-snapshot and restart CIDER

0:19 Here's the plugins k/v from my project.clj :plugins [[weavejester/cider-nrepl "0.7.0-SNAPSHOT"]]

0:24 jeremyheiler: why aren't you using the cider/cider-nrepl one?

5:03 pholey: has anybody here used lazybot? (clojure ircbot), i've been trying to get him to run commands, but have been failing awfully

5:04 https://github.com/Raynes/lazybot

5:04 @help

5:05 i see clojurebot in here, i mainly want the repl service it offers

5:10 AimHere: ,(+ 3 4)

5:10 clojurebot: 7

5:10 AimHere: &(+ 3 4)

5:10 lazybot: ⇒ 7

5:10 AimHere: Both bots working as intended

5:12 pholey: ah, finally something

5:13 i've been trying to get him set up on my own channel

5:13 granted, that something was a security error, but i think that is fixable

5:15 there we are, thanks!

5:57 TurkActivist: 240 Gaza targets attacked since Thursday: Israeli army http://www.aa.com.tr/en/news/361136--240-gaza-targets-attacked-since-thursday-israeli-army

6:26 luxbock: how would I write this macro without eval? https://gist.github.com/luxbock/8784c3b80111825802e2

6:26 it works as I want atm

6:29 Chousuke: luxbock: that ~ in front of m seems extra

6:29 and then you should be able to remove one layer of quasiquoting

6:30 mthvedt: luxbock: macros are like any other fn, you can execute code that makes code and return it directly

6:30 there’s no rule that says “macros have to use syntax quoted templates"

6:30 luxbock: Chousuke: that's what I tried at first but it complains about `m` being a symbol in that case

6:31 mthvedt: so you are basically saying that my appraoch is fine?

6:31 Chousuke: hm

6:31 I'd need a clojure repl

6:31 mthvedt: luxbock: no, you have an extra layer of templating and an eval

6:32 so you’re just wrapping a template then unwrapping it with eval

6:32 Chousuke: luxbock: wait, you're passing a variable to the fns-from-map macro instead of a literal map?

6:33 if that's the case you will need eval. no way around it.

6:33 since you need to eval the variable to get at the actual map structure :p

6:34 mthvedt: ,(doc resolve)

6:34 what’s the thing for

6:34 documentation

6:34 clojurebot: eval service is offline

6:35 mthvedt: &(doc resolve)

6:35 lazybot: java.lang.SecurityException: You tripped the alarm! resolve is bad!

6:35 mthvedt: =/

6:36 luxbock: I updated the gist with how I'd like to use it

6:36 mthvedt: luxbock: use resolve to get the map

6:36 Chousuke: yeah, you'll need to manually resolve the symbol into the map in the macro

6:37 luxbock: ok, I did not know about resolve

6:37 Chousuke: well, a (let [map (eval m)] ...) should do

6:37 except not map

6:38 but something that doesn't shadow the function :P

6:38 mthvedt: eval is evil

6:39 Chousuke: you can do a resolve and deref too but it's not that different in this case.

6:41 luxbock: I don't think I know how to use this: `(do ~@(map named-fn (resolve m))) <-- still isn't working

6:43 I tried a few different ways to use it but no luck

6:45 Chousuke: luxbock: https://gist.github.com/Chousuke/be7c9ad94c314c51a16b untested

6:45 instead of eval you can use @(resolve m)

6:46 luxbock: ah

6:46 Chousuke: also I made a typo. that should be amap as a parameter to the map, not m

6:46 luxbock: yeah that works, thanks

10:21 john2x: geting java.lang.IllegalAccessError: in-seconds does not exist, compiling:(ring/middleware/cookies.clj:1:1)..

10:22 it seems ring is depends on clj-time 0.6.0 which has `in-secs`, but in its source it's using `in-seconds` from 0.7.0

10:23 how do I work around this?

10:25 mthvedt: john2x: add 0.7.0 to project.clj

10:35 john2x: mthvedt: thanks

12:01 benkay: i'm attempting to implement a datomic query using the :with functionality so that i can get a 'bag' instead of a 'set' of results for aggregating, but i'm having trouble wrapping my tiny little brain around the example in Day of Datomic and how to make that work with a database. it's probably a simple mistake that i'm making, but i can't quite figure out how to make this function work: https://www.refheap.com/88366

12:02 specifically, i'm having trouble with the binding of the data store and the queried entity ID.

12:03 oh. *sigh*. PEBKAC.

12:22 donkey_boy: burn all jews in oven

12:22 death to infidels

12:22 god bless allah

12:22 allahu akhbar

12:22 i throw stones to jews

12:23 nobodyzzz: wtf?

12:23 donkey_boy: ?

12:23 CLOJURE IS INFIDEL PROGRAMMING LANGUAGE

12:23 I THROW STONES TO JEWS

12:23 MY STONES CRUSH ISRAELI TANKS

12:23 i am a holy warrior of allah

12:24 nobodyzzz: lol ok

12:24 systemfault: Wow, that retard isn’t even a bot.

12:24 Gotta admit he’s dedicated to his shitty cause.

12:24 Bronsa: technomancy: ^

12:24 systemfault: technomancy: Yo, time to take out the garbage man :(

12:25 donkey_boy: ALLAHU AKHBAR

12:25 systemfault: Wow, he’s from Finland… expected egypt

12:26 donkey_boy: yes but i am mohammed hussein 16 year old palestinian boy

12:27 nobodyzzz: http://cdn.ebaumsworld.com/picture/Antfish/poster84762152.jpg

12:52 catern: why does this happen to #clojure

12:52 WHY

12:53 hyPiRion: catern: It's been a very long time since last incident really

12:53 catern: there are never incidents in the other large channels i'm in

12:54 hyPiRion: catern: There was one in #haskell 2 days ago – not sure if you frequent there or not

12:54 catern: ok ok fine

12:55 we are not above the base rate of bots and crazy things being said

13:00 bbloom: sometimes i'm impressed by the crazy

13:00 i don't think i could even invent such stupid shit to say

13:36 Shayanjm: has anyone implemented a k-means algorithm on text data in clojure before?

13:45 Jaood: Is there anything wrong in using ns within the repl?

13:47 is easier than doing in-ns and the referring to clojure.core

13:48 awwaiid: Jaood: I see nothing at all wrong with using ns within the repl -- easily lets you jump into the existing ns of your code for example

13:49 Jaood: s/the/then/

13:49 awwaiid: ok

13:50 jeremyheiler: tho. just ns'ing into one of your namespaces doesn't require it

13:50 Jaood: jeremyheiler: that was my next question ;)

13:51 Shayanjm: Jaood: if you want to test one ns within the context of another, just use (use 'namespace)

13:54 Jaood: Shayanjm: yeah, I do that all the time from the user ns in the repl but was wondering of a workflow for developing a library

13:55 I wonder why switching to a ns doesn't require the ns itself, any reaons?

13:56 jeremyheiler: Jaood: i generally just work from separate namespace when working on a library, and reload the library namespace when i need to

13:56 Jaood: well, switching is different than requiring :-)

14:00 Jaood: jeremyheiler: yeah I guess requiring/referring to you lib in the user ns and working from there with :reload is not a bad workflow

14:02 jeremyheiler: Jaood: check this out http://thinkrelevance.com/blog/2013/06/04/clojure-workflow-reloaded

14:03 Jaood: jeremyheiler: was figuring out how to the cider thing manually, in cider when you evaluate a form it switches the repl to ns where the form was and also requires/refers it

14:04 cool

14:05 jeremyheiler: i suppose from cider, you would have the namespace you care about open in another buffer and would do C-c C-l to load it

14:51 timsg: Anyone know how to intercept *warn-on-reflection*’s warnings? They don’t seem to be on either *out* or *err*

14:54 bbloom: timsg: they are definitely written to *err*

14:54 something else must be capturing that, maybe your repl/edit/whatever

14:58 timsg: bbloom: yeah I think I was positioning something incorrectly

15:18 ro_st: where should i look to find out how i might stream a `tail -f logfile` to a web browser? i'm using HTTP SSE which is already working. i need the magic to do the tail and stream the output somehow

15:19 currently using clojure.java.shell/sh but will probably have to use something else

15:19 boxed: if it ain’t broke, don’t fix it?

15:22 ro_st: aha looks like https://github.com/hozumi/clj-commons-exec has a stream option for :out

15:24 fifosine: What are the differences between seq, list, and vector?

15:24 ro_st: http://clojure.org/data_structures http://clojure.org/sequences

15:25 seq is an abstraction. list and vector are two implementations of seq

15:25 with different semantics and performance characteristics

15:27 fifosine: ro_st: Ok, thanks.

15:45 timsg: are type-hints resolved before macroexpansion?

15:48 justin_smith: timsg: yes, they are reader-macros

15:49 bbloom: huh? what? no

15:49 metadata is not evaluated

15:49 at least not immediately

15:49 ,^{:x (prn 1)} []

15:49 clojurebot: 1\n[]

15:49 bbloom: ,(quote ^{:x (prn 1)} [])

15:49 clojurebot: []

15:49 Bronsa: well depends where it's attached to

15:50 metadata on the def symbol IS evaluated

15:50 bbloom: right, but that's after expansion

15:50 Bronsa: yeah

15:50 bbloom: timsg: macroexpansion and the compiler are orthogonal

15:51 you can macroexpand w/o compiling, and the type hints are entirely ignored unless the macro itself does something with it

15:51 fifosine: Is there a higher-order function that takes a function, a value, and a predicate and executes the function on the value until the predicate is false?

15:51 (continually execing func on return of last func call)

15:51 I know I can write one, I'm just curious if it already exists

15:53 timsg: bbloom: I ask because, in what’s probably a bad idea anyway, we’re seeing if we can macro away some redundant type hints for a particular interop situation on Clojure-CLR…

15:54 bbloom: timsg: what is a "redundant type hint"

15:54 you mean like at multiple places?

15:54 ie you want type inference?

15:56 timsg: bbloom: There’s a kind of strange API in Unity where you lookup components in game entities by their type. My understanding is it always returns an instance of that type, but then you have to type-hint that, too, so you wind up typing (keyboard) the type (semantic) twice; which some find onerous.

15:56 bbloom: ya type inference would be nice

15:56 bbloom: this is kind of a stupid hack in the absence of stronger type inference

15:56 bbloom: do you only want *local* type inference? ie C#'s var?

15:57 and is it only for initialization of locals?

15:58 timsg: Rather than (… ^FancyComponent (.GetComponent entity FancyComponent)), we would like (get-component entity FancyComponent) to work without reflection

15:58 clojurebot: Pardon?

15:58 bbloom: timsg: ok, gotcha

15:58 hm...

16:00 ,(defmacro m [hint & xs] (with-meta `(~@xs) {:tag hint}))

16:00 clojurebot: #'sandbox/m

16:00 bbloom: ,(let [x ^long (inc 5)] x) ; works

16:00 clojurebot: 6

16:00 bbloom: ,(let [x ^int (inc 5)] x) ; fails

16:00 clojurebot: #<VerifyError java.lang.VerifyError: (class: sandbox$eval76, method: invoke signature: ()Ljava/lang/Object;) Expecting to find integer on stack>

16:00 bbloom: ,(let [x (m long inc 5)] x) ; also works

16:00 clojurebot: 6

16:00 bbloom: ,(let [x (m int inc 5)] x) ; also fails

16:00 clojurebot: #<VerifyError java.lang.VerifyError: (class: sandbox$eval124, method: invoke signature: ()Ljava/lang/Object;) Expecting to find integer on stack>

16:01 bbloom: timsg: does that solve your problem? you just have a macro AND a function

16:02 ,(defmacro m [hint & xs] (with-meta xs {:tag hint}))

16:02 clojurebot: #'sandbox/m

16:02 bbloom: ,(let [x (m long inc 5)] x) ; also works

16:02 clojurebot: 6

16:02 bbloom: i didn't need the `(~@...) but it was illustrative :-)

16:02 timsg: bbloom: think I tried that but my syntax was a little different, I’ll check against CLR

16:03 bbloom: but yeah, that should cover the very limited case of inferring the type when the type name appears on the rhs

16:37 timsg: success?

17:08 timsg: bbloom: sorry about pause, yep, much success, just verified. Think this is what we were looking for: https://www.refheap.com/88374

17:08 thanks for help!

17:09 bbloom: the type inferencer is less broken than we’d somehow made it seem, so now the macro’s really just abbreviating type-args, a quirk of Clojure-CLR and C# generic methods.

17:10 bbloom: timsg: ah, yes, reified generics

17:11 timsg: bbloom: unfamiliar but nifty feature. C#’s a lot more fun than Java

17:19 andonilsson: Trying to learn some clojurescript, but having problems with the build.

17:19 I have a combined clj/cljs project. When running 'lein cljsbuild', all that is written to my js output file is:

17:19 goog.addDependency("base.js", ['goog'], []);

17:19 Isn't cljsbuild picking up my src-cljs directory, or what could be the problem?

17:33 hmm...could've been some issue with compiler settings :optimizations :none...

18:00 note to self: next time, remember to verify that clojurescript files are named .cljs, and NOT .clj

18:20 mdeboard: andonilsson: :P

18:33 bzzz: was wondering, what's the best lightweight web framework for clojure

18:33 I just want a web server that I can develop a RESTful api on, the rest is going to be in javascript with React

18:34 currently checking out luminus, but it's based on clojure 1.3.0, what gives? why isn't it using the latest?

18:35 jeremyheiler: buzz: check out compojure

18:36 and check out ring, which is the http abstraction that most clojure-based web apps use.

18:36 Frozenlock: bzzz: compojure + liberator is probably your best option

18:37 jeremyheiler: most things, including compojure, are build on ring.

18:37 built*

18:37 bzzz: Frozenlock: is there a simple template I can download? like lein new comp-lib blah

18:39 Frozenlock: bzzz: there is one for compojure https://github.com/weavejester/compojure/wiki/Getting-Started

18:40 bzzz: do you intend to use cljs, or simply js?

19:55 irctc: Hi clojure friends, I have a question about compiling clojure projects. I know it is possible to turn all my .clj files into .class files. However, does anyone know an easy way of turning all .clj files in the dependency libraries into .class files too? (so that the resulting jar will not have any .clj files.) Thanks in advance!

21:03 cyansea: hi all, clojure and functional programming newbie here, having only really programmed in VB. when debugging i like stepping through my code and watch the state changes of my locals. i understand that there arent any state changes with functional programming but is there some way step through a function call to see how elements in a sequence are passed around and binded. i am having trouble understanding how data moves through functions

21:03 that have many other functions nested. thanks in advance for any help!

21:05 jeremyheiler: cyansea: your best bet is to use the cursive plugin for intellij.

21:05 https://cursiveclojure.com/

21:07 cyansea: would you say this is an effective way to learn clojure to understand how data moves through a function, or is there a better way with regards to clojure and functional programming?

21:07 bbloom: cyansea: nothing against graphical debuggers, but you may want to try to program with your REPL on hand

21:07 cyansea: and thanks for the link, i will check it out

21:07 jeremyheiler: i'd say it isn't. break apart each function call and see what it otuputs

21:08 in a repl, like bbloom said

21:08 bbloom: generally, you have lots of small functions without side effects, so you can just test them instantly in your repl

21:08 cyansea: if you're used to the Intermediate window or Edit & Continue in VB, then you're half way to a good Clojure workflow

21:08 cyansea: so basically work inside out?

21:09 bbloom: the primary value of a debugger is that it lets you climb inside the environment as it's running, and see what exactly is going on

21:09 but a major benefit of functional programming is that you can break up your system in to small enough parts that you can look at them in isolation

21:10 such that you can use the scientific method to find the issue, without lots of extraneous noise of a running system

21:10 cyansea: yeah that defintely makes sense

21:11 bbloom: LightTable's inline evaluation & "instarepl" are great for beginners

21:11 especially if you're used to Visual Studio

21:12 (or worse: that weird VBA IDE thing... *cringe*)

21:12 cyansea: i am currently using lighttable but i am not used to having the whole function evaluated all at once

21:12 or i could just not be using it effectively

21:12 bbloom: a common trick is to put a big (comment ...) block at the bottom of your file

21:13 then you can evaluate a test form quickly

21:13 for example: https://github.com/clojure/clojure/blob/master/src/clj/clojure/zip.clj#L281-L318

21:14 cyansea: interesting, this is all really good info

21:14 bbloom: lighttable will do the load-file & refer stuff for you automatically when you eval the file

21:20 cyansea: thanks again all, i will most likely come back with more questions as i progress

Logging service provided by n01se.net