#clojure log - Jun 30 2013

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

3:31 jro_: transient is Alpha? Does it mean, that it might wise idea not to use it?

3:53 warpy: dark_element: hi

3:53 dark_element: warpy hello

6:54 wei_: how do you do you specify java-only code in crossovers? I'm aware of CLJSBUILD-REMOVE

6:55 is that the standard way of doing so at the moment?

7:06 Blkt: morning everyone

8:10 edbond: how to add core.async to leiningen project?

8:39 another questions on async: how to remember when use one or two '!' ?

9:14 horofox_: hi, anybody using pedestal.io? how to I receive post params? I'm having a problem where even inspecting the whole request… i can't find it.

9:44 gideonite: horofox_: ((:form-params req) "foobar")

9:45 horofox_: gideonite: oh thanks!

9:45 gideonite: horofox_: pleasure, good luck

9:46 horofox_: gideonite: why doesn't pedestal.io see body parameters as query parameters?

9:47 gideonite: i need to create an interceptor to do it, right?

9:47 gideonite: horofox_: sorry, i don't know what do you mean by body parameter?

9:47 horofox_: gideonite: the parameters that I send and are located in the body of the request

9:48 gideonite: oh i see, because you are submitting a form and the form is in the body of the html so it should be contained in the body? yeah i think that forms are dealt with in a special way, not just by pedestal but more generally in http

9:50 horofox_: i'm used with rails and it considers everything as a parameter(the query string, the route string and body), i know this isn't the best design but it leaves a lot of complexities out of the way

9:51 gideonite: but anyways, thanks for the good help!

9:52 jtoy_: does anyone here use ring with sessions? am I supposed to pass back the session in the output for every request?

9:53 i seem to loose my session all the time

10:18 how would I do a while loop where I need to go through a cursor and collect data? I made this example btu i know its completely wrong: https://www.refheap.com/16213

10:31 shadow_prince: why after (use [ns.lib :as lib]) works both (lib/function) and (function)? how can I use two packages with same function names?

10:32 technomancy: shadow_prince: undocumented implementation quirk. you should avoid use.

10:32 matko: what? avoid use altogether?

10:32 technomancy: matko: well, in code. it's fine in the repl

10:34 matko: I'm using use a lot, though I do use it with an :only declaration.. Why is this bad?

10:35 technomancy: it's not that bad; it's just that :require/:refer is preferred in order to simplify usage of the ns macro

10:35 at some point in the far far future use could be removed

10:35 wink: o_O

10:36 matko: if I use :refer, I can use the function as if it is in my namespace?

10:36 technomancy: yeah, it's another way of expressing the same thing

10:37 matko: Heh, here I always thought it was to limit the functions you could refer to with the namespace prefix

10:37 Cool, guess I'll be using that from now on

10:39 technomancy: use is still needed for backwards-compatibility with 1.3 and older, and it's shorter to type in the repl

10:40 matko: It's still the only way to get a full namespace included, right?

10:40 well, apart from listing every single symbol I guess

10:40 technomancy: matko: you can do (:require [some.ns :refer :all])

10:40 matko: ah

10:40 technomancy: but it should be used sparingly

10:41 matko: the ns macro is so big..

10:41 technomancy: that's why getting rid of `use` is desirable =)

10:49 wink: I'm a little shocked I never even read about it being discouraged

10:50 http://clojure.org/cheatsheet -> http://clojuredocs.org/clojure_core/clojure.core/use (1.3)

10:50 that basically explains it

