#clojure log - Apr 06 2014

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

0:00 arrdem: I suppose I can approximate a circle really well with an inscribed 64-gon but still.

0:00 $seen sjofra

0:00 lazybot: I have never seen sjofra.

0:06 mercwithamouth: starting to really like lisp =P i think i'll stick with it for a while

0:08 arrdem: really... this guy didn't deploy his F/OSS Clojure project to Clojars..

0:08 fine...

0:08 jph-: yeh, i get annoyed by that

0:08 and feel a bit awkward deploying my own

0:09 arrdem: I mean the guy's been inactive for four months... I could open a "deploy to clojars you fool" issue and see what happens...

0:09 nightfly: do that

0:10 kenrestivo: no harm in asking.

0:11 arrdem: eh I mean I could pull it down and package it myself then PR it in the same time...

0:11 * arrdem digs out the maven manual

0:18 arrdem: woah what the shit...

0:23 miseria: "un buscador, no es el que sabe lo que busca, un buscador es quien descubre que la vida, es una continua busqueda" bienvenidos: http://castroruben.com *temo_a_un_ser_sin_rival*

0:24 arrdem: second spambot in two days.. we must be popular :P

0:26 myguidingstar: somebody please help implement this Java thing in Clojure. I tried but can't get Java

0:26 https://gist.github.com/myguidingstar/27c6a1511fab4c5b2575

