#clojure logs

2015-01-26

00:00tomjackone extension point I discovered: (defmethod core.match/emit-pattern-for-syntax [:foo :default] ...)
00:01tomjackthen (match x (:foo y) :ok)
00:04tomvolekHI guys, I am trying to execute some sample syntax in Repl like : (difference #{1 2 } #{2 3}) I get error message "CompilerException java.lang.RuntimeException: Unable to resolve symbol: difference in this context," I thouth difference is in the core which gets loaded by Repl .
00:04justin_smithtomjack: clojure.set/difference
00:04justin_smithhere's how you can find it ##(apropos "difference")
00:04lazybot⇒ (difference)
00:05justin_smitherg... it behaves better in newer versions, heh
00:05justin_smith(actually shows the full ns)
00:05tomvolekthanks
00:07justin_smithyeah, with 1.7.0-alpha4 I see the whole ns with apropos
00:07justin_smith&*clojure-version*
00:07lazybot⇒ {:major 1, :minor 7, :incremental 0, :qualifier "alpha1"}
00:08justin_smith,*clojure-version*
00:08clojurebot{:interim true, :major 1, :minor 7, :incremental 0, :qualifier "master"}
00:17brainacidI have installed lein, LightTable and jvm and looking through The Joy of Clojure
00:17brainacid~book
00:17clojurebotbook is books
00:17brainacid~book
00:17clojurebotbook is http://www.pragprog.com/titles/shcloj/programming-clojure
00:19brainacid~book
00:19clojurebotbook is http://www.pragprog.com/titles/shcloj/programming-clojure
01:18jinagaranoi want t build an h2 database to use with korma. i set up a migration file for ragtime that builds the tables "students," "teachers," "guests," "contact-details," "emergency-contacts," and "address." how do i define the relationship between them? eg students should have an address, contact details, and an emergency contact; emergency contacts should have only contact details; and teachers will have an address and contact details, bu
01:19EvanRadios
01:19justin_smithjinagarano: the end of your question was cut off, because the question was too long
01:19jinagaranojustin_smith: where did it cut off?
01:19justin_smith; and teachers will have an address and contact details, bu
01:20jinagarano but no emergency contacts.
01:22justin_smithjinagarano: the typical approach is to have a unique ID column on each table, and then and have fields in other tables with content that points to those ids, and use the id field for a join on the tables in your query
01:26jinagaranojustin_smith: if i understand you right, I create tables in SQL and nothing more; i create table entities in korma to match, and don't use "belongs-to" or "has-many" right? i create all linking in the functions that query my db.
01:27justin_smithjinagarano: I believe so, with h2 at least
01:27justin_smithmaybe korma has something higher level that you want to use though
01:29justin_smithjinagarano: for many to many you would actually want a separate table, with an a_id column and a b_id column to create each of the cross table relations
01:29justin_smithsince having one refering id on each would not suffice, of course
01:30jinagaranofrom korma docs:
01:30jinagarano;; Relationships
01:30jinagarano(has-one address)
01:30jinagarano;; assumes users.id = address.users_id
01:30jinagarano(has-many email)
01:30jinagarano;; assumes users.id = email.users_id
01:30jinagarano;; but gets the results in a second query
01:30jinagarano;; for each element (belongs-to account)
01:30jinagarano;; assumes users.account_id = account.id
01:30jinagarano(many-to-many posts :users_posts))
01:30jinagarano;; assumes a table users_posts with columns users_id
01:30jinagarano;; and posts_id
01:30jinagarano;; like has-many, also gets the results in a second
01:30jinagarano;; query for each element
01:30justin_smithjinagarano: do not do that
01:30justin_smithuse a paste site like refheap.com, or provide a link to the source on github
01:30justin_smithplease
01:31jinagaranook sure, sorry
01:31jinagaranoi think i know how to do it now, thanks
01:31justin_smithjinagarano: yeah, I didn't see you mention korma at first, and I am not as familiar with that, but if you are using korma it looks like those are the functions you would want
01:31justin_smithcool
01:32justin_smithjinagarano: but do notice that those are query functions - they assume those tables / fields I mentioned above exist already
01:32justin_smithbut yeah, you should have a clear idea of how to make those columns / tables now
01:49jinagaranohow do i set up ragtime and h2 for migrating?
01:52justin_smithif you are using clojure.java.jdbc, it shouldn't be different from using any other db backend I don't think
01:53justin_smithhttps://github.com/weavejester/ragtime/wiki/Getting-Started just use the apropriate jdbc url
02:03drorbemetHi, do you know how to create a new namespace together with a new file and folders in a single command in emacs in a clojure project?
02:06justin_smithdrorbemet: specify the full path that reflects the namespace you want to create (even if some subdirectories don't exist), then M-x make-directory and the default option if you hit return is to create all the parent directories for that file
02:07justin_smithdrorbemet: when I say "specify the full path", do it as a file open, it will create a new file if the file you attempt to open does not exist
02:09drorbemetjustin_smith: ok, that's the first step, but I didn't find a "create new namespace" command, I just want to make shure that I don't miss somthing before I write an elisp function or a yasnippet
02:12justin_smithdrorbemet: there is a function to insert an ns declaration
02:12justin_smithand that is automatic based on the file name
02:13drorbemetjustin_smith: oh, there is?! great
02:22drorbemetjustin_smith: cljr-refactor contains an example, cljr-move-form is what I was looking for, thanks
03:06zactshum.. I'm looking for a book that teaches functional programming really well, and in a down to earth way, that I could apply directly to clojure
03:07SagiCZ1zacts: little schemer perhaps?
03:07zactshum.. yeah I own that book, but I'm thinking something more textbook style, yet still down to earth
03:07SagiCZ1down to earth as in easy to understand?
03:07zactsyeah
03:07zactsperhaps not quite so academic as SICP
03:07SagiCZ1i liked this one http://shop.oreilly.com/product/0636920013754.do
03:07codestorm777functional thinking, maybe
03:07zactsI hope to get through SICP, but that might take months to digest
03:08zactscodestorm777: is that a book?
03:08zactsSagiCZ1: oh cool, yeah I plan to read that too
03:08codestorm777yes, o’reilyy, it’s also a video series
03:08zactsoh neat. I'll check it out
03:09SagiCZ1the oreily book has some thoughts about how to make your programs more abstract shown on examples
03:10zactsoh cool
03:13zactshm.. I can't wait until the grokking functional programming by manning press is out
03:13zactsthat's kind of what I'm looking for
03:13zactsexactly too
03:13clojurebotI don't understand.
03:16ro_stany logback pros in the room? i need to log a specific set of namespaces to a different output file without it going to the file that the rest of the namespaces go to
03:43acron^morning
03:43acron^new clojurist here; if anyone's got the time, i'd appreciate some feedback on style and form - https://github.com/acron0/fae-scraper/blob/master/src/fae_scraper/core.clj
03:43slipsetdepends on your timezone, I guess
03:44SagiCZ1acron^: i also have morning.. good morning
03:44acron^:)
03:44acron^good [morning|afternoon|evening] then...just in case
03:44SagiCZ1acron^: maybe move to comments into the fn? you know if you add string after the arg list it is a regular doc
03:45SagiCZ1(doc take)
03:45clojurebot"([n] [n coll]); Returns a lazy sequence of the first n items in coll, or all items if there are fewer than n. Returns a stateful transducer when no collection is provided."
03:45SagiCZ1like this
03:45acron^ahh
03:45acron^(defn foo [x]
03:45acron^"comments here"
03:45slipsetlines 19 and 26, pull out in functions?
03:46SagiCZ1,(defn foo [x] "comments" x)
03:46clojurebot#'sandbox/foo
03:46acron^got it
03:46SagiCZ1also consider putting the arg list on a new line if it is longer.. depends on your taste though
03:46acron^slipset: you mean separate it more?
03:47slipsetalso, I'm not to enthused about prefixing functions as in "fae", but YMMV
03:47acron^is there a convention?
03:47slipsetacron^:yes especially the anon-function in line 26. Imagine you wanted to test that...
03:47acron^i guess all the funcs are namespaced so no need for a prefix >
03:48Glenjaminisn't it docstring before arglist? i always get mixed up :s
03:48slipsetacron^: I kind of like writing functions so that I can do the following:
03:48SagiCZ1Glenjamin: docs after arglist
03:48Glenjamin,(doc foo)
03:48clojurebot"([x]); "
03:48acron^whats the 'feel' on anon functions? good? bad?
03:48SagiCZ1slipset: i wouldnt extract that.. if it is the only place where he uses it.. he could test the whole function
03:48slipset,(map (partial + 1) [1 2 3])
03:48clojurebot(2 3 4)
03:48SagiCZ1acron^: they are perfectly idiomatic
03:48Glenjamin,(defn foo "comments" [x] x)
03:48clojurebot#'sandbox/foo
03:48Glenjamin,(doc foo)
03:48clojurebot"([x]); comments"
03:48Glenjaminit's docstring before arglist.
03:49acron^:o
03:49SagiCZ1Glenjamin: indeed.. my bad
03:49acron^,(defn bar [x] "test" x)
03:49slipsetSagiCZ1:I would, since then I could give the funciton a name, which kind-of documented what it did.
03:49clojurebot#'sandbox/bar
03:49acron^,(doc bar)
03:49clojurebot"([x]); "
03:50SagiCZ1slipset: i absolutely hate extracting something just to give it a name.. it fractures the code.. but i understand it is a matter of opinon..
03:50slipsetThat way I didn't have to try to figure out what (assoc
03:50slipset (:attrs %)
03:50slipset :desc (:alt (:attrs (first (:content %))))) was trying to achieve
03:50SagiCZ1slipset: in this case it would help i guess
03:51slipset:)
03:51acron^on line 43, I have a dissoc and and assoc
03:51acron^is there a better way to reformat a dict?
03:51SagiCZ1acron^: yeah i dont like that line very much.. try to keep the line shorter
03:51slipsetacron^: in line 43 you deffo want a ~doseq
03:52slipset~do-seq
03:52clojurebotIt's greek to me.
03:52hellofunkif you have trouble remembering if comments come before or after arglists, just remember how multi-arity fns are structured. it's one comment for the function, regardless of the number of arity implementations.
03:52SagiCZ1~doseq
03:52slipset~doseq
03:52clojurebotdoseq is like for, but for side effects instead of values
03:52clojurebotdoseq is like for, but for side effects instead of values
03:52slipsetThanks SagiCZ1,
03:52acron^hmm]
03:52SagiCZ1hellofunk: yeah actually i would prefer if i could comment each arity separately..
03:52slipsetanyways, the println in 43 will not print the whole thing since map is lazy
03:53SagiCZ1slipset: print forces the evaluation
03:53acron^not sure I understand do-seq but I'll have a play
03:53hellofunkSagiCZ1: no, because the idea is that the function as a whole is a single function -- which it is, so it should have a single unified purpose. therefore, one comment for the function.
03:53SagiCZ1,(println (map inc (range 99)))
03:53clojurebot(1 2 3 4 5 ...)\n
03:54SagiCZ1hellofunk: yeah but then i have to specify all the arities in the one docstring
03:54hellofunkacron^: doseq is just like for. the only difference is that for generates a lazy seq while doseq makes side effects like printing, etc. if you understand for, you understand doseq. study for first.
03:54hellofunkSagiCZ1: of course but then when an editor gives docstring hints, it doesn't have to know in advance which version of the fn you will use to tell you how the fn works.
03:55slipsetand SagiCZ1 is of course totally correct wrt println, my bad
03:55SagiCZ1hellofunk: makes sense.. okay
03:56hellofunkalso key thing to note is that doseq always returns nil. so right there you know it's not designed for generating a sequence but rather doing something off in the world instead.
03:56acron^ahhh
03:56acron^i get it
03:57acron^:)
03:57slipsetin fae-get-image-from-image-page
03:57slipsetcould you just continue your threading?
03:57clojurebotExcuse me?
03:57SagiCZ1acron^: your map achieves the same thing as doseq but doseq clearly states your intention to not collect the result into a collection
04:01jinagaranoi'm trying to build an h2 db and use it via korma. when i compile, i get an error "unable to resolve symbol defentity." why? i added korma as a dependency in project.clj and put (use 'korma.db) in the source file.
04:04acron^slipset: can you expand on that?
04:06slipset (s/id "content-image"))
04:06slipset page)
04:06slipset (first)
04:06slipset :attrs
04:06slipset :data-src)
04:08slipsetalso, in line 15, you could use def and comp, I guess, instead of defining your own function.
04:09TEttingerslipset: defn has the advantage of being able to add a docstring
04:09TEttingernot sure if you can do that with comp
04:10slipset(def fae-get-list-page (comp get-page-as-hickory format))
04:11slipsetor is it the other way around, I can never remember
04:12slipset~def
04:12clojurebotexcusez-moi
04:13TEttinger,(doc def)
04:13clojurebotTitim gan éirí ort.
04:13slipset,(def ted-nugent "The nuge rocks" 123)
04:13clojurebot#'sandbox/ted-nugent
04:13TEttinger(doc def)
04:13clojurebotCool story bro.
04:13TEttingerha
04:13TEttinger,ted-nugent
04:13clojurebot123
04:13TEttinger,(doc ted-nugent)
04:13clojurebot"; The nuge rocks"
04:13TEttingernice
04:14acron^,(doc comp)
04:14clojurebot"([] [f] [f g] [f g & fs]); Takes a set of functions and returns a fn that is the composition of those fns. The returned fn takes a variable number of args, applies the rightmost of fns to the args, the next fn (right-to-left) to the result, etc."
04:14acron^aha
04:15slipsetI guess the threading macros and comp are somewhat related in terms of functionality
04:15acron^just to be totally clear
04:15acron^-> is a threading macro ?
04:15ziltislipset: But threading macros work left-to-right
04:15SagiCZ1acron^: yes
04:15slipsetbut since the threading macros, are well, macros, you can't pass them around
04:16slipsetlike you can with functions
04:16ziltislipset: you could pass around #(-> % whatever fns (you use))
04:16acron^so whats the impact of using a thread procedurally like in fae-get-image-from-image-page, line 33?
04:16TEttinger,(apply str (map (comp char (partial + 64)) [3 1 20]))
04:16clojurebot"CAT"
04:17acron^it's explicitly lazy?
04:18TEttingerthat fae- stuff seems really C-style to me... the JVM always has namespaces/packages, you aren't going to have name collisions unless you :use or :require with :refer :all
04:18slipsetacron^: I'm on a bit of deep water here, but line 33 gets rewritten at compile time.
04:18acron^TEttinger: unsurprising, I'm a C programmer, new to Clojure :)
04:18TEttingerheh
04:18slipset,(-> 1 (+ 3))
04:18clojurebot4
04:19slipsetgets rewritten by the macro expander to
04:19slipset,(+ 1 3)
04:19clojurebot4
04:19acron^slipset: this code is adapted from hickory examples so I guess I dont see the benefit of the thread here
04:19zilti,(macroexpand-1 '(-> 1 (+ 3)))
04:19slipsetat compile-time, not at run time
04:19clojurebot(+ 1 3)
04:19SagiCZ1acron^: by "threading" we dont mean actual OS thread.. its just an expression that says that the following s-expression get rewriten into the familiar nested structure (..(..(..(..))) .. there is no overhead or speeed impact
04:19TEttinger,(-> 1 (/ 3))
04:19clojurebot1/3
04:19TEttinger,(->> 1 (/ 3))
04:19clojurebot3
04:20acron^SagiCZ1: ah, that's an important detail
04:20TEttingergood to know about ->> , which puts the threaded arg in the last position
04:20ziltislipset: It's important to note though that macros *are* available at runtime
04:20slipsetthere is also some-> which is quite nice
04:20SagiCZ1acron^: threading as in putting a thread through the needle.. i guess you are not native speaker?
04:20TEttingerSagiCZ1, it tripped me up too the first time I heard of a threading macro
04:21acron^SagiCZ1: not native clojure speaker :) i just assume threading/threads means OS threads/coroutines
04:21acron^assumed*
04:21SagiCZ1yeah okay i guess it's strange even for native speakers.. but yeah it took me some time to understand what it meant
04:22acron^,(-> 10 (- 5))
04:22clojurebot5
04:22acron^,(->># 10 (- 5))
04:22clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: ->># in this context, compiling:(NO_SOURCE_PATH:0:0)>
04:22acron^,(->> 10 (- 5))
04:22clojurebot-5
04:22zilti,(macroexpand-1 '(->> 10 (- 5)))
04:22clojurebot(- 5 10)
04:23acron^,(macroexpand-1 '(-> 10 (- 5)))
04:23clojurebot(- 10 5)
04:23acron^magic
04:23SagiCZ1acron^: also check out 'doto' which is commonly used with java interop
04:23zilti,(source ->) ; I wonder if that works
04:23clojurebotSource not found\n
04:23SagiCZ1(source ->)
04:24acron^guys, you've been really helpful thanks
04:25slipsethttps://github.com/clojure/clojure/blob/clojure-1.6.0/src/clj/clojure/core.clj#L1558
04:25alexyakushevLike Heisenberg said to Hank when he used too many parentheses: "Thread lastly"
04:25alexyakushevOr was it "Tread lightly"? We'll never know
04:27slipsetacron^: Jay Fields writes nicely on the usage of comp and partial, worth a read http://blog.jayfields.com/2011/01/clojure-partial-and-comp.html
04:28acron^thanks slipset, I shall
04:29SagiCZ1i always think whether i should use partial.. when the #( .. ) construct takes much less space..
04:29SagiCZ1partial is also sensitive to the arg order..
04:29Glenjaminpartial doesn't generate a class, if that's important to you
04:29SagiCZ1#() does?
04:30slipsetSagiCZ1: http://blog.jayfields.com/2011/01/clojure-partial-and-comp.html
04:30slipsetcrap, wrong link
04:30slipsetSagiCZ1: http://blog.jayfields.com/2013/05/emacs-lisp-font-lock-for-clojures.html
04:30SagiCZ1beware of your clipboard!
04:31slipsetl guess I was lucky this time.
04:31slipsetSagiCZ1: re arg order, I tend to like to build my functions such that they fit with partial
04:31SagiCZ1slipset: oh yeah.. or using an actual lambda symbol for 'fn' .. i saw that in the core.async talk... anyway i will have to ask cfleming if something like that is possible in cursive
04:32SagiCZ1slipset: yeah.. 3rd party fn dont always work well though..
04:32slipsethaving said that, I really wish there was a (reverse-args f) function in clojure
04:34Glenjamin(defn reverse-args [f] (fn [&args] (apply f (reverse args))))
04:35slipsetGlenjamin: cool! stuff is so simple in Clojure
04:36SagiCZ1slipset: ugh.. not always sadly.. i always struggle rewriting loops into higher order functions like reduce, iterate etc.. i dont always end up with better code
04:38slipsetSagiCZ1: I don't think I've hardly written a loop in Clojure, apart from in a, well, go-loop
04:38SagiCZ1slipset: wow.. well you need to teach me your ways
04:38acron^i doubt anyone here can claim to be the perfect programmer SagiCZ1 :)
04:38slipsetSagiCZ1: :)
04:39SagiCZ1slipset: loops like this give me trouble https://www.refheap.com/96481
04:40clgvSagiCZ1: seems to be more of an `iterate` - but there is no eager version of `iterate`
04:41clgvah well recursion itself ;)
04:41Glenjamincould write as (reduce) using (reduced), but (loop) seems fine for that
04:41SagiCZ1Glenjamin: well.. thats the thing.. is the loop fine or should i always try to get rid of it?
04:41Glenjaminis it causing you a problem at the moment?
04:42SagiCZ1nope
04:42Glenjaminthen i'd say it's fine
04:42SagiCZ1i just dont want to anger clojure gods
04:42clgvSagiCZ1: if you have that patternmore often you can write a fitting higher order function
04:43SagiCZ1clgv: function or a macro?
04:43clgvSagiCZ1: depends on the details, probably function
04:44slipsetSagiCZ1: you got me, I'm not even clever enough to see what this is doing.
04:44SagiCZ1slipset: it just executes steps updates w and b.. and when e (error) is zero it exits
04:48slipsetSagiCZ1: would something like (take-while p (partition 3 (repeatedly (partial rand-int 3))))
04:49slipsetbe something you could imagine?
04:49slipsetwhere p is your step and if-test combined?
04:50SagiCZ1possibly
04:50SagiCZ1thanks for the idea
04:52clgvSagiCZ1: though you will sacrifice speed by rewriting the loop with lazyseq
04:52SagiCZ1so there is not much to gain apart from maybe having nicer,, shorter code
04:53clgvyeah, but then try `iterate` with a surround `take-while`
04:53clgv*surrounding
04:54SagiCZ1clgv: i used that construct elsewhere in my project to replace similar loop... i am using atoms to track progress of the loops.. and in the iterate case it was kinda hard to do
04:55clgvSagiCZ1: I just recommeded it since it matches the semantics of your snippet pretty closely
04:55SagiCZ1clgv: yep.. true
05:32zarkonehello all. When i use REPL with clojurescript, cider-jump-to-var doesn't work. Am I do something wrong or it's not possible for now?
05:42jinagarano i'm trying to build an h2 db and use it via korma. when i compile, i get an error "unable to resolve symbol defentity." why? i added korma as a dependency in project.clj and put (use 'korma.db) in the source file.
05:44zactswhere can I get a list of supported clojure platforms? Well, perhaps that's a naive question, is it supported fully by all plaforms that support the jvm fully?
05:45jinagaranozacts: yes, that's the point.
05:45samiswellcooljinagarano: defentity is in korma.core
05:45zactsjinagarano: ah cool
05:46jinagaranosamiswellcool: stupid question maybe; where do i put korma.core in my project? i'm new to all this, it's probably obvious.
05:46samiswellcooljust another use statement (use 'korma.core)
05:46samiswellcoolor in your namespace (ns whatever.whatever (:use korma.core))
05:47jinagaranosamiswellcool: brillitant, thanks. does a dependency get the files from github/wherever, and make them available in my project?
05:49samiswellcoolit gets them from clojars I think, but basically yes
05:49samiswellcoolthen you have to include them as needed in individual files
05:51TEttingerzacts: I think clojure is compatible with anything that supports Java 6 or higher. Might be as low as 5.
05:51zactsTEttinger: cool
05:51zactsI'm just curious how well it runs on FreeBSD / OpenBSD
05:51zactsI'm considering switching OS on one of my laptops
05:52TEttingeralmost certain it will run there, not sure if you have access to an Oracle JDK on there
05:52jinagaranoto expand on the fundamentals - where can i find the h2 db file? i built it with a ragtime migration, and i think i have to link it with korma via (def h2-db (h2 {db :/....})) - right? well, i can't find the file i created.
05:52zactsTEttinger: I usually use OpenJDK
05:52zactsis that fine for clojure?
05:52TEttingeryep!
05:52zactsok neat! :-)
05:54TEttingerI wrote a lein plugin to package clojure apps with a standalone JVM, no installation required, using the Packr library. It downloads a pre-made OpenJDK 7 distribution for mac, windows, and/or linux, and assembles an uberjar into one exe with the JVM in a directory next to it
05:54TEttingerit's a total hack but does work fine with OpenJDK
06:08clgvTEttinger: zacts: it is Java 6 for Clojure 1.6
06:08zactsoh cool
06:08clgvthe versions before 1.6 required only Java 5
06:17GlenjaminTEttinger: sounds similar to capsule
06:17TEttingerprobably!
06:17TEttingerPackr is meant for games, primarily
06:17Glenjaminoh, not quite
06:17Glenjaminhttps://github.com/puniverse/capsule "Have your JAR automatically choose an appropriate JVM version, set JVM flags, and add an embedded JAR to the boot class path."
06:18TEttinger"Java 9 is expected to have a mechanism for packaging stripped-down versions of the JVM."
06:19TEttingerinteresting
07:17SagiCZ1does anyone know how future-cancel works? it cancels toy examples easily but in the real case the thread keeps going even though future-cancel returned true
07:17Glenjamin$source future-cancel
07:17lazybotfuture-cancel is http://is.gd/Z4YWxl
07:18Glenjaminwelp, that wasn't very helpful
07:19SagiCZ1i was thinking that it probably needs Thread.yield() somewhere to be able to cancel itself..
07:19clgvSagiCZ1: you cant really use it to reliably stop something that is already processed by a thread. but queue futures should be canceled correctly
07:20SagiCZ1what is a reliable way to stop the thread then? i see it in every single application.. long running tasks can be cancelled with the cancel button
07:20clgvSagiCZ1: you need some predicate (keep-running? ...) in your processing loop
07:20SagiCZ1clgv: no other way? thats just awful.. why cant jvm just kill the thread
07:21clgvSagiCZ1: just google that, there are a lot of discussions ;)
07:22clgvSagiCZ1: the magic of clojure could ease the pain. you write a `stopable` macro that does the check almost transparently.
07:22SagiCZ1clgv: yeah.. or maybe use the deprecated stop() method
07:23clgvSagiCZ1: and achieve nothing?
07:23SagiCZ1clgv: and see this is where i run into problems.. some of my tasks are loops.. ok they could be dealt with.. but some of them are long running HOF like iterated, reduce etc.. i would have to add the checking mechanism to so many places..
07:24cflemingSagiCZ1: You want your code to catch InterruptedException, generally
07:25cflemingSagiCZ1: Then whatever is doing the stopping can interrupt your thread and you can handle it gracefully.
07:25SagiCZ1cfleming: would it raise the exception? i though i would need to check isInterrupted() ..
07:25SagiCZ1my future code is already wrapped in try catch and doesnt throw any exception when i call future cancel
07:25cflemingSagiCZ1: The Java concurrency primitives check it at various points so you generally don't have to. If the primitives Clojure uses under the hood don't then you'll have to do that yourself, yeah.
07:26SagiCZ1cfleming: yeah i am not using any concurrency primitives
07:26cflemingSagiCZ1: Sure, but Clojure is on your behalf.
07:26SagiCZ1well thats just such a bummer.. i thought clojure would have some better mechanism to deal with this madness
07:26clgvhttp://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#interrupt%28%29
07:27clgvcfleming: seems that exception is just thrown in pretty specific cases
07:27SagiCZ1so we have all these futures and promises and delivers and it just all falls back on the primitive java threads which cant be even reliable stopped..
07:28cflemingclgv: Yeah, but those cases are actually pretty common. If your code is in a tight loop you'll have to check it yourself, but often you'll finish a bit of work, check a queue or something for more work and get the exception.
07:29clgvcfleming: the tight loop scenario seems to be the use case of SagiCZ1
07:29cflemingSagiCZ1: You can't stop a thread reliably, right. But the concurrency primitive do provide good (if non-obvious and tricky) ways to do it.
07:30SagiCZ1so yeah.. my previous solution was to have an atom called progress.. which was repeatedly checked and when someone from the outside set the value to negative, the thread would immediately stop and return.. i thought future cancel would help me avoid writing the atom checks.. btu i guess i have to go back
07:31cflemingSagiCZ1: http://stackoverflow.com/questions/13623445/future-cancel-method-is-not-working
07:31cflemingSagiCZ1: And http://docs.oracle.com/javase/tutorial/essential/concurrency/interrupt.html
07:31SagiCZ1cfleming: so if i added Thread/yield everywhere it should throw the exception?
07:32SagiCZ1yield is basically 0ms sleep
07:33SagiCZ1nope.. doesnt throw exception
07:33cflemingSagiCZ1: I would check the thread interrupted flag
07:33SagiCZ1and then throw the exception?
07:33cflemingOr exit your loop, or whatever you need to do, yeah
07:33clgvSagiCZ1: from the javadoc of yield "It is rarely appropriate to use this method."
07:34SagiCZ1well that javadoc can bite me!
07:34SagiCZ1:D
07:34clgvSagiCZ1: the remaining description suggest that it is not what you want anyway
07:34SagiCZ1(Thread/sleep 0) works.. if i call future-cancel it throws sleep interrupted exception which i can handle
07:35SagiCZ1so just add the sleep to every task and it should work
07:35cflemingSagiCZ1: yield (IIRC) was to allow your thread to try to give up its runnable status and allow it to be rescheduled. It's an obsolete method to try to influence thread priorities
07:35cflemingSagiCZ1: Seriously, just check the interrupted flag and throw the exception
07:35cflemingThat's what it's for
07:36SagiCZ1okay.. i can wrap that into a function so thats ok
07:36cflemingUsing Thread/sleep will have other effects that you may not want, like affecting the scheduler
07:36SagiCZ1thank you very much guys..
07:37cflemingSagiCZ1: If you can get a copy, Java Concurrency In Practice is the bible for this stuff, it's a really great book.
07:37SagiCZ1cfleming: I am learning clojure so I could avoid Java convoluted concurrency mechanisms..
07:37cflemingSagiCZ1: The first five chapters (IIRC) give a great background.
07:37SagiCZ1but i guess i will have to learn it one day
07:37cflemingSagiCZ1: Yeah, but sometimes you just have to know what's going on
07:39clgvSagiCZ1: You have to embrace the host platform my young padawan. ;)
07:40SagiCZ1clgv: hehe :)
07:40SagiCZ1cfleming: on a completely unrelated note.. do you think Cursive would be able to replace some common core function names with greek symbols? some people use this in emacs.. for example they use lambda symbol for 'fn' etc.. just visually, not internally
07:43cflemingSagiCZ1: Yeah, it should be possible to use code folding for that
07:43SagiCZ1what is that?
07:44cflemingSagiCZ1: To be honest though, it's going to be a very low priority since I've never really seen the point
07:44SagiCZ1cfleming: yeah i thought so
07:45cflemingSagiCZ1: That when IntelliJ allows you to fold code, like top-level forms. Their engine is actually pretty powerful, so it gets used for a lot of other things, e.g. in Java they hide new HashMap<SomeBigLongThing>() as new HashMap<~>()
07:46SagiCZ1oh i know what that is.. ok
07:46cflemingSagiCZ1: It basically does what you're asking about. I'm going to use it in the REPL to fold stacktraces, so it'll automatically fold non-Clojure items, or items that aren't in your project, or something similar
07:46cflemingSagiCZ1: so they'll be hidden, but you can click or hover to see them
07:47SagiCZ1cfleming: yeah thats a great idea with the task traces..
07:51cflemingSagiCZ1: So, to answer your original question - it's possible but it's unlikely to happen unless a lot of people suddenly ask for it.
07:51SagiCZ1cfleming: understandable
07:52clgvcfleming: does cursive provide a plugin api? then he could implement it himself...
07:52SagiCZ1cursive is meant to be stand-alone.. so maybe then
07:53cflemingclgv: Not yet - it'll provide an extension API, but I'm not sure this would be something you'd be able to achieve with it, at least initially. Someone could always do it as an IntelliJ plugin.
07:58slipsetSagiCZ1: You've probably considered it, but how 'bout using core.async to solve your problem
07:58slipsetThere is this example floating around, I think in a tbaldridge talk using alts! to choose from diffent channels, one of them being a timeout channel
07:59SagiCZ1slipset: yeah it would probably solve it... i started this project before i knew about core.async and this is just a finishing touch so i dont want to rewrite it all.. i actually solved the problem quite gracefully with what guys suggested here
07:59slipsetcool!
08:00jinagaranoif i make an h2 db with ragtime migration, where is the resulting file? i want to build a korma layer on top of it and can't figure out how to link them.
08:22EmpperiHOLY SHIT http://www.itworld.com/article/2875112/ibm-is-about-to-get-hit-with-a-massive-reorg-and-layoffs.html
08:23EmpperiIBM fires 111 800 people by the end of February
08:23Empperiand no, that number is not a typo
08:24hyPiRion"IBM fires 1/3 of Iceland"
08:25Empperithose numbers are just staggering
08:25Empperiseveral cities are going to shake with their economies after this
08:25hyPiRionIs IBM mainly located in the US?
08:26Glenjamini'm aware of lots of UK offices
08:26Empperiit's very much global company
08:26xemdetiahyPiRion, hardly.
08:26Empperithere are several offices in Finland too
08:27hyPiRionThen it's probably not as bad of a hit for the cities
08:27Empperireally?
08:28Empperiwhen Lehman Brothers bancrupted 26k people lost their jobs
08:28Empperithat with the debt fiasco led to current economic situation
08:28Empperino four times more people gets fired at once
08:28Empperithat's going to have some serious impact into economy world wide unless those people find new jobs and fast
08:29hyPiRionWell, I'm hanging out in #clojure, not #economics. Go figure :p
08:29Glenjaminthere's no shortage of programming jobs, just because IBM is failing doesn't mean people won't be snapped up by other companies
08:29SagiCZ1Empperi: IBM is all over the world
08:29EmpperiSagiCZ1: that's what I said?
08:29SagiCZ1Empperi: so the impacted is spreaded out
08:30SagiCZ1milions of people lose their jobs every year
08:30Empperiyes but not at once and on one industry at the same time
08:30SagiCZ1i doubt couple thousand people losing their jobs caused global economic crisis
08:30xemdetiaEmpperi, IBM is not a stranger to deep cuts like that.
08:30Empperiyes, they hold the previoius record
08:31daniel___its the apocalypse
08:31Empperiif there's some people here working for IBM I feel for you guys
08:32zactsok, back to clojure now
08:32EmpperiGlenjamin: IBM does a lot of other stuff too than just programming. Actually most of the layoffs are directed to people not doing programming
08:32Glenjaminah :(
08:32Empperiold mainframe guys, storage unit etc
08:33Empperibusiness-wise a good move
08:33SagiCZ1IBM's services are expensive and useless nowadays.. this was to be expected
08:33Empperibut the impact will be felt, badly
08:33EmpperiSagiCZ1: yeah
08:33SagiCZ1Empperi: doubt it.. maybe locally in the specific areas
08:33Empperitheir attempts to become a cloud provider have been abysmal
08:34Empperibut yeah, back to clojure now.
08:34Empperithat was just such a huge news I wanted to share it here
08:44Empperioh, btw to the IBM news: "Most of the layoffs will happen in the US, but some international operations will be affected as well"
08:44Empperihttp://www.cultofmac.com/310012/ibm-prepares-largest-corporate-layoff/#uqtJmQqlX00Ar9kG.99
08:44hyPiRionalright, that might be pretty bad
08:45Empperimost likely the worst hit is centered around few US cities
08:46yguantrying to be familiar with core.async. why should the following fail?
08:46cfleminghttps://news.ycombinator.com/item?id=8944999 "Cringely has made dooms day predictions in the past that were widely innacurate"
08:46yguan(let [c (chan)]
08:46yguan (go
08:46yguan (print (<! c)))
08:46yguan (go
08:46yguan (let [f (fn [v]
08:46yguan (>! c v))]
08:46yguan (f "ab")))
08:46yguan (Thread/sleep 100)
08:46yguan (close! c))
08:46dnolenyguan: use a pasting service please :)
08:47SagiCZ1yguan: replace thread/sleep with (<! (timeout 100))
08:47tbaldridgeno, the issue is that you can't use >! and <! outside of a go
08:47yguandnolen, ehh i'll figure out pasting :)
08:47tbaldridgeand go blocks stop translating at any call to (fn [...] ....)
08:47SagiCZ1tbaldridge: he doesnt have them outside of go
08:47SagiCZ1oh
08:47SagiCZ1nvm\
08:48yguantbaldridge, I see, feel a bit black magic here...
08:48tbaldridgethere'
08:49tbaldridgego blocks are basically nothing but black magic, elven herbs, and dwarven runes
08:50gfredericksstop blocks on the other hand just call System/exit, plain and simple
08:50hyPiRionthose dwarven FSMs
08:51tbaldridgeyguan: any async translation compiler like core.async, or C#'s async/await is going to have a few caveats, it's just the way the tech has to work if you don't want to transform your entire program
08:51dnolenyguan: supporting only shallow yield is a pretty common thing actually
09:08thhellerdnolen: whats the policy for upgrading closure compiler + library for CLJS? It's been about 6 months
09:09dnolenthheller: just someone testing it to make sure it doesn't break everything, it's happened before
09:09dnolenthheller: more recent versions of Closure busted browser REPL, not sure if this has been addressed in a release
09:10thhellerok thx, will see if I can do some tests
09:13stuartsierrathheller: G.Closure compiler releases are on search.maven.org; there are scripts in the ClojureScript tree to build JARs of the G.Closure library.
09:47thhellerdnolen: why is the :externs key outside :foreign-libs? I think it should be coupled with the foreign-lib?
09:47_KryDos_Hi guys. I'm learning Clojure and I need a little help. Could you please explain me the difference between (future) and (.start (Thread. ...))? And could you please give me information when I can search for answers on the similar questions. Thank you
09:47_KryDos_s/when/where/ - sorry
09:48thhellerdnolen: suppose I have a deps.cljs for with a couple of foreign libs where some might be included and some not. a "global" externs might not be available
09:49dnolenthheller: that's just because it's the expected shape of the build description, that is, it worked this way before, this hasn't changed in 3 years. otherwise more processing required
09:50dnolenthheller: I don't have a problem with allowing :externs per lib but will need a patch for that
09:51stuartsierra_KryDos_: `future` returns a java.util.concurrent.Future, from which you can get the value returned by the code inside it.
09:51thhellerdnolen: ok, was thinking of building a package for codemirror. there is a whole bunch of optional stuff in it, wiring all of it up via provide/require is gonna take some effort though
09:51stuartsierra_KryDos_: `future` uses a thread from a cached thread pool which Clojure maintains internally.
09:51thhellerdnolen: will see how far I get
09:52thhellerdnolen: pretty sure some of the addons require their own externs. thats why I'm asking
09:57_KryDos_stuartsierra: thank you so much for the answer
09:57stuartsierra_KryDos_: You're welcome.
10:05dysfunstuartsierra: just wanted to say thanks for building component. it seems like a nice way of building apps
10:05stuartsierradysfun: thanks!
10:05dysfunalthough it'd be even better if you didn't fully qualify it with com.stuartsierra
10:05dysfun:)
10:06stuartsierradysfun: I'm not going to try to claim ownership of the word "component" at the global Clojure namespace level.
10:06hyPiRionoh no, 16 more characters per require
10:06dysfunah, point :)
10:06justin_smithSagiCZ1: regarding future-cancel - it won't stop the thread unless it is blocking in specific contexts (which are frequent places to catch it but not guaranteed). You can check (.isInterrupted (Thread/currentThread)) to see if your thread has been cancelled, and use that as a conditional before looping
10:07dnolenthheller: right, happy to take a patch for this - should only need to touch a few bits of code to make it work
10:07stuartsierraAnd I don't like names that have nothing to do with what the code actually does.
10:07SagiCZ1justin_smith: and if i call the future-cancel it flips the interrupt flag so at any time after that point if i ask isInterrupted it would always return true, correct?
10:07justin_smithright
10:08justin_smithand like I said, if the thread was eg. blocking on a read, it would be stopped automatically as well
10:08justin_smithbut as you saw, that is not something you can always count on
10:09hyPiRionjustin_smith: huh? A thread blocking on a read cannot be interrupted before it actually receives some data.
10:09SagiCZ1justin_smith: okay.. yeah i wrapped the isinterrupt check into a simple function whcih throws an exception.. then i catch the exception much higher in the hierarchy where i can deal with resetting progress bar etc.. its good because the exception propagation is automatic and no extra code is required.. overall i am after all pretty happy with the solution
10:09justin_smithhyPiRion: hmmm... let me double check my source
10:09hyPiRionjustin_smith: http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4514257
10:10hyPiRionYou can't assume you can at least.
10:11justin_smithhyPiRion: I was going by this http://docs.oracle.com/javase/8/docs/api/java/lang/Thread.html#interrupt--
10:12justin_smithbut now I see that is specific to wait, IO on InterruptibleChannel s and Selector
10:14justin_smithbut regardless, of course, best to explicitly check interrupted status if you want future-cancel to actually work
11:39thhellerdnolen: think we should support :source-map for :file-min in foreign-libs? some js libs provide source maps. not sure how that would work if we merge the :file-min into the build though
11:59dysfuni need to do live video encoding. anyone know what the state of tools for clojure is?
12:06clgvs/clojure/java/
12:06TimMcdysfun: Probably nothing clojure-specific. Try Java-land.
12:06dysfunyeah, i've found jcodec and i'm pondering writing a wrapper
12:11TimMcDoes it need wrapping?
12:12dysfunanything that involves me writing lots of code using java method invocation syntax does, yes, for my sanity :)
12:21tbaldridgepersonally I'd try to keep as much of this out of the JVM as possible, and just do some sort of FFI wrapper around FFMpeg
12:21noncomdysfun: javacv is the option i think
12:21djames_I just posted a question about a challenge I'm facing with lots of nested functions that use destructuring to the ML. I find it convenient, but it makes memoization harder. I'm curious if others have faced this. I'm also interested in memoization.
12:21noncomi have a *very* positive experience with it
12:22djames_https://groups.google.com/forum/#!topic/clojure/RZE52iLY0oY
12:22noncomdysfun: worth noticing that javacv != opencv-for-java. it is much more. for example, it provides reach caps in playing and editing and converting video with ffmpeg
12:35aaelonyis conj.io down?
12:36puredangeryes, and arrdem is aware
12:36aaelonythx
12:41zactshum.. I'm finding I really prefer these two books the most: 0) brave clojure, and 1) O'Reilly Clojure Programming
12:46dysfunnoncom: ffmpeg sounds like JNI hell to me
12:46tbaldridgefor FFI stuff JNA is much easier and almost as fast.
12:48dysfuni'll give it a spin anyway
12:52hiredmanswig is nice
12:59noncomdysfun: not at all. ffmpeg is wrapped in javacv for you already
12:59noncomit works very well
13:00zactsI want to make a music composition app with clojure
13:00zactsand a visual composition app
13:01justin_smithzacts: you could look into kunstmusik/pink, it's from one of the lead csound devs
13:01zactsoh neato!
13:01zactsalso, how about ChucK?
13:01justin_smithit includes the signal processing stuff, and also higher level event processing too
13:02justin_smithChucK is novel
13:02devnhola
13:02zactsoh cool
13:02noncomdysfun: here are two files for you to start with: https://www.refheap.com/96496 , https://www.refheap.com/96497 - them are from my project where I use javacv to play video on a JMonkeyEngine texture
13:02justin_smithif you want to target a synthesis language, csound has the most built in stuff, and has the easiest syntax to generate I think
13:03zactsah ok
13:03justin_smithzacts: but with pink, you don't need to target another synth language, it implements its own in pure clojure
13:03zactsyeah, I'm a newbie in this regard
13:03noncomzacts: heeey, cojurists, do not forget http://overtone.github.io/ !
13:03zactsoh neat
13:03justin_smithyeah, overtone is an option too
13:03justin_smithit cheats by shipping supercollider in the jar :)
13:03justin_smith"cheats"
13:05noncomjava minim and beads libraries could come in handy too... depending on usecase..
13:07zactshow about visual programming art?
13:07zactslike fractals / designs / etc..
13:07zactsI think it would be cool to combine music with the visual aspect
13:08noncomzacts: i think that the simplest start for you would be with processing
13:08noncomzacts: https://processing.org/
13:09noncomzacts: and from the authors of overtone, here comes a clojuric processing wrapper for you: https://github.com/quil/quil
13:10zactsoh cool!
13:10zactsbrb, heading out for a sec
13:16sorenmacbethis it possible to write a macro that calls a java method dynamically? im dying here
13:17sorenmacbethsomething like (~meth ~obj ~val)
13:17sorenmacbethwhere ~meth is a symbol like .set_something
13:18puredangersure, although you'll probably want to use just . rather than .method I think
13:19puredangerso like (. ~obj (~setter ~value))
13:20puredangerI did something similar here: http://stackoverflow.com/questions/27308061/whats-the-idiomatic-way-to-do-this-java-function-in-clojure/27308254#27308254
13:27sorenmacbethpuredanger: yeah, like that
13:27sorenmacbeththat form didn't work fpr me when I tried it (at 2am)
13:28puredangerit doesn't work between 2-3 am
13:29chouserha!
13:30puredangerchouser implemented that
13:30stuartsierrachouser: long time, no see
13:32chouserstuartsierra: Hi!
13:38Glenjamindnolen: would it be fair to say the test.check ClojureScript port was "straightforward", i'm writing up some backstory on checkers ?
14:11sorenmacbethso that works, but not if you pass in symbols
14:12sorenmacbeth(set-fields my-map my-options)
14:12amalloysorenmacbeth: you have to use reflection. a macro can't do things "dynamically", because it emits code at compile time
14:13sorenmacbethamalloy: i was afraid you where going to say that
14:14dysfunnoncom: thanks :)
14:15sorenmacbeth(require '[clojure.reflect :as reflect])
14:15sorenmacbeth(def r reflect/reflect pv)
14:15sorenmacbethf
14:15sorenmacbethr
14:16sdegutisDoes Clojure have functors?
14:16justin_smithsorenmacbeth: are you trying to use the bot?
14:16sorenmacbethhaa, this is not my REPL buffer
14:16stuartsierrasdegutis: In the ML module functor sense, no.
14:17sdegutisaww
14:17sdegutisWhat does Clojure have instead?
14:17dysfunsequences
14:17justin_smithfunctions that operate on protocol / multimethod methods instead of concrete types
14:18noncomdysfun: np. as a notice: i have used a clojure agent as a receiver of frames that a grabber grabs (to later draw on a texture), since i thought of it as of best possible concurrency model for the task.. idk if it is though.
14:18stuartsierraYou can simulate functors in Clojure by combining protocols with some kind of dependency injection.
14:19dysfunnoncom: in this case i'm encoding video server side so i'm basically shoving it straight back out of a pipe
14:20tcrayford____sorenmacbeth: hail satan
14:20noncomdysfun: ah, better for you then :) if you read javacv forums and docs, i bet you find much info on converting / encoding and saving video
14:21dysfunheh
14:24dysfuni haven't been able to concentrate easily this week, and i've got to present what i'm doing tomorrow afternoon, so we'll see :)
14:25zactsback
14:25R0B_RODHey
14:26amalloysdegutis: do you mean functors in the ML sense like stuartsierra is saying, or the haskell sense?
14:26zactsheh, R0B_ROD I initially read your nick as ROB_FORD
14:27zactssorry man
14:30sorenmacbethtcrayford____: hail satan indeed
14:32zactsile
14:48sdegutisamalloy: I only know OCaml
14:48zactsdarn I forgot my headphones, and I'm at the cafe, so I'll have to try the overtone stuff laters
14:54hellofunksdegutis: if i remember, you are the author of the great oo library OOPS, am i right? then if so, i can understand your affinity for OCaml
14:57sdegutishellofunk: no, I am not the author of any great library
14:58sdegutishellofunk: I have written OOPS as an experiment, although I'm surprised I haven't yet deleted it
14:58sdegutishellofunk: it's certainly not in use anywhere
14:59hellofunksdegutis: i was a bit tongue in cheek, though i remember your interest in OO mixed with FP and now see you've discovered OCaml which seems like a worthy exploration for your interestts.
15:01sdegutishellofunk: I don't know anything about the OO part of OCaml yet. I just think dynamic typing is for toys and static typing is for serious projects, and OCaml has all my favorite Clojure features (destructuring, core.match, simple elegant syntax) and then some (polymorphic variants, etc).
15:02hellofunktheoretical question of the day: is it possible to express a simple average function as a single reduce?
15:02llasramhellofunk: yes
15:03hellofunkllasram: i suppose you'd keep a running count going in your reduction?
15:03sdegutishellofunk: you'd probably use clojure.core/reductions
15:03llasramhellofunk: even better actually
15:03llasramsdegutis: ho ho ho
15:03sdegutisllasram: did I win that one?
15:03tbaldridgeor if your input collection has O(1) count, just use that
15:03zactsmy cat named lambda says hi
15:04zactsso how often do clojurists use java libraries?
15:04justin_smithzacts: in every project
15:04tbaldridgezacts: often
15:04zactsoh interesting
15:04llasramhellofunk: something like this: https://gist.github.com/llasram/5860685
15:04justin_smithin most namespaces
15:04tbaldridgeevery 5th thursday of the month.
15:05sdegutiszacts: there's no point to clojure unless you're gonna use a java lb
15:05llasramhellofunk: Also numerically stable, unlike naive sum + divide
15:05dysfunsdegutis: or...a clojure lib?
15:06dysfunit's not like we don't have an extensive library ecosystem by now
15:06zactshuh ok, so I guess I need to understand how java's OOP libraries interact with clojure's functional paradigm?
15:06zactsaren't the two kind of conflicting in a sense?
15:06turbofailthere's not exactly much to understand... you call java methods when you need to using the (.foo blah) syntax
15:07turbofailoccasionally you might need to implement a java interface
15:07justin_smithzacts: that comes up sometimes - eg. when a poorly designed api won't accept implementation of an interface (easy to do from clojure) but instead needs you to subclass (harder to do from clojure)
15:07dysfunfirst parameter being the object to invoke the method on
15:07hellofunkllasram: i see, so my initial assumption was more or less on point, that you keep a running tally of things as your reduce along
15:07dysfunjustin_smith: potemkin makes it pretty easy
15:07zactshuh, cool
15:07zactsok
15:08zactswell I'm almost to the point of learning about java interop
15:08sdegutisdysfun: it probably uses a java lib
15:08dysfunthere's really not much to it
15:08justin_smithdysfun: wait, potemkin allows subclassing arbitrary java classes?
15:08dysfunsdegutis: many do, sure, but that's because we happen to be on java, just as you'd quite often integrate with a c library in ocaml land, i'm guessing
15:08zactsthat was my biggest question, if I'm using java libs quite often, how do I not let java's non-pure functionalishness infect my clojure code
15:08dysfunjustin_smith: deftype+
15:09dysfuntry and keep as much as possible in clojure space, not java space
15:09dysfunand bear in mind that most java data are mutable and require mutation to do things, rather than returning altered copies
15:10dysfunso reduce and map and all of those won't work so well
15:10zactshum..
15:10dysfunthere are some macros to make it a bit less painful, like doto and ..
15:10dysfun,(doc ..)
15:10justin_smithdysfun: hmm... potemkin source indicates that it supports "abstract types", but I see nothing about it allowing the creation of a concrete subclass
15:11clojurebot"([x form] [x form & more]); form => fieldName-symbol or (instanceMethodName-symbol args*) Expands into a member access (.) of the first member on the first argument, followed by the next member on the result, etc. For instance: (.. System (getProperties) (get \"os.name\")) expands to: (. (. System (getProperties)) (get \"os.name\")) but is easier to write, read, and understand."
15:11dysfunjustin_smith: deftype+ can have a provided parent class type
15:11dysfunjustin_smith: the usual case being to inherit from an abstract class
15:12zactsdysfun: Hm.. I'm assuming I'll learn how this all fits together as I gain more clojure experience
15:13zactsso my projects I want to do: 0) make a simple text editor with clojure 1) do music synth 2) do visual fractal art with clojure
15:13dysfunit could be that it *only* works with the def-abstract-type generated classes, but i haven't had to use it since i discovered potemkin
15:13justin_smithllasram: dysfun: yeah I am reading the source and I see nothing that would or could do that so far...
15:14alexyakushevzacts: Go straight for 1) and 2); 0) is boring :O
15:14zactsalexyakushev: ah, ok! :-D
15:14zactsI'll call it yet another editor editor
15:14zacts(kidding)
15:14dysfunzacts: for your music synth project, you'll want to look at overtone
15:14alexyakushevEspecially since Clojure already has great tools like Overtone and Quil
15:15zactsI'm also hoping to learn good software abstraction / design ideas from doing music synth with clojure
15:15zactsI'm feeling I'll get more of an intuitive sense of things
15:16dysfunhah, good luck with that
15:16alexyakushevHey get some inspiration https://twitter.com/jackrusher/status/467571017679114240
15:17zactswow that's pretty neat alexyakushev
15:17alexyakushevI keep this tweet in bookmarks so that I finally get to try Quil someday
15:21zactsso what is a good JSON alternative for clojure, is edn like this?
15:22zactsor should I just use clojure data structures in a text file?
15:22justin_smithzacts: it is easy to translate between json and edn, and also there is transit for faster network transfer
15:22tbaldridgeedn works well, depends on your needs.
15:22zactsoh cool justin_smith
15:22zactsah ok
15:22justin_smithfor usage within one app, edn is great, if communicating with a client I would use json or transit
15:23zactsso the only issue with edn, is that it's not a tottaly stable api
15:23tbaldridgeand if you're going JVM to JVM and clojure (or java) on both ends, Fressian is probably the fastest.
15:23justin_smithcheshire does a good job of translating from edn to json
15:23tbaldridgehttps://github.com/Datomic/fressian
15:23tbaldridgeall depends on what you need.
15:23zactsok neat
15:25zactsclojure reinvents the wheel, but it reinvents it to be a hovercraft
15:25zactsit's cool, although it still uses previous design lessons
15:25tbaldridgeyeah, it learns from the stuff we all forgot 40 years ago.
15:26zactsso perhaps I should ask what would be a good first project to do after reading braveclojure? Can I start right away into the music processing?
15:27zactsoh project euler I did want to try some of those
15:35sdegutisSo, anyone here know Haskell and have written a comparison between Clojure and Haskell to get Clojurians up to speed on Haskell? Thanks in advance, regards.
15:37dysfuni imagine if you google 'clojure vs haskell' you'll turn up all sorts of things like that
15:38sdegutisOnly one from callen
15:38raeksdegutis: do you happen to know another language from the ML family?
15:39hellofunksdegutis: i've seen a number of articls on the subject. google was my friend at the time, but you may choose an appropriate alternative as your friend if desired.\
15:39sdegutisraek: I started learning OCaml and stopped at Functors because it got too confusing to learn just by looking at code examples
15:39hellofunksdegutis: i wonder if they are anything like c++ functors, probably not
15:40dysfunthey are not
15:41dysfunhttp://www.catonmat.net/blog/on-functors/
15:41raekit's funny that so many languages use the name "functor" for so completely unrelated concepts
15:41justin_smithsdegutis: functors are like functions, but they operate on modules. To understand why they can't just be functions, you need to understand why modules can't just be normal data.
15:41justin_smithit's a wrinkle in ml, imho
15:41dagda1_is there any difference between (if (empty? []) or (if (seq [])) I see both ways used. Is there any real difference
15:42hellofunkdagda1_: well obvious they are opposite tests
15:42justin_smithdagda1_: they are opposite conditions
15:42justin_smithhehe
15:42hellofunk,(doc seq)
15:42clojurebot"([coll]); Returns a seq on the collection. If the collection is empty, returns nil. (seq nil) returns nil. seq also works on Strings, native Java arrays (of reference types) and any objects that implement Iterable."
15:42raeksdegutis: There's a guide called "A Gentle Introduction to Haskell". It does not compare Haskell to Clojure though.
15:42hellofunkoh that didn't have the extra bit that i find useful in the seq docstring
15:42sdegutisthanks
15:42tbaldridgeAnd as a favorite language developer of mine said once "If you start trying to implement parameterized namespaces, suddenly you realize that it breaks REPL development, because modules become the unit of compilation instead of the form being the unit of compilation"
15:42justin_smith,(doc empty)
15:42clojurebot"([coll]); Returns an empty collection of the same category as coll, or nil"
15:43justin_smith,(doc empty?)
15:43clojurebot"([coll]); Returns true if coll has no items - same as (not (seq coll)). Please use the idiom (seq x) rather than (not (empty? x))"
15:43justin_smiththat's the one
15:43dagda1_ha right, maybe the penny just dropped
15:43raeksdegutis: I found it useful to learn about the basic concepts and their syntax. (I came from Clojure and Standard ML.)
15:43hellofunkjustin_smith: yep that's what i was looking for
15:43sdegutisraek: :)
15:43sdegutisI'm probably going to turn into one of those Haskell people for some reason.
15:44raekit doesn't teach you how to "think in Haskell", but I found it useful as a reference manual
15:44sdegutisProbably a lot because of callen's testimony: http://bitemyapp.com/posts/2014-04-29-meditations-on-learning-haskell.html
15:45amalloyi mean, haskell is pretty cool. you don't have to become "a haskell person". you can enjoy both
15:45turbofailunless you're callen
15:45raeksdegutis: both Clojure and Haskell are nice languages... you don't have to abandon one for the other
15:46hellofunksdegutis: i am quite enamoured with the theories of math and how they intersect with programming, and haskell seems to be the great example of that. Even Sussman thinks haskell is the "greatest of the obsolete languages" (he thinks all programming languages today will soon be obsolete)
15:46dysfuni don't think he's wrong
15:47dysfundo you think we'll still be writing code in 20 years?
15:47hellofunkdysfun: i do.
15:47dysfuni do not
15:47justin_smithpeople still use lisp, fortran, and cobol, three of the oldest languages
15:48turbofail20 years isn't all that much time for such a drastic change in how we control computers
15:48hellofunkturbofail: exactly. now, 200 years, that's a different bet
15:48dysfunonce we figure out how we can get rid of bizarre languages and communicate more clearly with the computer, development will improve apace
15:48hellofunkdysfun: i doubt that will happen in just 20 years
15:48dysfunwe'll see :)
15:49tbaldridgeto put it into perspective, Python has been around for 24 years.
15:49hellofunkand the origins of computing itself, as a theory and idea, are approaching a century old now.
15:49nuwanda_dysfun: we'll be maintaining a bunch of code bases we're creating now in 20 years :) imho
15:49hellofunkwell, the modern idea of computing, anyway
15:50stuartsierraHaven't people been predicting the demise of programming languages ever since the invention of programming?
15:50dysfunnuwanda_: that too :)
15:50hellofunkstuartsierra: much like the constant exaggerated claims every few years across all of time about the impending doom or mystiquie of AI. recently there was another spattering of high profile claims. it's ridiculous.
15:51dysfunstuartsierra: moore's law held for long enough that it's possible
15:51sdegutishellofunk: dunno who sussman is but ok
15:51hellofunksdegutis: you heard of SICP?
15:51sdegutisoh yeah
15:51hellofunksdegutis: he's an author of that. MIT professor. quite influenctial.
15:51sdegutisi imagine that guy loves dynamic typing then
15:51hellofunksdegutis: he's a big fan of haskell, but clearly his background is much in lisp.
15:52sdegutisi imagine he wants a more dynamic, lispy haskell then
15:52tbaldridgeI would sit and listen to Sussman for hours if I had the chance.
15:52hellofunksdegutis: no, you're not going far enough.
15:52dysfunor a more typesafe lisp
15:52dysfun(which is what i want)
15:52sdegutismeh, i have no love for macros
15:52hellofunkno he thinks all manner of computing today is very far from the ideal power that could be available.
15:52tbaldridgeAny man who is both an expert programmer and an expert watch maker is pretty awesome IMO.
15:53dysfunpreferably with a touch of slightly clearer syntax on top. haskell does a reasonable job there
15:53sdegutistbaldridge: easy there buddy, hes just a human like you and me
15:53hellofunktbaldridge: let's not forget his prowess with electronics
15:53sdegutis;)
15:53tbaldridgeyeah, that too.
15:54noonianyou can find the sicp lectures on youtube, sussman is very fun to listen to because he's always excited about what he's teaching
15:54hellofunknoonian: i just watched one of this recently, my first. in the beginning i was like, "who is this cliche wearing a pocket protector and flip-up glasses?!" then i realized who he was and was like, dang, son, i'm gonna go get me a pocket protector imminently!
15:55noonianhellofunk: lol
15:58dysfuni never saw a need for a pocket protector anyway, but then by the time i grew up, we'd stopped using slide rules
15:58dysfunwe did use fountain pens, but it was such a rare ocurrence to get a leak...
15:59nooniani never knew what a pocket protector protected one from until this moment
16:01dysfunthese days noone carries a pen anymore
16:02ordnungswidrigdysfun: the pocket protector picure at wikipedia is weird.
16:04puredangerSussman took the Haskell workshop when he did the keynote at Strange Loop (iirc it was Bryan O'Sullivan teaching)
16:04puredangerparaphrasing, he said "those people are weird"
16:05dysfunordnungswidrig: why? because it's got a tux on it?
16:07ordnungswidrigdysfun: absolutly. I only know them blank and "reluctant"
16:08dysfunpretty sure if you wore a pocket protector at my old school you'd've had your head kicked in
16:09ordnungswidrigI still use a fountain pen but never carry it in a shirt pocket. I had no accident ever.
16:16samiswellcoolI carry a whole case of pens
16:16samiswellcooland my current notebook and my last notebook
16:27aaelonyI'm confused by clj-time: (clj-time.coerce/from-long (long 1418813990)) gives me #<DateTime 1970-01-17T10:06:53.990Z>, but http://www.epochconverter.com gives me GMT: Wed, 17 Dec 2014 10:59:50 GMT (which is correct) for the same value.
16:30justin_smithaaelony: is from-long doing a ms or ns conversion?
16:30justin_smithtry adding three zeroes to the end
16:30chouser,((get get get get) (get get get get) (get get get get) 5)
16:30clojurebot5
16:30justin_smithlol
16:30aaelonyjustin_smith: thank you.
16:30aaelonythat works now
16:34Glenjamin,(def get out)
16:34clojurebot#<CompilerException java.lang.SecurityException: denied, compiling:(NO_SOURCE_PATH:0:0)>
16:34sssilverHey guys, what does this Clojure snippet calculate? Any clue? (defn fact [n] (reduce * (range 1 (inc n))))
16:34sssilverlet me rephrase that... does that look like a correct implementation of factorial?
16:34amalloyhellofunk, did you notice http://stackoverflow.com/questions/28131135/how-to-implement-zip-with-foldl-in-an-eager-language ?
16:35amalloysssilver: try it on a few numbers and see?
16:35justin_smithsssilver: it would take 1 through n inclusive, and take each item in that list and multiply it by the previous total (starting with 1*2)
16:35sssilveramalloy: I don't have clojure on my machine
16:35amalloy,(map (fn fact [n] (reduce * (range 1 (inc n)))) (range 1 8))
16:35clojurebot(1 2 6 24 120 ...)
16:36amalloy&(map (fn fact [n] (reduce * (range 1 (inc n)))) (range 1 8))
16:36lazybot⇒ (1 2 6 24 120 720 5040)
16:36amalloythere is an abundance of online clojure evaluators, for example http://www.tryclj.com/ if you want to play around without installing anything
16:37sssilvercool, thanks guys
16:39Glenjaminhrm, my mobile friendly PR got merged, but it doesn't look like tryclj is updated yet
16:41Glenjaminamalloy: i'm really confused by that answer, foldl :: (a -> b -> a) -> a -> [b] -> a - but the answer has 3 args to the folding function
16:41amalloyGlenjamin: it's folding up into another function
16:41amalloyie, the accumulator is itself a function
16:41Glenjaminoh
16:42amalloya ~ (c -> d)
16:42Glenjaminaha, so it is
16:42Glenjamini find it really annoying having haskell arguments not named >.<
16:42amalloywhat do you mean?
16:43justin_smithGlenjamin: aka point free style?
16:43Glenjamin(a -> b -> a) -> a -> [b] - took me a min to figure out which was which
16:44Glenjaminand yeah, the point free doesn't help massively, i only just realised the ys is applied to the folded function
16:44Glenjaminoh, and so is the (const [])
16:45amalloywell this like...isn't point-free style at all
16:45Glenjaminwell, as i think about it more, the lack of parens is my problem
16:45amalloyhe could have even removed the 'ys' argument, since applying it at the end is unnecessary: zip1 xs = ... (const [])
16:46Glenjaminwhich is odd really, as i learnt haskell before any lisps
16:48amalloythe translation of that haskell to clojure is not really made more readable by all the parens: https://www.refheap.com/37b61066156c2265969b7dd89
16:48Glenjaminhaha
16:49Glenjamini think separating the reduce into a function from the unrolling would help
16:49Glenjaminin the haskell version also
16:50tbaldridgeamalloy: this is the code for the "multi arity map" thing from the other day, right?
16:50amalloytbaldridge: yeah
16:50amalloywell, this is the implementation of zip, which is "the hard part" of multi-arity map
16:51tbaldridgefrom what I saw of the haskell code the other day, aren't they just turning the second collection into nested closures? If so, then why not use lazy-seqs?
16:52amalloytbaldridge: my goal in finding this was to refute the claim that you can't do multi-arity map as a reduce. i'm not claiming this is a good implementation of zip that you would actually use
16:53amalloyi don't totally see how you would use lazy seqs instead of these nested closures; you can't really be lazy anyway, when you're reducing
16:53hellofunkamalloy: i'm glad to see you are still thinking about this. i spent the weekend reading about foldl and foldr and really understanding them as much as i can. i was thinking about continuing our conversation on that but am not well enough versed yet
16:53hellofunkamalloy: lots of old threads on the clojure mailing list about this, of which you participated, some going back five years
16:54amalloyhaha, do share. i don't remember most of the things i said
16:54Glenjamini'm not sure that this nested closure solution is really different from the (reverse)
16:54hellofunkmy general motivating factor, a theoretical musing perhaps, is the notion of a higher level to HOFs
16:54Glenjamindoesn't it still effectively do two traversals?
16:56amalloywell uh...probably. i can't really tell what's going on tbh
16:56amalloybut it's all one big fold! that was all i was after
16:57tbaldridgeamalloy: I always assumed multi-arity map could be done like this: https://www.refheap.com/96507
16:57hellofunkamalloy: i agree, the idea of folding in general, at the purest level, excites me, especially when a fold can be the composite of many folds, all of which have the same higher structure to each
16:59amalloytbaldridge: that does seem a lot simpler
16:59amalloythough you want to replace [[] ys] with [[] (seq ys)]
16:59tbaldridgeI don't think one is better than the other TBH. They both transverse twice, they both do allocation during reduction.
16:59sdegutisIs it bad practice to use :otherwise in a cond instead of :else?
16:59sdegutis(as the last case)
16:59Glenjamindammit tbaldridge, i was just typing that
17:00Glenjaminbut mine doesn't work yet :)
17:00justin_smithsdegutis: I prefer :YOLO
17:00Glenjamin(inc justin_smith)
17:00lazybot⇒ 172
17:00sdegutisjustin_smith: whence all dat karma bruh
17:01amalloyjustin_smith: hyphenated keyword-haiku
17:01justin_smithsdegutis: I stole it when technomancy wasn't looking
17:01samiswellcoolWould you recommend just using clojure.test to write tests?
17:01hellofunkamalloy: unless it's me, the word "zip" seems quite overloaded
17:01sdegutisToo bad about him, up and leaving #clojure like that.
17:01justin_smithsamiswellcool: yeah, clojure.test is good
17:01amalloy(cond x y, a b, :Light-of-the-moon-Moves-west-flowers-shadows-Creep-eastward "not found")
17:02justin_smith(inc amalloy)
17:02lazybot⇒ 216
17:02Glenjamini had https://www.refheap.com/96508
17:02Glenjamintook me 3 goes to remember that i needed the & to destructure
17:04amalloytbaldridge: do you mind if i post your clojure solution as another answer to that SO question? or you can do so yourself
17:05tbaldridgeamalloy: please do
17:06zactsooh, I want to make an RPG game too
17:06Glenjaminis there a strong reason to prefer first/next vs [x & xs] ?
17:06zactsbut mine will be simple
17:07hellofunkamalloy: further to the point is the recent article i read somewhere about how foldl and foldl' are both expressable as foldr, making foldr the higher level
17:07amalloyhellofunk: sure. you can also express foldr as foldl, if you don't mind giving up laziness
17:09hellofunkamalloy: no, the opposite. foldl as foldr
17:09amalloyhellofunk: right, i mean you can go either way
17:09amalloybut if you implement foldr using foldl you can't be lazy
17:11hellofunkamalloy: the other issue that got me curious is the idea of the consumer function. it should be able to evolve during the folding to create interesting patterns. like the consumer is feeding back on itself as a minifold within the larger fold
17:19amalloytbaldridge: http://stackoverflow.com/a/28159764/625403
17:23amalloyhellofunk: try picking up haskell, then. it's less hard if you already understand functional programming, although still foreign enough to teach you some new ways of thinking
17:24hellofunkamalloy: the syntax makes my eyes hurt
17:24amalloyhellofunk: complaining about that makes you a big baby, if you'll pardon my rudeness. people say the same thing about lisp all the time and clojure folks scoff at them
17:25amalloysurface syntax is an easy thing to complain about, but not terribly important
17:25hellofunkamalloy: fair enough, but it's still true. after staring at lisp all day, when you see haskell my eyes aren't trained to know where the expressions are delinieated
17:25amalloysure. i had the same problem too, sometimes still do. the solution is practice, like with anything else
17:25metellushellofunk: isn't that something you'd get over pretty quickly as you used the language?
17:26hellofunksure, but i don't use it, but as an example comparison, i also don't use java, having never written a line of it in my life, but somehow java is straightforward to read while haskell, well, my ignorance hurts my eyes
17:27turbofaili still have trouble making sense of scala syntax sometimes
17:27turbofailactually i have more of a problem with writing scala than reading it
17:27hellofunki feel like i have been spoiled by lisp syntax
17:28turbofailit's often not clear to me why something i've written in scala is a syntax error
17:29tcrayford____anybody got any idea why ring.util.codec/url-encode doesn't encode "," as "%2C" ?
17:29amalloytcrayford____: why would it?
17:30tcrayford____because , isn't a valid url part according to compojure haha :(
17:30hellofunkamalloy: just came across this and interestingly turbofail you are quoted in it: https://gist.github.com/hellofunk/a1582981ecafa6b36e63
17:30tcrayford____aka /some-user-defined-path had a "," in it, and compojure just 404s haha
17:30amalloywell, it depends what part of a url, right. like it's valid in a query, but not in a path part
17:31tcrayford____right
17:31amalloyhellofunk: i mean, java is like super inexpressive: there is a ton of redundant information, lots of whitespace, and a very regular structure
17:32tcrayford____amalloy: is there a better alternative to url-encode from ring.util.codec for encoding path-parts?
17:32turbofailah yeah i remember that discussion
17:32turbofailthat was in #emacs
17:33hellofunkamalloy: do you have a tip for a quality quick start read in haskell? i can't invest much time but would like to get to the heart of the basics in a hurry without leaving serious parts out
17:33amalloytcrayford____: actually , is valid in a path part. i was just assuming that it's not because you are having trouble with it
17:33uptownhello out there. i'm trying to retrofit midje into a project which had no tests but despite creating the correct diretory tree, "lein midje :autotest" doesn't find my tests. when autotest starts, it logs loading the source ns but not the test ns. has anyone run across this? i can't find the configuration magic...
17:33amalloyif compojure is having trouble serving routes with a , in them, you might just need to adjust what regex it uses in GET
17:33tcrayford____amalloy: guess this is actually a problem with clout then :/
17:34tcrayford____amalloy: no regex haha
17:34tcrayford____just :thingy
17:34amalloytcrayford____: i mean, it uses a regex to match this stuff
17:34amalloyand you can customize what regex is used
17:35tcrayford____amalloy: got a pointer to that? (this is literally a production bug for an customer)
17:36amalloyi think it's just (GET ["/pages/:foo" :foo #"[\w_,]+"] ...)
17:37amalloybut see https://github.com/weavejester/clout/blob/master/src/clout/core.clj#L108 for details, and note that the stuff after the url in a vector there gets mushed into a hashmap and passed to route-compile
17:37amalloyand of course use a different regex
17:38tcrayford____ta
17:38amalloyit looks like https://github.com/weavejester/clout/blob/master/src/clout/core.clj#L91 incorrectly excludes , from the characters it's willing to match in a path
17:40amalloy$mail weavejester it looks like https://github.com/weavejester/clout/blob/master/src/clout/core.clj#L91 incorrectly excludes , from the characters it's willing to match in a path, given the characters that are allowed in a path (see http://stackoverflow.com/a/4669755/625403 for one listing of such)
17:40lazybotMessage saved.
17:40amalloyi guess i should make a github issue but...irc is so nice
17:40tcrayford____I'm filing
17:45tcrayford____see https://github.com/weavejester/clout/issues/23
17:45tcrayford____amalloy: ^^
17:45tcrayford____thanks btw
17:46amalloytcrayford____: did the suggested workaround work?
17:46tcrayford____not tried it yet
17:47amalloyhellofunk: LYAH is pretty great. a bit slow but fun
17:47tcrayford____think I'm just gonna wrap up my own encoder that escapes ,
17:54tcrayford____amalloy: I'm unsure why compojure/ring even do their own url munging regex stuff :/
17:54tcrayford____java has url encoding stuff in the stdlib
17:56amalloywell, clout has to understand the urls
17:56amalloyand java.net.url is pretty dreadful
17:58amalloybut even if you built a url successfully and called getPath on it, you'd *still* need to parse out the path parts, which is the code that's currently not working
17:58tcrayford____ah, gotcha
18:00samiswellcoolI feel like I'm relying too heavily on loop and recur
18:01amalloyyou're probably not wrong, samiswellcool
18:06amalloywith some examples somebody could help you rewrite, but in general you probably should be using reduce or lazy sequences most of the time
18:10samiswellcoolI'm new enough to clojure that 'it works' is enough of a motivator for now, but I'm going through what I've done so far every now and again and refactoring parts away from recurring loops
18:20Glenjaminamalloy: is anything about loop..recur particularly worse than using reduce?
18:21amalloyGlenjamin: well. is anything better about map than writing for (i = 0; i < xs.size(); i++) {xs.get(i).whatever();}? reduce has the bookkeeping logic already written for you, so it doesn't muddy up the particular thing you're doing
18:22Glenjaminah right, makes sense
18:22Glenjamini was thinking they were equivalent, but forgetting you still need to split head/tail when loop ing
18:27tbaldridgealso, reduce is much faster for vectors and reduce-kv is faster for maps
18:27tbaldridgeless allocation that way
18:44eriktjacobsenOk Macro wizards! I have a recurive macro problem… Since the failure conditions aren’t known at expansion time, I understand why I get a stack overflow error… I’m having trouble visualizing how to break this apart though… helper functions? some sort of loop-recur inside the macro? http://pastebin.com/Th2uB2gU
18:45eriktjacobsenthe macro itself splits the first argument on thrown error into two smaller groups and runs them separately. I want that process to continue until it is running singles… but if I try to wrap the macro around each half-call, obviously it breaks.
18:46eriktjacobsenI’m still starting with macros, so visualizing how to break that into a helper function while maintaining what is a symbol, what is evaluated and what returns as a list is fuzzy for me
18:49amalloyso this doesn't look like a macro problem at all, eriktjacobsen
18:49amalloyyou just want a function that takes a function and some args
18:50amalloy(defn split-retry [f main-args more-args] (try (apply f main-args more-args) (catch Exception e (if whatever (split-retry f (first-half-of main-args) more-args)))))
18:52eriktjacobsenMy first intention was there was already a ton of code, so wanted something I could just wrap things… but if I did your way I could still make macro that just passed the body into that fn… yeah I way overcomplicated that
18:52eriktjacobsenThanks. Got stuck in the weeds
18:54hellofunkeriktjacobsen: it is a right of passage in clojure/lisp, the abuse of macros when you first learn the language.
18:54hellofunkthat should be "rite"
19:07Glenjaminthat code sample is making me imagine a brute force macro
19:08Glenjaminwhich keeps modifying the input until it stops throwing exceptions
19:09RaynesIf you put monkeys in a room with typewriters, eventually they'll produce Shakespeare
19:10Glenjamini saw a toy language once that deleted your code if it errored
19:10Glenjaminlike, from the disk
19:10Glenjaminhttps://github.com/munificent/vigil
19:11amalloyGlenjamin: https://github.com/mattdiamond/fuckitjs
19:11Glenjaminthe support section is a nice touch
19:25eriktjacobsenGlenjamin: Unfortunately, that is not far from the truth. I also have some code that randomly picks dates between 2005 - 2008 to get around same issue…. Its a google API, fyi
19:26eriktjacobsenIt randomly fails without any error messaging, even on same input… even with retries. Totally inconsistent, a list of ids that failed today for several hours would work the next day, etc
19:47{blake}Running under Windows (have to test IE) I find that access is denied when I try to open any port with "lein ring server". Python and Smalltalk can open ports with no difficulty.
19:48{blake}Could it be a Java thing?
19:51rplevyAny thoughts on alia vs cassaforte? They seem pretty similar.
19:51{blake}(Running in a corporate environment and situation suddenly changed, so suspecting some kind of remote administration shenanigans, but want to make sure.)
19:56{blake}Crap. It's ONLY Clojure? How is that even possible?
20:07Glenjamin{blake}: check your firewall settings
20:08{blake}Glenjamin: Local firewall isn't running. I can open the port (3000) with Java, Python, Smalltalk.
20:08amalloy{blake}: what is some actual code you are running and what is it doing
20:08Glenjaminthat's the extent of my windows knowledge i'm afraid. Maybe check java security settings?
20:09amalloynobody wants to play twenty questions to narrow down all possible network failures, when you have a specific failure in front of you
20:09{blake}Glenjamin: Weirdly, I just threw up a Java server and it works just fine.
20:09{blake}amalloy: I'm running "lein new compojure app".
20:10{blake}I get "Started server on port 3000" followed immediatel by "Exception in thread "main" java.io.IOException: Failed to open http://localhost:3000/. Error message: Access is denied."
20:38insamniac{blake}: You have no windows network security things running?
20:40insamniacand has your hosts file been investigated?
20:52R0B_RODEvening!
20:52R0B_RODIs the 540MB NetBeans IDE worth it at all for clojure??
20:52lazybotR0B_ROD: Definitely not.
20:53R0B_RODOk thanks lazybot
20:53amalloy*chuckle*
20:53justin_smithR0B_ROD: for IDE experience, I think cursive with intellij idea is likely the best right now
20:53R0B_RODTotal newbie here
20:53amalloybots make some funny conversations. i dunno if netbeans is any good, but you probably shouldn't blindly take lazybot's advice
20:53justin_smithwould lazybot every answer yes to two question marks??
20:53lazybotjustin_smith: What are you, crazy? Of course not!
20:54amalloylazybot: if your friends jumped off a bridge, would you do it too???
20:54lazybotamalloy: Yes, 100% for sure.
20:54amalloyi love this guy
20:54turbofailwhat about now??
20:54lazybotturbofail: Uh, no. Why would you even ask?
20:54R0B_RODam I brainacid??
20:54lazybotR0B_ROD: What are you, crazy? Of course not!
20:54R0B_RODam I brainacid?
20:54R0B_ROD...
20:54TEttingerbrainacid???
20:54lazybotTEttinger: Oh, absolutely.
20:56R0B_RODSure???
20:56lazybotR0B_ROD: Yes, 100% for sure.
20:56R0B_RODlazybot: You are correct!
20:57R0B_RODWell since I dont know what Im getting into yet, I have LightTable for now. Havent 'really' used it yet.
21:09elarsonIs there a let* clojure?
21:10justin_smithelarson: let already acts like common lisp let*
21:10elarsonah ok, thanks!
21:10justin_smith,(let [a 0 b (inc a) c (inc b)] c)
21:10clojurebot2
21:20gfredericks,(def x 5.975884771000674E307)
21:20clojurebot#'sandbox/x
21:21gfredericks,(Math/toRadians x)
21:21clojurebot1.0429886497374912E306
21:21gfredericks,(Math/toDegrees (Math/toRadians x))
21:21clojurebotInfinity
21:21gfredericks,(* 2 x)
21:21clojurebot1.1951769542001347E308
21:21gfredericks^ x is not close to the max double
21:23gfrederickshuh; the javadocs say both methods are "generally inexact"
21:25Blake2insamniac: The security's all taken care of elsewhere. But I haven't checked the HOSTS file out, maybe I fiddled with it. Thanks!
21:26Blake2Which is sort of like "funny lookin' in a general sort of way".
21:39dweaveI’m trying to better understand how macros should be used. It seems like most advice is something like “Macros should be avoided whenever possible”. It’s always POSSIBLE. Right? A prime example is probably compojure. Couldn’t routes be defined using types implementing a ‘view’ interface much the same way we do in rails/django type frameworks.
21:40dweavewhy do compojure and other libraries chose to use macros for these types of things
21:40elarsonI'm positive this is a dumb question, but... are there some functions for reading from a file handle? specifically I'm looking at reading the input stream from a java Process object and wanting to write to the input.
21:40dweaveelarson slurp
21:41elarsondweave: I'll take alook
21:41elarson*a look
21:41TEttinger(doc slurp)
21:41clojurebot"([f & opts]); Opens a reader on f and reads all its contents, returning a string. See clojure.java.io/reader for a complete list of supported arguments."
21:41justin_smithslurp works if you want to block until the stream closes
21:41justin_smithif you want to read output from a proc as it is available, you want to do something different than slurp
21:41oskarkvelarson also maybe take a look at http://clojuredocs.org/clojure.java.io
21:42elarsonjustin_smith: right, that would be my concern.
21:42elarsonoskarkv: that looks much closer to what I was thinking. Thanks!
21:43justin_smithif it's a fairly long running process, to get output as it is available, you can use the .read method on the thing and read into a buffer
21:43justin_smithI don't think anything in clojure.java.io will help with that
21:44elarsonjustin_smith: that should be OK. I'm just checking for a password prompt
21:44justin_smithahh - yeah password prompt means you definitly want .read, since even an abstraction like line-seq would fuck that up (prompt does not end with a newline)
21:45elarsonI'm assuming that something like (.write (clojure.java.io/writer (:in proc) "hello")) would work as expected
21:45justin_smithelarson: you would also want to flush it (usually newline flushes but I am not as sure about process input)
21:46elarsonjustin_smith: ok, that is also something I was thinking might be necessary :)
21:46amalloyso uh, i have to say that doing this from clojure by hand looks a lot harder than using `expect` or something
21:47elarsonjustin_smith: btw, thanks for consistently responding to my questions. I hope they aren't so obvious as to assume I'm avoiding RTFM
21:48elarsonamalloy: I'll take a look at `expect` as well
21:48justin_smithI still think about making an expect like tool in clojure sometimes
21:56amalloyi expect that the best part of writing your own expect variant would be all the wordplay options it opens up
22:06oskarkvdweave I'm not familiar with compojure. Could you provide another example? :P
22:14TimMcexpclject
22:15TimMcecjpectl
22:15amalloyTimMc: that sounds like a botched magic spell
22:17TimMcajjume
22:18amalloynow you're just typing sneezes
22:18TimMcall the best library names happen that way
22:18TimMcalso
22:18TimMc&(format "lib-%04d" (rand-int 1e4))
22:18lazybot⇒ "lib-6971"
22:32notbrent_if you happen to be in vancouver, canada, i'm organizing a clojure/clojurescript meetup on feb 5 at 6pm to try to revive the meetup group: http://www.meetup.com/Vancouver-Clojure/events/220103236/
22:56jonh/close
22:58dnolenOm contributions welcome, just me an email to request a CA https://github.com/swannodette/om#contributing
22:58dnolener, "just send me"
23:00TEttingerI'm glad the clojure community is so friendly
23:11mercwithamouthcan anyone tell me if the clojure for the brave book offers more than the web version?
23:12mercwithamouthi've planned on buying it just to support...he gives an excellent introduction...
23:17puredangerafaik, it's same content. but you could just ask Daniel, he is a friendly guy. :) He's @nonrecursive on Twitter.
23:18mercwithamouthpuredanger: ok. either way purchasing...it's a really enjoyable book...
23:20mercwithamouthalso the web development lispcast package...does anyone know what sort of app he makes?
23:30szatzIt seems like it is more idiomatic to access map elements with the key preceding the map, such as (:some-key some-map), but Clojure also proudly totes complex keys. Isn't this preceding key problematic because it could clash with an external function name?
23:30justin_smithszatz: :some-key cannot clash with a function name
23:30justin_smithit is a keyword
23:31szatzWell... You can use things that aren't :-prefixed as keys, too, is what I'm getting at.
23:31justin_smithno
23:31justin_smithnot as lookup
23:31justin_smithwell, OK symbols work, but nothing else
23:31justin_smithszatz: clojure decides what to invoke based on what is next to the open paren
23:31justin_smith:keyword invokes get
23:32justin_smith'symbol will too
23:32justin_smithbut a function will be called
23:32justin_smith,(seq {seq 1})
23:32clojurebot([#<core$seq__4091 clojure.core$seq__4091@2d973d4f> 1])
23:33justin_smith,({seq 1} seq)
23:33clojurebot1
23:33szatzHmm... OK, so ("justin" {"justin" "smith"}) is invalid, but ({"justin" "smith"} "justin") is fine, yet the former is more idiomatic, were it to use a key instead. Does that sound about right?
23:34amalloyszatz: you only look up keywords that way
23:34justin_smithszatz: if your keyword is a literal, put it in the first position
23:34amalloysee http://stackoverflow.com/a/7037211/625403 for a philosophical answer
23:34justin_smith,('or-symbols '{or-symbols true}) ; but this is more rare
23:34clojurebottrue
23:36alexyakushev,('nowai '{nowai jezaz})
23:36clojurebotjezaz
23:36alexyakushevWho ever does that?
23:36justin_smithalexyakushev: nobody, but it is worth knowing about because it makes a specific error message easier to understand
23:37justin_smith,('+ 1 2 3)
23:37clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: Symbol>
23:37justin_smith,('+ 1 2) ; or lack of error message...
23:37clojurebot2
23:38alexyakushevYes, that thing I remember reading somewhere
23:38szatzjustin_smith, amalloy: Thanks for the info!
23:39amalloyi actually have ('foo x) in the source file i have open right now
23:40justin_smithfirst I've heard of using it intentionally
23:40amalloyi can't remember doing it very many other times, but sometimes a map wants symbols for keys, and when it does, you might as well look them up that way
23:40justin_smithfair enough, yeah
23:41alexyakushevonly because of the cognitive gap I would use (get...) in that case
23:41alexyakushevtakes everyone to new symbol semantics to immediately grasp what's going on
23:41alexyakushevs/new/know/
23:53szatzAnother question if you guys are still around; In ClojureScript, since it's single-threaded, I'm guessing the main benefit of using reducers would be the lack of intermediate collections from a chain of higher-order functions. Is there much more to it than that?
23:54amalloyszatz: that's the main benefit on the jvm too. parallel fold is a fringe benefit really
23:56szatzAhh, OK, because the parallelization isn't always guaranteed (associativity required), but the removal of intermediates is, right?
23:56amalloyplus, most of the reducing you do is actually on small collections *anyway*
23:57justin_smithit's also that the overhead of going parallel can be smaller than the gains it provides (with smaller inputs in particular)
23:57amalloylike you reduce over a four-item map, or a vector with a couple dozen items
23:57justin_smitherr, s/smaller/bigger
23:57amalloyman i tried subbing out the wrong "smaller", got even more confused
23:58justin_smithamalloy: notice that there was no /g - only subbing the first instance
23:58amalloyyeah but i refuse to believe that anyone does that on purpose
23:59szatzRight, right. You guys are handy. Thanks again.