10:51 we need someone to keep up with docs it seems :(

11:18 horofox_: ExceptionInfo :transact/bad-data Value 100.0 is not a valid :double for attribute :creditcard/available_balance clojure.core/ex-info (core.clj:4327)

11:18 why????

11:18 100.0 isn't double?

11:20 hyPiRion: ,(class 100.0)

11:20 clojurebot: java.lang.Double

11:20 hyPiRion: ,(class (double 100.0))

11:20 clojurebot: java.lang.Double

11:20 horofox_: it is, right?

11:20 so why am i getting this error

11:20 ?

11:20 hyPiRion: double != Double though, that may be the issue

11:25 jtoy_: any ideas on how to do this?: how would I do a while loop where I need to go through a cursor and collect data? I made this example btu i know its completely wrong: https://www.refheap.com/16213

11:32 shadow_prince: (+ 1 2)

11:32 clojurebot: 3

11:32 shadow_prince: (conj [1 2] 3)

11:32 jtoy_: do i need to use some non functional method to do this?

11:32 Okasu: horofox_: You don't want to use double as type of balance or any other money related things.

12:31 shadow_prince: (+ 1 1)

12:31 clojurebot: 2

12:31 shadow_prince: (conj [1 2] 3)

12:31 (str "a" "b" "b")

12:33 bot have cooldown, or can't execute such functions?

12:34 plausibility: (str "a" "b" "c")

12:34 must not be able to do complex functions?

12:34 saati: (/ 1 0)

12:34 plausibility: heh

12:34 shadow_prince: (+ 1 2)

12:34 clojurebot: 3

12:35 plausibility: (+ 1 1 1 1)

12:35 clojurebot: 4

12:35 shadow_prince: (class 0.0)

12:35 plausibility: magic.

12:35 shadow_prince: (class 1.0)

12:46 edbond: ,(+ 1 2)

12:46 clojurebot: 3

12:46 edbond: ,(type :str)

12:46 clojurebot: clojure.lang.Keyword

12:46 plausibility: haked

12:46 edbond: `(+ 1 1)

12:47 ,(conj [1 2] 3)

12:47 clojurebot: [1 2 3]

12:47 edbond: ,(/ 1 0)

12:47 clojurebot: #<ArithmeticException java.lang.ArithmeticException: Divide by zero>

12:49 shadow_prince: ,(conj [1 2 3] 4)

12:49 clojurebot: [1 2 3 4]

12:49 plausibility: (rm -rf /)

12:49 clearlygoing to work.

12:50 shadow_prince: ,(use [clojure.java.shell :only [sh]])

12:50 clojurebot: #<CompilerException java.lang.ClassNotFoundException: clojure.java.shell, compiling:(NO_SOURCE_PATH:0:0)>

12:50 babilen: Can we help with anything?

13:18 bbloom: hmm not really sure how to deal with a variable number of channels in a higher order fasion… given all the multiplexing operations are macros...

13:18 oh dur

13:18 alts!

13:18 not a macro haha

13:24 noncom_: hi, this might be a little off-topic.. i'm looking into using emacs-live for coding some clojure projetcts. however, i am a new to emacs and the biggest question with emacs-live for me is how to get the project file tree tool?

13:35 jyeo: ,(+ 2 3 1)

13:35 clojurebot: 6

13:39 QSteven: core.logic: what's the difference between walk and -reify?

14:17 bbloom: as a learning exercise, i'm porting Rx to core.async… it's going extremely smoothly

14:33 xpe: I can't think of a better function than http://stackoverflow.com/questions/17393451/does-number-fall-in-interval-in-clojure -- am I overlooking some kind of range comparison operator?

14:35 in case you don't want to click: (defn in-interval? [a b] (fn [x] (and (>= x a) (<= x b))))

14:37 wow, got an amazingly simple answer! awesome.

14:40 ;(map #(<= 2 % 4) [1 2 3 4 5])

14:40 ,(map #(<= 2 % 4) [1 2 3 4 5])

14:40 clojurebot: (false true true true false)

15:03 wy: hey

15:04 Clojure newbie here

15:04 I'm trying to set up my Emacs using the instruction from http://clojure-doc.org/articles/tutorials/emacs.html, but got stuck at one point

15:05 Emacs says: package-install: Package `starter-kit' is not available for installation

15:07 doh… I guess I know what's wrong now. just installed the emacs from home-brew, and it works now...

15:07 seangrove: Might've been the system emacs, which is usually ~v22 or so I think

15:10 wy: seangrove: maybe.. emacs doesn't seem to work as nice under mac osx

15:11 seangrove: Really? Haven't had much of an issue here, but I've been using it for awhile of course

15:11 Only place I didn't much care for it was on windows machines, but I never did much with them

15:14 wy: seangrove: maybe I haven't got used to it. I found the white dots on the left hand side of the window ugly

15:15 seangrove: wy: we probably have pretty different setups, I'm not sure which white dots you mean ;)

15:15 podviaznikov: hey everyone. I'm also Clojure beginner and having trouble using my own library from clojars in another project...

15:15 wy: seangrove: hmm… I should check that. I just reused my set up under linux

15:16 podviaznikov: so I have this library(https://clojars.org/pygdown - which converts markdown to html with syntax highlighting using pygments). it works locally from repl. and tests work on travis

15:17 when I try to include this library into another project I'm getting CompilerException java.lang.ClassNotFoundException: pygdown.core...

15:18 I'm stuck finding the problem. Did I deploy library correctly to clojars? how even to check that? All my previous libraries were deployed successfuly

15:19 hyPiRion: podviaznikov: I'll have a look. It seems like the code is compiled, so there may be some issues there.

15:20 podviaznikov: hyPiRion: Thanks, Yes, I was using gen-class for the first time.

15:20 wy: I got an error "java.io.FileNotFoundException: Could not locate command_line_args/core__init.class or command_line_args/core.clj on classpath:" when I tried to use C-c C-k to compile the file, anybody knows why?

15:21 amalloy: the variable is called *command-line-args*

15:21 iirc

15:21 hyPiRion: wy: and it's not a class

15:22 ,*command-line-args*

15:22 clojurebot: nil

15:22 wy: hyPiRion: I just tried to follow the instructions from http://clojure-doc.org/articles/tutorials/emacs.html

15:23 hyPiRion: What should I change then?

15:24 hyPiRion: oh, you're trying out leiningen

15:25 wy: amalloy: Can you let me know more details about what's wrong with the variable?

15:26 command-line-args is the project's name

15:28 hyPiRion: podviaznikov: it works just fine here

15:28 I add in a line in the ns like this: (:require [pygdown.core :as py]), and then call py/to-html without any issues.

15:29 may I suggest that you clear your ~/.m2 directory? It may be that you're having some cached values in there.

15:30 amalloy: hyPiRion: more likely, he misnamed his file command-line-args/core.clj instead of command_line_args/core.clj

15:30 i can't think of any maven weirdness that would cause that

15:31 wy: amalloy: Is it supposed to be underscores?

15:31 amalloy: the page told me to use "lein new command-line-args"

15:31 hyPiRion: amalloy: if he's the author of the lib, he may have done lein install and not gotten the clojars version

15:32 amalloy: oh, i lost track of who you were replying to, hyPiRion

15:32 wy: amalloy: I have these things here: ./src/command_line_args/core.clj, ./test/command_line_args/core_test.clj

15:33 amalloy: Do I need to do something with the classpath of jam?

15:33 s/jam/jvm

15:34 podviaznikov: hyPiRion: thanks! cleaning ~/.m2 helped. I was trying lein clean lot of times but I didn't know about ~/.m2

15:34 amalloy: wy: then src isn't in your classpath. how are you launching your repl? you need to make sure that you M-x nrepl-jack-in from a buffer that's located inside the project somewhere

15:36 wy: amalloy: ah got it… that's what was wrong

15:36 amalloy: it now works. Thanks so much

15:37 amalloy: Can you tell me how to change the CWD of the repl btw?

15:37 amalloy: you can't; it's a jvm limitation

15:37 not after it's launched, anyway

15:38 wy: I see, not a big deal though

15:38 amalloy: i think `lein help sample` prints out a project.clj that includes all possible options, including, i think, a working-directory thing

15:56 akhudek: bbloom: ping

15:58 bbloom: akhudek: pong

15:59 akhudek: bbloom: I didn't see how the IZipper protocol was useful and tried removing it. Performance is unchanged. Is there a specific reason you suggested it?

16:00 bbloom: akhudek: you still have an IZipperLocation protocol, right?

16:00 akhudek: bbloom: no protocols at all https://github.com/akhudek/fast-zip/tree/no-protocol

16:01 bbloom: oh, even better

16:01 :-P

16:01 i guess you don't really need polymorphism at all

16:01 akhudek: ok, glad you agree. :-)

16:01 I also experimented with :inline stuff, but it made no difference

16:02 think most of the remaining cpu cost is in creating records constantly

16:02 bbloom: in theory there could be benefits to the protocol for the ability to have a single object to pass around

16:02 but in practice, i'm not sure that matters

16:02 akhudek: True, though the benchmarks don't show it.

16:03 Could also achieve the same thing with a second record type.

16:03 bbloom: looks good to me :-)