0:26 (it's very short)

0:33 ambrosebs: myguidingstar: see deftype

0:34 myguidingstar: ambrosebs, do I have to import something to use an interface?

0:35 ambrosebs: myguidingstar: you don't need to load anything, but you can use import/:import to abbreviate the interface name

0:35 via the ns macro

0:37 myguidingstar: (in my pure Clojure brain they look like undefined symbols)

0:37 btw, in `public TemplateModel exec` so what do I do with `TemplateModel`?

0:39 ambrosebs: myguidingstar: I can't remember. It might work without type annotations, otherwise you might need something like gen-class.

0:39 try something like: TemplateModel (exec [this args] ...)

0:40 myguidingstar: thanks, let me see

0:41 gtrak: in core.async, do taps close their passed-in channel?

0:42 docs say they close if the channel closes, but I want the reverse.

0:44 hrm..

0:44 looks like no

0:45 except in my case, maybe it'll get GC'd

0:47 amalloy: ambrosebs: the return types for interfaces are inferred by name

1:06 gfredericks: amalloy: yeah, I started with the loop and then pulled it out because emitting was just as easy and less nested

1:06 and ~@ is easier than concat

2:03 dissipate: what is the best unit testing framework for clojure? is it midje?

2:26 Raynes: dissipate: It's whatever your favorite is.

2:32 arrdem: Raynes: dat cop out tho

2:32 Raynes: His question is fundamentally unanswerable.

2:33 There are a variety of libraries throughout the Clojure ecosystem providing solutions for more or less any sort of testing methodology or combinations thereof that one could ever ask for.

2:33 dissipate: Raynes, i'm asking for opinions. :P

2:33 Raynes: Aimed at different people, these libraries do not deserve to be compared.

2:33 * Raynes sits on the floor in the corner with black eyeliner on.

2:35 * arrdem contemplates why this class has no .x when the docs say it does

2:37 trap_exit: in cljs, what is the inverse of clojure.edn/parse-string ?

2:37 i.e. I have a data structure, and I want to string-encode it via edn

2:51 maxthoursie: trap_exit: can't you use pr-str?

3:14 trap_exit: maxthoursie: yes, pr-str works

3:14 maxthoursie: great

3:45 vimuser2: For recur, im a bit confused why you can do something like (loop [] (let [] recur)) but not (loop [] #(recur)) . I thought let just expands to a anonymous function anyway?

3:45 (above isn't valid lsip, was just focusing on order of function calls)

3:53 mercwithamouth: vimuser2: i'm fairly new to clojure and most likely wrong but wouldn't #(recur) screw up the scope?

3:54 you're putting it inside of a function thats not actually called or hit...

4:04 vimuser2: mercwithamouth: yeah, meant to say something like (#(recur .. ))

4:05 dissipate: what is going on with this error? Exception in thread "main" java.lang.RuntimeException: No such var: leiningen.util.injected/add-hook, compiling:(NO_SOURCE_PATH:1)

4:05 all i did was 'lein new my-project' and then 'cd my-project' and 'lein test'

4:23 nevermind, i found out my version of leiningen was out of date

5:14 ggherdov_: hi, for my program I need an HTTP client library. What would be the go-to choice?

5:36 scottj: ggherdov_: clj-http

5:57 ptcek: any way to get namespace part of keyword/symbol (as `name` gets the, ehm, name)?

5:59 ,(namespace :ns/name)

5:59 clojurebot: "ns"

5:59 ptcek: so obvious... :)

8:47 mercwithamouth: (->> (range 10)(map inc)(interpose 5)(reduce +))

8:47 ,(->> (range 10)(map inc)(interpose 5)(reduce +))

8:47 clojurebot: 100

8:47 mercwithamouth: ok why does that work here but i get an illegalstateexception error in my repl?! =(

8:50 ,(->> (range 10)(map inc)(interpose 5))

8:50 clojurebot: (1 5 2 5 3 ...)

9:00 ivan: mercwithamouth: can you paste your error?

9:02 ToxicFrog: mercwithamouth: works for me.

9:11 mercwithamouth: ivan: IllegalStateException Attempting to call unbound fn: #'user/inc clojure.lang.Var$Unbound.throwArity (Var.java:43)

9:19 ok weird i restarted my repl, now it works

9:28 stain: did you accitdentally def 'inc' perhaps?

9:43 gfredericks: ,(def inc dec)

9:43 clojurebot: #<CompilerException java.lang.SecurityException: denied, compiling:(NO_SOURCE_PATH:0:0)>

12:52 hiteki: hi

13:21 vimuser2: Is there a built in function for applying a function to each element in a seq?

13:22 as in, given f, and a [1 2 3], then (f 1) (f 2) (f 3) will be called. I don't care about the output (doing side effect stuff)

13:22 ambrosebs: vimuser2: (doall (map f coll))

13:22 vimuser2: i could technically use reduce and just keep returning ni

13:23 ambrosebs: or dorun, doseq

13:23 see the docs for the differences

13:23 vimuser2: ah thanks

13:23 bbloom: would be nice to have clojure.core/each, *shrug* oh well

13:29 zakwilson: I'm trying to use sensors on Android, and the Java documentation for that involves casting a SystemSensorManager to a SensorManager, but when I call (cast SensorManager the-SystemSensorManager), the object returned is still a SystemSensorManager, which does not define the registerListener method and therefore crashes at runtime.

13:29 bbloom: tbaldridge: spotted effect_lisp -- glad to see you're experimenting too :-)

13:49 yotsov: zakwilson: SystemSensorManager extends SensorManager, so it looks like you are trying to upcast, which cannot have the benefit of exposing more methods

13:51 AmandaC: zakwilson: where are you getting a SystemSensorManager from?

13:52 zakwilson: because there’s no such class that I can find.

14:29 dissipate: how the hell do you do a simple 'find and replace' in light table

14:33 `szx: dissipate: cmd+f?

14:34 cmd+shift+f for for multiple files

14:36 dissipate: `szx, that's find what about replace?

14:36 `szx: dissipate: it's both - left field is find, right field is replace

14:36 dissipate: 0

14:37 `szx, i see, thanks

14:37 `szx: UI could be better, i agree

14:43 zakwilson: AmandaC: (.getSystemService ^Activity a "sensor") returns a SystemSensorManager. The class is not documented in the Android docs.

14:43 AmandaC: zakwilson: ah, I see.

14:44 zakwilson: and it doesn’t function the same?

14:44 zakwilson: yotsov: what you say sounds right to me, but I get "No matching method found: registerListener for class android.hardware.SystemSensorManager" at runtime. Wait... it could do that if I supplied incorrect arguments too.

14:45 AmandaC: I'm not sure. The Java example code includes the cast. I'm exploring the possibility that I'm calling it wrong.

14:46 It really doesn't look like I am though.

14:46 AmandaC: zakwilson: the Java Exampple Code includes the cast because getSystemService returns an Object, IIRC

14:50 miseria: "el deseo de vivir un millon de años, me obligan a buscar y matar la muerte, antes que ella me convierta en calavera" bienvenidos: http://castroruben.com *temo_a_un_ser_sin_rival*

14:52 zakwilson: AmandaC: that makes sense, now that I think about it.

15:05 yedi: is there a function that does (first (filter fn coll)) more tersely?

15:06 some

15:06 hyPiRion: yedi: some does something else in the general case

15:06 bbloom: if you're binding a name to the result, you can leverage destructuring:

15:07 ,(let [[x] (filter pos? [0 -1 2 1 0])] x)

15:07 clojurebot: 2

15:07 yedi: hyPiRion: how so? is it not always the first element?

15:08 bbloom: (doc some)

15:08 clojurebot: "([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence, otherwise nil: (some #{:fred} coll)"

15:08 hyPiRion: yedi: ##((juxt (comp first filter) some) pos? [0 -1 2 1 0])

15:08 lazybot: ⇒ [2 true]

15:08 yedi: oh, i see

15:08 * hyPiRion got to use juxt today. Today is a great day.

15:08 bbloom: (inc juxt)

15:09 lazybot: ⇒ 7

15:37 Averell: as long as it's not one of the 4clojure juxt exercises :)

15:39 DomKM: Is there a way to write to a java.io.BufferedWriter without reflection?

15:39 (with-open [^java.io.BufferedWriter wrtr (clojure.java.io/writer path)] (.write wrtr "string"))) uses reflection

15:42 clifton: hi, i have a proprietary jar file launches a swing interface. is there a good way to use leiningen to have that jar file included in the classpath when i launch the repl?

15:43 im trying to programatically manipulate the interface (seesaw looks nice) and do not have access to the source code

15:43 hiredman: DomKM: what makes you think it uses reflection?

15:43 DomKM: hiredman: I get a reflection warning

15:44 hiredman: DomKM: with that actual code, or is that a simplified example?

15:45 DomKM: hiredman: it's a simplified example

15:45 hiredman: DomKM: do you actually get a reflection warning with it?

15:45 (I don't think you will, so I don't think it is a good simplified example)

15:47 DomKM: hiredman: you're right, I didn't

15:48 hiredman: I needed to replace "string" with (cheshire.core/encode {}) to get a warning

15:48 hiredman: ^String (cheshire.core/encode {})

15:49 or I believe cheshire has functions for encoding directly to streams

15:49 DomKM: hiredman: perfect, thanks :)

15:49 hiredman: https://github.com/dakrone/cheshire/blob/master/src/cheshire/core.clj#L36

15:49 noprompt: $seen Raynes

15:49 lazybot: Raynes was last seen talking on #clojure 13 hours and 16 minutes ago.

15:50 Raynes: sup

15:50 noprompt: hey cool, you're here.

15:50 * Raynes pretends he isn't currently writing Python

15:51 noprompt: could lein-pdo be tweaked to tag output from tasks? ex. lein pdo a, b would do something like

15:51 [a] STDOUT from a

15:52 [b] STDOUT from b

15:52 Raynes: noprompt: ship it

15:52 noprompt: Raynes: so it's possible?

15:53 Raynes: I highly doubt it.

15:53 But I also haven't looked at that plugin since the 5 minutes it took me to write it.

15:53 noprompt: that's what i thought.

15:53 Raynes: noprompt: I mean, it might be possible.

15:54 noprompt: You could perhaps rebind *out* to intercept prints.

15:54 Each task execution is just a function call, so presumably (binding ..) would apply.

15:54 noprompt: Raynes: i'll give it a shot. i ended up handrolling something at work before i knew about lein-pdo.

15:55 pandeiro: anyone know a strategy for swapping out URLs in a cljs app meant for a service-oriented architecture where development and production URLs are different?

15:55 noprompt: pandeiro: you can use enlive to do that.

15:55 hyPiRion: noprompt: just ensure you perform a locking on the original *out* value, otherwise you end up with possibly interleaved prints

15:55 pandeiro: noprompt: i will use enlive for the html part, yeah

15:55 but i am talking about within the cljs app

15:55 noprompt: pandeiro: at work we have a build process that compiles new html files for production apps after we push new builds to s3.

15:56 pandeiro: noprompt: cool yeah html problem is resolved for me

15:56 enlive is perfect for that

15:56 michaniskin: does doing (def thing (future ...)) not make sense for some reason? i'm having trouble compiling a namespace that assigns a var like that (compiling seems to take forever)

15:56 pandeiro: but within my cljs app i have a lot of xhr to do

15:57 noprompt: pandeiro: ah ok. well, you could write a macro that reads something from the environment etc. and handle it there.

15:57 pandeiro: noprompt: ah ok so at macro-expansion time, interesting

15:57 noprompt: pandeiro: since cljs macros are expanded in clojure you could pretty much do whatever you want.

15:57 pandeiro: sure, that's the path then

15:57 thanks

15:58 noprompt: pandeiro: the idea is similar to this https://gist.github.com/noprompt/9086232

15:58 pandeiro: ah but how do i determine in the macro if it's a dev or prod build?

15:58 noprompt: pandeiro: probably do something like ENV=production lein cljsbuild ...

15:58 pandeiro: yep, ok

15:59 * pandeiro wonders if that is that isn't something that should be in cljsbuild

16:00 andyf_: Bronsa: ping

16:00 noprompt: hyPiRion: how do i do that?

16:02 Raynes: noprompt: If you need assistance let me know and I'll be as useless as ever.

16:02 :D

16:02 noprompt: lol

16:03 i don't mind the output being interleaved, i just want it tagged so i know where it's coming from.

16:03 hyPiRion: noprompt: interleaved as in `lein pdo shell echo 111, shell echo 222` may print out '11222\n1'

16:04 noprompt: yeah that's fine. i'd like to see

16:05 [shell echo 111] 111

16:05 [shell echo 222] 222

16:05 hyPiRion: exactly, which means you probably don't want to see `[shell echo 111] 11[shell echo 222] 2221`

16:05 noprompt: oh wait but i see what you mean.

16:06 hyPiRion: I think it should be sufficient to reify some interface, then do `(locking original-out (. call original-out with-args))` on every fn.

16:07 Writer, probably.

16:08 Only thing is that you'd likely want to gobble data until you hit a newline or EOF, then print a line. That may be a bit more complicated.

16:08 Bronsa: andyf_: pong

16:09 noprompt: gotcha

16:09 andyf_: Still as busy as ever fixing tools.analyzer(.jvm) bugs, I see (and thank you)

16:09 noprompt: alright i'm gonna dig in to this and see what i come up with.

16:09 andyf_: I was curious whether there was a relatively short set of rules I could use in Eastwood to warn about badly placed :tag metadata

16:10 Bronsa: andyf_: eh, I have a list of bugs to solve that I discovered a couple of days ago but I'm too tired to fix them now

16:10 andyf_: I don't have such a set of rules in my head yet, and was hoping you could help me bypass a big chunk of guessing, experimentation, and reading code, if you had such knowledge ready at hand.

16:11 Bronsa: andyf_: the only place where I saw people put metadata where it actually isn't doing what they think it's doing is in def symbols

16:11 andyf_: Do you know of any good reasons to put tag metadata on symbols being def'd?

16:12 i.e. does the compiler itself ever pay attention to it there?

16:12 Bronsa: andyf_: maybe, I don't remember, let me check

16:13 andyf_: So the short rule might look something like (def ^nothere myfn ^ret-tag-here [^arg1tag arg1 ^arg2tag arg2 ...] fn-body)

16:14 Oops, that should be defn, not def

16:14 ztellman: anyone on here who knows core.async well?

16:14 have a question about 'alt'

16:15 andyf_: and more generally (defn ^nothere myfn (^rettype1 [^arg1tag arg1] body-for-1arg) (^rettype2 [^arg1tag arg1 ^arg2tag arg2] body-for-2-args))

16:15 Bronsa: andyf_: actually the compiler uses tag attached on Vars too

16:15 andyf_: the only issue really is if you're tagging primitives

16:16 it works fine for objects

16:16 andyf_: So those code snippets I showed are what should be used for primitive type tags, and the only ones supported are ^long and ^double ?

16:16 Bronsa: yeah

16:16 S3thc0n: Hello everyone, I spent the last few weeks pondering the very basics of programming languages and wondered: How (except for forward reference) would a global let differ from using defs? Since (IMHO) everything should be an expression and not a statement I think this would be cleaner. But the problem of other libraries / namespaces with their own let arises, as well as accessing declared

16:16 values/functions from outside (a REPL for example). What do you think?

16:16 Bronsa: if you tag with a primitive tag the Var rather than the arglist there are going to be two problems

16:17 andyf_: And if they are non-primitive tags, they will work in the same places as for primitive ones, but a non-primitive tag on a Var "works the same way" as if it is on the arg vector?

16:17 Bronsa: - the Var meta is going to be evaluated so you'll get :tag #<the-primitive-function> instead of the tag

16:18 andyf_: Yeah, I've seen that case plenty of times now

16:18 Bronsa: - even if you quote the tag, the compiler will not optimize the function with a prim interface for the return type

16:19 e.g. (defn ^{:tag 'long} x [^long a] a) will make x a IFn$LO rather than IFn$LL

16:19 so you get boxing on the return type

16:20 if you do (defn x ^long [^long a] a) however you get what you'd expect

16:21 andyf_: And non-primitive type tags are only used for avoiding reflection in Java interop calls, either in the function body for type tags on args, or wherever the function return value is used for the return type tag?

16:21 Bronsa: andyf_: yes

16:22 well, and to hint at the correct method too

16:22 andyf_: OK, I think I'm down to 1 question, and then I go off to experiment with these variations for my own confirmation: A non-primitive tag on the Var, or on the arg vector, work the same way, or nearly so?

16:23 Bronsa: say you have a class A which implements B and C, and you have a method foo that takes a B or a C, a type hint to B in a function that returns an A makes a call to foo resolve to the call to foo(B)

16:24 andyf_: that should be correct, I can't think of a case where that would be false

16:25 andyf_: So it sounds like the main cases where it would help if Eastwood gave warnings are for attempted primitive tags that are neither long nor double, anywhere they appear, or for ^long or ^double on Vars.

16:25 Bronsa: andyf_: well

16:26 andyf_: Oh, I guess ^int and such are still useful in a Java interop call?

16:26 Bronsa: right

16:26 I was just going to say that

16:26 andyf_: Are primitive hints ever used in a let or loop binding?

16:27 Bronsa: andyf_: you can do that

16:28 andyf_: By which I mean a code snippet like (let [^double x 0.0] let-body)

16:28 amalloy: can you? i think you have to write (let [x (double 0.0)] body)

16:28 or, well, 0.0 is a double literal, so you don't have to. but like (long 0)

16:28 Bronsa: you can't do that specifically, but I believe you can do (let [^double x (something)] ..)

16:32 amalloy: looks like you can indeed

16:32 yedi: anyone know what this might mean? compiling cljs: Caused by: java.lang.IllegalStateException: Nested #()s are not allowed

16:33 Bronsa: amalloy: (fn [] (let [^int a (Integer. 1)] (clojure.lang.RT/box a))) compiles to http://sprunge.us/OBjJ

16:33 while (fn [] (let [a (Integer. 1)] (clojure.lang.RT/box a))) compiles to http://sprunge.us/LQag

16:33 yedi: i'm not getting a line number in the stack trace or anything so debugging that is proving to be a lil difficult

16:34 amalloy: yedi: #(foo #(bar))

16:35 yedi: ah found it

16:35 thanks amalloy

17:06 in om/react, does rerendering not detect changes in styles?

17:07 S3thc0n: Hello everyone, I spent the last few weeks pondering the very basics of programming languages and wondered: How (except for forward reference) would a global let differ from using defs? Since (IMHO) everything should be an expression and not a statement I think this would be cleaner. But the problem of other libraries / namespaces with their own let arises, as well as accessing declared

17:07 values/functions from outside (a REPL for example). What do you think?

17:07 yedi: i have it so that i change the color of some spans, however when i rerender the new colors don't show and the old color still remains

17:08 i'm assuming it's because the diffing algo doesn't detect differences within the style attribute?

17:08 atleast that's what it looks like..

17:09 gfrederi`: S3thc0n: clojure's defs are very much not like a let

17:10 gfredericks: one of the things clojure's design accomplishes is that entering code at the repl is almost exactly the same as having it in a file that's loaded

17:11 I think your ideas would make that relationship a lot more complex; would also have to figure out what code-reloading means, if it even makes sense

17:15 hiredman: lisp is small pieces has a good section on different strategies for top-level environments

17:15 lisp in small pieces

17:31 yedi: in om: are you allowed to om/transact! cursors in (will-mount) ?

17:31 my cursor is showing up as nil

17:32 clifton: anyone here familiar with seesaw?

17:32 yedi: however it seems to works after some specific state changes

17:35 heh, used (om/get-props owner) instead of the cursor passed to the component and it seemed to work

17:37 gtrak: yedi: has it clicked for you yet? I'm still figuring it out as I go along.

17:37 yedi: gtrak: i'm slowly figuring things out

17:37 gtrak: maybe I'll make another pass at react docs once I've built the thing I'm trying to build.

17:38 time-pressure sucks :-)

17:38 yedi: i've spent quite sometime grappling with some silly gotchas but i figure after this initial foray into om things'll go a lot more smoothly

17:39 `szx: yedi: gtrak: do you guys use sablono/kioo or just straight up om?

17:39 just wondering

17:39 gtrak: sablono's nice but it adds yet another layer. been using it. yea.

17:39 yedi: i'm using straight up om

17:39 i may switch to sablono once im more familiar with om

17:39 `szx: yedi: yeah, i think i might do that as well

17:39 no time pressure here :)

17:40 yedi: `szx: likewise, we're lucky

17:40 gtrak: I made a single component that worked, but it got way too tedious to use om dom once I started worrying about styling.

17:40 they compose though

17:41 `szx: gtrak: how does sablono help the styling issue?

17:41 yedi: whats weird is i know that much of the stuff ive done in om so far id be able to do way faster in an imperative jquery style

17:41 gtrak: just easier to see stuff at a glance, it's more terse and regular.

17:42 yedi: but one thing i noticed is that as the app's complexity increases, the spaghetti-ness of my code doesn't

17:42 it's relatively simple to add new functionality with core.async and om

17:42 `szx: yeah, with jquery you invariably end up with spaghetti in my experience

17:43 whodidthis: how do i set value = something; in clojurescript

17:43 yedi: (let [value something] value)

17:43 whodidthis: to a javascript variable

17:43 michaniskin: whodidthis: (set! (.-value js/window) something)

17:44 gtrak: `szx: it was getting unwieldy: https://gist.github.com/gtrak/10011760

17:44 whodidthis: sweet, thanks

17:44 michaniskin: whodidthis: (aset js/window "value" something)

17:44 that's like window["value"] = something;

17:46 gtrak: `szx: the data parts and the code parts just feel different and are easy to pick out visually, I feel like om/dom stuff just has more mental overhead, and I'm not super familiar with hiccup.

17:46 `szx: gtrak: yeah, this look nice and clean

17:46 *looks

17:49 noprompt: hyPiRion: i don't think i understand what's happening here: https://gist.github.com/noprompt/b2893da6dd4fb6551874

17:49 hyPiRion: i'd expect to see [foo] bar

17:52 hyPiRion: noprompt: so apparently writer is probably not what you'd like to use

17:52 noprompt: hyPiRion: well it works fine for plain old print but not println

17:53 hyPiRion: what would your recommend instead? i haven't ventured in to these parts of clojure before.

17:54 michaniskin: noprompt: maybe java.io.PrintWriter?

17:55 hyPiRion: noprompt: Well, I guess a writer could work, but you just need to know where a line starts and another ends

17:57 pandeiro: michaniskin: how is hoplon/boot coming along?

17:57 hyPiRion: noprompt: so essentially, you'll have to buffer the write calls, and whenever you see a newline or somebody closes the writer, you print the current buffer with the prefix

17:58 michaniskin: pandeiro: we're plugging away, planningthe future of boot next week.

17:59 pandeiro: michaniskin: i need to take a look, it's been a while... been teaching and writing too much to program over the last several months (eternity in open source time ;)

18:00 cddr: Is it possible to deploy to clojars after a successfull travis build? I

18:00 see that travis has "secure environment variables". Is there a way to

18:00 get lein deploy to get the input it needs from these?

18:00 michaniskin: pandeiro: you're welcome to join us, check out the topic in #hoplon for the schedule

18:01 bob2_: cddr, if you can write them to ~/.lein/credentials.clj sure

18:05 noprompt: sorry

18:05 pandeiro: michaniskin: awesome, filled out the poll and hope i can be there

18:05 noprompt: sorry, had to step a way for a second.

18:06 michaniskin: i'm proxying java.io.PrintWriter. did you see the gist?

18:06 haole: how do I map over a set of hashmaps? I want my function to be applied to each hash, and not have clojure apply it to the set of first items, then seconds and etc

18:07 bob2: haole, isn't that already how it works?

18:07 haole: bob2: not quite... for example: I'd like (def hs {:a 1 :b 2 :c 3}) (map #(print %) hs) to be equivalent to (print hs)

18:08 but I get ([:b 2][:c 3][:a 1])

18:09 arrdem: haole: what are you trying to do with this behavior?

18:09 haole: the example you give is an artifact of clojure core semantics.. you aren't going to change that.

18:10 michaniskin: noprompt: sorry, ignore my comment; it was nonsense

18:10 haole: arrdem: my data structure right now is a hash-map in a given format and I'd like to iterate over hashmaps

18:10 and not their key-value pairs

18:11 arrdem: unclear. give me an IO case.

18:11 cddr: But hs seems like a single hashmap to me

18:11 Wouldn't (map #(print %) [hs]) do what you want?

18:11 haole: cddr: yes, it is, but I'd like to use a set of hashmaps

18:11 michaniskin: ,(map #(pr-str %) #{ {:a 1 :b 2} {:c 3 :d 4} })

18:11 clojurebot: ("{:c 3, :d 4}" "{:b 2, :a 1}")

18:12 arrdem: haole: you could do (map my-fn (juxt :key1 :key2 :key3))

18:12 haole: cddr: hmmm maybe

18:12 michaniskin: haole: that's a set of hash-maps

18:12 arrdem: haole: or you could map over (vals)..

18:12 haole: ha! that's what I want: (map fn [hs])

18:12 :D

18:12 arrdem: wat.

18:12 that's exactly (fn hs).

18:13 haole: I'm using Clojure with the basic concepts first... I'll evolve into proper data structures as I get familiar with the language

18:13 arrdem: (map fn [hs]) makes fn be called in each hs and not the k-v pairs

18:14 I hope I'm making sense :D

18:14 noprompt: michaniskin: cool. i just have no idea why i'm getting the extra "[foo]" at the end of the string. regular print works just fine.

18:14 haole: and I hope that I'm not using Clojure in an awkward way

18:14 noprompt: oh i think i see now

18:14 bjorkintosh: as long as you don't write fortran in it!

18:15 haole: wow, wait... juxt replaces most of the logic I've written for my function

18:15 damn! gonna use that instead :D

18:15 cddr: hoole: lol :D

18:16 haole: I have a set of functions that I have to apply in a set of hashes

18:16 I was doing something like: (map #(% hs) set-of-funcs)

18:16 looks like juxt to me now

18:16 noprompt: it's (newline)

18:16 i didn't implement append

18:17 michaniskin: comp, juxt, partial, apply, the solution to all of life's problems

18:18 dpathakj: Does anyone know a good way to get access to a list containing vars bound via destructuring with :keys?

18:18 michaniskin: dpathakj: are you writing a macro?

18:18 dpathakj: Naively, something like ((fn [{:keys [a b] :as k}] k) {:a 1 :b 2}) but with ':as k' inside the vector [:a :b]

18:18 haole: michaniskin: I'm already using partial without even thinking about it... the others will come with time and practice :)

18:19 dpathakj: Nope, just runtime shenanigans. It's not really important because the application I'm thinking of has only two keys.

18:19 I'm aware that as written, (vals k) works.

18:22 I think what I was thinking of probably doesn't exist since the docs on destructuring would mention it.

18:22 Wondered if anyone here would see something I missed.

18:23 michaniskin: dpathakj: your anon fn is basically the identity function with the exception that it'll throw an exception if you call it with something that isn't associative?

18:25 noprompt: michaniskin, hyPiRion: this seems to work just fine https://gist.github.com/noprompt/b2893da6dd4fb6551874

18:25 dpathakj: Don't think so.

18:25 ,((fn [{:keys [a b] :as k}] k) 1)

18:25 clojurebot: 1

18:26 noprompt: Raynes: i guess we can tag the output then.

18:27 arrdem: $seen tbaldridge

18:27 lazybot: tbaldridge was last seen joining on clojure-social 19 hours and 50 minutes ago.

18:28 arrdem: damnit lazybot y u ping

18:34 haole: if I want to apply a function in a value or in a set of values, how do I do it in a simple way? currently, I'm ussing (flatten (list my-value)) before applying map to it

18:34 arrdem: ~flatten

18:34 clojurebot: are you still sleeping in the job...

18:36 haole: I want to filter, for example, 1 to (1) and (1 2 3) to (1 2 3)

18:36 hyPiRion: noprompt: might work for your case, but may also mangle output

18:36 haole: (flatten (list ...)) seems to work but it smells bad :D

18:37 michaniskin: ,(flatten (list {:a [1 2 3]}))

18:37 clojurebot: ({:a [1 2 3]})

18:38 michaniskin: ,(flatten (list [:a [1 2 3]]))

18:38 clojurebot: (:a 1 2 3)

18:38 bob2: haole, can you change the api to not require that?

18:38 haole: ,(flatten 1)

18:38 clojurebot: ()

18:38 haole: heh

18:38 bob2: consistent types will make things easier to implement and understand, imho

18:38 haole: yeah, probably... I'm asking to get to know all the alternatives :)

18:38 my program is way too lispy right now

18:39 maybe I'll have to step back and use some more advanced data structures

18:39 noprompt: hyPiRion: well how could i stress test it to find the edge cases?

18:39 michaniskin: haole: flatten does recursion, which you probably don't want there

18:39 haole: hmm good point

18:39 bob2: I don't think you need more advanced data structures

18:39 arrdem: my advice: fix your types, don't use flatten. flatten is one of those functions which rarely exhibits the desired behavior.

18:39 bob2: just to use the oens you're already using, better

18:40 michaniskin: i don't think i've ever wanted to use flatten in 3 years now

18:40 wenever i think i want it, i always end up wanting prewalk or postwalk or something

18:40 noprompt: michaniskin: funny, i just realized a similar thing not to long ago.

18:41 haven't used flatten in a while.

18:41 arrdem: (watching TB's tools analyzer talk) is there a spec _anywhere_ for the intersection of Clojure and clojurescript?

18:41 michaniskin: noprompt: tree-seq ftw

18:41 holo: hi

18:41 hyPiRion: noprompt: (let [timeout (+ (System/currentTimeMillis) 50)] (with-out-tag "foo" (loop [] (println "hello from foo") (if (< (System/currentTimeMillis) timeout) (recur))))) or something

18:42 noprompt: ok let me try that.

18:45 hyPiRion: It may also work just as you want it to, depending on the JVM you use, cores, etc. Its thread-unsafeness makes it hard to know what exactly will happen.

18:45 noprompt: ah, interesting.

18:45 holo: I want to use this kind of stuff in my clj/cljs code: かな? but ? is not a valid character for identifiers in cljs, it seems. it is valid in clj though. would it be possible to extend identifiers allowed characters to ?in cljs?

18:45 noprompt: hyPiRion: why does this happen with the loop example?

18:46 arrdem: holo: most likely that's an issue with JS, so I doubt it.

18:46 holo: you'd need to implement UTF8 munging in the cljs compiler

18:46 holo: not worth it.

18:48 holo: I see. I asked this because "?" is also not a valid js character. check it here: http://mothereff.in/js-variables so if the exception was made for "?", why not make it for "?" too?

18:49 hyPiRion: noprompt: because you call it so often that it's almost guaranteed that a .write call starts while another .write call is currently running

18:49 holo: arrdem, sorry, the answer above was for you :)

18:49 hyPiRion: that's not the case when you wait over a millisecond

18:50 noprompt: hyPiRion: so that's why you were saying i should implement a locking mechanism. gotcha.

18:50 arrdem: holo: you could implement arbitrary UTF8 munging for cljs, just like ? is munged, but clearly it wasn't a developer priority.

18:52 noprompt: ok, gotta step out for an early dinner. i'll work on this a bit more later.

18:52 hyPiRion: noprompt: it's not that hard to do it here, luckily. just wrap all proxy methods in a (locking old-out ...), then you should in theory be set

18:54 holo: arrdem, OK I'm going to try doing that

18:54 (inc arrdem) ; :D

18:54 lazybot: ⇒ 23

18:55 arrdem: tbaldridge: ping

18:55 tbaldridge: this time for real :P

19:01 haole: michaelneale: fixing my API to work only with lists has reduced my code by 1/3

19:02 thanks for the tip

19:02 ops... it's michaniskin ^

19:02 :D

19:02 michaelneale: haole: I think that would be for someone else - I don't recall providing a tip!

19:02 I am sure it was a good tip!

19:03 michaniskin: haha, just the tip, though. it's a pretty good tip.

19:03 haole: :)

19:08 rberdeen: in a clojurescript repl, should the variables in a namespace be available after evaluating (ns whatever)?

19:08 they appear to be in the vanilla clojurescript repl, but not when I use austin

19:14 it looks like i need to (load-namespace 'whatever) before (ns whatever) even if the namespace has been loaded in the browser...

19:21 michaniskin: whatever happened to pods? was the concept abandoned?

19:23 bob2: haole, it's a useful thing to do in most languages

19:26 hyPiRion: michaniskin: yeah, it's abandonded

19:27 michaniskin: hyPiRion: thanks. "pod" is a choice name, but don't want to confuse with core Clojure things

19:28 hyPiRion: I think you can safely use the term pod in your project without being scared of it suddenly popping into existence

19:29 michaniskin: oh thank god

19:41 antonv: why when I evaluate (require 'myprj.core), I get "syntax-ppss: Lisp nesting exceeds `max-lisp-eval-depth'" error in CIDER?

19:41 is it some circularity in the returnined value, preventing object printing?

19:42 I mean printing of the returned namespace object?

19:42 clifton: anyone know why it says method not in interface when it is? (reify AWTEventListener (eventDispatched [event] (println event)))

19:43 antonv: but in *cider-repl* (require 'myprj.core) works

19:53 holo: I found a trick to not pull out my hair when developing clj/cljs compatible macros to use in .cljx. just create two .clj files. one for clj macros, other for cljs macros, and name the macros the same way in both files, only change impl. then in the ns form use #+clj/#+cljs. sanity back!!

19:54 clifton: nevermind, it didnt work because interface methods need to be reified with [this & args] and not just [& args]

20:09 creese: I need to create a local library that I can link to. Anyone know how to do the equivalent of 'python setup.py develop'?

20:13 ered: creese: what does `python setup.py develop` do?

20:15 creese: it installs a local version of the library into your environment so you can use it elsewhere, changes in the source lib are automatically reflected in other projects, useful for development

20:15 ered: creese: you might want lein checkouts

20:16 https://github.com/technomancy/leiningen/blob/master/doc/TUTORIAL.md#checkout-dependencies

20:19 yedi: anyone have experience deploying datomic clojure apps to ec2?

20:19 creese: ered: That's exactly what I need. Thanks!

20:19 yedi: if so wanna send some pointers my way?

20:23 michaniskin: yedi: http://docs.datomic.com/aws.html <-- worked for me

21:05 noprompt: well it didn't work.

21:05 Raynes: can't figure out what i need to do to make this happen.

21:05 if it's even possible.

21:06 hyPiRion: thanks for the tip by the way. it works great now.

21:09 arrdem: michaniskin: pods?

21:10 michaniskin: arrdem: these things: https://kotka.de/blog/2010/12/What_are_Pods.html

21:10 arrdem: michaniskin: already reading it..

21:14 oinksoft: is it normal to isolate exported classes in an aot namespace?

21:15 a project i am working on has :aot [this-project.aot]

21:15 and other source files will say ;; gen-class statement in this-project.aot

21:20 noprompt: well i'm fresh out of ideas.

21:21 hyPiRion: if you're still around and you have any thoughts ping me.

21:38 chare: someone buy me terraria

22:07 TravisD: Does anyone know if Gorilla REPL can display incanter data? (Charts, matrices, etc). Also, is it mature enough to use as a tool?

22:09 arrdem: TravisD: well it features plugable rendering so if it doesn't you can add it..

22:10 TravisD: arrdem: Yeah, that's true :)

22:10 arrdem: TravisD: as to maturity it seems to still be really young so I wouldn't expect so.

22:10 TravisD: ah, shucks. Are there other graphical notebook-style repls?

22:10 arrdem: I mean.. it works. It's just also being actively developed.

22:11 nope looks like Gorilla is the first and only Clojure notebook

22:11 unless you count Light Table

22:12 TravisD: cool, thanks!

22:15 ivan: TravisD: Session is another

22:15 arrdem: $google clojure Session repl notebook

22:15 lazybot: [Session — Medium] https://medium.com/p/1a12997a5f70

22:15 arrdem: also ultra new and actively developed...

22:16 TravisD: hehe, cool :D Thanks for checking. I feel like I didn't do my own legwork

22:17 arrdem: eh... I'd love to have a good notebook style tool, so this is personal research for me too :P

22:19 TravisD: hehe :D

22:20 arrdem: hum... anyone care to comment on using core.logic with a relatively large external dataset?

22:21 I suppose that I could dynamically construct DBs... but that feels a little gross.

22:25 gtrak: anyone have any tips how to debug core.async? I'd like to be able to see which channels are blocked/full. Maybe fantasy :-).

22:26 I might resort to sliding buffers, but that seems dirty.

22:40 arrdem: do we have a standard way of writing edn files, all I see is pr-str :c

22:42 ivan: arrdem: http://dev.clojure.org/jira/browse/CLJ-1201

22:42 nothing else yet afaik

22:42 * arrdem facepalms

22:42 arrdem: thanks ivan, voted the ticket up.

22:57 Raynes: noprompt: Well.

22:57 noprompt: I can't think of a way to make it work very well.

22:58 noprompt: I guess you can buffer lines and output them with tags.

22:58 My idea was just replace *out* with something you control, and then handle outputting yourself with tags.

22:59 oinksoft: aw clojure doesn't have guards :(

22:59 noprompt: Raynes: so yeah: https://gist.github.com/noprompt/a29cf0da3684990e6373#file-dup-clj-L23

23:00 Raynes: You expect me to work with you when you link to gist?

23:00 I'm not a savage bro

23:00 noprompt: lol

23:00 Raynes: well video call you and share my screen.

23:00 Raynes: haha

23:01 Raynes: solving a problem over IRC is savagery.

23:01 Raynes: Video calls give me hives.

23:01 noprompt: so where did we get with all this?

23:01 no where.

23:01 haha

23:02 Raynes: So what isn't working about this?

23:03 noprompt: it's either a) tagging one line and then not tagging the rest or b) not tagging anything at all and showing no output.

23:04 Raynes: noprompt: You're right, we definitely needed a video call for that sentence. :P

23:04 clojurebot: Huh?

23:05 Raynes: clojurebot: shhhh

23:05 clojurebot: Cool story bro.

23:05 Raynes: Moving to PM

23:06 amalloy: ~guards

23:06 clojurebot: SEIZE HIM!

23:06 amalloy: ;; for oinksoft

23:06 bob2: oinksoft, as in for pattern matching?

23:30 oinksoft: amalloy, haha

23:30 bob2, yea

23:30 amalloy: oinksoft: i mean, clojure doesn't have pattern matching at all, so the fact that guards are missing isn't what would get me down

23:31 oinksoft: amalloy, i found this https://github.com/clojure/core.match

23:31 Raynes: $google core.match

23:31 lazybot: [clojure/core.match · GitHub] https://github.com/clojure/core.match

23:31 Raynes: DAMN IT

23:31 oinksoft: :p

23:31 * Raynes sulks away

23:32 amalloy: sure, but if you're willing to use core.match, that has guards

23:32 https://github.com/clojure/core.match/blob/master/src/main/clojure/clojure/core/match.clj#L1443-L1448

Logging service provided by n01se.net