#clojure logs

2012-12-15

01:19mdeboardAnyone know if it's possible to run cascalog jobs via nrepl? iow not compiling the jar and running it that way?
01:21sw2wolf,(sqrt 100)
01:21clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: sqrt in this context, compiling:(NO_SOURCE_PATH:0)>
01:21sw2wolf,(sin 1)
01:21clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: sin in this context, compiling:(NO_SOURCE_PATH:0)>
01:25ivanisn't it kind of weird to invade someone's namespace as clj-http-lite does with clj-http.lite?
01:26sw2wolfi cannot visit http://www.khanacademy.org/, then how to use clojurebot ?
01:27ivando the two have anything to do with each other?
01:27technomancyivan: namespaces actually are not hierarchical
01:28technomancyso there's no invading going on; it's just an illusion
01:28ivansw2wolf: perhaps https://www.wolframalpha.com/input/?i=sqrt%28100%29 would interest you
01:28ivantechnomancy: yeah but what if clj-http wants its own .lite
01:28ivanthat's what I meant by invasion
01:29sw2wolfivan: it is using clojure ?
01:29ivanheh, no
01:29sw2wolfoh
01:29ivan&(Math/sqrt 100)
01:29lazybot⇒ 10.0
01:29technomancyyeah, you'd have to communicate
01:29technomancyivan: in this case both libs are written by co-workers
01:30sw2wolfthx
01:30ivanwell, that solves the problem
01:30sw2wolf&(range 10)
01:30lazybot⇒ (0 1 2 3 4 5 6 7 8 9)
01:32sw2wolf"/msg clojurebot &(range 10)" returns strange thing ?!
01:33ivan& is for lazybot
01:33lazybotjava.lang.RuntimeException: Unable to resolve symbol: is in this context
01:33ivantry a ,
01:34sw2wolflazybot works but "/msg clojurebot ,(range 10)" return nothing
01:35amalloy~help
01:35clojurebotNobody can help with "X doesn't work". Please provide context: what you did, what you hoped would happen, and what happened instead. A stack trace is especially helpful, if applicable.
01:35amalloytechnomancy: that used to return "help is http://www.khanacademy.org/&quot;; thus the connection
01:40technomancyheh
01:41sw2wolf,(make-vector {:a 1, :b 2, :c 3})
01:41clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: make-vector in this context, compiling:(NO_SOURCE_PATH:0)>
01:42sw2wolf&(make-vector {:a 1, :b 2, :c 3})
01:42lazybotjava.lang.RuntimeException: Unable to resolve symbol: make-vector in this context
01:43sw2wolf,(doc into)
01:43clojurebot"([to from]); Returns a new coll consisting of to-coll with all of the items of from-coll conjoined."
01:43ivan&(seq {:a 1, :b 2, :c 3})
01:43lazybot⇒ ([:a 1] [:c 3] [:b 2])
01:43sw2wolfivan: thx
01:44ivansw2wolf: btw, lein repl
01:44amalloyor /msg lazybot, or...
01:44sw2wolfivan: i know. but this is freebsd box without JRE installed
01:45sw2wolfamalloy: sorry! i will use /msg later.
01:56ghengis_is clojure/java.jdbc pretty much the standard sql interface or are there other significant choices?
01:59ioexceptionghengis_: I don't know or "do any clojure", but clojureql looks also nice http://clojureql.org/
02:01ghengis_ioexception: thanks, this looks nice too
02:04amalloyyikes, clojureql. if you want to do sql, use https://github.com/clojure/java.jdbc
02:17sw2wolfwhich emacs mode is for clojure ?
02:17ivanclojure-mode
02:17sw2wolfthx
02:17ivanyou also want nrepl.el
02:17ivanand perhaps paredit
02:21dabdsince clojure vectors have O(log32n) access if I want O(1) access i should use java arrays?
02:21alex_baranoskyhey guys, is there a way to get equivalent behavior to 'realized?' for promises in 1.2.1?
02:24ivandabd: only if you hate values
02:24ivanis log32n too slow for you?
02:25dabdyes I would like the fastest possible access
02:26amalloydabd: so why are you using java? or virtual memory? or an operating system? it would be faster to connect wires straight to the RAM sticks
02:26amalloythe point is everything's a tradeoff, and the performance cost of using vectors rather than arrays is minimal
02:28alex_baranoskyhas anyone used promises in 1.2?
02:28alex_baranoskyis there no way to ask it if it has been yet delivered to?
02:29dabdamalloy: actually Java may not be the right tool for the job. Perhaps I should use C and jni to call it from Clojure
02:31ivanRAM sticks are way too slow, man
02:31ivanyou've got that DDR3 protocol in your way
02:41alex_baranoskyI'm afraid the lack of response about 1.2.1 promises is not a good sign for me
02:43amalloyalex_baranosky: it's a great sign! you have an excuse to stop using 1.2
02:53alex_baranoskyamalloy: I've got a lot of excuses to stop. IF you can fathom it, we just moved to leiningen a month ago on the project I want the promises for
02:54alex_baranoskyamalloy: this just means I need to prioritize moving to 1.3 before I can make this change., I guess
02:54amalloyhah, amazing
02:54alex_baranoskyor 1.4 preferrably :)
02:55amalloyalex_baranosky: iirc in 1.2.x, (promise x) is just (reify IDeref (...) IFn (...)), so anything that's not exposed in that reify can't be gotten/done
02:55alex_baranoskyyeah I just took a look at the history of core.clj, and you are correct
02:55amalloyyeah, 1.3 is terrible. upgrading to 1.4 is easier than upgrading to 1.3
03:22vsyncif I have a PHP (ugh) server which I need to serve a bit of data to a ClojureScript client, what's the laziest and most trouble-free way? XML, JSON, or Clojure s-exprs?
03:23vsyncand especially that for this iteration it will be a static file that i will later serve dynamically
03:32tomojsuppose you change #'binding and you double the time of a performance test that calls binding over and over in a loop. is that really bad?
05:53squidz_what would be the simplest way to read in a password from the cmd-line, and save it with clojure? Is it possible without a database?
06:06squidzWhat's the easiest way to save a passsword passed in the commandline without a Database?
06:13pepijndevos_Is nrepl specific to Clojure, or can it be used with any server?
06:18Raynessquidz: Hi.
06:18Raynessquidz: Sit still and I will answer you. :p
06:18Raynessquidz: So, is your question "How do I get a password on the command line" or "How do I store a password without a database"?
06:19RaynesOr both?
06:22squidzhow to store it
06:22squidzsorry if I asked my question twice, I was having problems with my irc client
06:23mindbender1`lein classpath` is not picking `:source-paths` in project.clj. is this normal
06:23mindbender1as a result lein ring server returns classnotfound
06:30Raynessquidz: How would you like to store it?
06:30Raynessquidz: In a file somewhere?
06:30squidzi just dont want that somebody can see it as plaintext
06:31borkdudesquidz hash it?
06:31Raynessquidz: You can hash it.
06:31Raynesborkdude: GTFO
06:31Raynes;)
06:32borkdudeRaynes I looked up what that means. You want me to get the fuck out?
06:32RaynesWell, that makes it sound mean.
06:32squidzhow do I hash it? then store it in a file?
06:32borkdude=)
06:33Raynessquidz: jbcrypt for hashing, spit for storing.
06:34Rayneshttps://github.com/noir-clojure/lib-noir/blob/master/src/noir/util/crypt.clj
06:34borkdudeI would like to express my appreciation of the read-line support in CCW now… but nobody is here to receive it. So I won't.
06:34squidzthanks
06:46borkdudehmm, I sometimes get this exception in CCW, but I don't know how to reproduce it https://www.refheap.com/paste/7601
06:47borkdudeah well, I do know now! using an atom and applying swap! to it from the repl will
06:47hyPiRionas in (apply swap! ...) ?
06:47hyPiRionor (swap! ...)
06:47borkdudehyPiRion just (swap! ...)
06:48hyPiRionHuh, IOExceptin
06:48borkdudenot immediately though, only sometimes
06:49hyPiRionDoesn't really sound like an error with swap! and atoms though.
06:50hyPiRionBut it seems like it's activating the error somehow
06:50borkdudehyPiRion yeah, I'm trying to reproduce now, but no luck
06:56borkdudehmm, never mind
06:56borkdudecan'r reproduce it anymore :-s
06:59mindbender1technomancy: lein classpath is not reflecting my :source-paths entry, is there a way of tracing the problem?
07:02mindbender1lein trace
07:03hyPiRionclasspath != source path
07:03hyPiRionclasses are the java binaries, source is the source code
07:06mindbender1hyPiRion: but I thought source-paths get influence classpaths with lein
07:07hyPiRionhm
07:07mindbender1:)
07:08hyPiRionright, I see both target/classes and my src-folders here
07:08hyPiRionwhat version are you running?
07:08hyPiRion`lein version`
07:08mindbender1I think the problem is with my silly head I actually forgot that I changed lein script to point to lein2
07:08mindbender1I found out with lein version
07:09hyPiRionheh
07:09mindbender1:)
07:09hyPiRionI make lein point to lein 2.0, and lein1 to lein 1.7
07:09hyPiRionI use lein 2.0 so much now that lein1 is essentially only for building lein2.
10:43ravsterhello everyone
10:49borkdudehello ravster
11:02gauravagis there any parallel implementation of filter?
11:12hyPiRiongauravag: not afaik, the concatenation of lists/vectors would kill the performance
11:13ravsterWhat does the ',,,' mean when used in a thread? It doesn't look like it gets parsed at all, but its not a comment either.
11:13lantigagauravag: look into the reducers library http://clojure.com/blog/2012/05/08/reducers-a-library-and-model-for-collection-processing.html
11:13gauravaghyPiRion, lantiga: thank you
11:14Bronsaravster: , is treated as a whitespice by the clojure reader
11:14lantigaif the filtering function is heavy, you could also gain some speed with (filter identity (pmap f coll))
11:14ravsterBronsa: I see. my lead dev uses 3 (so ',,,'), but it can even be a ',' and it'll still be unprocessed?
11:15Bronsayes
11:15Bronsa',,,' is usually used in threading macros as -> and ->> to indicate the position where the variable will be threaded
11:16gauravagthe filtering function is not really heavy, but the seq is long enough
11:16ivaraasenso, the most hilarious thing ever happened today. they handed out our exam with the solution stapled to it.
11:16ivaraasenmultiple choice exam as well.
11:17gauravagivaraasen: wrong window?
11:18ivaraasengauravag: yeah, sorry for that. still pretty hilarious though
11:18gauravag:D
11:19ravstercool, thanks Bronsa
11:19gauravaghttps://gist.github.com/4296706
11:19gauravagIs there any way to optimize it?
11:20ravsteris there a preferred way of doing docstrings in clojure? I've got a CL background, and all thats done there is a string after the def. But clojure also has some '^' meta thing going on.
11:26joegalloravster: don't worry about that. just do (def foo "some docstring blah blah blah" 4) and (defn bar "some docstring" [arg list] ...). that'll get you through 95% of situations.
11:27ravster[arg list]?
11:27ravsteroh, right, defn.
11:27ravsternvm.
11:27ravsteroh, so the docstring comes before the [arg list]
11:28ravsterjoegallo: thanks
11:29joegallogauravag: you don't need to compare numbers, you can just keep them as strings, OR, you can just compare seqs
11:29joegallo,(defn palindromic? [s] (let [s (str s)] (= (seq s) (reverse s))))
11:29clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
11:29joegallo~(defn palindromic? [s] (let [s (str s)] (= (seq s) (reverse s))))
11:29clojurebot,(let [testar (fn [x y] (if (= (reduce + (filter odd? (range 0 x))) y) (str y " is an")) )] (testar 10 25))
11:30joegallo(palindromic? 101)
11:30joegallo(palindromic? 101) would work the same as (palindromic? "101"), which is somewhat nice...
11:30gauravagoh yeah..
11:31gauravagthat is a nice to have.. but I still have the performance problem! :(
11:31joegalloravster: yes, see https://github.com/dakrone/clj-http/blob/master/src/clj_http/core.clj#L28 for an example.
11:32joegallothe defn and name on one line, then a line or paragraph of docstring, and then arguments vector on the line after. that's pretty much standard.
11:33joegallogauravag: you are checking more number than you need to.
11:33joegallo100*101 = 101*100, so you can modify your number generator to do a better job of avoiding the duplicate multiplications.
11:34joegalloand then that would have you checking fewer results to see if they're palindromic.
11:35hyPiRionReverse the problem.
11:35gauravagI understand that.. but the logic would become complex if am trying to avoid 15*8 and 40*3
11:35joegalloyeah, worry about that later.
11:36gauravaghyPirion: explain?
11:37joegallogauravag: takes 1.5 seconds on my machine -- how fast do you need this to be?
11:37gauravagjoegallo: I was looking to leverage the multi-core architecture for this problem
11:38gauravagIf the number increases it really makes no sense even if I am able to filter out only some of the numbers.
11:39gauravag4-digit * 4-digit, or going higher than that would be very difficult!
11:39hyPiRiongauravag: First off, what do you know about a number which is a product of two three-digit numbers?
11:39joegalloright, but by adding a :when (=< x y) you can cut the size of the problem in half...
11:40hyPiRion,(* 999 999)
11:40clojurebot998001
11:41hyPiRionSo the highest possible palindrome is on the form abccba.
11:41hyPiRionwhere a is nonzero.
11:42gauravagoh yes..
11:43gauravagyou are looking towards a different solution?
11:50hyPiRioniterate over the abc's descending instead, and check if it's possible to split in two.
11:54hyPiRionlike this
11:54hyPiRion,(let [cands (set (range 100 1000)) good? (fn [n] (some cands (map (partial / n) cands)))] (first (filter good? (for [a (range 9 0 -1) b (range 9 -1 -1) c (range 9 -1 -1)] (Long. (str a b c c b a))))))
11:54clojurebot906609
12:00gauravag(let [cands (set (range 100 1000)) good? (fn [n] (some cands (map (partial / n) cands)))] (first (filter good? (for [a (range 9 0 -1) b (range 9 -1 -1) c (range 9 -1 -1)] (Long. (str a b c c b a))))))
12:00gauravaghyPiRion: have you really optimized for tried optimizing for time?
12:01brainproxyanyone else found themselved using datomic and its db functions feature to achieve polymorphism, i.e. along lines of multimethods and protocols, but more meta-data driven?
12:03brainproxyi've flipped flopped a few times now on that approach, fearing it would be hard to maintain, but the lure is very strong
12:04hyPiRiongauravag: not completely, but it's running on roughly 150 msec here.
12:04hyPiRionYou could do some more mathy tricks to get it even further down
12:06gauravag(source partial)
12:08brainproxyGuest18246: what you sticking the range into a set?
12:08brainproxywhoops
12:08brainproxygauravag: ^
12:08brainproxy*why are
12:09brainproxysorry, just woke up
12:09gauravagwas just wondering the same thing!
12:10brainproxyi mean, it will work, but I don't see that it changes anything, you're still leveraging it as a collection
12:10brainproxyso might as well stick with the LazySeq coming back from range
12:55gauravagBronsa: , are basically white spaces in clojure
12:55Bronsayeah
13:32antoineBhello, does exist a macro that transform (my-or = a [c d]) to (or (= a c) (= a d)) ?
13:44borkdudeantoineB the closest would be (#{c d} a) probably
13:44mattmossantoine left
13:45mattmossI was thinking: (some (partial = a) [c d])
13:46borkdudemattmoss or just (or (= a c) (= a d)), what's the big deal anyway ;)
13:46ChongLiif your [c d] vector happens to have thousands of elements
13:46mattmossborkdude: No biggie... context is everything. However, antoineB left.
13:47ChongLikinda silly to ask a questin and leave so quickly
13:47jeremyheileryeah... i mean at least 4 of us where thinking about it
13:47mattmossBets on him coming back and asking again?
13:48ChongLiI've seen him here in the past
13:48ChongLiso he'll probably be back
13:48ChongLimaybe not today though
13:58jeremyheiler(defmacro my-or [f a vs] (cons 'or (for [v vs] `(= ~a ~v))))
13:58jeremyheilermeh?
14:00jaimefjava stack traces always ruin such a great lang
14:05firesofmayHi, is it possible to include a library inside repl? or is it possible to have a library which is always available without adding it to all repos project.clj? Like clojure-docs api for example? : https://github.com/dakrone/clojuredocs-client
14:05ivanjaimef: ask chouser to release longbottom
14:05alexakarpovhm? I have just started with Clojure, but I find it's stack traces really puzzling... or are you saying it's Java's fault?
14:05dakronefiresofmay: if you are talking about the clojuredocs-client in particular, lein2 already includes it in the repl
14:05firesofmaydakrone, ah okay.
14:06AimHereThe stack traces appear to be raw Java stacktraces, which are very definitely annoying to work with
14:06dakronefire up a lein2 repl and do (cdoc map)
14:06AimHereWhose fault it is is left as an exercise for the lynch mob
14:07alexakarpovoh I see; so Clojure doesn't have it's own mechanism for producing stack traces, then?
14:07firesofmaydakrone, How to I run it? (cdoc map) is giving me error. Unable to include also : (use 'cd.client.core) > error.
14:07dakronefiresofmay: are you using lein version 2?
14:07firesofmaydakrone, i mean (use 'cd-client.core)
14:07firesofmaydakrone, yes
14:07firesofmaydakrone, I am running this inside emacs btw using slime.
14:07dakroneahh, so that REPL is a little different
14:08dakronecd-client gets added to the vanilla `lein repl` repl
14:08firesofmaydakrone, okay. so is there a way around this?
14:08dakronefiresofmay: you could add it as a dev dependency to your project, so it'll be available while you're at your dev REPL
14:09firesofmaydakrone, But Is there a way to add this like a global library?
14:09firesofmaydakrone, without me adding it to every project.clj
14:09dakronefiresofmay: you could add it to your ~/.lein/profiles.clj :user profile, I'm not sure if that one gets added to each project for a slime connection (or you could put it in the :dev profile in ~/.lein/profiles.clj, but that's not a great repeatability practice)
14:10ChongLiI'm very interested in longbottom
14:10ChongLiit seems to remain shrouded in mystery though
14:10ChongLiapart from some slides
14:10firesofmaydakrone, I thought its only for lein plugins ~/.lein/profiles.clj no?
14:11dakronefiresofmay: depends on where you add it, you could add {:user {:dependencies [[cd-client ...]]}}
14:11firesofmaydakrone, I see.
14:12dakronefiresofmay: not sure if this is an approved way, I would recommend looking into nrepl.el and using middleware for it
14:12firesofmaydakrone, okay
14:14berdariodakrone: do you know about nrepl.el?
14:14technomancyyeah :dev in ~/.lein/profiles.clj will be likely to conflict
14:14dakroneberdario: yes? that is an ambiguous question
14:15dakroneyes I know about it, I use it
14:16berdariodakrone: I was just wondering if you could help me debug a problem with launching it
14:16berdariothat is, it fails when M-x nrepl-jack-in
14:16dakronewith what error?
14:17berdarioit's an error related with $SHELL, function or variable
14:17berdario(it says that variables may not be used as commands... and indeed, I'm not using a standard bash shell)
14:18dakronenot really familiar with that error, have you tried opening an issue on the github repo?
14:19berdariodakrone: I usually avoid to report problems if I'm not able to pin down exactly what's going wrong
14:19berdariobtw, it just dawned upon me, that... even if I installed nrepl.el from marmalade, I can just try to modify the .el file, and...
14:20berdario(I just realized that I don't know where it's stored...)
14:20jaimefI am saying the java stacktrace wakes me up from my lisp fantasy :P
14:20ttvdlol
14:21jaimefwant a ":1 to continue :2 <abort>"
14:21dakroneberdario: ~/.emacs.d/elpa/nrepl*
14:21berdariook, elpa/nrepl
14:21berdariodakrone: thanks :)
14:22berdariodakrone: since you're probably more emacs-knowledgeable than me... do you suggest to erase the .elc or to use a command to recompile them?
14:23jaimefberdario: did you install manually? or through package-install?
14:23berdariojaimef: package-install
14:23jaimefwhat problem are you getting?
14:23jaimefis this win32?
14:24jaimefberdario: which OS are you using?
14:24berdariojaimef: Linux (Ubuntu 12.10), emacs 24
14:24jaimefodd. what is your $SHELL?
14:25technomancyberdario: you can always find where something is defined in Emacs with C-h f
14:26berdariojaimef: fish, and fish indeed doesn't let to use variables as commands... I was expecting to find a shebang or a way to configure the shell in which to execute the command inside nrepl.el, but I'm at a loss for the moment
14:26technomancythough I recommend the elisp-slime-nav package for even better navigation
14:27technomancyberdario: if you clone from git you can use M-x package-install-from-buffer to apply your changes and get the byte-compilation/autoloads set up
14:27berdariotechnomancy: thanks, I'll look into elisp-slime-nav (uh, I have tons of things to install and configure, already)
14:27berdariotechnomancy: thanks again :)
14:27technomancythat one is pretty simple; just install it and suddenly M-. works in elisp like you'd expect
15:05berdariodakrone: I got it to work... opened the issue on github :) https://github.com/kingtim/nrepl.el/pull/192/files
15:43tgoossensI noticed when solving problems on 4clojure I very frequently end up using loop, recur. Is it the nature of the problems on 4clojure or is it just me trying to use tail recursion to bring back my familiar loops of imperative programming.
15:43bbloomtgoossens: maybe a mix of both :-)
15:44tgoossensprobably :)
15:44bbloomin generally, i'm a big believer in loop/recur while working through the problem
15:44bbloomit forces you to consider the base case and the general case
15:44bbloomyou need to think about termination conditions, what changes on each iteration, etc
15:44tgoossensit has worked great for me. yes indeed
15:44bbloomi often write the loop/recur version, and then go back and extract it into a multi-step process
15:44bbloomand then find the builtin for each step
15:45tgoossensjust wrote a function for infix caluclations (infix 1 + 2 / 3) :)
15:45tgoossensi was hoping to find a solution with reduce
15:45tgoossensbut so far i haven't
15:45tgoossensi did it with loop,recur
15:46tgoossensand some curry
15:46bbloompaste your solution on refheap
15:48tgoossensok
15:51tgoossensbbloom: https://www.refheap.com/paste/7608
15:51bbloomtgoossens: random nitpick… seems like 2 spaces are preferred over tabs in most clj i see :-)
15:52tgoossensjust coming from java :p
15:52tgoossensand lol, you are not the first one to say that to me :p
15:52bbloom(doc empty?)
15:52clojurebot"([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:53tgoossensmm
15:54bbloomok so reduce in core is really a foldl, which is defined in terms of a binary operator, an initial accumulator value, and a sequence
15:54bbloomhere, your base case of "(empty? expr)" basically says "exhaust the input sequence"
15:55tgoossenscorrect
15:55bbloomand you are combining expr and value in some way (two operands) on each non base case loop
15:55bbloomso yeah, definitely a reduce opportunity! :-)
15:55bbloomtry this: move the if form inside the second argument to recur
15:55tgoossensi've been thinking about partitioning first
15:55bbloomthat's basically your binary operator
15:55tgoossens(partition 2 ... ) or something and then use reduce
15:56bbloomit's simpler than that :-)
15:56tgoossenswhich of the ifs?
15:56bbloomthe number? check
15:56tgoossenshmm
15:56bbloomnotice that the first argument to recur is always the same
15:56bbloomso you can use the if inside the expression for the second argument
15:57tgoossensmmyes
15:57bbloomminimize the scope of any particular expression (where it doesn't hurt readability)
15:57bbloomand that will get you closer to abstracting out the binary operator you need for reduce!
15:57tgoossenslet me try that
15:57bbloombrb
15:57epitrondo you clojure people find yourself parsing english sentences with parens as clojure code? :)
15:59tgoossensepitron: kind of :p
16:00epitron(if that makes sense)
16:00AimHereI find myself writing the left parens in front of the function name in C-like languages and Excel spreadsheets
16:00tgoossensaimhere: same "problem" here
16:00tgoossensit happens a lot that i write
16:00tgoossens(if
16:04dimovichhey ppl
16:04tpopehi
16:05dimovichcan someone enlighten me regarding the web crawler example from Clojure programming book?
16:05dimovichthe agent action uses a (try ... (finally)) form...
16:06dimovichwe return the new state in the try body, but we use this new state in the finally form...
16:06clojurebotanybody is anyone
16:07dimovichso... is the finally form evaluated after we return from the function... or how does it work?
16:07tpopedimovich: the finally is evaluated before returning
16:08AimHereEven if there's an exception in the try block
16:09dimovichhttps://gist.github.com/4299179
16:09dimovichget-url returns the new state... but we need this new state in the run function which is called in the finally block
16:11dimovichhow is the new state assign to the agent before returning?
16:11dimovich*assigned
16:11tgoossensbbloom: i did it
16:11tpopedimovich: the body of the try is evaluated before the finally. but both run before the function returns
16:11tpopeI'm not sure if that answers your question
16:11bbloomtgoossens: post it :-)
16:11tgoossensbbloom: i think its magical now :D
16:13tgoossensbbloom: https://www.refheap.com/paste/7609
16:13tgoossensstill checking how i'm going to make it even cleaner
16:13tgoossensbut i think its already pretty clean
16:15tgoossensapparently when copying it doesn't preserve my 2 space intendation, bah!
16:16tpopetgoossens: if you're using hard tabs defined as 2 spaces, then no, it won't copy
16:17tgoossensah
16:17tgoossensok that explains it
16:17tpopebetter to just use spaces. "soft tabs"
16:17tgoossensi'll remember that
16:17ravsterhello everyone
16:17tgoossensravster: hi
16:17tpopehi
16:19bbloomtgoossens: usually, when you split up arguments on to multiple lines, you line them up one argument per line, so that people don't need to count parens
16:19bbloomtgoossens: i was confused by the "identity expr"
16:20tgoossensok
16:20bbloomtgoossens: here's your exact code reformatted https://www.refheap.com/paste/7612
16:20bbloomnow you can clearly see the arguments t reduce
16:21solussdlooks like this is solved in clojurescript, but in clojure I cannot use clojure.walk functions with records b/c records don't implement the empty function of IPersistentCollection. Looks like there is an open, unresolved bug for it (CLJ-1105), but it's in the backlog. Does that mean no chance we'll see a fix in Clojure 1.5? :)
16:21tgoossensah cool
16:21tgoossensmuch clearer indeed
16:22tgoossensi'm so proud of myself now :p
16:22bbloom:-)
16:22bbloomthat's a pretty reasonable solution
16:22tgoossensclojure is a language where you really can get complete satisfaction from a piece of code :p
16:22bbloomyup
16:23tgoossensnext semester after my exams i should find myself some projects in clojure instead of playing around with 4clojure :p
16:24borkdudetgoossens I see you're getting really addicted.. nice ;)
16:25borkdudeI wonder what language is more addicting, clojure or Haskell -- I think clojure, but I don't know why really
16:25tgoossensborkdude: never worked with haskell before.
16:25tgoossensnext year i'll be seeing it in a course "declarative languages"
16:25tgoossensso now i'm focusing on other languages
16:26borkdudetgoossens in my first year at university we were taught Miranda - it was kind of a predecessor of Haskell
16:27ravsteris anyone having issues with ring.middleware,
16:27ravstera
16:27tgoossensthe problem with a language like haskell (i think) is that - like rich hickey state in his talks - is that we need to be able to model "processes"
16:27ravsterbah
16:27ravsterbasic-authentication
16:27borkdudetgoossens haven't seen a hickey talk in a while, so explain
16:27xeqi~anyone
16:27clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
16:28ravsterxeqi: :O
16:28ravsterthanks
16:28ravsterI'm now
16:28ravsterI'm not sure that its modifying the request object
16:29xeqican you make a paste showing how you're using it?
16:29borkduderavster maybe it helps when you post your handler.clj to refheap
16:30tgoossensthere are "processes" in your software that produce new values. There is the identity car. you can perceive that car in a certain state. The next time you perceive (look at it) it can may be in a different state.
16:30ivan"You cannot vote for an issue you have reported" what is this, metafilter? ;)
16:31tgoossensIt is the process that makes transitions possible and takes in account external events
16:31tgoossensits not the car that is *behaving* but rather
16:31borkdudetgoossens yeah, identity vs state
16:31tgoossensthe proces that brings the car into a new state
16:32bbloomtgoossens: clojure's notion of value, identity, and state is super interesting and enlightening, but i don't think that haskell is in anyway incapable of that approach
16:32tgoossensno it is capable
16:32tgoossens(monads i suppose)
16:32bbloomtgoossens: well haskell would utilize monads to implement it, but monads are an orthogonal issue
16:32tgoossensoh well, i think i should first learn the language
16:32tgoossensbefore i make such statements :p
16:32borkdudebbloom tgoossens isn't this more about persistent datastructures than anything else?
16:33bbloomborkdude: it's a bit deeper than that. it's about this idea that identity and value are two components of state
16:33tgoossensthe key thing is
16:33tgoossenswhat rich tried (and how i interpret it)
16:33tgoossensis to make a clear separation of
16:34tgoossensthe pure and the impure (process) part of the software
16:34tgoossensrather than trying to make eveything pure
16:34Chousukea state is the value of an indentity at a given point in time.
16:34Chousukethat's how they relate to each other.
16:34borkdudeChousuke right
16:34bbloomtgoossens: haskell excels at separating pure and impure :-P
16:35tgoossensbbloom: i'll let you know how i think of that next year then :
16:35tgoossens:)
16:35tgoossensi've seen people bringing monads (i have only a very very little understanding of the concept btw) to clojrue
16:35clojurebotI don't understand.
16:36Chousukebbloom: as far as I know, technically there is no such thing as "impure" in haskell :P
16:36tgoossensso maybe it'll become popular in the future
16:36tgoossens(more)
16:36bbloomChousuke: well of course there is
16:36Chousukebbloom: even IO is pure
16:36borkdudethe IO Monad.....
16:36Chousukesince from haskell point of view IO actions are pure values
16:36bbloomChousuke: if you're program doesn't explicitly do something impure, then the only thing it is doing is heating up your desk :-P
16:37bbloomtgoossens: haskell offer's clojure's notion of identity and state in several packages
16:37devncore.logic is so cool
16:37bbloomfor example http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Concurrent-MVar.html
16:38bbloomyou'll notice a similar API: readMVar is like deref, swapMVar is like swap!, etc
16:38Raynesborkdude: A popular misconception is that IO is impure. In reality, IO functions return IO actions that are instructions on how to perform an IO action and not the result of an actual IO action being performed right there at that moment.
16:38tgoossensbbloom: i wonderd. was clojure state / identity separation a new and unique idea introduced in clojure.
16:38Chousukebbloom: yeah, but that's outside the language :P
16:38Raynesborkdude: And then a little dude comes out and goes and performs those actions when you run the program.
16:39Chousukebbloom: from haskell point of view, IO actions are pretty much just like any other value
16:39bbloomtgoossens: i don't think that rich hickey claims novelty for any part of clojure :-P
16:39borkdudeRaynes yeh ok
16:39xeqithat unsafePerformIO is sneaky
16:39bbloomclojure is about pragmatism and clarity of mission
16:40Chousukexeqi: that's an extension
16:40Chousukeit's not actually haskell
16:40xeqihaha
16:40RaynesIt's amusing, but completely true.
16:40bbloom"let's take all the good new ideas and use them with all the good old ideas"
16:40bbloomwhere good ideas are very carefully defined
16:40tgoossensmmyes i can follow you on that
16:45devni like the idea of saying that clojure is about "what" and less about "how"
16:45devnRE: bbloom
16:45borkdudehttp://stackoverflow.com/questions/4063778/in-what-sense-is-the-io-monad-pure
16:46bbloomdevn: it's certainly evolving that way
16:46bbloomhowever, haskell & friends did a lot of deep research into separating the pure from the impure
16:46bbloomi think we need a language to deeply study the separation from how and what
16:46bbloomthen we can back port those good ideas into a lisp :-)
16:47bbloombecause, fundamentally, clojure dictates "how" at a very deep level: (f (g x) (h y)) says that g, h, and then f will be evaluated… in that order!
16:55SiphonblastCan someone help me setup clojure-mode within emacs? adding to my ~/emacs.d/init.el doesn't make the package-install [RET] clojure-mode visible.
16:55SiphonblastI'm new to emacs and none of this really makes any sense at all, really.
16:55Siphonblasthttp://dev.clojure.org/display/doc/Getting+Started+with+Emacs
16:57devnbbloom: reducers, though, as dnolen points out, fixes some of this
16:57devnbbloom: "should I use foldl or folr?" -- reducers don't care
16:57devnfoldr*
16:58devndeclarative programming, not order complected.
17:02bbloomof course, but like i said: declarative programming is the new frontier
17:02bbloomimmutible objects weren't a new idea in haskell
17:02bbloombut that community deeply explored functional programming
17:02bbloomprolog started to explore logic programming, but didn't really get into constraint programming
17:03bbloomoz/motzart has explored constraint programming more and dnolen et al are starting to import some of those good ideas
17:03devnviolent agreement complete!
17:04bbloom:-)
17:04devnbbloom: like most things, you need to take something to its extreme to discover where it is most useful
17:04bbloomdevn: yeah, i love "one issue languages" as learning experiments
17:05devnwhat i like about clojure is the idea of a la carte paradigms
17:05devnso we can have some (f (g x) (h y)) here and there, and then take all of that how, and use it in our what
17:05devnwhich sounds dirty
17:06bbloomdevn: i've been considering creating an experimental new language that has a strict separation of what and how
17:06bbloomjust to see what happens :-)
17:06bbloom(and how it happens :-P)
17:08TimMcbbloom: "Bah, your language is no good -- you're still complecting 'what I want to do' with 'the source code I write'."
17:08gfredericks(run 5 [r a b x] (== r [a b]) (infd a b (domain 1 2)) (<fd a b) (firsto r x))
17:08gfredericks^ errors o_O
17:09bbloomTimMc: i assume you're making a joke, but i'm not sure i get it and am curious for an elaboration :-)
17:09borkdudeI guess there is a function that gets the current date in Haskell? How on earth can that be a pure function?
17:09SegFaultAXI'm so happy that complect has made it into the daily vernacular of this channel. :)
17:09gfredericksborkdude: it wouldn't be; it'd return an IO Date or something like that
17:09devnSegFaultAX: it's spread pretty far and wide
17:09bbloomSegFaultAX: i was just saying yesterday: complect and reify are my two new favorite works :-)
17:09devni hear it a lot at work from people who are primarily ruby programmers
17:09SegFaultAXbbloom: Well, reify isn't new.
17:09devn(and quite often, since they're ruby programmers)
17:09devn;)
17:09bbloomSegFaultAX: yeah, but damn if it isn't a good word
17:10TimMcbbloom: Just a throwaway joke about source code being "too related" to what a program does. Clearly you need to separate those concerns better!
17:10SegFaultAXbbloom: Hah, you got me there.
17:10borkdudegfredericks I think we just established that IO of something was considered pure, because it was only a recepy of how an IO action would be performed
17:10devnTimMc: ha! i was thinking the same thing...
17:10bbloomborkdude: http://www.haskell.org/haskellwiki/Getting_the_current_date
17:10ivanSiphonblast: are you typing it into the minibuffer that pops up when you hit M-x
17:10SegFaultAXbbloom: But reification is a pretty general term.
17:10gfredericksborkdude: okay; well that's how it's pure then
17:10bbloomTimMc: i think the bigger challenege in separating "what" from "how" is that often the "what" *is* the "how"
17:10bbloomie with business processes
17:11borkdudegfredericks but a pure function always returns the same output with the same input…. getCurrentTime of course doesn't
17:11TimMcYeah, that's the ha-ha-only-serious side of my joke.
17:11TimMcI think you could go a long way before that's your biggest design problem, though!
17:12SegFaultAXborkdude: I think you mean a referentially transparent function.
17:12gfredericksborkdude: sure it does; it always returns you the same IO Date
17:14ravsterin compojure routes, does using [] in the argslist of the GET call just pass on the whole request?
17:15gfredericksravster: probably does nothing. you could either replace [] with req or {:as req}; I expect at least one of those would do that
17:20borkdudegfredericks you mean, it always returns the same "recepy for getting the current date" or smth? I think I'm too tired to understand this, but is there no way to create an impure function in Haskell?
17:21SegFaultAXborkdude: That's correct.
17:21gfrederickswell there is performUnsafeIO
17:21gfredericksbut pretend that there isn't
17:22gfredericksborkdude: that's what makes haskell interesting; the compiler forces the IO stuff to propogate all the way to the top. You can't "reach into" the IO yourself, you have to either let ghci do that, or the main function of a program.
17:22gfredericksso you can't hide side effects
17:24borkdudegfredericks well yeah, hmm, so… but you can get the current date inside a do block right? but it will always be wrapped inside an IO smth when you want to return it, so it will in fact always be a recepy of how you will get the current time and use that… or smth - I will look into this later, I'm really too tired :P
17:25SegFaultAXborkdude: We can help you in #haskell.
17:25borkdudeSegFaultAX so the only impure function in Haskell can be main?
17:25SegFaultAXborkdude: Impure function isn't a thing in Haskell.
17:26gfredericksborkdude: if the type of main is an IO Thing, then the IO will actually get performed
17:27gfrederickssame thing in ghci, which can be rather misleading
17:38borkdudegtg, bye
17:40Siphonblastivan: Thanks for the help, but I solved it just now. The solution was to install Emacs24 rather than wank around with the init.el of 23 like a noob :D
17:40ivanheh
17:40ivanyou might also want to take a look at what emacs-starter-kit does and copy things from it
17:43Siphonblastokay.
17:44hallski*qiot
17:50Siphonblastoh wow, this starter-kit-mode has confused the hell out of me, ironically.
17:50Siphonblastheh.
17:50SiphonblastThe GUI button at the top went away and were replaced with a scratch buffer or something. Oh gosh I have so much to learn.
17:50ivanM-x menu-bar-mode to turn the menu back on
17:51ivanthe toolbar that got turned off is pretty darn useless
17:51sshackOkay, A question and a riddle.
17:52sshackFirs the question. What's the current reasonable choice for CSV parsing libraries that support fieldnames in clojure?
17:56SegFaultAXsshack: What does it mean to support field names?
17:56sshackWell, in many CSV files, the first row contains the names of the columns. Like "name", "account", "balance", "address", etc.
17:57SegFaultAXsshack: Right, but what behavior do you need with those names, exactly?
17:57sshackIdeally I'd like to refer to the fields by name. Rather than field 3, field 4, etc.
17:58tgoossensequals equals equals
17:58tgoossens,(= = =)
17:58clojurebottrue
17:59SegFaultAXsshack: But you could do that yourself, no?
17:59sshackNo, I couldn't.
17:59SegFaultAXLike, (def headers [:one :two :three]) (into {} (map vector headers row))
18:00sshackAt that point I might as well be programming in assembler, writing my own pmode routines.
18:01SegFaultAXsshack: Hah. Anyway, I've used data.csv and clojure-csv, and they both worked fine.
18:01sshackI'll look at data.csv
18:03sshackclojure-csv doesn't do field names.. I'm dealing with CSV files that had missing/added fields and fields are frequently reordered.
18:03sshackHaving to do the mapping myself would leak that complexity into my app.
18:04SiphonblastO.O
18:04SiphonblastThis autocompletion and beginner mode is amazing.
18:04SiphonblastI feel like I've just had sex with software for the first time.
18:05pandeiroSiphonblast: well how was it?
18:05OctopusDoes anybody know the library quil?
18:05SegFaultAXsshack: That's like... 60 characters or something. Is it really as bad as all that?
18:06sshackSegFaultAX: It's a slippery slope. One I've fallen (or been shoved) down before.
18:06SegFaultAXsshack: That must have been awful for you... having to map your own headers.
18:06Siphonblastpandeiro: I don't know. I am still trying to interpret my experience.
18:08SegFaultAXsshack: If it means anything to you, the same pattern is common when using Python's csv module. [dict(zip(headers, row)) for row in mycsv] etc.
18:08sshackActually python's csv supports headers now too.
18:08SegFaultAXsshack: Oh? How recent is that?
18:08sshackheaders/fields/columnnames whatever you'd want to call them.
18:09sshackSegFaultAX: I was using python 2.7. so whenever.
18:09SegFaultAXOh, dictreader, yea.
18:09SegFaultAXBut that's just a wrapper for the above logic.
18:11sshackThat's fine. It still doesn't leak the complexity off to me.
18:12SegFaultAXsshack: Who hurt you?
18:12SegFaultAXsshack: I want you to know, I'm here for you.
18:12sshackSegFaultAX: sendmail.
18:12sshackand his friends autoconf and autotools
18:13sshackI appreciate it.
18:13sshackOkay, next the riddle.
18:14ravsterhello everyone
18:14SegFaultAXsshack: gogogogo
18:14SegFaultAXravster: Herro.
18:14sshackI've got a core dataset, say customers with name, account, balance, age, address, and postalcode
18:15sshackI'm splitting the customers into some number of groups (the whales, the average customers, cheapskates, etc).
18:15sshackThen I'm doing some aggregate statistics on the whales, normals, cheapskates, etc). Say average, stddev, etc.
18:16sshackBut I have proxy data for my customers too, based on zip code. So for example, average income, urban vs rural area, crime rate, etc.
18:16sshackI want to calculate the same statistics for those different groups on my proxy data as well.
18:17sshackThoughts on approaches?
18:17sshackbtw, this data isn't cheap to calculate, so I'm storing it in a table.
18:17SegFaultAXsshack: Sounds relational. Database?
18:17sshackI thought that part was a given.
18:18SegFaultAXsshack: Then what's the question? You have some reports you need to generate, go write some queries.
18:18sshackRight now the only approaches I can think of are quite complex. huge number of joins, etc.
18:19SegFaultAXsshack: Reporting is like that.
18:20SegFaultAXsshack: Sometimes it's useful to spin up a read replica specifically to serve your report generation.
18:20sshackThat won't be necessary here. It's a very low volume app.
18:22SegFaultAXsshack: Another option might be to use a datastore that's good at this sort of thing.
18:23SegFaultAXsshack: Eg a mapreduce datastore (couchbase, for example)
18:24SegFaultAXExpress your reports as designs documents and let the datastore figure out how to efficiently parallelize that over your dataset.
18:24sshackIt isn't a large data problem, it's a modelling one.
18:24sshackThe actual processing isn't an issue here. Just the modelling.
18:24SegFaultAXLike, your data model is bad and you should feel bad?
18:26sshackWell, perhaps.
18:26SegFaultAXsshack: That's the nice thing about pulling your data out and putting it into something like couch. I'm assuming that your current dataset is highly normalized which would lead to a lot of joining across loads of tables...
18:27SegFaultAXsshack: But that's REALLY expensive when you're trying to build lots of aggregates. If you load it into couch or something, your first step is to figure out a reasonable way to denormalize the data into core collections.
18:28sshackWell, my dataset fits into $500 worth of RAM. So the database isn't changing.
18:28SegFaultAXsshack: For example, your current user information + proxy exists as several tables (from your description) but you might join that information together into a much larger "user" document.
18:28sshackI was thinking about views. Which would work nicely. But I'm not sure how to make adding/removing proxy data reasonably easy.
18:30SegFaultAXWell views won't really help you here. Materialized views might, though.
18:32sshackI think there's multiple ways to go about this.
18:32sshackviews is the obvious first choice. But I'm not sure that'd be flexible.
18:34craigbroI don't understand the aversion to joins here
18:34SegFaultAXcraigbro: Just the slowness I'm assuming.
18:34craigbrojoins across alot of tables is not epensive if you have your indexes built right
18:34craigbroespecially if, as you said, it all fits in ram
18:37craigbroit WILL gen expensive if you start doing alot of OR or NOT conditions, or aggregates, and then sorting
18:37craigbroOR/NOT can mess up your query planners use of indexes and stop you from just index scans and instead do a table scan
18:37SegFaultAXcraigbro: But that's the thing, he's building reports. So yea, probably lots of aggregates, complex constraints and lots of derived tables.
18:37craigbroand aggregate and sortings on big big data usually ends up CPU bound
18:38craigbroif it fits in ram, tho none of this is gonna amount to much
18:38craigbroon my 3tb+ database it is only if I'm doing aggregates on the biggest tables 150million plus rows, that I notice DB time at all
18:38SegFaultAXsshack: Ultimately, I think you should just pick the simplest possible solution and measure. Improve after you have real data.
18:39craigbroand that's with a horrid IO constraint due to a hardware problem on that server right now
18:39sshackSegFaultAX: I agree. I'm taking baby steps out from there now.
18:40sshackcraigbro: I'm wanting to do aggregates for each of the columns, for the multiple classes.
18:40ravsterhow do I cleanly exit from an nrepl.el session?
18:40ravster(quit) and (exit) and C-d don't work.
18:41craigbrosshack: how many rows in your core set (customers) and in your annotation data (demographics etc..?)
18:41craigbrothe slowness of aggregates here I mentioned is prolly not an issue if your DB fits in memory
18:41sshack170, Probably a few hundred in my proxy data in the end.
18:41craigbrowhat?
18:41clojurebotWhat is 2d6
18:41craigbrothat's all
18:41craigbrofuck, just put it into a DB and write your SQL
18:42craigbroleave it in whatever DB it's in
18:42craigbroany concern about the performance of an sql database on that dataset is, well, misplaced 8)
18:42sshackcraigbro: I know. I was trying to get that point across to segfault. It's a modelling problem, not a DB problem.
18:42craigbroyah
18:42craigbrosorry, that's what I get for jumping in late 8^)
18:42sshackAny concern about performance can be cured by money in this case.
18:42SegFaultAXsshack: 170? Really? Wow.
18:42craigbroI acually find highly normalized tables easy to deal with
18:43craigbrosshack, you want some fun?
18:43craigbroload ALL the ata up into a bunch of core.logic defrel/facts
18:43craigbroand then write your reports that way
18:43SegFaultAXsshack: I thought we were talking about actual data.
18:43craigbrothat's what we do for generate reports on our malware analysis runs (which are a bouple megs of JSON each, and quite complex)
18:44craigbrosshack, of hell, just load each table up intoa couple of refs
18:44craigbro/sof/or
18:44craigbros/of/or even!
18:44sshackcraigbro: Actually, I don't want fun. I want someone to say "Well that's obvious, lets move on".
18:44SegFaultAXLet's move on.
18:44craigbrowhat? no fun? 8^(
18:44craigbroI want fun
18:44craigbroi never get any fun anymore
18:44sshackcraigbro: The fun part is looking at your bank account if you've done things right.
18:45craigbronothing for ugluk, nothing for ghishnak
18:46craigbrook, gotta go
18:46sshackSo my current idea is to have a separate table storing table, column and class along with the aggregate result.
18:47sshackand then another table which has details of what proxy data to join in.
18:47SegFaultAXsshack: Your current dataset probably fits in a few megs /at most/. It literally doesn't matter.
18:48sshackSegFaultAX: It's about 9gig currently.
18:48sshacka few million rows.
18:48SegFaultAXYou said 170.
18:48sshack170 columns
18:48SegFaultAXOhhh, 170 columns.
18:48sshackoops.
18:49sshack170columns+few hundred proxy columns. A few million rows. Still nothing though.
18:49SegFaultAXHe asked how many rows.
18:49SegFaultAXNot columns.
18:50sshackYeah, I'm sorry. I misread.
18:50SegFaultAXWell that changes everything.
18:51sshackRegardless, it's still a modelling problem. Not a data problem. The data will all still fit in memory.
18:53sshackA view would be brittle (couldn't easily add/change things on a dime.
19:05ravsterwhen we use datomic sessions through ring.middleware.sessions, do the keys in the :session have to match the key-names in the DB schema?
19:11ravsterWhere can I find information on the SessionStore protocol that ring.middleware.sessions is using?
19:11erwagasoreMoustache vs Compojure? What is the best choice?
19:12NonIncGood evening! I've got this list with a single string in it. This string is a decimal number. Now i want to create a symbol to give me its value so i can do calculations with it. In the example https://gist.github.com/4301198 I need to replace stragedef with something i do not know. Can you please help me?
19:13scottjerwagasore: compojure is much more popular and I think has more features. other than that I think it's personal preference.
19:16NonIncI'm sorry, just learning. I read about sequences and found out i can 'decapsule' a single element with (first list). Nevermind
19:34bbloomNonInc: your problem is not clear, what are you trying to accomplish?
19:35ravsterwhich rabbitmq client do people here prefer using?
19:39SegFaultAXDecapsule?
20:23bbloomseangrove: the more i work on this cps transform, the less i think it will actually be useful
20:23seangrovebbloom: Would be cool to share your thoughts and rationale
20:23seangroveQuick post on the current state?
20:23seangroveI'd love to try to understand it myself
20:24bbloomthoughts still forming on the usefulness of it
20:24bbloombut in the meantime, i've scoped it down a tad
20:24bbloomat first, i wanted to do basically what scala did: provide automatic continuations throughout the system
20:25bbloombut i think some kind of type system is necessary to have that work in a sane way....
20:25bbloomany higher order function that accepts a continuation passing function needs to be implemented differently
20:26bbloomscala gets static polymorphic dispatch based on types, you can overload a function such that (reduce f coll) is different depending on if f accepts a continuation or not
20:26bbloomas it stands, i'd need to do like the reducers library does with r/map etc
20:26bbloomi'd basically need k/map and k/reduce and all that jazz for continuation passing style higher order functions
20:27bbloomunless you add some "type hints" that says this function is or isn't CPS
20:27bbloomand then compile two version of every higher order function :-/
20:30bbloomseangrove: does that make sense?
20:31seangrovehmm, yes
20:31seangrovePresumably you could do it if the signature of the function matched some contract?
20:32bbloomseangrove: so the calling convention i'm using is that any CPS function takes as it's first argument an IContinuation object
20:33seangroveSo then any function could be made to work with a tailored wrapping function then?
20:33bbloommaybe? it needs more exploration
20:34bbloomso like i said, i reduced down the scope a bit: i'll no longer recurse into function bodies when doing the transform
20:34bbloomso you need to opt into a cps transform with a macro and any nested functions will be protected from transformation
20:34seangroveSounds reasonable, that's what I've been with the libraries I've been trying to use - organize wrappers for them so they all use the same calling convention, so I can macro away some of the tedium
20:34bbloomyou'll have to explicitly use call-cc, just like you would explicitly async/await in C#
20:35seangroveYeah, that sounds right
20:35bbloommy goal is to get to there
20:35bbloomand if any more useful macros or libraries can be built on top, that'd be good news
20:35Sgeoooh, someone's implementing call/cc?
20:36seangrovecall-cc makes me smile though, I haven't worked with anyone who both 1.) understood it and 2.) thought it was a good idea to expose by itself
20:36bbloomSgeo: https://github.com/brandonbloom/cljs-cps/
20:36Sgeobbloom, here's one: Delimited continuations allow for a very pretty interface for using monads
20:36bbloomSgeo: eh, i'm not super interested in monad libraries
20:36bbloom:-P
20:36SgeoOh
20:36bbloombut if you think you can built one on my cps lib, i'd love to see it
20:36bbloom:-)
20:37bbloombut i decided to implement call-cc as the basis, rather than start w/ delimited continuations b/c of the nature of the top level being a non-cps form
20:37SgeoI'm currently rather interested in Factor. It has threads that "block" etc. etc., with 1 "real" thread and co-operative multithreading based on call/cc
20:37bbloomshift/reset can be implemented with call-cc, an atom, and some macros
20:37SgeoInteresting stuff
20:37SgeoAlthough sucks when you accidentally write an infinite loop
20:38bbloomSgeo: yeah, co-operative multithreading use cases would be interesting too
20:38bbloomi'm trying to get the simplest bits to work reliably
20:38bbloomhence some macro (tenatively called spawn, needs to be renamed) which transforms it's lexically enclosed form
20:38seangrovebbloom: Sounds like a good idae, I think it's a very interesting area to explore and build on
20:39bbloomany uses of (call-cc f x y z) inside that macro then get transformed into (f K x y z)
20:39bbloom(would also be an apply-cc too
20:39bbloom)
20:39Sgeobbloom, can a function in the macro call another function that itself calls call-cc?
20:39bbloomSgeo: should be able to
20:39SgeoOk, good
20:39SgeoBecause without that, it would be difficult to build useful abstractions on top of it
20:41bbloomyeah, well that would of course work :-)
20:41bbloomso i think i'll "ship it" when this thing is basically equivilant to the async/await keywords in C#
20:41bbloomwill be a tiny bit different
20:41bbloombut i think libs can be built on top of that
20:42bbloomi'm not sure what those libs will be yet
20:51dnolengfredericks: ping
20:58aphyrUh, what's a good way to tell prn not to recurse indefinitely and run out of stack?
21:03amalloy&(doc *print-depth*)
21:03lazybot⇒ nil
21:03amalloy&(doc *print-level*)
21:03lazybot⇒ ------------------------- clojure.core/*print-level* *print-level* controls how many levels deep the printer will print nested objects. If it is bound to logical false, there is no limit. Otherwise, it must be bound to an integer indicating the maximum l... https://www.refheap.com/paste/7619
21:03aphyrAha! Thanks amalloy!
21:04aphyrWeird, why is that not in core.clj...
21:04tpopecore_print.clj
21:05tpopeI discovered this just today!
21:21tpopesome projects are like foo.bar-test and others are like foo.test.bar. Is there a backstory there?
21:22aphyrtpope: bar-test is the new style.
21:23aphyrI expect it changed so that projects could use myproject.test namespaces without colliding.
21:23tpopeah, makes sense
21:28caecusumHi. I'm trying to figure out how to use (eval) in the context of a simple client/server application that lets the user type in expressions. I've borrowed some Clojurescript code from the Sierra/VanderHart book, and have it all working for the most part. The problem is, any time I try to eval my own functions, they aren't in scope. The code looks like this: http://pastebin.com/W00BkmeU
21:29caecusumSo if I send a request with an expression like (+ 2 2) it works, but if I do (k) then it doesn't
21:46aphyrcaecusum: my guess is you're not evaluating the code in the context of cljs-d3.server
21:46aphyrTry this: (binding [*ns* (find-ns 'cljs-d3.server)] (eval expr))
21:47aphyr... and make sure your host is server is firewalled, haha. ;)
21:47caecusumI know it's unsafe, I'm just doing it through localhost as an experiment :)
21:50caecusumbinding the namespace worked great! thanks
22:00wingywhat's the easiest way to convert all string keys in a map to keyword keys?
22:01wingyeg. {":foo" 1} to {:foo 1}
22:01aphyrOn clojure 1.4?
22:01wingyyeah
22:01wingyhmm btw
22:01wingylet me reprahse
22:01wingyrephrase
22:02wingyi wanna eval all keys/values in a map
22:02wingyeg. {":foo" "2"} -> {:foo 2}
22:02aphyrGotcha.
22:03aphyr(into {} (map (fn [[k v] [(read k) (read v)]) coll))
22:03aphyrer, think I forgot to close the fn args
22:04aphyruse (eval (read)) if you actually want to evaluate them as code
22:05wingycan't i use read-string if i made that map to a string
22:06aphyrAh, yes, read-string
22:06wingyim actually using ring's form-params
22:06wingywanna eval all form-param's key/value pair
22:06wingys
22:07ivandepends on how hard you want to get owned by #= in a key
22:07wingywhat is that?
22:07ivanuser> (read-string "#=(+ 2 3)")
22:07ivan5
22:08aphyrwingy: if you're writing a web application, I strongly suggest using a more restrictive parsing
22:08wingyyeah
22:09wingyi should
22:09wingybut luckily me im just doing a prototype
22:09wingyi need something fast
22:09aphyrIf all you want is to convert keys to keywords, that's pretty straightforward
22:09aphyr(though again, you have to worry about the possibility of someone exhausting your keyword space!)
22:09wingyi need to convert values as well to clojure data
22:10aphyrIs there a strict EDN parser out there yet?
22:13seangroveIs there a reason why (swap! my-atom #({})) wouldn't swap the value of my-atom?
22:13aphyrwell anyway this will read string forms: http://cljbin.com/paste/50cd3abbe4b0b37878b7565d
22:14aphyrseangrove: #({}) becomes (fn [] ({}))
22:14aphyrseangrove: which means it's executing a map as a function
22:14seangroveAh, jesus
22:14aphyrIf you want to change the value of my-atom without respect to its current value, use reset!
22:14seangroveThank you
22:14aphyrIf you want a function that returns {}, use (constantly {})
22:15aphyrseangrove: yeah that bit me for about six months haha
22:15seangroveaphyr: I'm using dissoc, but that's not having any affect as well, so I was experimenting with just straight #{}
22:15wingyaphyr: great solution!
22:15aphyrDissoc should work...
22:16aphyr`(let [x (atom {:foo 1 :bar 2})] (swap! x dissoc :foo) @x
22:16aphyr,(let [x (atom {:foo 1 :bar 2})] (swap! x dissoc :foo) @x
22:16clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
22:16aphyr,(let [x (atom {:foo 1 :bar 2})] (swap! x dissoc :foo) @x)
22:16clojurebot{:bar 2}
22:16wingyaphyr: i should make a middleware out of it
22:16aphyrwingy: I really wouldn't encourage this, haha ;-)
22:16seangroveOh yes, I'm sure it's something I was doing
22:16wingyhaha
22:17seangroveOr am, rather
22:17wingyaphyr: RAP ftw!
22:17wingymeaning zero security
22:17wingyi meant RAD :P
22:18aphyrwingy: https://clojars.org/fogus/ring-edn
22:19aphyrwhat the what, that just uses read-string internally
22:19aphyrUghhhhhh
22:20seangroveIs that bad?
22:21aphyrseangrove: oh, this is for wingy's problem
22:21aphyrit means the web application using it is subject to arbitrary code execution
22:22madsyWhat are you guys talking about? Does ring have an evil/read-string flaw?
22:22aphyrNo, but ring-edn does!
22:22madsys/evil/eval
22:23madsyOh, okay. I'm not using that, phew
22:23aphyrhttps://github.com/fogus/ring-edn/blob/master/src/ring/middleware/edn.clj#L14
22:25wingyaphyr: so it evals the form posted to ring? so if someone types (println "hello world") in a form field i get that evaled in the server?
22:25aphyrChecking.
22:26aphyrI've never delved that deep into #= before
22:27aphyr(read-string "#=(map inc [1 2 3])")
22:27aphyr(nil nil nil)
22:29ambrosebsdnolen: what's nominal unification?
22:32ambrosebsdnolen: I think you'll enjoy this as a musician and a programmer. Overtone + core.logic by an AFAICT non-musician https://vimeo.com/55677313
22:34aphyrOK so this is... AFAIK undocumented, but binding *read-eval* false will close the #= hole
22:35aphyrAha, and wrap-edn-params does this. Terrific.
22:35ivan,(doc *read-eval*)
22:35clojurebot"; When set to logical false, the EvalReader (#=(...)) is disabled in the read/load in the thread-local binding. Example: (binding [*read-eval* false] (read-string \"#=(eval (def x 3))\")) Defaults to true"
22:36aphyrYeah, just never found #= in the reader docs before
22:36aphyrdidn't know it existed til today
22:36dabdI have a seq with some indices and I want to initialize each index (taken from the list) of a vector with some value. What is the functional way?
22:36ivan,(read-string "#=(eval (map inc [1 2 3]))")
22:36clojurebot#<RuntimeException java.lang.RuntimeException: EvalReader not allowed when *read-eval* is false.>
22:38dnolenambrosebs: yes I just watched that a little while ago - so cool!
22:41aphyr,(let [indices [1 6 2]] (reduce #(assoc %1 %2 true) (vec (repeat (apply max indices) false)) indices))
22:41clojurebot[false true true false false ...]
22:41aphyr^-- dabd
22:42dabdaphyr: i used recursion but this seems nicer. thanks
22:43ivanI think this is going on inside the #= weirdness with map
22:43ivan,(map 'inc [1 2 3 4])
22:43clojurebot(nil nil nil nil)
22:44ivanonly the first symbol is resolved
22:45dnolenambrosebs: nominal unification is a part of alphaKanren, it's to support nominal logic programming
22:46dnolenambrosebs: alphaKanren from Byrd's thesis allows for this. Basically it a logic programming approach that supports reasoning about scope. I'm sure there's much more to it than that but I haven't had time to look into beyond that Byrd describes.
22:47dnolenambrosebs: Byrd was skeptical that we could make it work w/ the constraint system we currently have - but I was pretty sure we could. It looks like Nada Amin thought so as well :D
22:48amalloyRaynes: http://www.reddit.com/r/gaming/comments/npdrt/a_very_portal_christmas_tree/
22:48amalloyer, wrong channel. but hey, maybe y'all will enjoy it too
22:48Raynesamalloy: Wrong channel
22:48RaynesOh man, that's awesome.
22:49ambrosebsdnolen: nice. I remember Will explaining nominal logic programming at Conj 2011, I didn't really understand it.
22:50ambrosebsdnolen: what does this test mean:
22:50ambrosebs(is (= (run* [q] (nom-fresh [a] (== q a))) '(a_0)))
22:50ambrosebsWhat is a_0?
22:52dnolenambrosebs: a term
22:53dnolenambrosebs: it gets interesting tho when you express that terms are free or bound in some other term.
22:54wingyaphyr: it was actually better to convert it myself using your code
22:54wingythan using edn middleware
22:55wingyno magic and i can add security
22:55ambrosebsambrose: what is a_0 vs _0? Is the former bound, latter free?
22:56dnolenambrosebs: oh sorry, nom-fresh creates fresh noms, which are different from logic vars
22:56ambrosebsoh got it
22:57dnolenambrosebs: thus they reify differently - a_0 vs _0
22:57dnolenambrosebs: http://arxiv.org/pdf/cs/0609062v2.pdf
22:57dnolenambrosebs: the first couple of pages sum up what's cool about it.
22:59ambrosebsthx!
23:12n_bYou declare a var as dynamic by defining it like this: (def ^:dynamic foo "bar"), right?
23:13n_bohhh, I see
23:14n_bI've misunderstood how this function, I think. If I within a REPL do (def *auth* new-val) I'm not rebinding, *auth* but overwriting it, and so would have to include the metadata again, correct?
23:20n_band the proper way to actually handle it is using binding so any changes to auth are thread-local?