16:03 akhudek: ok, I'll make a final update and post it to the list

16:07 manutter51: dang, my Clojure repl suddenly quit working in Sublime Text

16:08 lein repl works fine, hmm

17:16 kmicu: tmux select-window -t :0

17:32 seangrove: Wow, getting unit + functional tests for our cljs app via cemerick.cljs.test, clojure.test, clj-webdriver, and Sauce Labs was a long and twisting path

17:33 Now the one big problem is that clojure.test doesn't seem to be able to run concurrent tests

17:35 bbloom: https://github.com/brandonbloom/asyncx/blob/master/src/asyncx/core.clj

17:36 seangrove: Are you suggesting to I string together core.async and the clojure.test api to run tests in parallel?

17:36 bbloom: no, i was totally ignoring you b/c i was so excited about my code :-)

17:36 seangrove: Haha, ok, because I was initially intrigued at the idea ;)

17:37 bbloom: dnolen_: you'll dig that ^^

17:42 seangrove: bbloom: Seems like a bunch of HOF implementations using the new channel stuff?

17:42 bbloom: seangrove: yup

17:42 i emailed the clojure list w/ some context

17:42 seangrove: Awesome, will check that out now

17:51 arohner: sigh. Joda Days have (.toStandardSeconds), but Years do not

18:24 podviaznikov: hi, everyone. I'm Clojure beginner. I created few very small Clojure libraries: https://github.com/hashobject/rsa-signer/, https://github.com/hashobject/sitemap/, https://github.com/hashobject/translate. Can somebody review my Clojure code and give me some advises? Also is it ok to have library in Clojure that has one method? Is it good practice?

