#clojure logs

2013-03-07

00:15devnRaynes: you got it babe.
00:25devnyogthos: howdy
01:18michaelr5251I love Thursdays :)
01:20jeremyheilerWhy is that?
01:21michaelr5251Because it's the last work day of the week (here in Israel)
01:21jeremyheilerahihi, that would make Thursday's better.
01:21jeremyheilerAh**
01:28kencauseymichaelr5251: Do you start again on Sunday or Monday?
01:29michaelr5251Sunday
01:29kencauseyOK, nice to learn new things about distant societies. Thanks!
01:30michaelr5251haha
04:08ciphergothIt seems weird that if I want a task to happen in a separate thread, I can just give it to an agent, but if the agent wants to try again in one second, I'm going to have to start worrying about Java thread pools. Am I looking at this wrongly?
04:09mpenetagents are about shared acces to some state, if doesn't really make sense to use it just to run a task in a separate thread, futures could be better for that
04:11ciphergothagents are appealing because I can send a message to an agent saying "here, add this to the list of things you ask about when you poll"
04:11mpenetbut anyway, they are backed by a cachedthreadpool so in theory you shouldn't have to worry about that
04:12ciphergothOK
04:12mpenetand if you (really) need to take control of the underlying pool you can do it with send-via, if you are running 1.5
04:14ciphergothI don't think I do need or want to take control of the underlying pool - that's what I was hoping to avoid!
04:14ciphergothYou say "Supports :at-fixed-rate :with-fixed-delay :once, matching the corresponding Java methods." - I can't find what corresponds to :once, though I can guess what it means
04:14ciphergothit sounds like I can just use your library, and schedule the next poll with (schedule :once :with-fixed-delay 1000 #(send ...))
04:16mpenetthis matches http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ScheduledExecutorService.html
04:16mpenetand you cannot combine :once :with-fixed-delay
04:17ciphergoth"once" doesn't appear on that page
04:17ciphergothOK
04:18ciphergothdoes "once" take a time to wait before executing?
04:19mpenetyes, you can pass :initial-delay, there's an example in the readme
04:19ciphergothah!
04:20ciphergotham looking at the source now, I see it
04:20ciphergoththank you!
04:20mpenetnp
04:24mpenettechnomancy: since clojurescript-mode is deprecated, would it make sense to add cljs extension to auto-mode-alist on clojure-mode?
04:41FoxboronBasic question. I got a vec, i want a function to be used on all the items in the vec. I have tried for and map, but still dosnt work.
04:45mpenet,(map inc [1 2 3])
04:45clojurebot(2 3 4)
04:45mpenet,(mapv inc [1 2 3])
04:45clojurebot[2 3 4]
04:46mpenetFoxboron: maybe you are being tricked by lazyness
04:48Foxboronhmm
04:49Foxboronmpenet: well basically, i got this IRC bot i want to join several chans. So i got a vec of chans.
04:49FoxboronIt dosnt even seem to execute the function itself.
04:49mpenetyou are using map for side effect in other words
04:50mpeneteither you wrap it with doall, or better use doseq
04:50Foxboronahh doseq.
04:50Foxboronawsome, thanks :)
04:52Foxboronmpenet: awsome, it works :D
04:58mpfundsteinwhats the newest clojure.contrib version?
04:59vijaykiranmpfundstein: there's no clojure.contrib anymore - http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
05:00mpfundsteinah ok
05:01mpfundsteinso command-line-arguments is now included in clojure?
05:01mpenetit's in tools.cli now
05:26corecodehi
05:26corecodei'm working through the 4clojure excercises
05:26corecodeand i wonder how to implement an efficient fib sequence
05:27corecodethat whole recursive call thing is compact but also has a terrible complexity
05:28corecodeideally i'd like to use lazy-cons, but i don't know exactly how to
05:31lekucorecode: good questiosn I think, maybne just bad timing
05:31lekuit is 4:32 AM here in the US of A
05:32corecodeno european cljers?
05:32noidicorecode, do you want the answer or just a hint? :)
05:32corecodeso my hunch is that i have to carry along the 2 last fib numbers
05:33corecodeso that i can grow the sequence
05:33noidiyes
05:33corecodeaha
05:33corecodesee i watched an outdated talk
05:33corecodewhere rest still returned nil, and lazy-cons existed
05:33noidiand the sequence is infinite, so it has to be lazy. hence, wrap it in (lazy-seq ...)
05:33noidiand prepend to it using cons
05:52corecodehm
05:52corecode(take 4 (fn fib [] (cons 1 (cons 1 (lazy-seq (map + (fib) (rest (fib))))))))
05:52corecodethis doesn't work
05:53Foxboroncorecode: loop & recur?
05:54corecodei'll try that
05:55noidino, recur is strict
05:55corecodenoidi: you mean loop is?
05:55noidiyou can use recur without loop :)
05:55corecodeyes
05:55corecodei saw the definition of filter
05:56noidicorecode, write a (defn fibs [a b] (lazy-seq ...)) that returns a lazy sequence of all the fibonacci numbers starting with a and b
05:57noidihmm, it's hard to give hints without giving the full solution :)
06:00noidinote that in order to be lazy, you must only prepend one concrete result to a lazy sequence that contains the rest of the items
06:00corecoderight
06:00corecodei get an obscure error message
06:00noidiwelcome to clojure :P
06:00corecodeIllegalArgumentException Don't know how to create ISeq from: java.lang.Long clojure.lang.RT.seqFrom (RT.java:505)
06:01noidiI'd guess you're trying to cons to a number
06:01noidi,(cons 1 2)
06:01clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
06:02corecodeaha!
06:02corecodeforgot my actual call
06:02corecodevery nice
06:03corecode(take 10 ((fn fib ([] (cons 1 (fib 0 1))) ([a b] (cons (+ a b) (lazy-seq (fib b (+ a b))))))))
06:03corecodeyey
06:04noidigreat :)
06:05Foxboroni always struggle with Fib :c. IRC Bot sockets etc? No problem. Pritning 1 1 2 3 5 etc....nope
06:06noidihere's what I came up with initially
06:06noidi(defn fibs ([] (fibs 0 1)) ([a b] (lazy-seq (cons a (fibs b (+ a b))))))
06:07Ember-sniff... beautiful
06:07corecodeaha
06:07Ember-:)
06:07corecodeyes
06:07corecodebetter
06:18corecodehuh? why is
06:19corecode,(reduce #'and '(false false))
06:19clojurebottrue
06:19corecodeoO
06:23edoloughlinAnyone using clojure.data.xml? Should this be possible?
06:23edoloughlinreply.eval-modes.nrepl=> (use 'clojure.data.xml)
06:23edoloughlinnil
06:23edoloughlinuser=> (emit-str (element :something {} false))
06:23edoloughlinIllegalArgumentException No implementation of method: :gen-event of protocol: #'clojure.data.xml/EventGeneration found for class: java.lang.Boolean clojure.core/-cache-protocol-fn (core_deftype.clj:541)
06:44noidicorecode, with #' you're getting hold of the function that implements the macro. the fact that macros are implemented as functions is an implementation detail which you shouldn't rely on
06:45corecodethat's no good
06:45corecodethat means i need to know what is a macro and what is a function
06:46noidithe macro functions take two arguments before the "real" macro arguments, so the result you're getting is the macroexpansion for `and` called without arguments
06:46noidi,(macroexpand-1 '(and))
06:46clojurebottrue
06:46noidiyes, you need to know the difference, but Clojure helps you there
06:46noidi,and
06:46clojurebot#<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/and, compiling:(NO_SOURCE_PATH:0:0)>
06:47noidiyou've gone around that check by using #' to get hold of the var holding the macro function
06:47noidibut you'd get that error if you tried to call (reduce and ...)
06:48noidithe proper way to write that reduce would be (reduce #(and %1 %2) ...)
06:58tsdhHow do you natives say to (map f coll)? f is mapped through the elements of coll?
07:00ciphergoth(zipmap (vals map) (keys map))
07:03noiditsdh, I'm not a native English speaker, but I think "f is mapped over ..." is a valid way to put it
07:04noidigoogle seems to agree :) https://www.google.fi/search?q=functional+programming+&quot;is+mapped+over&quot;
07:04tsdhnoidi: Ok, thanks.
07:06tsdhnoidi: Ah, it seems one says "f is mapped over coll", or "coll is mapped through f".
07:12AWizzArdIs there a better way to consume a PushbackReader stream of Clojure objects? (take-while identity (repeatedly #(read pbr false false)))
08:01ciphergothI'm pretty sure this line is being executed, but trigger-poll isn't being called: (knit/schedule :once :initial-delay 2 trigger-poll)
08:01ciphergotham I missing some kind of setup that makes this work?
08:13tomojshould there be (defmacro as->> [name & forms+expr]) ?
08:14ciphergothIs there a better way to do (apply dissoc map keylist)
08:21Kowboycemerick, does CCW have support for ctrl+click navigation to function definitions?
08:21cemerickKowboy: yup
08:21cemerickcmd + click on OS X FWIW
08:21Kowboycan you think of a reason it wouldn't be working?
08:22cemerickKowboy: do you have a REPL open for the project in question, with your code loaded therein?
08:22Kowboyat the moment, no
08:22cemerickDo so, and you'll have code completion, go-to-definition, etc
08:23Kowboyinteresting
08:23Kowboyso, the project I am working on loads some namespaces at runtime
08:24Kowboybased on configuration
08:24Kowboyso I don't get go-to-def functionality on those
08:24Kowboyunless I load them in the repl
08:25mrb_bkgood morning #clojure
08:26cemerickKowboy: right; introspection only ever works if you have a running environment
08:32Kowboyis there documentation on the supported features of CCW's paredit mode?
08:33dan_bargh classpath. or jni search path, if that's a thing
08:37clgvdoes someone know how to modify the theme of rainbow-delimiters in emacs?
09:21devnclgv: (omg (this (looks (like (a (clown car))))))
09:22clgvdevn: lol. wrong order of the sentence with respect to execution order ;)
09:22clgvdevn: I hardly see the color distinction with the default fonts...
09:27IcarotGuys, I am a terrible programmer.
09:28Kowboycan we blame it on Perl?
09:29IcarotAnd for some reason, I cannot for the life of me even formalize in psuedocode how to track the frequency of hours, given some data.
09:29Icarote.g., (1, 12, 30, 13, 14) -> Array[2]
09:30IcarotI feel like I'm trying to implement a kth largest element selection algorithm.
09:30Icarotexcept, somewhere along the line, I forgot that I'm an idiot.
09:37ciphergothis there something like ring.mock.request for multipart params?
09:42grcmacro and meta data problem: I wish to use a macro to define a function with meta-data which is passed as an argument to the macro.
09:42grc(defmacro foo [a] `defn ^#{:bar ~a} baz [] 42)
09:43grcBut this is rejected with (defmacro foo [a] `defn ^#{:bar ~a} baz [] 42)
09:43grcor rather java.lang.IllegalArgumentException: Metadata must be Symbol,Keyword,String or Map
09:43grcAny suggestions on how to get tehre?
10:07llasramgrc: Well, you have several problems there
10:08grcsomehow I'm not surprised! Up for education though
10:08grcllasram: ^
10:08llasramFirst: ##(quote '(`defn baz [] 42))
10:08lazybot⇒ (quote ((quote clojure.core/defn) baz [] 42))
10:09llasramThe body of your macro consists of the single syntax-quoted form `defn followed by a bunch of un-quoted things
10:09llasramFirst: ##(`defn baz [] 42)
10:09lazybotjava.lang.RuntimeException: Unable to resolve symbol: baz in this context
10:10llasramEr, didn't mean to re-say "First", but you get the picture
10:10llasramSecond, the ^{} reader metadata notation is just that -- *reader* metadata. It puts metadata on the forms being read
10:10llasram&(meta (^:example 'x))
10:10lazybotclojure.lang.ArityException: Wrong number of args (0) passed to: Symbol
10:11llasram&(meta ^:example 'x)
10:11lazybot⇒ nil
10:11llasram&(macroexpand `(meta (^:example 'x)))
10:11lazybot⇒ (clojure.core/meta ((quote clojure.core/x)))
10:11llasram&(macroexpand `(meta ^:example 'x))
10:11lazybot⇒ (clojure.core/meta (quote clojure.core/x))
10:12llasramI keep trying to use paredit in the ERC buffer... apparently need more coffee :-)
10:12grcFirst one was a poor truncation of my actual problem: I'm passing in baz to the macro and teh body reads (defn ~baz ....)
10:13llasramOk
10:14clgvgrc: if you want help with a macro always show the intended macro call syntax and the expansion you want to create...
10:14llasramSo skipping along -- because the reader metadata syntax is in fact reader syntax, it applies immediately to forms as they are read
10:14grcOK I think I've grokked the reader aspect. For now. So how do I apply meta data to the function I'm defining in the body of teh macro? Is taht through use of (meta ...)
10:14grcsorry cross-typing
10:15llasramnp
10:15clgvgrc: use `with-meta` on the symbol
10:15llasramYou need to porgrammatically generate the metadata with ^^ clgv with-meta, or vary-meta
10:17llasram&(let [a 'foo, b `~(vary-meta a assoc :example true)] [b (meta b)])
10:17lazybot⇒ [foo {:example true}]
10:17grcllasram, clgv: whenever I play with macros I seem to get lost in a twisty maze of indirection. I'll go and hack some code, but first and more importantly, think this through properly. Thanks fo ryour help
10:18llasramgood luck!
10:20solussdwhat's a good way to enforce a protocol's contract when implemented? e.g. if I define a protocol with a function that must return a string, how can I enforce that someone implementing the protocol uses a function that returns a string?
10:21solussdin other words, how can I put pre/post conditions on the protocol function declarations?
10:21llasramsolussd: Does it work to just put the pre/post condition metadata on the protocol function declaration? I know it works with other standard var metadata like :private
10:21solussdit does not. :(
10:22solussdit is ignored
10:22llasramsolussd: Aww. Well, I guess create a private protocol and expose public wrapper functions with the conditions?
10:25solussdyou mean: the protocol could declare a private fucntion, e.g. -protofunc that calls a public function, protofunc which the user of the protocol implements?
10:25solussdthat was suggested before, I just forgot the details. thanks
10:34AnderkentAnyone know why midje might fail to intercept a call to a public function? i.e. (fact <testcode> (provided (a/func anything) => ...result)) , and a/func is called from the testcode.
10:34AnderkentIt uses the real implementation in and complains that the prerequisite function is never called
10:39clgvAnderkent: you will have to post more context.
10:39Anderkentfigured it out - apparently provided only applies to the latest arrow, not the entire fact
10:39Anderkenti.e. (fact (foobar 1) => 1 (foobar 2) => 2 (provided (foobar [x] 2))) can succeed
10:40Anderkentrather unintuitive, but well
10:40danneuin an OOP language, if you create an array of Tweet objects (with Tweet#text and Tweet#username), is the surrogate for that in clojure a list of {:username _, :text _} hashmaps?
10:42clgvdanneu: yes
10:42dan_bthat would certainly be one way to model it
10:42dan_bdepends what questions you want to ask about that data, i guess
10:43clgvdanneu: it is the most general way. in special cases you would need defrecords or deftypes if you really need those
10:47danneuclgv: thanks. just read about those on the clojure website. i like it
10:49S11001001danneu: careful; defrecord/deftype are great ways to overdesign
10:49clgvdanneu: just start with the maps^^
10:51danneucool. i've been rewriting Ruby to Clojure and have been using hashmaps.
10:52kittylystAm still getting my sea-legs back after an absence. I wrote this to exclude any user with a freeware address (freemail domain held in list) from a list of users:
10:52kittylyst (mapcat (fn [domain] (filter #(re-matches (re-pattern (str ".*" domain ".*")) (:email %)) users)) freemail)
10:52kittylystIt's obviously inefficient, not that it matters for the list sizes
10:52kittylystSuggestions for a more idiomatic / cleaner solution?
10:53danneuMy biggest learning obstacle is how to organize my Clojure code that was once organized into succinct Ruby classes.
10:54kittylystWhoops, actually that code returns all the freemail users. C&P wrong code - but basic question stands
10:56Foxborondanneu: i was told this. 1 file for one purpose, and namespaces should give you the general idea.
10:56borkdudewould anyone know why (ref:someid) doesn't work in some clojure code block in org-mode when exported to html?
10:57borkdudeit does when I put it on its own commented line: ;;(ref:someid)
11:07danneuWow, LightTable is amazing
11:08Ember-not ready, but promising, yes
11:09danneuBetter than my Vim workflow for Clojure
11:09danneuAt least*
11:09Anderkentyou don't have a very good vim workflow for clojure then, I guess? :P
11:10danneuAnderkent: right. it's hard to arrive at a workflow when im still new to clojure though
11:10FoxboronI am using Emacs....but really not THAT happy. Anyoen tried Emacs and VIM with Clojure?
11:11danneuand?
11:11kittylystdanneu: I am using Emacs on a Mac & am very happy
11:11Anderkentfair enough. I find vim-foreplay and a backgrounded repl work nice (though because of YouCompleteMe if I don't have a repl open opening a file takes a while as it times out while connecting - need to get that fixed)
11:11danneuI didn't mean to suggest that anyone was unhappy with their setup! I just meant to express some love for LightTable
11:12pimeysI found it pretty horrible at this point
11:12pimeysbut 15 years of history with vim and now using emacs, I kind of find every other editor pretty horrible
11:13danneupimeys: yeah i guess it's just the simple point of clojure (and jvm build step) being new enough to me to where using a ide at the beginning is more convenient than the convience of editing code with vim
11:13pimeyswhat's the difference between an ide and emacs/vim :)
11:13pimeysless menus?
11:13pimeysno, emacs has menus
11:13pimeysok, setting them up requires some patience
11:14arrdemplugin systems that don't suck?
11:14danneuhey now, vim with vundle is nice!
11:14pimeysvery
11:14mpfundsteinFoxboron: i do all coding in vim
11:14pimeysand emacs with elpa
11:14mpfundsteinFoxboron: fastest environment for editing code
11:15Foxboronmpfundstein: well, i was more after someone who have used both heavily and can elaborate on what they think
11:15pimeysvim command mode must be the best way to edit anything
11:15Foxboronmpfundstein: "fastest enviorment" is a relativ term for the person
11:15danneuby ide i guess i mean software that tends to handle build steps for you and integrate with them. like showing you eval'd output next to the code.
11:15clgvdanneu: you can try counterclockwise as well ;)
11:15Anderkentclgv: not until slurp and barf are in :P
11:15pimeysdanneu: so, emacs is an ide :)
11:15clgvAnderkent: your choice ;)
11:16clgvemacs is an operating system :P
11:16Foxboronhahaha
11:16Foxboronwith a bad text editor
11:16pimeysand a potato
11:16pimeysFoxboron: with evil mode, it's pretty good
11:16pimeysand all those evil plugins
11:16AnderkentI use vim, actually :P having to toggle paredit to fix every single mistake in counterclockwise is just too much pain for me
11:16nDuffdanneu: Personally, LightTable is great for exploration, but I find myself using emacs+nrepl for interactive evaluation when doing real work.
11:16Foxboronpimeys: i know, i use evil mode. Just gotta learn the vim keybinds better
11:16nDuffAnderkent: that's only the case because CCW's paredit is underpowered.
11:17pimeysI cannot use emacs without it
11:17pimeysbut everything else in emacs is better than in vim
11:17nDuffAnderkent: ...full emacs paredit you don't _need_ to disable to fix mistakes.
11:17pimeysvim has a better editor
11:17clgvAnderkent: "toggle paredit to fix ..." care to explain what you mean exactly?
11:17danneunDuff: cool, that's what i was trying to say
11:17arkxAgain this discussion… :)
11:17AnderkentnDuff: yes, that's why I said I need slurp/barf
11:17nDuffAnderkent: *nod*.
11:18Anderkentclgv: say I want to do ((function arg1 arg2) arg3) but type ((function arg1) arg2 arg3)
11:18Anderkentto fix it in counterclockwise I have to disable paredit and move the paren by hand
11:18Anderkentin vim i just go to the paren and press ,>
11:19clgvAnderkent: laurent mentioned that the underlying lib for paredit got more functionality lately. so the missing parts will be there soon^^
11:21Anderkentyeah, I have the issue starred :) Once it's in I might switch to ccw just for the debugging support
11:26corecodewhat's counterclockwise?
11:26nDuffcorecode: Clojure plug-in for a Java IDE; I don't offhand recall which one.
11:26corecodeah
11:27nDuffAnderkent: With respect to debugging support, I'm hoping to see ritz merged into emacs-live soon.
11:27corecodenm then
11:29clgveclipse ;)
11:36gfredericksderefing a private atom: @@#'foo.bar/baz
11:36pjstadiggfredericks: you should be ashamed
11:37nDuffThat's... actually a lot less ugly than how I'm getting into clojure.data.xml's privates.
11:37Anderkentalso a lot nicer than how I'm changing the set of currently loaded namespace in clojure.core ...
11:37pjstadigof course i should talk https://github.com/pjstadig/nio/blob/master/src/nio/core.clj#L48
11:38Anderkenthttps://github.com/lshift/cloverage/blob/master/cloverage/src/cloverage/coverage.clj#L103
11:38Anderkentare we bringing out the dirt? :P
11:39Anderkent(I know I should be doing it via #' probably, but at the time it was an improvement over (in-ns 'clojure.core) (apply ...) (in-ns orig-ns) :D
11:39nDuff...had forgotten about #', which is considerably the saner approach.
11:40nDuff(convincing relevant folks to expose the function, of course, being ideal, _but_).
11:40Anderkentbut indeed
11:52gfredericksin this case I am the relevant folk.
11:52gfredericksI tend to privatize things even when their publicity makes testing easier
11:52corecodeis there a way to revert (use)?
11:52clgvlet's really free those functions in these open source projects by declaring them public ;)
11:53clgvthere was a call for that for java open source projects ;)
11:53nDuffgfredericks: ...the relevant folk for clojure.data.xml, you mean?
11:53clgvcorecode: only for the mapping part
11:54nDuffgfredericks: ...because if so, yes, I'd welcome an opportunity to lobby for making pull-seq public
11:54clgvcorecode: ns-unmap
11:55nDuff(as is the case when trying to handle results from javax.xml.xquery)
11:55corecodeclgv: what does that mean, for the mapping part?
11:55corecodeclgv: (use 'clojure.string) overwrote my 'reverse
11:55corecode:/
11:55clgvcorecode: without classloader artistic you can not undo that the namespace was loaded
11:55corecode(in the repl)
11:56clgvcorecode: the lesson here is to use (require '[clojure.string :as str]) and using e.g. (str/join ...)
11:56corecode:)
11:57corecodeyea, i'm still struggling with use, require, import
11:59llasramcorecode: You can ignore `use` for new >=1.4 code
11:59corecodeokay
12:00llasram(:use [some.namespace :only [foo]]) <-> (:require [some.namespace :refer [foo]])
12:01papachanweird
12:01papachani have a Exception in thread "main" java.lang.ExceptionInInitializerError
12:01clgvllasram: `use` is not deprecated in the docs though. is the intention to get rid of `use`?
12:01papachanwhen i launch today clojure
12:02llasramclgv: My understanding is that it's kind of "unofficially deprecated". Not sure why not officially, since `require` now can do everything `use` does
12:03papachannothing say. it working fine now
12:04gfredericksnDuff: not clojure.data.xml, just my own code
12:05gfredericksdon't futures run in a fixed-size thread pool? How does that interact with IO-bound futures?
12:06technomancyIIRC they use the send-off pool
12:06gfredericksI create 300 futures with a Thread/sleep in them, and apparently they all are running in parallel
12:06llasramgfredericks: Yeah, futures use the Agent/soloExecutor pool, which unbounded
12:07gfredericksah ha
12:07gfredericksso if I want a bounded number of jobs running at one time, I need a different mechanism
12:07llasramsend-via!
12:07llasramWell, or just a queue
12:13jcidaho`Hi - anyone got any elisp using nrepl for loading a default ns when nrepl loads in a project - I know this question has been asked a few times. I've got some for if the user has the project.clj open, but if any file in the directory tree for that project is open it's proving very tricky
12:14technomancyjcidaho`: I think there's an open pull request for that in nrepl.el that hasn't been applied yet
12:15jcidaho`Does it work :-) I'll try it
12:15borkdudewhat's the difference between require with no options such as :as and load?
12:16gfredericksborkdude: require will only load once
12:17borkdudeI wondered why this file contains load statements: https://github.com/clojure/clojure/blob/master/src/clj/clojure/pprint.clj
12:17technomancyload lets you do terrible things with namespaces
12:18llasramWell, I wouldn't say "terrible." It lets you divide a single namespace into multiple files.
12:18Anderkentborkdude: because load doesnt enforce the other file to have its own namespace
12:21technomancyload is only suitable for development tools to use; you shouldn't use it in actual code
12:21AnderkentI guess the drawback is it's hard for a person to find the source for a function by hand
12:21Anderkent(a tool obviously can just load the ns and look at the metadata of the function to locate it)
12:21tgoossenshow can i load a jar file for use in repl?
12:21llasramtechnomancy: Why so?
12:21Anderkenttgoossens: after starting the repl or before?
12:22tgoossenspreferably after ?
12:22llasramIt seems like otherwise people go through weird contortions to define vars in implementation namespace then expose them in API namespaces
12:22technomancyllasram: because you are not a unique snowflake; you can follow the rules for namespaces like everyone else =)
12:22Anderkenttgoossens: you can use clojure.core/add-classpath , though it seems it was deprecated
12:22Anderkentnot sure what the suggested alternative is
12:23jballanc,(when-let [foo (:bar {:bar nil})] (println "This makes sense"))
12:23clojurebotnil
12:23llasramtgoossens, Anderkent: you can use pomegranate to add arbitrary deps via aether dependency resolution
12:23jballanc,(when-let [{:keys foo} {:bar nil}] (println "This seems like a bug"))
12:23clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol>
12:23jballancwhoops...meant this
12:23jballanc,(when-let [{:keys [foo]} {:bar nil}] (println "This seems like a bug"))
12:23clojurebotThis seems like a bug\n
12:23jballanc^^^ any reason why ":keys" destructuring does that?
12:24llasramtechnomancy: I honestly haven't had a big need for it in my code, but having some mechanism for implementation/interface separation seems sensible, and `load` seems to be the closest the stdlib gets
12:24Anderkenttechnomancy: uh any actual examples of how it's bad? I.e. what intuition about namespaces does it break for you?
12:25technomancyAnderkent: for starters, it leads to files that don't have ns forms in them
12:25llasramjballanc: when-let just checks to ensure that the expression is non-nil, and `{:bar nil}` is definitely non-nil. It can't check that each of your destructured things is non-nil without essentially re-implementing destructuring
12:25Anderkentsure, but these files are not exposed, so consumers of the lib don't care?
12:26technomancyAnderkent: regularity makes for fewer surprises in tooling
12:26technomancyusing load is like using resolve; it's a sign that you're getting clever and whatever you're doing will confuse automated tools
12:27technomancyllasram: it doesn't really help with implementation/interface separation since all the implementation stuff still lives in the same namespace
12:27technomancyso someone browsing via ns-map will still see it
12:28llasramtechnomancy: I was just thinking that... Good point
12:28jballancllasram: ok, yeah...that makes sense
12:28Anderkentisn't that ns-map's fault for showing private members by default?
12:30AnderkentI mean it seems to me that since any tool can find the file a particular symbol was defined in no matter if it's required or loaded this isn't really that bad
12:30technomancyAnderkent: depends on what you want. you can use ns-publics for that case. but my point is that public/private is how you address hiding; putting it in separate files doesn't help.
12:30hiredmanand hiding is dumb
12:31hiredmandon't do it
12:31technomancyif I were reading through code and wondering what namespaces it required, I would be really annoyed if I couldn't just go to the top of the file to find it
12:31hiredmanI say this as someone staring at the stuff I need in the guts of javamail, and I have to use reflection to get it
12:35corecodeclojure makes my head pop
12:37solussderm.. when did clojure.core/protocol? become private?
12:38solussd..and why?
12:49pjstadighiredman: "and hiding is dumb" you say that now, but when they are banging down your door...you'll hide
12:55technomancyheh
13:01tgoossenswith paredit ((xx)) -> (xx) . I'm unable to do it so far :p
13:01technomancytgoossens: M-s
13:01tgoossenslet my try that :)
13:02ed_gtgoossens, another way is kill the (xx) and yank it somewhere else, then you can erase the emtpy ()'s
13:02tgoossenspfft :p
13:03solussdhow can I tell if something is a protocol now that I don't have the "protocol?" function?
13:03borkdudetgoossens I defined this in a script which I load for every repl I spin up: https://www.refheap.com/paste/12229
13:03borkdudetgoossens so I can load in dependencies afterwards, if I need them
13:04tgoossensmmyes
13:04tgoossensthanks
13:04llasramsolussd: When do you need to test if something is a protocol? In ClojureScript protocols aren't even reified -- there's nothing to call a `protocol?` function on
13:10tgoossensinteresting
13:11tgoossens(using leiningen resource paths) i import classes from a jar into my mainspace
13:11tgoossensfor some classes I finds a class , for others classdefnotdound
13:29fbernierhow could I pass what's inside a vector as arguments to recur ?
13:31fberniersince apply recur seems invalid
13:31llasramfbernier: Manual unpacking, I'm afraid. Or alter your interface so you're `recur`ing on a vector
13:32technomancyrecur is weird since it's not technically a new function invocation
13:32technomancyit doesn't even re-apply destructuring, which is really surprising to most people
13:36fbernierI see
13:36fbernierthanks
13:37fbernierI was trying to remove the loop from my 4clojure solution since I realized you can recur on functions
13:37fbernierbut I think It's better to leave it there in this case
13:44jweissis there a way to compose this with comp and/or partial - (fn [x & args] (apply hash-set x args))
13:46Anderkenttechnomancy: how do you mean it doesnt apply destructuring?
13:46Anderkent,((fn [[head & rest]] (prn head) (when rest (recur rest))) [1 2 3 4])
13:46clojurebot1\n2\n3\n4\n
13:46Anderkentthat seems to destructure it fine?
13:46borkdudejweiss ((partial hash-set 1) 2 3) ?
13:49technomancyAnderkent: sorry, I meant rest args
13:49technomancy,((fn [head & rest] (prn head) (when rest (recur rest))) 1 2 3 4)
13:49clojurebot#<CompilerException java.lang.IllegalArgumentException: Mismatched argument count to recur, expected: 2 args, got: 1, compiling:(NO_SOURCE_PATH:0:0)>
13:49Anderkentright, ok
13:50technomancy,((fn f [head & rest] (prn head) (when rest (f rest))) 1 2 3 4) ; whereas re-invoking f works fine
13:50clojurebot1\n(2 3 4)\n
13:51technomancyeh; I guess you'd need to apply there. anyway, it's unexpected
13:52hiredmanyeah, varargs in fns don't really mesh with destructuring, even though the syntax is the same
13:54gfredericksif I don't shutdown a thread pool, but I lose refs to it and it runs out of jobs, will it be GC'd? or is shutdown important?
13:55pjstadiggfredericks: YOU'RE BONED!
13:55gfredericksO_O
13:55pjstadigjust kidding, i don't really know
13:55pjstadigi'm not a clojure programmer, i just play one on tv
13:55technomancyyou can't shut down your computer anymore
13:55gfredericksoh pjstadig. always yelling at people that they're boned.
13:55technomancythose threads will just run to the heat death of the universe, sorry
13:55hiredmanhttp://stackoverflow.com/questions/7728102/why-doesnt-this-thread-pool-get-garbage-collected
13:56gfrederickshiredman: thanks! Now I am no longer boned.
14:09ghadishaybanI wish there was a most remote REPL award, because only today, I'd win it
14:09tgoossensif (ns :import [pgx.blablah ClassName]) gives NO compile error. But (ClassName. xxxx) throws a classdefnotfound. Then what might be wrong?
14:10ghadishaybanI'm sitting in north Lebanon (http://goo.gl/maps/mClpg) sipping packets off a wireless mesh network connecting the hilltops
14:10ghadishaybanat a breezy 15KB/s
14:11ghadishaybanwish I could nREPL everyone in
14:16ghadishaybantgoossens: i think i know what you mean, but that ns form should give you a compile error. can you paste specifics into refheap?
14:16tgoossenssure
14:16tgoossensinteresting. (new to emacs) how do i copy from emacs to another app? :p
14:17ghadishaybanhighlight and then Meta-W should do it (i'm new too)
14:17technomancytgoossens: depends on the OS
14:18tgoossenshmm (linux)
14:18technomancythe correct answer is that if you do everything in Emacs, you don't ever have to
14:18tgoossenstsssk :p
14:18llasramheh
14:18chronnoha
14:19tgoossensM-W does the trick
14:19ghadishaybansudo technomancy
14:19tgoossenshttps://www.refheap.com/paste/12234
14:19ghadishaybanerrgh su
14:19tgoossensghadishayban: https://www.refheap.com/paste/12234
14:19llasramtgoossens: If you enable cua-mode, you can just use ctrl-{x,c,v}
14:20tgoossensllasrm: interesting
14:20technomancycua-mode has composability issues
14:20llasramI don't do it myself, but it might be an easier path to having the same bindings in emacs as in your other apps
14:20llasramtechnomancy: I thought they'd ironed most of those out?
14:21chronnoas technomancy said, if you were trying to copy something to paste it in refheap, you don't have to leave emacs: https://github.com/Raynes/refheap.el/blob/master/refheap.el
14:21ghadishaybantgoossens: your threading form is the culprit,
14:21technomancyllasram: there are workarounds, but it's not the kind of problem you can just solve
14:21tgoossensinteresting
14:21tgoossenshow come?
14:21ghadishaybanmake sure you do (-> (Constructor.) ... blah)
14:21tgoossensaha
14:21tgoossensof course
14:21tgoossensstupid me
14:22tgoossensyeah it works now :)
14:23ghadishaybanthe threading form needs something tangible to "carry" through the form
14:24tgoossensyou are completely right. many thanks
14:24jweissborkdude: ##((partial hash-set) nil 2 3)
14:24lazybotclojure.lang.ArityException: Wrong number of args (1) passed to: core$partial
14:25jweissborkdude: i'm trying to create the function before x and args are known
14:25borkdude,((partial hash-set 1) 2 3)
14:25clojurebot#{1 2 3}
14:25jweissso you are including x in the partial
14:26borkdude,(fn [x & args] (apply hash-set x args)) ;; why no good?
14:26clojurebot#<sandbox$eval69$fn__70 sandbox$eval69$fn__70@f7d693>
14:26asteveain't no party like a clojure party because a clojure party causes you to determine how many parenthesis!
14:26jweissborkdude: it's fine, just asking if there was another way
14:26jweissthe general problem is i want to update a value to add to a hash-set, but the value might start off as nil
14:27rabbit_airstrikeso I inherited this big clojure project, and just stumbled across a 75 line defn with 17 optional args
14:27borkdudejweiss there are dozens of other ways, but this is the most obvious one. but hash-set already accepts the same arguments
14:27jweissso i wanted a function that always returns a hash-set. conj will assume nil is a list
14:27rabbit_airstrikeI feel ill just looking at it
14:27borkdudejweiss this sounds like into?
14:28borkdudejweiss or remove the nils?
14:28jweiss,(apply into #{} nil #{2 3})
14:28clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (4) passed to: core$into>
14:28borkdude,(hash-set nil 1 2 3)
14:28clojurebot#{nil 1 2 3}
14:28jweiss,(into #{} nil #{2 3})
14:28clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: core$into>
14:28borkdude,(doc into)
14:28clojurebot"([to from]); Returns a new coll consisting of to-coll with all of the items of from-coll conjoined."
14:29borkdude,(into #{} nil)
14:29clojurebot#{}
14:29jweiss,((comp conj (partial into #{}) nil 1)
14:29clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
14:29technomancyI wonder why compojure's site handler doesn't use wrap-file-info
14:29jweiss,((comp conj (partial into #{})) nil 1)
14:29clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: core$into>
14:29jweissbah
14:33borkdudejweiss:
14:33borkdude,(reduce #(if (nil? %2) %1 (conj %1 %2)) #{} [nil 1 2 3]) ?
14:33clojurebot#{1 2 3}
14:34jweissI really just want conj, except i want the final value to be a hash-set even if the inital list is nil
14:34jweissbut yeah that's pretty much what you wrote :)
14:35gfredericks(fnil conj #{})
14:35borkdude,(apply hash-set (remove nil? [nil 1 2 3]))
14:35clojurebot#{1 2 3}
14:36jweissgfredericks: +10 internets :)
14:36borkdudegfredericks jweiss ah :)
14:36borkdudefnil
14:37jweiss,((fnil conj (hash-set)) nil 1)
14:37clojurebot#{1}
14:37jweissw00t
14:38noidiwow, fnil looks really useful
14:38borkdudethis week's function: fnil
14:38owengalenjonesanyone have an idea why the second fact form would fail? Only difference is using the hash lookups: http://d.pr/i/Patj
14:39noidiowengalenjones, how does it fail?
14:40owengalenjonesnoidi: http://d.pr/i/IzsC
14:40jweissthanks Raynes - i really should just add useful to my project.clj so i can browse around when i need something
14:40noidia bit OT, but I'd replace the lookups with concrete values
14:41owengalenjonesso just not use hashes?
14:41noidi(call ..url.. :login "valid-user" "valid-key")
14:41hiredmanI would stop using midje
14:41owengalenjones?
14:42hiredmanmy guess is it is doing something ridiculous
14:42noidiowengalenjones, btw. in your first example you call (login ..url.. ...), in the other you're doing (login "http" ...)
14:45owengalenjonesnoidi: from prior tests, still happens without :( oh well thanks for your time
14:45nDuffEmacs clojure-mode question -- how can one pull up the next token, when potentially separated by larger amounts of whitespace, to start only a space away from the current token?
14:45technomancynDuff: M-SPC
14:46nDufftechnomancy: shoot; I'll have to adjust my window manager's keybindings to get it to give that up.
14:46technomancynDuff: esc spc?
14:46nDuffAhh; that works.
14:48noidiowengalenjones, FWIW, I'd rewrite the test like this https://www.refheap.com/paste/12235
14:48nDuffIs there a cheaper way to cancel a transaction than throwing an exception?
14:48noidithe only args whose value is important is the :login arg to call
14:48noidi-s
15:14actsasgeekI have an application that refreshes data from a database. Because the data fetch is initiated by a work request and these all arrive at the same time every day and at once, I have to keep from doing multiple data fetches. What seemed to work is a future wrapped in a delay wrapped in an atom. In local testing this was fine, but now I'm seeing multiple hits on the database. Is there a known solution for this use case? I'm not sure what the problem is
15:14actsasgeekunless (-> cache deref deref deref) isn't getting the right locks. Any suggestions?
15:22nDuffactsasgeek: That seems like serious overkill.
15:23nDuff...but anyhow, that's beside the point of the behavior at hand.
15:23amalloynDuff: i actually use a data structure that looks like (atom {:key (delay (future ...))}). it's more useful than you think
15:24Bronsabut then you have to @@(:key @map) :(
15:24actsasgeekit may well be. The data has to be re-fetched every day so that suggests an atom. The data fetch is initiated by the first thread that gets there so that suggests a future and I don't want it to execute until it is demanded so that suggests a delay.
15:24amalloyif you want to store a fugure in an atom, the only way to *get* it there is with a swap!, and since that can retry, you can't actually create the future inside of the swap!
15:25amalloyso, wrap it in a delay, let the first guy "win", and then deref it when you're done swapping
15:25nDuffamalloy: ...ahh; that makes sense.
15:27pjstadigactsasgeek: if you want something to not happen until you demand it you use a delay, but i'm not understanding where the future comes in
15:29actsasgeeksorry. this is basically what I have which may make more sense than me describing it: http://pastebin.com/qJy7MqxC
15:30nDuffactsasgeek: would you mind putting that somewhere without the animated flash-based advertising?
15:30actsasgeekno problem.
15:30nDuff(we're partial to refheap, here, being as it's written in Clojure)
15:31actsasgeekhere you go: https://www.refheap.com/paste/12239
15:32RaynesnDuff: o/
15:32RaynesMy buddy, my pal.
15:32actsasgeekoddly enough this works…you only see "reading the actual database" once and you always get the same value until you update -database.
15:32amalloyactsasgeek: this test code doesn't look threadsafe at all. what if all 10 threads you start block for a second or so before the scheduler gets around to them? then the reset-calc and update-database functions get called before any calls to the original cache happen
15:32actsasgeek…but not in real life.
15:33amalloyor if one of them runs, you hit the database, you reset, and then the rest run? they hit the database a second time
15:33nDuffactsasgeek: If you want the test to be a more realistic one, make the read-database call block for a while.
15:34nDuff(and, err, I'm not sure what the future is giving you here that you don't already get from the delay).
15:35actsasgeekdo delays block other threads?
15:35amalloy"block other threads" doesn't make sense as a question
15:35nDuffAhh, gotcha.
15:36nDuff...delay doesn't document its semantics there.
15:37actsasgeekas I understand it. a dereferenced future causes the calculation to be performed in another thread, prevents other threads from doing the same (blocks them), and returns the value of the calculation to everyone.
15:37actsasgeekso no subsequent thread causes the function in the future to be executed.
15:38actsasgeeka delay only prevents any enclosed value from being evaluated but the evaluation, when dereferenced, is on the dereferencing thread. (could be wrong here).
15:39pjstadigdelay also caches the result and returns the cached result on future derefs
15:39nDuffI'm not sure those nest the way you want them to, though. If dereffing the delay twice at the same time creates two different futures (before the first one has finished and been cached), you've got your race.
15:39actsasgeekyes, that's what I'm afraid of.
15:39amalloynDuff: it doesn't, though. dereferencing a delay blocks just as much as dereferencing a future
15:40nDuffamalloy: Ahh. If _that's_ the case, there's no need for the future at all.
15:40amalloyit's what they're *for*: the &body of a delay will never be executed more than once
15:41amalloy"invoke the body only the first time it is forced"
15:41amalloybut really, a lot of clojure's promises aren't painted in bright-red letters
15:41actsasgeekexcept the future executes in a separate thread…maybe there's no reason for the delay? just the future?
15:42actsasgeekideally there are multiple threads requesting work and multiple threads getting data together…but I need only one actual request for each data element.
15:42nDuffactsasgeek: ...well, the future starts immediately on creation.
15:42nDuffactsasgeek: it's up to you whether you want to precache the value or wait for someone to want to retrieve it.
15:42actsasgeeknDuff: which is why I wrapped it in a delay :(
15:43actsasgeekbut apparently those don't compose well.
15:43nDuffErr.
15:43sritchiecemerick: what was that ring handler you had that forced https?
15:43sritchiedidnt' bookmark that library
15:43nDuffI don't think "delays don't compose well" is established takeaway here.
15:43Bronsao
15:43cemericksritchie: it's a separate middleware in Friend
15:43cemericksritchie: requires-scheme*
15:43sritchieokay, but that's where I can find it
15:44sritchieyeah, cool
15:44pjstadigactsasgeek: why is it important that it happen in a separate thread? the first thread to deref a delay will execute it, is that bad?
15:45pjstadigif you want it to happen on a separate thread, then you want a delay wrapped future, but if it can happen on the first deref'ing thread, then a delay should suffice
15:45nDuffactsasgeek: ...what I'm getting from amalloy's clarification is that you really don't need the future here, and only need the delay.
15:45actsasgeekpjstadig: to do the work there are multiple large (several Gb) Hive queries…I don't want to do them serially.
15:45pjstadigthey would happen serially on the future's thread?
15:45actsasgeekeach request is a separate one of these caches.
15:46actsasgeeknDuff: I *thought* I tried that first…but I could be concurrency punchdrunk.
15:46sabrahamhey, multithreading question for the room: i'm getting a weird issue with an agent hanging: in the dispatch action to the agent, there's a call to pmap of a function-- when i use pmap the agent hangs, when i map instead, the dispatch action completes
15:46sabrahamanyone have any insight as to why that may be happening?
15:47ravsterhey all
15:47actsasgeeknDuff: oh, I probably didn't because again, there are several of these caches being managed, each with a 20 minute Hive query. I'd rather do them in parallel.
15:48corecodeis there a FAQ on "none of my friends understand my exitement with clojure"?
15:49actsasgeekthe box I'm running on has 76Gb of memory and 24 cores.
15:49nDuffactsasgeek: ...but you're acting to prevent them from running in parallel by doing the triple-deref, which blocks until there's a result to continue.
15:50nDuffactsasgeek: If you wanted to kick them off by dereffing all the delays but not the futures in an initial stage, _that_ I'd understand.
15:50llasramsabraham: I can't think of a reason off the top of my head. Can you reproduce with a minimal example?
15:53sabrahamllasram, i'll try and concoct something and report back
15:53actsasgeeknDuff: yeah, I think you're right…my mental image of how the data request threads and work request threads interacted wasn't quite correct.
15:54sabrahamone possiblity is that pmap uses the same threadpool as the agent's, so maybe pmap is requesting the agent thread?
15:54amalloysabraham: futures use an unbounded thread pool
15:54sabrahamone thing i think i have ruled out is that the agent is in a failed state, as a i have an error handler set on it, and it never reports
15:55actsasgeekamalloy: I now understand your confusion…those stray functions before the (dotimes…) were not called in the REPL that way…it's just where I pasted them.
15:56jtoycan maps hold millions of key/value pairs ?
15:56actsasgeeknDuff: how can I make that read-database function block in Clojure?
15:57amalloyjtoy: try it and see
15:58sabrahamamalloy: ah, i see. i wonder why i was mistaken. out of ideas then
15:58actsasgeekjtoy: yes. I have one that has 25Gb of data: long => [long]
15:59jtoyactsasgeek: gret to hear, im going to use a clojure hash-map inside of hadoop
15:59actsasgeekmaybe not quite that much…25 million records, though.
15:59actsasgeekI'm holding the results of a Hive query in one.
16:00actsasgeekactually, I'm holding the results of 5 Hive queries in 5 of them.
16:00jtoyactsasgeek: mine should only be 1-2 million
16:05actsasgeeknDuff: LOL…just make it sleep. Darn but I've been at this too long today.
16:12puchaczhi, I come from Common Lisp. I would like to read something about streams, iterators and generators
16:12puchaczto steal some ideas
16:13hiredmanclojure has none of those things
16:13technomancyyeah, not having any of those is a pretty good idea worth stealing
16:14technomancythe main thing CL could learn from Clojure is that sometimes you have to remove things to improve the language
16:14puchaczreally? streams can be non-destructive, purely functinal
16:14technomancybut the CL mantra is that you can always improve the language by adding new things; macros will save us, etc.
16:15actsasgeeknDuff, amalloy thanks for you help.
16:15puchaczright, did I start religious war? I did not intend to
16:15RaynesNo.
16:15RaynesYou provoked the two hardest to please people in the channel is all.
16:15RaynesCarry on.
16:15pjstadighaha
16:15amalloytechnomancy has been promoted to "religious war"? this is excellent
16:16pppaulpuchacz there is a library that adds channels to clojure… i think it may be similar to streams
16:16ToBeReplacedis there a lazy-shuffle implementation lying around?
16:16duck1123Lamina is probably what you want
16:16puchaczso seriously, what would you recommend to read on clojure way dealing with restartable, and long data sources?
16:16brehautpuchacz: Oleg has got your back http://okmij.org/ftp/Streams.html http://okmij.org/ftp/continuations/
16:16Raynesamalloy: %!
16:16Raynesamalloy: Someone just asked for lazy shuffle. Your time has come.
16:16trptcolinbrehaut: beat me to it. that is something to read, indeed
16:16amalloyomgomgomg
16:17brehauttrptcolin: i recognise most of the words as words anyway
16:17puchaczok, thanks, will check Oleg. just heard about him on CL channel
16:17brehautpuchacz: thats because Oleg has a brain the size of a small planet and has covered all this stuff
16:17amalloyexcept my current implementation is a bit stupid. take-shuffled requires a numeric arg, instead of just giving you all of them and letting you use take
16:18amalloyi must have a real lazy-shuffle around somewhere
16:18technomancyI dunno; a lot of people come asking how to learn from clojure's approach to concurrency, when usually the answer is just that referential transparency makes it a non-issue.
16:19puchaczcoolio, starting to read. thanks
16:19technomancy"When he heard this, he left very sad, because he was a man of great wealth."
16:19amalloytry https://www.refheap.com/paste/c8275b404d8ec64446008ede5
16:19gfredericksyep, religious war
16:19brehauttechnomancy: you are biblical motherfucker
16:20amalloy(ToBeReplaced)
16:20ToBeReplacedamalloy: thanks looking
16:20technomancybrehaut: sell all your mutable data structures and give to the poor, and you will have concurrency.
16:21brehaut(inc technomancy)
16:21lazybot⇒ 47
16:21hiredman~#68
16:21clojurebot68. If we believe in data structures, we must believe in independent (hence simultaneous) processing. For why else would we collect items within a structure? Why do we tolerate languages that give us the one without the other? -- Alan J. Perlis
16:22technomancybrehaut: it's easier for a camel to go through the eye of a needle than for an imperative program to run concurrently without bugs.
16:22technomancyok, I'm done
16:22llasramTruly, it is easier for an experienced programmer to pass through the pages of the Camel book than to enter the kingdom of the concurrent
16:22technomancynice!
16:23gfredericksany #clojure conversation that continues for long enough eventually degenerates to bible recitation
16:24technomancyI tried to make it work as an OCaml joke, but it wasn't happening
16:26hiredman~#46
16:26clojurebot46. Like punning, programming is a play on words. -- Alan J. Perlis
16:30arohnerare there any decent JVM libraries for process management? I'm looking to run `ps` and `kill` from clojure
16:30brehautarohner: conch.sh
16:31arohnerok, let me rephrase that :-)
16:31arohneris there a decent library that will tell me "is there a process whose name matches regex", without having to parse the output of `ps -ef`?
16:31pjstadigprobably not
16:32pjstadigthe JVM isn't very unixy
16:32arohnerk. I was hoping to avoid platform-specific output of ps
16:37jtoyis defonce lazy?
16:39jtoymeaning inside the defonce if i read a file and add create a hash will that happen upon the functino definition or when i call it?
16:41technomancyonly seqs are lazy
16:41technomancyif you want to delay evaluation of non-seqs, you can use an explicit delay
16:42devnHave a feeling you cats will be interested in this kind of thing, or not: http://notonlyoo.org/
16:43trptcolini read that as "not on YOLO" the first time
16:44technomancyoh no a manifesto
16:44jimkcarLet's go write some Java! #YOLO
16:44Sgeo"That is, while there is value in the items on the right (except for nulls), we value the items on the left more"
16:44SgeoI like the hate on nulls
16:45trptcolinmanifesto (n): Karl Marx's favorite core.logic function
16:45technomancy"✓ manifests over manifestos"
16:45SgeoUm. Is the entire manifesto seriously "We like these over those other things?"
16:45technomancySgeo: that's all the Agile manifesto is too
16:46brehaut(inc trptcolin)
16:46lazybot⇒ 1
16:46jimkcarBlog page has swag for sale
16:46brehautseriously? 1?
16:46gfrederickstrptcolin: do you value reading over earning #clojure karma?
16:47technomancybrehaut: trptcolin doesn't connect to freenode often enough to bask in his well-earned repl glory
16:47brehauttechnomancy: apparently so. i <3 reply
16:47technomancywhich is too bad because it's a good source of vitamin D
16:48trptcolinit's a very exciting pronunciation
16:48brehautTRPTCERLERN
16:49ivanarohner: maybe pgrep works on more platforms
16:49Raynesbrehaut: ERMAHGERD
16:54arohnerivan: good idea, thanks
16:55firefuxWhat's recommend today to connect to postgres from Clojure?
16:56pppauldatomic
16:57Raynespppaul: Leave this channel and never return,
16:57gfredericks{:simple clojure.java.jdbc, :easy Korma}
16:57brehautfirefux: java.jdbc
17:00abpgfredericks: Korma can be simple too, but there are many simple things.
17:00abpAt least simpler than writing sql.
17:00gfrederickssql is pretty simple.
17:00pppaul:D
17:00abpBut verbose
17:00brehautabp: ?? writing sql is really straight forward. its the reuse and composability of the written sql that is pants
17:00abpjava can be pretty simple too :P
17:01technomancySQL without syntax highlighting is a drag
17:01abpbrehaut: Right, and I always compose my queries.
17:02brehauttechnomancy: and writing SQL via an abstraction that isnt a clean match semantic match is also a drag :/
17:03gfrederickscome on guys just use hibernate
17:03technomancybrehaut: https://mobile.twitter.com/collinvandyck/status/305031087896281088?p=v
17:03gfredericksthe answer has been right in front of us the whole time
17:03gfrederickswe just had our heads stuck too far up our parentheses to see it
17:03brehauttechnomancy: lols
17:04brehautgfredericks: the empty list literal is now an emoticon i cannot unsee :/
17:05gfredericksoh man I wasn't even thinking of that
17:10brehautthis is a longshot, but anyone got any idea how you specify optional fields in a map using core.typed? (where the key may not be present, rather than a nilable value)
17:13hiredmanyou need paradox absorbing buffers for your robot's head
17:16brehaut.toString comes from of Object in java, rather than some interface right?
17:17metellusObject has a default .toString but it's usually overridden
17:17brehautright, but in terms of types if something is toStringable, its and Object rather than IStringable
17:17metellusyes
17:18brehautthanks
17:20canweriotnow1what's the best way to handle native dependencies with leiningen, when packaging a library?
17:21canweriotnow1i.e., if a Java dependency has platform-specific *.so binaries?
17:35akhudekI added domina to the toggle class performance test included with dommy: {:domina 18.9, :jquery 11.412, :dommy 4.73}
17:40konrwould it be a bad idea to port Backbone.js to ClojureScript?
17:43akhudekok, just updated it by adding a proper toggle-class to domina that uses google closure's toggle function
17:43akhudek{:domina 4.465, :jquery 11.326, :dommy 4.621}
17:46tomojkonr: yeah
17:46tomoj:P
17:47konrtomoj: why?
17:50tomojyou either wind up with something ugly or something that isn't backbone
17:51tomojit may well be a good idea, if only as an exercise
17:52tjgillieswhats the best way to show exceptions in compojure?
17:54nDuff...hrm; clojure-mode is highlighting lines with errors/warnings on C-c C-k compile, but I'm unclear on how to see what those warnings actually _are_.
17:54danneukonr: dunno how it's a 'bad idea'. you're just replicating work and need to backport changes that happen on backbone master
17:55danneusounds intellectually/educationally fun tho
17:55squidzi am trying to call a function for every node of an xml document where the function differs if the node is an end node or not. Whats the easiest way to do this in clojure?
17:55hiredman"end node"
17:56squidzhiredman: ?
17:57squidzright now I am maping said function over (xml-seq ..), but I am not sure if there is a function out there that returns true/false based on if an xml node is an end node or not
17:58technomancycanweriotnow1: unfortunately the process for creating those jars isn't documented currently; you have to read the source
17:58technomancyor copy an existing native jar
17:59squidzalso, is there something out there that gives the depth of the xml node in xml-seq?
17:59canweriotnow1technomancy: is it still the native/target_os/target_arch schema?
18:00technomancycanweriotnow1: basically yeah
18:00technomancyevery time someone asks, I tell them once they figure it out they should submit a pull request with documentation
18:00canweriotnow1also: I guess that means it's necessary to package native deps as a separate jar and add it to project.clj, I can't bundle them with my project?
18:01canweriotnow1hah, if I figure out a good way to do it, I'll definitely submit one!
18:01danneusquidz: im new to clojure but your requirements sound really simple http://www.gettingclojure.com/cookbook:xml-html
18:01technomancycanweriotnow1: yeah, that's usually how it's done. just a bunch of .so/.dll/whatever-mac-uses in a certain path structure in the jar
18:02tomojclojurescript.test! woot
18:02canweriotnow1okay, thx... I wish maven handled this better :(
18:03squidzdanneu: yeah that is pretty much what I have so far, but doesnt tell me how to figure out how deep I am in the xml
18:04squidzit looks like what I want is clojure.zip, but i cant seem to get it to work
18:05ed_gsquidz: does end? not work for you?
18:06squidzed_g: no, it is giving me a : string cannot be cast to IFn exception. Maybe it is because I am using xml-seq?
18:09ed_gsquidz: I would guess so. by end node you mean node with no children? in a zipper it means the last node when traversing the zipper.
18:09squidzed_g: okay I see I have to use xml-zip instead of xml-seq to be able to use end? but I am getting null pointer exceptions now
18:10jtoyhow would split a string and have the first element in a variable and the remaining items in anothern variable?
18:11canweriotnow1technomancy: Thanks! It's ugly, but it worked!
18:12canweriotnow1(all this just to write a clj wrapper for Pam auth)
18:12akhudekjtoy: this is a very confusing question. If you split a string and get back a seq of results, the first element is (first results) and the rest would be (next results).
18:12jtoymy code for it is bad now: (let first_part (first (clojure.string/split line )) last_part (range 1 -1 (clojure.string/split line )) )
18:12jtoyakhudek: I mean like that
18:13ed_gsquidz: it sounds like your definition of end node is similar to what you might also call a leaf node, that is a node with no children? do I have that right?
18:13squidzyes that is what I mean
18:13akhudekjtoy: split it once, and use first and next on the result
18:14technomancycanweriotnow1: ugly sounds about right
18:14akhudekjtoy: you can also use destructuring if you really want to be clever
18:14ed_gin which case you can iterate using xml-seq and look for nodes without :content
18:15technomancyat least you don't have to recompile it on every install like you do with rubygems though
18:15akhudekjtoy: (let [[f & r] (clojure.string/split line)] …)
18:16canweriotnow1ha, true!
18:17jtoyakhudek: hmm, that might be too advanced for me ,not sure what that does
18:17danneuakhudek: does clojure have a func that's like Enumerable#partition in Ruby/Scala? [1, 2, 3].partition { _ > 1 } #=> [[1], [2 3]]
18:17akhudekjtoy: all you need is first and next
18:17ed_gfor instance (filter (fn [e] (empty? (:content e))) (xml-seq your-xml))
18:18akhudekjtoy: (let [result (clojure.string/split line) f (first result) r (next result)] … )
18:20scottjdanneu: partition-by and group-by
18:21squidzed_g: im trying it out. ill let you know if it works
18:22nDuffHrm.
18:25saolsenDoes anybody know off hand the state of clojurescript sourcemaps? I've been googling around and found a few different discussions on it but I can't tell.
18:26ed_gsquidz: I wrote a version of map and filter for zippers which you might find useful just for experimenting, not sure where the paste page is for this channel but I can put them there
18:27squidzokay just send me the paste link
18:30ed_ghttp://pastebin.com/1QeuTpuf keep in mind that modifying a zipper this way is challenging.
18:31tjgilliesim working with cheshire and monger
18:31tjgilliesim requiring monger.json like in the docs
18:31tjgilliesbut cheshire/encode can't serialize the doc
19:09amalloyed_g: huh? why have map-zipper and filter-zipper, instead of just mapping and filtering over a zip-seq?
19:12ed_gamalloy: because I didn't see zip-seq in my quick reference docs :-)
19:12ed_gactually I still don't -- what library is it in?
19:12amalloyed_g: i don't know that it exists, but writing it yourself is preferable to writing map-zipper and filter-zipper
19:13ed_gamalloy: keep in mind these are basically the first functions I wrote in clojure
19:13korny_Hi - anyone here familiar with Liberator? We're trying to define a basic resource with a basic JSON representation, but it seems we have to explicitly call (json-str data) to get a json response
19:14korny_e.g. (defresource foo :handle-ok ["a" "b" "c"] :available-media-types ["application/json"]) gives an error
19:15korny_whereas :handle-ok (json-str ["a" "b" "c"]) works, but it seems strange to have to explicitly call this.
19:21sshackIs there a clojure library for parsing csv files that handles headers? I swear there was at one point, but can't remember the name now.,
19:24scottjsaolsen: idk but I think status is not working but being worked on here and there when dnolen gets the time and motivation. see source-map branch on clojurescript repo maybe
19:29jtoyhow do I turn a vector of items into a vetor of vectors? this doesnt work: (defn ts [i] [(map #([%]) i)]) ; (ts [1 2 3 4])
19:30technomancyjtoy: (vec (map ...))
19:30technomancyerr
19:31technomancy(vec (for [i is] [i]))
19:31jtoyok
19:31jtoynot sure what the difference is between map and for, seem almost the same
19:31technomancymap is a function that takes a function as an argument; for is a macro
19:31hiredmanfor can filter and concat
19:32jtoyok, imtesting itthanks
19:33technomancyit can concat?
19:34hiredman,(for [a [[1 2] [3 4]] b a] b)
19:34clojurebot(1 2 3 4)
19:34hiredmanconcat
19:34technomancyoh, because of how it nests. yeah, never thought of it that way but it makes sense
19:35hiredmanI just had an idea
19:35hiredmanreducers/for
19:35hiredmanthat expands in to calls to the reducer fns
19:36technomancyyou might say
19:36technomancythat I'm for it
19:36technomancy( •_•)
19:36technomancy( -_-)~⌐■-■
19:36technomancy(⌐■_■)>
19:37hiredman~clap
19:37clojurebotGabh mo leithscéal?
19:38hiredman~applaud
19:38clojurebotexcusez-moi
19:38technomancyI need to make an emacs defun for that because I was worried someone would respond in between lines
19:40amalloyhiredman: because having the entire implementation of the 'for macro copy/pasted into 'doseq wasn't bad enough
19:41hiredmanamalloy: well, you can't do it as a c&p
19:43hiredmanman, I never remember :while
19:43hiredmanand I always try and use :where instead of :when
19:44technomancy:where would make more sense
19:45hiredman:where would be sql like
19:48amalloyhiredman: the tricky bit is remembering what :while does
19:49amalloy(for [x '[a b c] y [1 2 3 4] :while (< y 3)] [x y]) returns '([a 1] [a 2] [b 1] [b 2] [c 1] [c 2]), whereas it's easy to forget and expect it to just be '([a 1] [a 2])
19:49hiredmanyeah, screw :while
19:55hiredmanhttps://gist.github.com/5113363 fitting in the :when's would be tricky
19:56sshackSo, clojure csv libraries?
20:14sshackOkay, question. How do I map a function with dirty > 1 ? Trying to do (map (nth 3) myseq)
20:14sshackIn mathematica I'd do Map[nth[&,3], mylist]
20:14sshack& standing in for the mapped list.
20:14lazybotjava.lang.RuntimeException: Unable to resolve symbol: standing in this context
20:15root`you want every third value from `myseq`
20:15root`?
20:16sshackroot`: Well, each whatever value.
20:16sshackI've got a seq of seq's (rows from a csv file)
20:16sshackSo I want to handle all the values of each type one at a time.
20:16sshackDo I make sense?
20:17root`sshack: yea, one sec
20:18qbg&(map #(nth % 2) [[1 2 3] [4 5 6] [7 8 9]])
20:18lazybot⇒ (3 6 9)
20:20sshackqbg: Perfect! Thanks.
20:20qbg&(apply map vector [[1 2 3] [4 5 6] [7 8 9]])
20:20lazybot⇒ ([1 4 7] [2 5 8] [3 6 9])
20:20qbgThat might be useful for you too
20:22sshackqbg: That is actually
20:24sshackqbg: Is the JVM smart enough to not clobber memory resources doing that?
20:24sshackI'm thinking about 400meg csv files here.
20:25qbgHow many columns do you have?
20:25sshack200 or less
20:25sshackfew hundred thousand rows.
20:26qbgmap is lazy, so the above might be sufficient
20:27qbgeh, got that backwards.
20:27sshackCool. I'm trying to cut down the number of columns. Should be ~50-70 soonish.
20:27qbgapply map vector would yield some big vectors in that case
20:27sshackI have this in my toolbox: (def transpose
20:27sshack (partial apply map list))
20:28qbgthat is the same as above :)
20:29qbgIf you have a seq of seqs, you'll be walking the outer seek when processing each column
20:29qbgSo almost certaintly you'll end up with the entire file in memory
20:30sshackGood point. I think the best approach is get the data into a DB first. Then deal with it there.
20:31sshackSo now I have to remember the name of that CSV file that deals with headers.
20:31qbgdb would work. You could also read the entire file multiple times
20:33sshackI've sort of been burnt dealing with CSV files (mathematica, python, etc). So I think I'll parse things into a normalized DB and then go from there.
20:44ambrosebsIt might be useful, say if you had a seq of possibly nil Closeables, and you (map close! cseq)
20:44ambrosebs(doall ...) :)
20:46ambrosebssorry wrong chat
20:50alandipertis there a slurp-binary or similar in someone's awesome lib somewhere?
20:50alandiperti have an input stream and know the length, would like to get a byte array w/ the stuff in it
20:51qbgThere is a static method for that in apache commons io's IOUtils at least
20:57FrozenlockIs there a way to make everything in the repl pretty-printed?
20:59alandipertFrozenlock: it depends on how you're repl-ing; with lein repl i know you can do :repl-options [:print clojure.pprint/pprint] in your project.clj
21:00alandiperti've never tried to do it any other way though, maybe nrepl and swank can be configured similarly
21:00FrozenlockThanks, that's exactly what I was looking for!
21:06xeqialandipert: in clojars we use something like: (let [bs (java.io.ByteArrayOutputStream.)] (io/copy in bs) (.toByteArray bs))
21:06xeqifor a slurp-binary
21:07alandipertxeqi: oh, that's nice, len not required even. thanks!
21:12Frozenlockalandipert: I must have done something wrong... I see now difference :(
21:12Frozenlock*no
21:23FrozenlockOh well.. (define-key map (kbd "C-c C-p") 'nrepl-pprint-eval-last-expression) .... should have read the nrepl.el sooner.
21:23brehautdo i have to officially ask for my jira privs to be bumped on the dev list, is someone just able to do it for me?
21:47amalloyif anyone important were in here, they could do it for you, brehaut
21:47brehautamalloy: andy fingerhut did it on the list, but cheers
23:23RazWellesdoes clojureclr have any sort of introspection, like dir() for python?
23:23RazWellesalso, how do you register event handlers?
23:33nopromptRazWelles: I'm not sure about the CLR version, but theres the doc function. You could try that
23:33noprompt,(doc map)
23:33clojurebot"([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & ...]); Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments."
23:33RazWellesnoprompt, I found something that kinda works... but now I'm at a loss for how to register an event handler :\
23:53n_bIf I have a vec, is the more idiomatic way to access the last item in faster than linear time than doing (some-vec (dec (count some-vec)))?
23:55n_bI suppose (nth (dec (count some-vec)) some-vec)?
23:55alandipertn_b: peek may be what you want
23:55RazWellesArgumentTypeException expected EventHandler`1, got EventHandler .CallSite.Target (:0)
23:55RazWellesAny idea what this means?
23:56n_balandipert: That'd do it. Cheers!
23:56jeremyheilern_b Maybe (first (rseq [1 2 3]))?
23:57jeremyheilerahihi, didn't see your reply there, alandipert
23:57jeremyheilerAh*