#clojure logs

2013-06-30

03:31jro_transient is Alpha? Does it mean, that it might wise idea not to use it?
03:53warpydark_element: hi
03:53dark_elementwarpy hello
06:54wei_how do you do you specify java-only code in crossovers? I'm aware of CLJSBUILD-REMOVE
06:55wei_is that the standard way of doing so at the moment?
07:06Blktmorning everyone
08:10edbondhow to add core.async to leiningen project?
08:39edbondanother questions on async: how to remember when use one or two '!' ?
09:14horofox_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.
09:44gideonitehorofox_: ((:form-params req) "foobar")
09:45horofox_gideonite: oh thanks!
09:45gideonitehorofox_: pleasure, good luck
09:46horofox_gideonite: why doesn't pedestal.io see body parameters as query parameters?
09:47horofox_gideonite: i need to create an interceptor to do it, right?
09:47gideonitehorofox_: sorry, i don't know what do you mean by body parameter?
09:47horofox_gideonite: the parameters that I send and are located in the body of the request
09:48gideoniteoh 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
09:50horofox_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
09:51horofox_gideonite: but anyways, thanks for the good help!
09:52jtoy_does anyone here use ring with sessions? am I supposed to pass back the session in the output for every request?
09:53jtoy_i seem to loose my session all the time
10:18jtoy_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:31shadow_princewhy after (use [ns.lib :as lib]) works both (lib/function) and (function)? how can I use two packages with same function names?
10:32technomancyshadow_prince: undocumented implementation quirk. you should avoid use.
10:32matkowhat? avoid use altogether?
10:32technomancymatko: well, in code. it's fine in the repl
10:34matkoI'm using use a lot, though I do use it with an :only declaration.. Why is this bad?
10:35technomancyit's not that bad; it's just that :require/:refer is preferred in order to simplify usage of the ns macro
10:35technomancyat some point in the far far future use could be removed
10:35winko_O
10:36matkoif I use :refer, I can use the function as if it is in my namespace?
10:36technomancyyeah, it's another way of expressing the same thing
10:37matkoHeh, here I always thought it was to limit the functions you could refer to with the namespace prefix
10:37matkoCool, guess I'll be using that from now on
10:39technomancyuse is still needed for backwards-compatibility with 1.3 and older, and it's shorter to type in the repl
10:40matkoIt's still the only way to get a full namespace included, right?
10:40matkowell, apart from listing every single symbol I guess
10:40technomancymatko: you can do (:require [some.ns :refer :all])
10:40matkoah
10:40technomancybut it should be used sparingly
10:41matkothe ns macro is so big..
10:41technomancythat's why getting rid of `use` is desirable =)
10:49winkI'm a little shocked I never even read about it being discouraged
10:50winkhttp://clojure.org/cheatsheet -> http://clojuredocs.org/clojure_core/clojure.core/use (1.3)
10:50winkthat basically explains it
10:51winkwe need someone to keep up with docs it seems :(
11:18horofox_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:18horofox_why????
11:18horofox_100.0 isn't double?
11:20hyPiRion,(class 100.0)
11:20clojurebotjava.lang.Double
11:20hyPiRion,(class (double 100.0))
11:20clojurebotjava.lang.Double
11:20horofox_it is, right?
11:20horofox_so why am i getting this error
11:20horofox_?
11:20hyPiRiondouble != Double though, that may be the issue
11:25jtoy_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:32shadow_prince(+ 1 2)
11:32clojurebot3
11:32shadow_prince(conj [1 2] 3)
11:32jtoy_do i need to use some non functional method to do this?
11:32Okasuhorofox_: You don't want to use double as type of balance or any other money related things.
12:31shadow_prince(+ 1 1)
12:31clojurebot2
12:31shadow_prince(conj [1 2] 3)
12:31shadow_prince(str "a" "b" "b")
12:33shadow_princebot have cooldown, or can't execute such functions?
12:34plausibility(str "a" "b" "c")
12:34plausibilitymust not be able to do complex functions?
12:34saati(/ 1 0)
12:34plausibilityheh
12:34shadow_prince(+ 1 2)
12:34clojurebot3
12:35plausibility(+ 1 1 1 1)
12:35clojurebot4
12:35shadow_prince(class 0.0)
12:35plausibilitymagic.
12:35shadow_prince(class 1.0)
12:46edbond,(+ 1 2)
12:46clojurebot3
12:46edbond,(type :str)
12:46clojurebotclojure.lang.Keyword
12:46plausibilityhaked
12:46edbond`(+ 1 1)
12:47edbond,(conj [1 2] 3)
12:47clojurebot[1 2 3]
12:47edbond,(/ 1 0)
12:47clojurebot#<ArithmeticException java.lang.ArithmeticException: Divide by zero>
12:49shadow_prince,(conj [1 2 3] 4)
12:49clojurebot[1 2 3 4]
12:49plausibility(rm -rf /)
12:49plausibilityclearlygoing to work.
12:50shadow_prince,(use [clojure.java.shell :only [sh]])
12:50clojurebot#<CompilerException java.lang.ClassNotFoundException: clojure.java.shell, compiling:(NO_SOURCE_PATH:0:0)>
12:50babilenCan we help with anything?
13:18bbloomhmm 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:18bbloomoh dur
13:18bbloomalts!
13:18bbloomnot a macro haha
13:24noncom_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:35jyeo,(+ 2 3 1)
13:35clojurebot6
13:39QStevencore.logic: what's the difference between walk and -reify?
14:17bbloomas a learning exercise, i'm porting Rx to core.async… it's going extremely smoothly
14:33xpeI 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:35xpein case you don't want to click: (defn in-interval? [a b] (fn [x] (and (>= x a) (<= x b))))
14:37xpewow, got an amazingly simple answer! awesome.
14:40xpe;(map #(<= 2 % 4) [1 2 3 4 5])
14:40xpe,(map #(<= 2 % 4) [1 2 3 4 5])
14:40clojurebot(false true true true false)
15:03wyhey
15:04wyClojure newbie here
15:04wyI'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:05wyEmacs says: package-install: Package `starter-kit' is not available for installation
15:07wydoh… I guess I know what's wrong now. just installed the emacs from home-brew, and it works now...
15:07seangroveMight've been the system emacs, which is usually ~v22 or so I think
15:10wyseangrove: maybe.. emacs doesn't seem to work as nice under mac osx
15:11seangroveReally? Haven't had much of an issue here, but I've been using it for awhile of course
15:11seangroveOnly place I didn't much care for it was on windows machines, but I never did much with them
15:14wyseangrove: maybe I haven't got used to it. I found the white dots on the left hand side of the window ugly
15:15seangrovewy: we probably have pretty different setups, I'm not sure which white dots you mean ;)
15:15podviaznikovhey everyone. I'm also Clojure beginner and having trouble using my own library from clojars in another project...
15:15wyseangrove: hmm… I should check that. I just reused my set up under linux
15:16podviaznikovso 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:17podviaznikovwhen I try to include this library into another project I'm getting CompilerException java.lang.ClassNotFoundException: pygdown.core...
15:18podviaznikovI'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:19hyPiRionpodviaznikov: I'll have a look. It seems like the code is compiled, so there may be some issues there.
15:20podviaznikovhyPiRion: Thanks, Yes, I was using gen-class for the first time.
15:20wyI 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:21amalloythe variable is called *command-line-args*
15:21amalloyiirc
15:21hyPiRionwy: and it's not a class
15:22hyPiRion,*command-line-args*
15:22clojurebotnil
15:22wyhyPiRion: I just tried to follow the instructions from http://clojure-doc.org/articles/tutorials/emacs.html
15:23wyhyPiRion: What should I change then?
15:24hyPiRionoh, you're trying out leiningen
15:25wyamalloy: Can you let me know more details about what's wrong with the variable?
15:26wycommand-line-args is the project's name
15:28hyPiRionpodviaznikov: it works just fine here
15:28hyPiRionI add in a line in the ns like this: (:require [pygdown.core :as py]), and then call py/to-html without any issues.
15:29hyPiRionmay I suggest that you clear your ~/.m2 directory? It may be that you're having some cached values in there.
15:30amalloyhyPiRion: more likely, he misnamed his file command-line-args/core.clj instead of command_line_args/core.clj
15:30amalloyi can't think of any maven weirdness that would cause that
15:31wyamalloy: Is it supposed to be underscores?
15:31wyamalloy: the page told me to use "lein new command-line-args"
15:31hyPiRionamalloy: if he's the author of the lib, he may have done lein install and not gotten the clojars version
15:32amalloyoh, i lost track of who you were replying to, hyPiRion
15:32wyamalloy: I have these things here: ./src/command_line_args/core.clj, ./test/command_line_args/core_test.clj
15:33wyamalloy: Do I need to do something with the classpath of jam?
15:33wys/jam/jvm
15:34podviaznikovhyPiRion: thanks! cleaning ~/.m2 helped. I was trying lein clean lot of times but I didn't know about ~/.m2
15:34amalloywy: 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:36wyamalloy: ah got it… that's what was wrong
15:36wyamalloy: it now works. Thanks so much
15:37wyamalloy: Can you tell me how to change the CWD of the repl btw?
15:37amalloyyou can't; it's a jvm limitation
15:37amalloynot after it's launched, anyway
15:38wyI see, not a big deal though
15:38amalloyi think `lein help sample` prints out a project.clj that includes all possible options, including, i think, a working-directory thing
15:56akhudekbbloom: ping
15:58bbloomakhudek: pong
15:59akhudekbbloom: 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:00bbloomakhudek: you still have an IZipperLocation protocol, right?
16:00akhudekbbloom: no protocols at all https://github.com/akhudek/fast-zip/tree/no-protocol
16:01bbloomoh, even better
16:01bbloom:-P
16:01bbloomi guess you don't really need polymorphism at all
16:01akhudekok, glad you agree. :-)
16:01akhudekI also experimented with :inline stuff, but it made no difference
16:02akhudekthink most of the remaining cpu cost is in creating records constantly
16:02bbloomin theory there could be benefits to the protocol for the ability to have a single object to pass around
16:02bbloombut in practice, i'm not sure that matters
16:02akhudekTrue, though the benchmarks don't show it.
16:03akhudekCould also achieve the same thing with a second record type.
16:03bbloomlooks good to me :-)
16:03akhudekok, I'll make a final update and post it to the list
16:07manutter51dang, my Clojure repl suddenly quit working in Sublime Text
16:08manutter51lein repl works fine, hmm
17:16kmicutmux select-window -t :0
17:32seangroveWow, 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:33seangroveNow the one big problem is that clojure.test doesn't seem to be able to run concurrent tests
17:35bbloomhttps://github.com/brandonbloom/asyncx/blob/master/src/asyncx/core.clj
17:36seangroveAre you suggesting to I string together core.async and the clojure.test api to run tests in parallel?
17:36bbloomno, i was totally ignoring you b/c i was so excited about my code :-)
17:36seangroveHaha, ok, because I was initially intrigued at the idea ;)
17:37bbloomdnolen_: you'll dig that ^^
17:42seangrovebbloom: Seems like a bunch of HOF implementations using the new channel stuff?
17:42bbloomseangrove: yup
17:42bbloomi emailed the clojure list w/ some context
17:42seangroveAwesome, will check that out now
17:51arohnersigh. Joda Days have (.toStandardSeconds), but Years do not
18:24podviaznikovhi, 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:26Glenjaminseangrove: late to the party, but i'd be weary of running tests concurrently in the same process
18:27gfrederickspodviaznikov: if there's no reason to include anything else, a one-function lib is fine
18:27Glenjaminmulti-process or even on a virtualised CI cluster is much less likely to collide
18:27gfredericks$google github system-slash-exit
18:27lazybot[fredericksgary/system-slash-exit · GitHub] https://github.com/fredericksgary/system-slash-exit
18:30gfrederickspodviaznikov: https://github.com/hashobject/translate/blob/master/src/translate/google.clj#L10
18:30gfredericksyou may as well (def empty-str "") and then remove the parens around line 10
18:31podviaznikovgfredericks: thanks! it was my almost very first clojure code. Now, I know about def. Will fix it
18:31gfredericksand line 20 there could be (-> resp :body :data :translations first :translatedText)
19:01bbloomdoes anybody else ever feel the need for when-let and if-let which only test for nil & not false?
19:05seangrovebbloom: Yeah
19:06seangroveLess than I thought tough, on reflection
19:08hyPiRionwell, you can just do (let [val expression] (if-not (nil? val) true-expr false-expr))
19:08gfredericksstuff would be simpler if we didn't have true and false
19:09gfredericksif we could reject the jvm we could just use :true and nil
19:09hyPiRionI 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:10hyPiRion/s/had/have/
19:10gfredericksthat's what the some family is about though, no?
19:11gfredericks,[(some-> false str) (some-> nil str)]
19:11clojurebot["false" nil]
19:11hyPiRiongfredericks: keep, you mean?
19:11bbloomit comes up A LOT now w/ core async b/c you need to check for nil when channels are closed
19:11bbloombut false is, in theory, a valid message
19:12hyPiRion,(some #{false} [false])
19:12clojurebotnil
19:12hyPiRionfunny how some-> and some->> differs from some.
19:12gfredericksI coulda sworn rich picked the name some-> specifically to match the truthiness semantics of some
19:12gfredericksnow I have no idea what the name is about
19:13gfredericksYOU HAVE TURNED MY WORLD UPSIDE DOWN SIR
19:13hyPiRiongfredericks: I consider it a maybe-monad thingy.
19:35gfrederickslet's redo core.logic with core.async. conde is just an alt!
19:40bbloommmmm parallel logic.
19:46wyany idea why get and nth behave differently when the index is out of range and not-found is not supplied?
19:46hyPiRionwy: the documentation should be enough, I think
19:47hyPiRion(doc nth)
19:47clojurebot"([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:47hyPiRion(doc get)
19:47clojurebot"([map key] [map key not-found]); Returns the value mapped to key, not-found or nil if key not present."
19:47wyhyPiRion: I know that. I was just trying to find a reason they are designed that way.
19:48wyget returns nil, but nth throws exception, … why throws exception?
19:49wywhy not also returns nil?
19:51seangroveIs there a way to capture stdout in a function executed in a future, and get both the return value and the output?
19:53hyPiRionseangrove: (future (binding [*out* (java.io.StringWriter.)] [expression (str *out*)])) I suppose?
19:54seangrovehyPiRion: fair enough, that works, thanks
20:22dnolen_bbloom: Rx stuff in core.async nice
20:22bbloomdnolen_: thanks :-) i was just playing with it as a learning exercise, but it came out so nice, i had to share
20:23bbloomi'm not sure how much time i should invest into it, considering i can only assume rich is exploring what's possible here
20:25bbloomdnolen_: 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:25bbloomunfortunately, there is some complexities with the interaction between publish & other operators i haven't quite wrapped my head around
20:26bbloomin 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:26bbloomi'm not really sure how to address "hot" sources
20:26bbloomhttp://www.introtorx.com/Content/v1.0.10621.0/14_HotAndColdObservables.html#HotAndCold
20:27dnolen_bbloom: can work around this you do this with alts! + default?
20:27dnolen_"can you work around this"
20:27bbloommaybe at one level, but anytime you hook up a blocking reader, there is some delay
20:27bbloomany delay means that a hot source can have missed messages
20:28bbloomyou need a buffer or a timeout or some backwards communication or something
20:28dnolen_yeah was thinking of a buffer solution ...
20:29bbloomit's sort of like an inherent debounce :-/;
20:29bbloompublish works just fine if you don't mind losing messages
20:30bbloomthe problem is only really obvious with zero-latency sources, like range
20:30dnolen_yeah I'm wondering if the problem is simply inherent
20:30bbloomi think it might be
20:30dnolen_you don't want to miss messages from hot source - but that seems unrealistic
20:30bbloominherently, hot sources push shit at you whether you are ready or not
20:30dnolen_yeah
20:31bbloomthe 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:31bbloomso you *need* a buffer of some kind
20:39dnolen_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:39bbloomdnolen_: i'd got to imagine that they have to provide a map function, lol
20:40bbloomentertainingly, variadic map was the trickest function to write haha
20:42bbloomhaha
20:44bbloomwhile 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:44bbloomi already use bi-directional communication for closing subscribers w/ the event helper
20:47dnolen_bbloom: what happens if you don't propagate?
20:47bbloomdnolen_: i don't propegate now… the garbage collector does it's thing
20:47bbloomthe issue is if you have some IDisposable type source
20:48bbloomin which case, you have to hold on to a channel for closing that thing
20:48bbloomhold on, i'm adding an events example so you'll understand
20:54bbloomakhudek: = vs identical? --- how did i miss that?! killer.
20:54bbloomthat's much faster now. super cool
20:54Raynescallen: https://vine.co/v/haHEJWdQrxg How can one not like Panic! At The Disco when Brendon Urie consistently puts out stuff like this?
20:55akhudekbbloom: 3.9x! Though that benchmark only tests next, node and end. I should add some for testing replacements/additions too.
21:06bbloomdnolen_: https://github.com/brandonbloom/asyncx/blob/master/src/asyncx/core.clj#L327-L333
21:06bbloomthat's an IDisposable style case
21:07bbloomdoesn't work right now tho, i need to multiplex on the returned channel & allow that to be closed
21:10Licenseram 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:11bbloomLicenser: unfortunately, clojurescript does not have bound-fn
21:11bbloom(doc bound-fn)
21:11clojurebot"([& 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:12Licenserah okay makes sense so I'm out of luck for that :) was kind of hoping it would work out of the box :P
21:23bbloomhmm actually, i can't figure out how to let a close send a message propegated back up the other direction
21:23bbloomb/c you can't really "peek" at a channel
21:24dnolen_bbloom: not sure I follow your code, but I don't know if I have the context to
21:24bbloomthe events function is borked
21:24bbloom:-P
21:26bbloomoh dur i need to do a alt-ed put…. hmm
21:40bbloomdnolen_: 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:40bbloomneed to use a separate control channel
22:04min|dvir|usIs clojure pure?
22:06dnolen_min|dvir|us: no
22:06dnolen_but it's probably the only widely used language besides Haskell which emphasizes value oriented programming which more important anyway
22:22gfredericks~value
22:22clojurebotExcuse me?
22:22bbloomgfredericks: maybe you need an s?
22:22bbloom~values
22:22clojurebotCool story bro.
22:22bbloomclojurebot: fuck you
22:22clojurebotNo entiendo
22:23gfredericks(deftype Value [^:mutable-volatile x])
22:23bbloomthat's a Box :-)
22:24gfredericksapparently it's :volatile-mutable anyhow; shows how much I use it.
22:25bbloomeh, i still can't remember the argument order to reduce & i use that constantly
22:27gfredericksha
22:27gfredericksthe arg order for re-{matches,find} always throws me off
22:29bbloomoh yeah
22:29bbloomre- 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:29jcolechangedI've been having a lot of trouble getting SublimeText to play nice with Clojure. Has anyone gotten it to work recently?
22:32dnolen_bbloom: hmm strange
22:33dnolen_so alts! allows select as reading *and* writing in the argument?
22:33bbloomdnolen_: yes
22:34dnolen_interesting
22:34bbloomcheck out how publish uses that
22:34bbloom& re-read the doc string about 8 times before you do :-P
22:34lazybotjava.lang.RuntimeException: Unable to resolve symbol: re-read in this context
22:35dnolen_bbloom: not I mean (alts! [[c v] c' c''])
22:35dnolen_one attempted write, two attempted rads
22:35dnolen_read
22:35bbloomdnolen_: oh all at the same time? yeah you can do that too, i think
22:35bbloomyou get back [x p] where x is nil for writes
22:36bbloomx is also nil if you were waiting on a read
22:36bbloom… and the channel was closed
23:11pcarrierhey
23:18lynaghkping: bbloom