18:26 Glenjamin: seangrove: late to the party, but i'd be weary of running tests concurrently in the same process

18:27 gfredericks: podviaznikov: if there's no reason to include anything else, a one-function lib is fine

18:27 Glenjamin: multi-process or even on a virtualised CI cluster is much less likely to collide

18:27 gfredericks: $google github system-slash-exit

18:27 lazybot: [fredericksgary/system-slash-exit · GitHub] https://github.com/fredericksgary/system-slash-exit

18:30 gfredericks: podviaznikov: https://github.com/hashobject/translate/blob/master/src/translate/google.clj#L10

18:30 you may as well (def empty-str "") and then remove the parens around line 10

18:31 podviaznikov: gfredericks: thanks! it was my almost very first clojure code. Now, I know about def. Will fix it

18:31 gfredericks: and line 20 there could be (-> resp :body :data :translations first :translatedText)

19:01 bbloom: does anybody else ever feel the need for when-let and if-let which only test for nil & not false?

19:05 seangrove: bbloom: Yeah

19:06 Less than I thought tough, on reflection

19:08 hyPiRion: well, you can just do (let [val expression] (if-not (nil? val) true-expr false-expr))

19:08 gfredericks: stuff would be simpler if we didn't have true and false

19:09 if we could reject the jvm we could just use :true and nil

19:09 hyPiRion: I mean, certainly, it is value in brevity, but I haven't felt people in general had a need for conditionals which just branch on nil.

19:10 /s/had/have/

19:10 gfredericks: that's what the some family is about though, no?

19:11 ,[(some-> false str) (some-> nil str)]

19:11 clojurebot: ["false" nil]

19:11 hyPiRion: gfredericks: keep, you mean?

19:11 bbloom: it comes up A LOT now w/ core async b/c you need to check for nil when channels are closed

19:11 but false is, in theory, a valid message

