#clojure logs

2013-08-31

00:00TimMcllasram: You mean you didn't have auto-shave back then? :-O
00:00technomancyI always associated INI with Windows
00:01xeqitechnomancy: same
00:01technomancybut I guess python people like it too
00:01SegFaultAXI actually have no idea why ini is used in Ansible.
00:01SegFaultAXIt makes no sense at all when you consider that /everything else/ is YAML
00:01TimMctechnomancy: Specifically Windows 3.1
00:01SegFaultAXI associate ini with Unreal Tournament for some reason.
00:01technomancythe yaml spec is kinda nuts
00:02SegFaultAX(It used ini heavily for all the engine configuration)
00:02llasram^^ understatement (technomancy)
00:02SegFaultAXI haven't read it, what's crazy about it?
00:02technomancyjson for config would be nice except for the idiotic refusal to allow comments
00:03SegFaultAXjson for config would be awful. :(
00:03technomancythough I don't know how widely that's enforced by parsers
00:03TimMctechnomancy: All you need is .jsonc, which would be preprocessed to remove comments. :-P
00:04llasramJSON's non-acceptance of terminal commas also drives me nuts
00:04llasramE.g., invalid JSON: [1, 2, 3,]
00:04SegFaultAXllasram: Yea.
00:05SegFaultAXFor configuration it really isn't an ideal format to be edited by hand.
00:05SegFaultAXLots of useless characters ,{}"" lack of multiline string support, etc.
00:06technomancyyeah, it'd need to be a superset
00:07llasramOr just use EDN. If you squint and ignore the Clojure-specific parts, it really is (or could be) a better JSON
00:08fkeyhmm question, (def foo "bar") (= foo (cljs.reader/read-string "foo")) returns false...but when i quote "foo" ,its true
00:08fkeyie (def foo "bar") (= 'foo (cljs.reader/read-string "foo"))
00:08llasramI've been doing a lot with a subset of EDN which round-trips through JSON, and it's been working out pretty well
00:08SegFaultAXfkey: Why would "bar" be the same as "foo"?
00:08SegFaultAX,(name 'foo)
00:08clojurebot"foo"
00:08llasramfkey: Reading isn't the same as evaluating
00:09SegFaultAXThat's why the second one is happening.
00:09fkeyah that makes sense
00:09fkeyhm, but (= '1 1) are the same?
00:10SegFaultAX,(type '1)
00:10clojurebotjava.lang.Long
00:10SegFaultAX,(type 'a)
00:10clojurebotclojure.lang.Symbol
00:10SegFaultAX,(type "a")
00:10clojurebotjava.lang.String
00:10llasramfkey: Quoting suppresses evaluation, but numbers are read as numbers, with no evaluation required
00:10fkeyah ok
00:11llasram&'[1 2 3 foo :bar "baz"]
00:11lazybot⇒ [1 2 3 foo :bar "baz"]
00:25SegFaultAXyogthos|away: Ping.
00:41TimMcfkey: And not all alphabetic sequences read as symbols either.
00:41TimMc&(type 'true)
00:41lazybot⇒ java.lang.Boolean
00:41TimMc&(type 'trux)
00:41lazybot⇒ clojure.lang.Symbol
01:33andrehIn general, in a function that steps through a list, is it better to use mapcar or (tail-)recursion?
01:33rhg135Map
01:35dobry-denandreh: do you have ane example
01:37andrehSuppose you want to add the index of each element to itself.
01:37andrehI believe it would be better with arrays, but I want to compare map and recursion
01:38dobry-den,(map-indexed (partial +) [1 2 3])
01:38clojurebot(1 3 5)
01:40dobry-den(pretty unhelpful example). i'm no clojure pro but (loop [] ... (recur)) is clojure's low-level loop. not every process can be simplified to "map this function across this collection".
01:41rhg135Yup
01:42ddellacostaso, anyone have tips on getting SSL going on Heroku with run-jetty?
01:43ddellacostaseems like it should just pick it up, but it seems not to be finding my ssl cert, only heroku's
01:45dobry-denMy files start with a Clojure map and then have a bunch of plain text. (read-string (slurp file)) will pluck out the map. but is there a robust way to get a string of everything else after the map?
02:06SegFaultAXandreh: What do you mean compare map and recursion? They aren't mutually recursive concepts.
02:06SegFaultAXMutually exclusive, rather.
02:14SegFaultAXIt feels pretty amazing to see all the ANN posts on the list.
02:14SegFaultAXSo much new development. :)
02:35ddellacostaSegFaultAX: seriously…it's totally wild how much new stuff is coming out all the time.
02:35ddellacostaawesome
03:06rurumateAfter some successful evaluations, my clojurescript repl (emacs inferior-lisp + cljsbuild repl-listen) doesn't evaluate things on RET anymore. What seems to be the problem here?
03:12rurumateOh, looks like it loses its RET-eval powers when I do M-x clojure-mode. But without clojure-mode, I won't have syntax highlighting and autocomplete
03:48arcatanis there a way to attach docstring to a macro after defining it
03:51RaynesWell, it requires sacrificing a child, but yes.
03:51RaynesYou'd have to modify the var in place to add the :doc metadata.
03:51RaynesBut please don't do that unless you have a very, very good reason that more people than just you have decided is a good enough reason :P
03:55arcatan:)
03:56dpathakjwhat situation are you in that this problem came up?
03:59arcatani was trying to add one macro's docstring to another macro
03:59arcatanasked that before i igured out ^{:doc } works.
04:09arcatani guess there's nothing around for re-exporting things from other namespaces? (appararently like defalias that used to be in clojure-contrib)
05:19clj_newb_2345http://docs.datomic.com/getting-started.html <- is this tutorial available as a *.clj rather than a bunch of commands ot type into bin/shell
05:22sojacquesHello everyone, I am looking for advice regarding a relatively simple database interacting app that I just started
05:23sojacquesI tried googling, but couldn't find anything to help me generate routes or simple crud operations, so I'm asking here
05:23clj_newb_2345use datomic
05:23clj_newb_2345it solves all db problems
05:24sojacquesdoes such a thing exist? or is this something that goes against idiomatic clojure ways?
05:24sojacqueswhat makes datomic so good? I was considering a sql store because of simple reporting & all that
05:24vijaykiransojacques: there's no rails like scuffolding stuff AFAIK
05:25s4muelsojacques: if you're looking for Clojure's "Rails", no, there isn't one -- and it wouldn't really be very idiomatic.
05:25sojacquesI'm not looking for rails, but as I saw compojure and korma, I thought that maybe someone made something to generate code
05:25sojacquesI'm against the idea of a monolithic framework, and more looking for simple tools
05:26vijaykirannope, I do it by hand - some notes here: http://www.vijaykiran.com/tags/clojure/
05:26sojacquesvijaykiran: thanks for the answer anyways!
05:26s4muelsojacques: compojure + liberator for RESTy things? Luminus, perhaps?
05:27sojacqueswow, liberator looks impressive
05:27sojacquesthanks a lot guys
05:27clj_newb_2345how does "lein repl" and "lein trampoline repl" differ, and how do I get nrepl.el to start emacs in the 2nd mode
05:29s4muellein tramopline kills the original leiningen jvm process after running whatever you want to run (in this case, a repl)
05:29s4muels/tramopline/trampoline/
05:30vijaykiranclj_newb_2345: can't you connect using nrepl and specify 127.0.0.1 and whatever the port from emacs ?
05:39sojacquesfollowup question: as I already did some scaffolding stuff from db models in other languages, I was told that lisp dialects were the best thing code, but I have ho experience and am looking to do it
05:39sojacquesso I can learn why lisps are good
05:40sojacquescan anyone lead me towards what's good with clojure for generating code?
05:40javehello
05:41sojacquesdamn that feels horrible to ask questions that are probably very beginner level
05:41vijaykiransojacques: so you want to learn about macros ?
05:41vijaykiransojacques: I don't think code generating code is the same as scaffolding ...
05:42noidisojacques, http://pragprog.com/magazines/2011-07/growing-a-dsl-with-clojure
05:42noidimaybe that could help
05:42javeI would like to make a call to a json rest backend in clojure. is there some convenient library? I have done the same in emacs lisp and it was pretty straightforward there: https://github.com/jave/curconv
05:43sojacquessorry, let me try to be more clear, I want to connect to a db, query tables and relations, generate korma code and compojure routes from that, and save them to files
05:43sojacquesconnecting to a db and operating sql is fine
05:43vijaykiranjave: how does this look : https://github.com/technomancy/clojure-http-client
05:44sojacquesbut the rest is what I don't know
05:44vijaykiransojacques: then it isn't a macro exploration per se - AFAIK
05:45vijaykiransojacques: if you have the "result" code, you can work your way up ..
05:46sojacquesvijaykiran: I see, in this case, does clojure provide me with anything over "generate strings in C, as you know how korma code will look like"
05:46vijaykiransojacques: of course, edn
05:46sojacquesPlease feel free to tell me if I'm totally misled
05:47sojacqueswow
05:47vijaykiransojacques: e.g. if you have one table Users, and you want to generate /users/:id, /users routes and korma code to generate .. first start with the resultant code
05:48vijaykiransojacques: and work in "reverse"
05:48sojacquesthis is what I would like to do, yes
05:48sojacquescan I treat this code as some list that I would just generate?
05:48sojacqueslists*
05:48vijaykiranyup
05:48sojacqueswoah
05:48vijaykiranthat's LISt Processing
05:49vijaykirana.k.a LISP
05:49sojacquesbut those lists are full of keywords and the like, won't the compiler scream all the way?
05:49sojacqueswell I'll try anyways, now I got the direction
05:49sojacquesthanks
05:49javevijaykiran: thanks, i followed the link, and they in turn recomended this, which seems nice: https://github.com/dakrone/clj-http
05:50vijaykiransojacques: good luck :)
05:50vijaykiransojacques: you just quote the forms
05:51sojacquesalright, finally I'll do something more interesting in Clojure than solving algorithmic problems, I get to do something that will save my precious time in the long run
05:52sojacquesthanks a lot
05:53javeanother question, if i want to add leiningen deps on the fly, withouth restarting the repl, do i use this: https://github.com/cemerick/pomegranate, or some other means?
05:54vijaykiranjave: pomegranate should be it.
05:54vijaykiranjave: also, see http://thinkrelevance.com/blog/2013/06/04/clojure-workflow-reloaded
05:56javethanks
05:57javeim a bit rusty with clojure, it seems.
08:03llasramjave: Use alembic: https://github.com/pallet/alembic
08:33sheldonhi'm a newbie trying to implement my own reverse function (just to explore), and i don't understand why my function returns ((5(4(3(2(1())))))) instead of (5 4 3 2 1). some cons subtlety that i don't understand, maybe? http://fpaste.org/36232/
08:36llasramsheldonh: Because the `& b` means "accept any number of additional arguments and return them as a list". So each call is (effectively) wrapping the second argument in a second layer of list
08:37sheldonhllasram: argh! like a splat in the languages i'm used to. okay thanks!
08:37llasramsheldonh: Np. Something else to note in your function is that Clojure has what's called "nil punning"
08:38llasramThe `nil` value isn't *identical* to an empty list (like it is in some Lisps), but you can generally treat it as one
08:38llasramSo you don't actually need to have the explicit `nil` case in your cond -- you already get the effect of an empty list "for free" there
08:38sheldonhllasram: i thought i was asking whether "the one optional argument called b was given?" :)
08:40llasramsheldonh: Yah. For that you generally just implement multiple arities of the function
08:40sheldonhllasram: perhaps i should just not bother trying to do it with one function, and have (defn xreverse-general [a b] ...) and (defn xreverse [a] ...)
08:40llasramsheldonh: No no -- one function is the way to go. There are at least two ways to do it
08:41sheldonhllasram: that sounds good. reading http://clojure.org/functional_programming ... thanks!
08:42llasramsheldonh: If you're just getting started, I highly recommend http://www.clojurebook.com/
08:42llasram(the book -- not the website for the book)
08:42sheldonhhehe
08:45grandyhello, just doing a tutorial about seesaw and have a question. In my app, after loading lein repl, the function (show-gui) is not able to be resolved... not sure what i'm missing: http://nathanwilliams.github.io/2013/05/15/seesaw-gui-programming-the-clojure-way/
08:47grandyanyone have the patience to help me with this very newb oriented problem
08:48sheldonhllasram: lovely, 'tworks! thanks. will check out the book when i've finished congratulating myself :) http://fpaste.org/36233/
08:49grandywhen i start lein repl will my namespaces be loaded automatically?
08:50llasramgrandy: If you have a :main namespace it will, and the REPL will start in that namespace. Otherwise not
08:50grandyllasram: is there a way to ask the repl what namespace it's in?
08:50llasramIt should be printed in the prompt. Usually starts as `user`
08:51llasramYou can check the value of *ns* to see explicitly
08:51grandyllasram: hmm, it just says the namespace is user
08:52grandyllasram: in my project.clj file I have :main "myprojectname.core"
08:52grandyllasram: and when is type lein run the program works as expected
08:52grandyllasram: however when i type lein repl and try to manually start the program, it is not being resolved
08:54llasramgrandy: I'm not sure why the REPL isn't automatically ending up there, but you can always enter it manually, which is what one generally does anyway honestly
08:54grandyllasram: with :use ?
08:54llasramIn the REPL, just `require` the namespace then `(in-ns 'correct.namespace.symbol)`
08:54grandyahh
08:54llasramOr use your editor facility for the same
08:54llasramM-n in nrepl.el, for example
08:55grandyhmm ok let me try that
08:55sheldonhgrandy: are you sure you're following that blog post? the namespace for the project.clj in the anvil-view repo is anvil-view.devel
08:55llasramsheldonh: I kind of hope he's not following that blog post, because when I check out the project, it explodes with missing dependencies :-)
08:56grandysheldonh: well i didn't copy that aspect of it, i just am using the default lein app structure and I added seesaw and a basic dialog box, which opens when i type lein run
08:57sheldonhgrandy: i was going to suggest a diff against the repo to spot the missing dependency, but llasram has cast doubt on that strategy, what with the repo exploding with missing dependencies out of the box. sorry :(
08:57grandyllasram: ok when i followed those steps in the repl (require and in-ns) it works as expected... i am guessing this must be how it's supposed to work
08:57grandysheldonh: yeah was going to do that too until i noticed that about the deps
08:58grandyso is the repl *supposed* to load a namespace other than user by default if I have added :main key to my project.clj?
09:00vijaykirangrandy: nope, :main is just a hint that that namespace contains main function
09:01grandyvijaykiran: ahh ok perfect, glad my app is working as intended... just learning clojure and have read a fair bit but decided that actually building a few simple apps would be a good way to learn...
09:01grandythanks for the help, everyone
09:01vijaykirangrandy: https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L163
09:02grandyvijaykiran: ahh ok, looks like it's very well documented, i should read up
09:02llasramgrandy: You can also pull that by running `lein sample`
09:03grandyllasram: ahh that's a clever feature
09:03llasramgrandy: How are you REPL-ing? Raw `lein repl`, or nrep.el, or something else?
09:04grandyllasram: just raw lein repl
09:05llasramWeird. I definitely see that `lein repl` automatically switches to the project :main namespace.
09:05llasramWhat version of lein?
09:06grandy2.1.1
09:06llasramThat said -- I definitely recommend hooking up some editor integration. You don't get the full experience without being able to just shoot forms back and forth between your editor and your persistent REPL
09:06grandyllasram: hmm ok that sounds intriguing, i am using clojure mode, i'll try nrepl.el unless you have another recommendation?
09:07llasramgrandy: Well, non-ancient. Weird, but not quite weird enough to convince me to dig much deeper :-)
09:07llasramYes -- nrepl.el is definitely the way to go from emacs
09:07llasramShould be just a M-x package-install away, then you can just hit M-j w/in a Clojure project to fire up an attached REPL
09:08grandyllasram: cool just installed it
09:13ToxicFrogIs there a convenient form for (if x x y)
09:13llasramToxicFrog: (or x y) ?
09:15ToxicFrogllasram: thanks
10:24grandyquick follow on question to my namespace question earlier... now that i'm in my project's namespace, typing (doc reduce) into the repl doesn't resolve... nor does (clojure.core/doc reduce) ... just curious how i'd access it w/o switching namespaces
10:24llasramgrandy: `doc` is actually in the `clojure.repl` namespace
10:24grandyllasram: ahh ok :)
10:25llasramgrandy: But if you're using nrepl.el now, try hiting C-c C-d on a symbol
10:26grandyllasram: hmm do i need the symbol to be fully selected first?
10:27llasramgrandy: You should just need to have the cursor w/in a symbol
10:27grandyllasram: hmm getting some kind of url class loader exception
10:27llasramHmm
10:27llasramThat's.... unfortunate
10:28vijaykirangrandy: some Meta .. blah blah ?
10:29grandyactually i noticed that it says class not found clojure.repl
10:29llasramOh! Weiird. It should be auto-requiring that namespace
10:30llasramTry manually `require`ing it
10:30llasramThen C-c C-d
10:30grandyahh now it works!
10:30llasramWell, at least it's working now...
10:30grandythat's fantastic.. .looks like something about my setup isn't doing the typical autorequiring
10:30llasramOOC, do you have anything odd in your ~/.lein/profiles.clj ?
10:30grandyllasram: just default everything
10:31grandyllasram: let me look at it, have not edited it
10:31grandyfile doesn't exist
10:33grandyllasram: just curious how you set up emacs windows, do you leave one for the output of C-c C-d etc.?
10:33grandy(buffers)
10:34llasramgrandy: Mostly. I've got some advice which shrinks doc windows down to be just large enough to contain the docstring
10:35grandyahh ok
10:35llasramEmacs' default policy of wanting to hand over half the vertical space is a bit troublesome :-)
10:35grandyllasram: yeah agreed....
10:36grandyllasram: what 3 things should i learn to use nrepl for first?
10:37llasramEr. Let's go with -- Compilation, docstring-lookup, and running tests (via clojure-test-mode, as much technomancy wants to be able deprecate it)
10:39llasramHere's my less-vertical-space advice btw: https://github.com/llasram/rcfiles/blob/master/basic/emacs.d/init.el#L225-L230 (using this function: https://github.com/llasram/rcfiles/blob/master/basic/emacs.d/elisp/tight-fit.el )
10:43vijaykiranllasram: you use eclim ?
10:43vijaykiranI gave up after it started toasting emacs and my CPU
10:44llasramvijaykiran: Was hacking on a Maven-using Java project recently (Avro). The feature I was writing was large enough that I didn't want to write that much Java unassisted, so I decided to try it out
10:44llasramI'm not frequently doing that much Java, so I don't need to leave the eclim server running all the time :-)
10:44llasramBut it actually worked pretty well
10:44vijaykiranAh, okay - I'm mostly in IntelliJ with "enterprise" projects
10:45llasramI keep saying I'll think about trying an IDE for Java or Scala, but then in practice I just want to stay in Emacs forever :-)
10:46vijaykiran:)
11:01riggervi/emacs
11:01riggersublimetext2
11:02seangrov`~emacs
11:02clojurebotemacs is an out-moded belief system
11:02riggerhehe
11:04crocketclojure.org is down
11:05vijaykirancrocket: work for me
11:05vijaykiranworks*
11:05riggersame
11:06crocketdamn
11:06crocketDoes anyone know a good clojure learning material?
11:07vijaykirancrocket: Oreilly Clojure book
11:07vijaykiran,clojure-book
11:07clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: clojure-book in this context, compiling:(NO_SOURCE_PATH:0:0)>
11:07vijaykiranmeh
11:07crocketvijaykiran, Is it free?
11:07vijaykirancrocket: :) nope, but worth it
11:07crocketvijaykiran, I just want to skim a preview of clojure quickly.
11:08vijaykirancrocket: try ociweb tutorials
11:08vijaykirancrocket:,google "ociweb clojure"
11:23crocketgood
11:23crocketvijaykiran, clojure looks promising
11:39kawas44Hello
11:40kawas44do people find stange behavior between println and printf ?
11:40kawas44compare this two lines of code that should have the same output to me
11:41kawas44(->> [["one" 1]] ((fn [coll] (doseq [[f i] coll] (println f i)))))
11:41kawas44(->> [["one" 1]] ((fn [coll] (doseq [[f i] coll] (printf "%s %s%n" f i)))))
11:42kawas44the second example print nothing :/
11:42noncomhow do i define a function in another namespace?
11:42noncom(intern)?
11:43noncom,(intern 'clojure.core 'heeeey "wow")
11:43clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
11:43dnolennew core.async post http://swannodette.github.io/2013/08/31/asynchronous-error-handling/
11:44noncomdnolen: cool! gonna read it
11:45cjfriszdnolen: already read
11:45cjfriszNow I just need to write some core.async code to get my head in that space
11:46cjfriszAnd also probably learn JS so I can appreciate not being in callback hell
11:46kawas44,(->> [["one" 1]] ((fn [coll] (doseq [[f i] coll] (println f i)))))
11:46clojurebotone 1\n
11:46kawas44,(->> [["one" 1]] ((fn [coll] (doseq [[f i] coll] (printf "%s %s%n" f i)))))
11:46clojurebot#<SecurityException java.lang.SecurityException: denied>
11:47dnolencjfrisz: you won't want to live there for very long ;)
11:47kawas44...
11:47cjfriszdnolen: I was secretly going to avoid that as best as I could :-)
11:49bbloomcjfrisz: it's definitely worth learning javascript for the same reason it's worth learning x86 assembly
11:50bbloomx86 isn't the best compilation target, but it's pretty damn popular
11:50bbloomthat's how i feel about javascript :-P
11:50cjfriszbbloom: agreed
11:51cjfriszThough I try to keep my JS learning to just the bits I need for writing CLJS experiments, and then try to hide that code in a separate namespace
12:10fuzcan anyone tell if there is anything wrong with my async usage here? http://pastebin.com/jSpKq52f
12:10fuzi get an error when compiled down to javascript….the code works (reads and writes to the channel)
12:11fuzbut there is always a javascript error Uncaught TypeError: Object [object Object] has no method 'call'
12:17javeI wrote some clojure web apps some time ago. What is the current best way to write a super simple web app? it should really just show a generated image
12:21kawas44jave: look there https://github.com/TechEmpower/FrameworkBenchmarks for code example using http-kit, compojure or luminus
12:22javekawas44: thanks. the last one i did was based on compojure i think
12:24kawas44jave: http-kit is a bare http server but very efficient, compure is still a good general web framework, luminus continue where noir left as an easy package of web function to rapidly prototype web site
12:26kawas44fuz: does your code work in vanilla clojure ?
12:28noncomwhy
12:28noncom,(symbol ''''i)
12:28clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to java.lang.String>
12:29noncom(type ''''i)
12:29noncom,(type '''i)
12:29clojurebotclojure.lang.PersistentList
12:29noncom^^
12:29noncomwhy the type is PersistentList?
12:30fuzkawas44, i don't know, i'll have to try that… probably shouldn't have used clojurescript specific libraries
12:31kawas44noncom: '(quote i) is indeed a list
12:31noncomah
12:31noncomi see
12:32kawas44,(symbol "i")
12:32clojureboti
12:32noncomyeah, just was curious about '''
12:38kawas44fuz: I was just asking to know if your algo and your clojure implementation was working with vanilla clojure
12:39kawas44fuz: because your exception gives an hint on a typo error or misuse of the language
12:39kawas44fuz: you have an anonymous function with a go block and a boolean ?? what do you want to do in here ?
12:42fuzoh that was me trying to work out where the error was being raised (by inspecting the generated javascript)
12:42fuzit doesn't need to be there
12:42fuz(there true that is)
12:43fuzfor some reason it's trying to run '.call(this)' at the end of the code…but the [object object] has no call method
12:43fuzso i assumed it was some part of the call was being evaluated as something it shouldn't be
12:43fuzcall-> code ^
12:48kawas44Does anyone knows the difference between those two codes execution ?
12:48kawas44,(->> [["one" 1]] ((fn [coll] (doseq [[f i] coll] (println f i)))))
12:48clojurebotone 1\n
12:48kawas44,(->> [["one" 1]] ((fn [coll] (doseq [[f i] coll] (printf "%s %s%n" f i)))))
12:48clojurebot#<SecurityException java.lang.SecurityException: denied>
12:49kawas44just using printf instead of println...
13:23ToxicFrogEurgh this is disgusting
13:23ToxicFrog40 lines of HTTP POST messiness
13:26SegFaultAXToxicFrog: Java?
13:27ToxicFrogNo, clojure
13:27ToxicFrogBut for a site with no actual API, so it's all HTML scraping and then doing POSTs with a dozen parameters to mimic form entry.
13:28SegFaultAXToxicFrog: Ugh, sorry to hear that.
13:28ToxicFrogI mean, this is replacing 400 lines of Lua messiness, but still, it's not pretty.
13:28SegFaultAXThat's awful.
13:34SegFaultAXSynthread looks awesome.
13:52clj_newb_2345The monger bindings as awesome ins htat I can store CLojure data structures as Monger documents.
13:52clj_newb_2345Howver, can we go a step further where a _incremental_update to a clojure data structure gets stored as a _incremental diff_ to the monger db?
14:06callenSegFaultAX: yes it does.
14:06callenSegFaultAX: solves a problem I had been thinking about lately (I'd been experimenting with the Continuation Monad in Clojure)
14:30javeim trying to do a simple webapp with http-kit and compojure. How can I reload the routes, and restart the server?
14:32javeatm I redefine the routes and restart a server on a new port, but thats a bit tedious
14:33callenjave: http://http-kit.org/migration.html#reload
14:34javeah, thanks
14:37fredyranybody here uses evil-mode in emacs for clojure?
14:39fredyri ask because i'm trying it and don't get the paredit and indentation to work reasonably
14:42kmicu$google evil mode paredit
14:42lazybot[roman/evil-paredit · GitHub] https://github.com/roman/evil-paredit
14:43fredyrwell ldo
14:43fredyrthats the one i've tried
14:43dnolenOK crazy realization of the day
14:43SegFaultAXThis talk about HTTP performance and privacy is awesome: http://www.infoq.com/presentations/HTTP-Performance
14:43dnolencore.async allows you to get sensible stack traces from async code
14:46shaungilchristimplicitly or provides the basis for doing so?
14:48dnolenshaungilchrist: provides the basis for doing so, promises mangle because errors must propagate through promises machinery
14:48dnolenuseless stack traces
14:48dnolenshaungilchrist: with core.async you can throw, thus short circuit and recover clean traces
14:48dnolentrivially
14:50kmicuobviously
14:50shaungilchristawesome, I just read your latest article w/ the <?
14:55callendnolen: pretty cool :)
14:55callendnolen: I used core.async to demonstrate how to write reliable tests for asynchronous services and code to my coworkers yesterday :)
15:15dnolencallen: were they impressed?
15:17callendnolen: yes but by different things depending on their experience level.
15:17dnolencallen: gotcha
15:17callendnolen: it wasn't the best possible demonstration of core.async since (go ...) was nearly irrelevant, but I did make a point of showing off how you can have disparate consumers and producers on the same channel (async on one side, sync on another)
15:18dnolencallen: nice
15:18callenI also showed how my functional tests exercising RabbitMQ were safe because all test-case results were coming over channels, not by trying to capture callback results through global state or stdout.
15:36irctcdoes anyone know how to add a list of values where some have nil?
15:40xeqi##(reduce (fnil + 0 0) [1 2 3 nil 5]) or ##(reduce + (filter identity [1 2 3 nil 5]))
15:40lazybot(reduce (fnil + 0 0) [1 2 3 nil 5]) ⇒ 11
15:40lazybot(reduce + (filter identity [1 2 3 ni... ⇒ 11
15:40irctcI was thinking just remove nils before reducing
15:40irctc(reduce + (remove nil? awesomelist))
15:41xeqithats a better formulation of the intent with the second one
15:42TimMcYou know what fn I keep forgetting to use? clojure.core/keep
15:43xeqi&(doc keep)
15:43lazybot⇒ "([f coll]); Returns a lazy sequence of the non-nil results of (f item). Note, this means false return values will be included. f must be free of side-effects."
15:43xeqi&(doc filter)
15:43lazybot⇒ "([pred coll]); Returns a lazy sequence of the items in coll for which (pred item) returns true. pred must be free of side-effects."
15:43TimMcI bet most cases of (filter identity (map f xs)) are only filtering for nil and not for false, so keep would be better.
16:01noncomcan i intern a macro which itself calls for a macro, in another namespace and how do i call it then to make the inner macro return *and execute* the value (and not just to return the macro itself). by execute i mean that the returned value is a function
16:02TimMcI dunno, this sounds pretty nuts.
16:03TimMcWhat in tarnation are you trying to do?
16:03Brand0L o L
16:03noncomTimMc: bad design, right?
16:03TimMcCould be, could be.
16:03TimMcCan't actually stay to talk, but I'm curious about what you're up to.
16:04noncomyes, i think that it surely is. it is just for my research work. i not gonna put it to production :) the actual task was to replace (ns) macro with a custom macro
16:04noncom(surely is nuts)
16:04noncomi do some kind of mathematical research
16:06Brand0emacs live anyone?
16:08callenBrand0: no.
16:08callennoncom: "research"
16:08callensometimes it's research, sometimes you're just burning ants with a magnifying glass.
16:08kmicuBrand0: Ask.
16:11arkhcan clojurescript use 'defn-' ? e.g. (defn- my-private-func [...] ...)
16:11noncomcallen: depends on which side of the moon you are today i think.. but really i'm doing mathematical research on expressibility and self-expressibility in languages.. it is pure fundamental math, so i guess it has no straight application.. but i was given the task, so..
16:12noncomcallen: it actually is about natural languages, but there is a subtask to analyze some programming languages too, to illustrate the differnces.
16:12noncomthe results will look like a bunch of formulas, so not very exciting
16:14fredyrarkh: yes defn- works in clojurescript
16:15arkhfredyr: thanks - google turned up nothing (treats "defn-" as "defn") but duckduckgo found the answer right after you o.0
16:16hfaafbhow might i stick something inbetween elements of a collection like this https://gist.github.com/samuelcferrell/6400223 ?
16:16bbloomarkh: don't be afraid to peek at the source! it's not that scary
16:17rhg135intersperse
16:17rhg135it's a thing
16:17rhg135interpose*
16:17hfaafbty
16:17noncomcallen: the (ns) macro is one of the primary targets for analysis because of its significance.. so do you maybe know how to replace it with a custom one?
16:27SegFaultAXnoncom: I'm also really curious about what you're working on. Intuitively it doesn't seem like what you're asking for is possible.
16:27SegFaultAXBecause it's predicated on being able to lift a macro into runtime, which is a contradiction in terms.
16:32noncomSegFaultAX: 'not' possible is also an answer.
16:34SegFaultAXnoncom: Either way it seems like a complicated way to accomplish whatever it is that you're doing.
16:34SegFaultAXnoncom: Why do you want to replace the ns macro?
16:37noncomSegFaultAX: there is a research on languages which has to present some theoretical linguistical data. it is built around the theory that the ability of a socium as whole to interact with reality depends on language characteristics of that population group. a special attention is paid to the characteristics of a language to 1) describe itself 2) to modify itself depending on context.
16:37arkhhfaafb: I'm sure there's a better way but here's one: (interleave [1 2 3 4] (repeat -1) (repeat -1))
16:38noncomSegFaultAX: now again the research is about real languages. and there is a subsection to try research computer language societies the same way. firsts we have to build the characteristics of the language.
16:39noncomSegFaultAX: replacing (ns) macro and allowing customize the behavior of namespace declaration would give much information on language self-expressivenes and self-modification characteristics
16:39noncomor a clear statement that this is not possible
16:39noncomwill do too
16:39SegFaultAXnoncom: Why do you have to reuse the name though?
16:40SegFaultAXEg clojure.core/ns
16:40SegFaultAXYou're of course free to define noncom/ns
16:40SegFaultAXAnd that can have whatever operational characteristics you're after.
16:41noncomSegFaultAX: oh, i think reusing name is not crucial. that option of self-reference is not that important. what is importatnt - is it possible to create a macro with the same power, customizable and use it instead of (ns). no need to take the same name
16:42noncomso now, ok. when I (require) a namespace, can the macro be devised in such a way that it will have the same power as (ns) to create that namespace and then execute the file contents inside it?
16:42SegFaultAXnoncom: In the case of ns in particular, yes.
16:43SegFaultAXnoncom: But there are other forms where that isn't the case.
16:43SegFaultAXNamely special forms.
16:44hfaafbty arkh
16:44SegFaultAXnoncom: Macros don't really /do/ anything. Their purpose is to take unevaluated lisp forms and produce new lisp forms.
16:45SegFaultAXnoncom: In this case, ns isn't what's important. Only the forms that ns eventually [recursively] expands to matter.
16:45noncomSegFaultAX: yes, i have read about them. I am a programmer and currently I am switching to clojure from scala... wheeeew!!! :)
16:45SegFaultAXSome of those forms are special and therefore not open to modification like other types of clojure forms.
16:46noncomSegFaultAX: so far I have been unable to write a macro which could replace (ns) at the beginning of a file.
16:46noncomthese "special forms" are language archetypes
16:46noncomall languages have them
16:46SegFaultAXYes.
16:47SegFaultAXns isn't one of them, though.
16:47noncombut i was unable to create a replacement for ns. could you give an example of such a replacement?
16:48amalloySegFaultAX: it's extremely difficult to replace ns, even though it's not a special form. you can write a replacement, but how do you get that replacement into scope without using ns first?
16:48noncombtw: what is ineteresting, is the relation and interaction between real and computer languages archetypes
16:48SegFaultAXamalloy: Well you'd have to have access to all the forms ns has access to first of all, which you don't outside of clojure.core.
16:50noncomamalloy: SegFaultAX: ok, there is the time flow, just like IRL. first was ns. now, from the environment where ns exists, can a replacement for it appear? i mean, i can make my first namespace with (ns), and it can define that another macro. possible?
16:50amalloyof course
16:51amalloybut your "second" namespace can't *get at* your replacement macro, because it's not implicitly required/referred like ns is
16:51noncomamalloy: so it has to be somehow implanted to the core then?
16:52noncom(intern 'clojure.core ...)?
16:52amalloyi suppose
16:52amalloyi dunno if that actually works
16:53noncomdoes intern work for macros?
16:53SegFaultAXThat's why I explicitly asked if it had to reuse the same name
16:53SegFaultAXclojure.core/ns
16:54SegFaultAXIf it does then that's significantly more difficult.
16:54noncomi guess it does not have to. no other new language cornerstone usually reuses some past predecessor's name. thats due to the natural development.
16:54SegFaultAXBut if you're merely trying to write a macro that does something similar to the existing ns macro (without replacing the existing one) then ns isn't particularly interesting.
16:54amalloySegFaultAX: even if it uses a different name i'm not so sure
16:55amalloythere is definitely some ns-related stuff that is special-cased in the compiler
16:55amalloymostly related to in-ns, but refer-clojure is also a bit fiddly
16:56SegFaultAXYea, that's the other thing you'd have to address. Some of the special forms (and macros and functions) that clojure.core/ns relies on aren't available outside that context.
16:56SegFaultAXBut I don't think the ns macro is special in any way other than the scope it's evaluated in, is it?
16:57noncomSegFaultAX: amalloy: so the new macro has to partly imitate ns! otherwie the system won't let in! What about using ~ to make it auto-resolve in clojure.core?
16:57noncom*auto-resolve what needs to be autoresolved inside clojure.core and not outside
16:58SegFaultAXI think (at least part of) amalloy's point is that ns should be considered as close to a special form as you can get without actually being one.
16:58noncomalright, first, the easiest question: can i write a *copy* of ns, but with another name and make it equal to ns in my program?
16:58amalloySegFaultAX: it is special: it's one of a few symbols which, even in a namespace with no requires/refers, will resolve
16:59noncomoh
16:59amalloyeg, try (in-ns 'new-ns) +
16:59amalloythe + doesn't resolve, but ns or in-ns would
16:59SegFaultAXamalloy: Ah, so the name is interned before the clojure.core is evaluated?
16:59amalloyno, it's not interned
16:59noncom,(in-ns 'new-ns) +
16:59clojurebot#<Namespace new-ns>
16:59amalloyit's a special case in Compiler/resolveIn and a couple other places
16:59noncomoh damn
17:00amalloynoncom: in a real repl
17:00SegFaultAX,((in-ns 'new-ns) +)
17:00clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Namespace cannot be cast to clojure.lang.IFn>
17:00noncom,(do (in-ns 'new-ns) +)
17:00clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: + in this context, compiling:(NO_SOURCE_PATH:0:0)>
17:00noncomhere
17:00noncomi got this in real repl
17:00noncomBUT
17:00noncom,(do (in-ns 'new-ns) ns)
17:00clojurebot#<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/ns, compiling:(NO_SOURCE_PATH:0:0)>
17:01SegFaultAXamalloy: I see. Well then I take back my earlier statement that ns is a plain 'ol macro :)
17:01noncomSegFaultAX: oh and i was hoping so much...
17:01noncom:)
17:01noncomi tried reading ns source, but saw nothing special (at least to the extent of what i was able to understand from there)
17:02SegFaultAXnoncom: That's not what makes it special.
17:03noncomso, the result is: "it is impossible to create a macro, similar to ns in its power, without modifying the language core, which is not available from the language itself", right?
17:04amalloyi mean, you could start every file with (ns foo.bar (:use my.tools :only [my.ns])) (my-ns ...)
17:04amalloybut that's not very satisfying
17:04noncomright
17:06noncomheeey looook
17:06noncom,(do (in-ns 'new-nssss) in-ns)
17:06clojurebot#< clojure.lang.RT$1@b7c1d2>
17:07noncomspecial form
17:07noncomoh, too bad.
17:07noncommy hopes we so high for clojure
17:08noncommaybe it will change with clojure-in-clojure if it ever comes
17:08SegFaultAXnoncom: The thing is, Clojure is really good for actual work. :)
17:08SegFaultAXSo don't give up on it yet.
17:08noncomi know, this is my new language for work :)
17:09noncomand so far it seems like i am not gonna jump off. simply nowhere else to go (at least in java ecosystem, which i am addicted to)
17:10noncomwell, thanks, that was an interesting trip! i will do some more research on core then, to find where things start go "strange" and compare with the real langs
17:13SegFaultAXTIL: Clojure isn't a real language.
17:14noncomahahah :D
17:16noncomsometimes virtual reality is more real than the.. umm.. well, the other reality.. especially that is very browsable in symbolic systems and how they interact with psyche. and today that has a great value for research..
17:41noncomSegFaultAX: amalloy: i just thought that maybe i was coming from a wrong direction. ns is a passive (feminine) aspect. maybe it is the active aspect require (masculine), which instead has to be customized in order to increase self-expressiveness of the language to reach anisotrophic state.
17:42noncomthat is how it usually happens actually..
17:42amalloydid your cat just step on your keyboard? quite aside from the irrelevant gender stuff, that made no sense
17:43noncomi think i will experiment with custom require. then there is no need in inventing any ns successor. if i define a custom file-reading and parsing utility, then anything can be placed instead of ns
17:44noncomamalloy: i have two cats actually :D
17:44noncomhow i was so dumb, torturing ns... it is late here, must be sleeping already
17:45noncomabout the gender stuff: sorry to load you with all that linguistic terminology :D
17:50asdf__question here. I have two variables, one a value and the other a list of values. I want to return a sequence where each index is the value returned from a function that takes the single value and one of the values from the list. Any ideas on how to do this cleanly?
17:50asdf__or even if this makes sense
17:51noncommaybe you mean return a {}, not sequence?
17:52noncomaside from that, i would use (map).. maybe with (partial)..
17:53noncom(map #(partial fn-that-takes-2-args the-one-value) the-initial-collection)
17:53asdf__return a sequence
17:54noncomhow can you engineer indices in a collection?
17:54noncomdont them simply go 0, 1, 2, 3... n?
17:54noncomgive an example of result you want
17:55asdf__single value can be 2 then '(1 2 3 4) and the final value something like '(2 4 6 8) if the function was (defn double [f s] (*f s))
17:57noncom,(map #(* 2 %) '(1 2 3 4))
17:57clojurebot(2 4 6 8)
17:57noncomlike that?
17:59asdf__Yup. that works perfectly.
18:00asdf__I'll have to look up the syntax to know exactly what is going on but thanks. Otherwise I was going to have to go with a loop and I didn't want that
18:00noncomasdf__: btw, maybe you find it easier use vectors instead of lists for sequences..
18:00noncomlook
18:01noncom,(map (fn [s] (* 2 s)) [1 2 3 4])
18:01clojurebot(2 4 6 8)
18:01noncom#() is a shortcut for (fn)
18:01asdf__either way. anything that can be indexed. That should work for both right?
18:01noncomasdf__: if you have sequences of numbers, then [] are preferable
18:01noncomi guess
18:02noncomyes it works for both
18:02noncomwell, good luck! i have to go now
18:13bbloomdnolen: lol, mutable promises
18:14bbloomdnolen: "hey, let's take something hard and MAKE IT HARDER"
18:23grandyanyone know why using a println inside a seesaw event handler causes an exception?
18:25grandyactually i get this exception when i put a println into the event handler method: java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn
18:26amalloygrandy: too many parens
18:26grandyamalloy: hmm
18:27grandyamalloy: not sure i understand, you mean i put in an extra one? or that the nesting is not allowed?
18:27amalloyyou wrote (x) instead of x, where x is a string
18:28grandyamalloy: hah i think you're right :)
18:28grandyembarrassed now but still going to keep learning clojure
18:29amalloyit's a mistake everyone makes a few times
18:38hfaafbhttps://gist.github.com/samuelcferrell/6401004 is there a simpler way to map a coll across multiple functions like this?
18:39amalloyif they're anonymous functions, why aren't you just combining them? (map #(...) coll)
18:41hfaafbamalloy: i could, certainly not a bad answer but it feels weird to me to pack all my transformations into a single fn
18:41amalloyhfaafb: i mean, (= (map f (map g (map h coll))) (map (comp f g h) coll))
18:42amalloyso you can do that if you want. but i'd probably write it like (for [x coll] (...do stuff with x...))
18:42grandyadvice on the best way to pull values out of a ui event in an event handler using seesaw? they don't appear to behave like maps
18:43hfaafbthanks amalloy both fit nicely
19:17coventryIs there a clojure function which will escape a string to a regex which just matches that string, e.g. "." -> "\."? I'm guessing not from http://stackoverflow.com/a/11672480
19:31hyPiRioncoventry: Not a clojure function, but a java method?
19:31hyPiRion,(Pattern/quote ".-with-random\\stuff")
19:32clojurebot#<CompilerException java.lang.RuntimeException: No such namespace: Pattern, compiling:(NO_SOURCE_PATH:0:0)>
19:32hyPiRion(import 'java.util.regex.Pattern)
19:32hyPiRion,(import 'java.util.regex.Pattern)
19:32clojurebotjava.util.regex.Pattern
19:32hyPiRion,(Pattern/quote ".-with-random\\stuff")
19:32clojurebot"\\Q.-with-random\\stuff\\E"
19:32hyPiRionthere
19:32hyPiRionThen convert that one to a regex
19:38coventryThanks, hyPiRion.
20:24coventryIs there a way to clone a protocol so that you can extend it without impacting other functionality using it?
20:27bbloomcoventry: hmm… i mean, they are just data. have you tried just aliasing one?
20:27bbloomcoventry: i dunno if it would work, but (def MyProtocol TheirProtocol) might just work
20:28bbloomcoventry: but note that protocols interoperate with java interfaces, so the protocol would be missing some definitions if they were embedded directly at type creation time (ie inside deftype or defrecord, etc)
20:36coventrybbloom: The def trick doesn't seem to work with the clojure.walk2/Walkable protocol. I can still break walk2 by (extend-protocol my-walkable clojure.lang.PersistentList (bogus operation)).
20:37bbloom,CollReduce
20:37clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: CollReduce in this context, compiling:(NO_SOURCE_PATH:0:0)>
20:37bbloom,(require 'clojure.core.reducers)
20:37clojurebot#<FileNotFoundException java.io.FileNotFoundException: Could not locate clojure/core/reducers__init.class or clojure/core/reducers.clj on classpath: >
20:37bbloom,(require 'clojure.reducers)
20:37clojurebot#<FileNotFoundException java.io.FileNotFoundException: Could not locate clojure/reducers__init.class or clojure/reducers.clj on classpath: >
20:38bbloom(require 'clojure.reflect)
20:38bbloom,(require 'clojure.reflect)
20:38clojurebotnil
20:38bbloom,clojure.reflect.Reflector
20:38clojurebotclojure.reflect.Reflector
20:39bbloomweird, that's a class… hmmm
20:39bbloomif you do (defprotocol P)
20:39bbloomthen P
20:39bbloomi get a map
20:41coventryIt bothers me that I can extend a protocol in any namespace, from any namespace. Does it ever become a source of confusing bugs?
20:42bbloomit's particularly annoying when doing interactive development. that's why most people put their protocols in a namespace by themselves
20:42bbloomalso, the general rule is that you should only extend a protocol if you 1) own the type 2) own the protocol or 3) both
20:43bbloomit would be cool if deftype returned a curried extend-type function and defprotocol returned a curried extend-protocol function
20:43bbloomso then you'd need either extender function as a sort of secret key to extend (this is formally called a "capability")
20:44robinkIs it OK to use Hickory for destructuring HTML?
20:46coventrybbloom: I bet there is already some code out there which depends on the current liberal arrangement. I was a little tempted to write some in this case. Mostly wanted to check whether clojure would protect me from myself.
20:47bbloomcoventry: i'm certain that a large number of projects depend on the mutability of protocols: any time you see (:require …) without any references to anything from that namespace, it means somebody is loading a library for effects (such as defmethod or extend)
20:47bbloomit's very common
20:55amalloyi don't think you can usefully alias protocols
20:56amalloyif you alias just the value, then it's not mutable; if you alias the var, then changes to it ripple to the original
21:22coventryIs there a clojure function which returns the cartesian product of its argument functions? I.e. ((f g h) a b) => (list g(a) h(b))
21:24mduponthowdy
21:28amalloynot a builtin, coventry
21:28coventryamalloy: thanks.
21:28amalloyi wrote one at https://github.com/flatland/useful/blob/develop/src/flatland/useful/fn.clj#L94
21:29coventryOh, great, a reason to use useful.
21:32coventryOh, it has map-keys. Just what I need.
21:44RaynesI'm surprised that function isn't in core.
21:44RaynesIt meshes nicely with juxt.
22:08fkeyafter using reify, how do you tell if the object contains a function given it's name?
22:19devnwhy does clojure.walk have *-demo fns and other core libs don't?
22:19devnfor instance, clojure.zip
22:19devn(note: mostly rhetorical)
22:21devni think there's always been a desire to have a (clojure.repl/examples ...)
22:21devni mean, that's why i made http://getclojure.org/
22:24devnovertone has an example macro
22:46loganlinnIs there a good way to detect if compiling for ClojureScript vs Clojure in a crossover namespace?
23:00devnloganlinn: what do you mean?