19:12 hyPiRion: ,(some #{false} [false])

19:12 clojurebot: nil

19:12 hyPiRion: funny how some-> and some->> differs from some.

19:12 gfredericks: I coulda sworn rich picked the name some-> specifically to match the truthiness semantics of some

19:12 now I have no idea what the name is about

19:13 YOU HAVE TURNED MY WORLD UPSIDE DOWN SIR

19:13 hyPiRion: gfredericks: I consider it a maybe-monad thingy.

19:35 gfredericks: let's redo core.logic with core.async. conde is just an alt!

19:40 bbloom: mmmm parallel logic.

19:46 wy: any idea why get and nth behave differently when the index is out of range and not-found is not supplied?

19:46 hyPiRion: wy: the documentation should be enough, I think

19:47 (doc nth)

19:47 clojurebot: "([coll index] [coll index not-found]); Returns the value at the index. get returns nil if index out of bounds, nth throws an exception unless not-found is supplied. nth also works for strings, Java arrays, regex Matchers and Lists, and, in O(n) time, for sequences."

19:47 hyPiRion: (doc get)

19:47 clojurebot: "([map key] [map key not-found]); Returns the value mapped to key, not-found or nil if key not present."

19:47 wy: hyPiRion: I know that. I was just trying to find a reason they are designed that way.

19:48 get returns nil, but nth throws exception, … why throws exception?

19:49 why not also returns nil?

19:51 seangrove: Is there a way to capture stdout in a function executed in a future, and get both the return value and the output?

19:53 hyPiRion: seangrove: (future (binding [*out* (java.io.StringWriter.)] [expression (str *out*)])) I suppose?

19:54 seangrove: hyPiRion: fair enough, that works, thanks

20:22 dnolen_: bbloom: Rx stuff in core.async nice

20:22 bbloom: dnolen_: thanks :-) i was just playing with it as a learning exercise, but it came out so nice, i had to share

20:23 i'm not sure how much time i should invest into it, considering i can only assume rich is exploring what's possible here

20:25 dnolen_: btw, the publish function is super cool! first time i used multiplexing on put (and i've done some socket work in the past, heh)

20:25 unfortunately, there is some complexities with the interaction between publish & other operators i haven't quite wrapped my head around

20:26 in particularly, trying to use publish and replay results in every other message being dropped from the published port, due to a race between reading and writing

20:26 i'm not really sure how to address "hot" sources

20:26 http://www.introtorx.com/Content/v1.0.10621.0/14_HotAndColdObservables.html#HotAndCold

20:27 dnolen_: bbloom: can work around this you do this with alts! + default?

20:27 "can you work around this"

20:27 bbloom: maybe at one level, but anytime you hook up a blocking reader, there is some delay

20:27 any delay means that a hot source can have missed messages

20:28 you need a buffer or a timeout or some backwards communication or something

20:28 dnolen_: yeah was thinking of a buffer solution ...

20:29 bbloom: it's sort of like an inherent debounce :-/;

20:29 publish works just fine if you don't mind losing messages

20:30 the problem is only really obvious with zero-latency sources, like range

20:30 dnolen_: yeah I'm wondering if the problem is simply inherent

20:30 bbloom: i think it might be

20:30 dnolen_: you don't want to miss messages from hot source - but that seems unrealistic

20:30 bbloom: inherently, hot sources push shit at you whether you are ready or not

20:30 dnolen_: yeah

20:31 bbloom: the problem is, that even if you're ready, there is some inherent latency in the machinery, since the order of goroutine execution is non-deterministic

20:31 so you *need* a buffer of some kind

20:39 dnolen_: bbloom: I'm not convinced anything Rx related will land in core.async, I think the idea is simple to make it flexible enough

20:39 bbloom: dnolen_: i'd got to imagine that they have to provide a map function, lol

20:40 entertainingly, variadic map was the trickest function to write haha

20:42 * dnolen_ really wants to fix alts! in CLJS version

20:42 bbloom: haha

20:44 while somebody who understands this stuff is in IRC…. dnolen_ what do you think about closing behavior for this rx style stuff? should closing propegate close all the way up the chain?

20:44 i already use bi-directional communication for closing subscribers w/ the event helper

20:47 dnolen_: bbloom: what happens if you don't propagate?

20:47 bbloom: dnolen_: i don't propegate now… the garbage collector does it's thing

20:47 the issue is if you have some IDisposable type source

20:48 in which case, you have to hold on to a channel for closing that thing

20:48 hold on, i'm adding an events example so you'll understand

20:54 akhudek: = vs identical? --- how did i miss that?! killer.

20:54 that's much faster now. super cool

20:54 Raynes: callen: https://vine.co/v/haHEJWdQrxg How can one not like Panic! At The Disco when Brendon Urie consistently puts out stuff like this?

20:55 akhudek: bbloom: 3.9x! Though that benchmark only tests next, node and end. I should add some for testing replacements/additions too.

21:06 bbloom: dnolen_: https://github.com/brandonbloom/asyncx/blob/master/src/asyncx/core.clj#L327-L333

21:06 that's an IDisposable style case

21:07 doesn't work right now tho, i need to multiplex on the returned channel & allow that to be closed

21:10 Licenser: am I confused about binding or is it a bit odd in clojurescript? Having a binding outside of a callback function does not cause the binding to exist witin the callback it seems

21:11 bbloom: Licenser: unfortunately, clojurescript does not have bound-fn

21:11 (doc bound-fn)

21:11 clojurebot: "([& fntail]); Returns a function defined by the given fntail, which will install the same bindings in effect as in the thread at the time bound-fn was called. This may be used to define a helper function which runs on a different thread, but needs the same bindings in place."

21:12 Licenser: ah okay makes sense so I'm out of luck for that :) was kind of hoping it would work out of the box :P

21:23 bbloom: hmm actually, i can't figure out how to let a close send a message propegated back up the other direction

21:23 b/c you can't really "peek" at a channel

21:24 dnolen_: bbloom: not sure I follow your code, but I don't know if I have the context to

21:24 bbloom: the events function is borked

21:24 :-P

21:26 oh dur i need to do a alt-ed put…. hmm

21:40 dnolen_: oh double dur. apparently go's type system disallows close on read-only channels. i guess that means it's a bad idea to use close as a way to communicate back to the publisher… especially b/c closing doesn't dispatch multiplexed puts

21:40 need to use a separate control channel

22:04 min|dvir|us: Is clojure pure?

22:06 dnolen_: min|dvir|us: no

22:06 but it's probably the only widely used language besides Haskell which emphasizes value oriented programming which more important anyway

22:22 gfredericks: ~value

22:22 clojurebot: Excuse me?

22:22 bbloom: gfredericks: maybe you need an s?

22:22 ~values

22:22 clojurebot: Cool story bro.

22:22 bbloom: clojurebot: fuck you

22:22 clojurebot: No entiendo

22:23 gfredericks: (deftype Value [^:mutable-volatile x])

22:23 bbloom: that's a Box :-)

22:24 gfredericks: apparently it's :volatile-mutable anyhow; shows how much I use it.

22:25 bbloom: eh, i still can't remember the argument order to reduce & i use that constantly

22:27 gfredericks: ha

22:27 * gfredericks tries to remember what he can't remember

22:27 gfredericks: the arg order for re-{matches,find} always throws me off

22:29 bbloom: oh yeah

22:29 re- is weird, so then i assume it's like how weird is weird with the letters swapped, but then i weird myself out and type wierd

22:29 jcolechanged: I've been having a lot of trouble getting SublimeText to play nice with Clojure. Has anyone gotten it to work recently?

22:32 dnolen_: bbloom: hmm strange

22:33 so alts! allows select as reading *and* writing in the argument?

22:33 bbloom: dnolen_: yes

22:34 dnolen_: interesting

22:34 bbloom: check out how publish uses that

22:34 & re-read the doc string about 8 times before you do :-P

22:34 lazybot: java.lang.RuntimeException: Unable to resolve symbol: re-read in this context

22:35 dnolen_: bbloom: not I mean (alts! [[c v] c' c''])

22:35 one attempted write, two attempted rads

22:35 read

22:35 bbloom: dnolen_: oh all at the same time? yeah you can do that too, i think

22:35 you get back [x p] where x is nil for writes

22:36 x is also nil if you were waiting on a read

22:36 … and the channel was closed

23:11 pcarrier: hey

23:18 lynaghk: ping: bbloom

Logging service provided by n01se.net