#clojure log - Aug 31 2013

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:00 TimMc: llasram: You mean you didn't have auto-shave back then? :-O

0:00 technomancy: I always associated INI with Windows

0:01 xeqi: technomancy: same

0:01 technomancy: but I guess python people like it too

0:01 SegFaultAX: I actually have no idea why ini is used in Ansible.

0:01 It makes no sense at all when you consider that /everything else/ is YAML

0:01 TimMc: technomancy: Specifically Windows 3.1

0:01 SegFaultAX: I associate ini with Unreal Tournament for some reason.

0:01 technomancy: the yaml spec is kinda nuts

0:02 SegFaultAX: (It used ini heavily for all the engine configuration)

0:02 llasram: ^^ understatement (technomancy)

0:02 SegFaultAX: I haven't read it, what's crazy about it?

0:02 technomancy: json for config would be nice except for the idiotic refusal to allow comments

0:03 SegFaultAX: json for config would be awful. :(

0:03 technomancy: though I don't know how widely that's enforced by parsers

0:03 TimMc: technomancy: All you need is .jsonc, which would be preprocessed to remove comments. :-P

0:04 llasram: JSON's non-acceptance of terminal commas also drives me nuts

0:04 E.g., invalid JSON: [1, 2, 3,]

0:04 SegFaultAX: llasram: Yea.

0:05 For configuration it really isn't an ideal format to be edited by hand.

0:05 Lots of useless characters ,{}"" lack of multiline string support, etc.

0:06 technomancy: yeah, it'd need to be a superset

0:07 llasram: Or just use EDN. If you squint and ignore the Clojure-specific parts, it really is (or could be) a better JSON

0:08 fkey: hmm question, (def foo "bar") (= foo (cljs.reader/read-string "foo")) returns false...but when i quote "foo" ,its true

0:08 ie (def foo "bar") (= 'foo (cljs.reader/read-string "foo"))

0:08 llasram: I've been doing a lot with a subset of EDN which round-trips through JSON, and it's been working out pretty well

0:08 SegFaultAX: fkey: Why would "bar" be the same as "foo"?

0:08 ,(name 'foo)

0:08 clojurebot: "foo"

0:08 llasram: fkey: Reading isn't the same as evaluating

0:09 SegFaultAX: That's why the second one is happening.

0:09 fkey: ah that makes sense

0:09 hm, but (= '1 1) are the same?

0:10 SegFaultAX: ,(type '1)

0:10 clojurebot: java.lang.Long

0:10 SegFaultAX: ,(type 'a)

0:10 clojurebot: clojure.lang.Symbol

0:10 SegFaultAX: ,(type "a")

0:10 clojurebot: java.lang.String

0:10 llasram: fkey: Quoting suppresses evaluation, but numbers are read as numbers, with no evaluation required

0:10 fkey: ah ok

0:11 llasram: &'[1 2 3 foo :bar "baz"]

0:11 lazybot: ⇒ [1 2 3 foo :bar "baz"]

0:25 SegFaultAX: yogthos|away: Ping.

0:41 TimMc: fkey: And not all alphabetic sequences read as symbols either.

0:41 &(type 'true)

0:41 lazybot: ⇒ java.lang.Boolean

0:41 TimMc: &(type 'trux)

0:41 lazybot: ⇒ clojure.lang.Symbol

1:33 andreh: In general, in a function that steps through a list, is it better to use mapcar or (tail-)recursion?

1:33 rhg135: Map

1:35 dobry-den: andreh: do you have ane example

1:37 andreh: Suppose you want to add the index of each element to itself.

1:37 I believe it would be better with arrays, but I want to compare map and recursion

1:38 dobry-den: ,(map-indexed (partial +) [1 2 3])

1:38 clojurebot: (1 3 5)

1:40 dobry-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".

1:41 rhg135: Yup

1:42 ddellacosta: so, anyone have tips on getting SSL going on Heroku with run-jetty?

1:43 seems like it should just pick it up, but it seems not to be finding my ssl cert, only heroku's

1:45 dobry-den: My 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?

2:06 SegFaultAX: andreh: What do you mean compare map and recursion? They aren't mutually recursive concepts.

2:06 Mutually exclusive, rather.

2:14 It feels pretty amazing to see all the ANN posts on the list.

2:14 So much new development. :)

2:35 ddellacosta: SegFaultAX: seriously…it's totally wild how much new stuff is coming out all the time.

2:35 awesome

3:06 rurumate: After 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?

3:12 Oh, 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

3:48 arcatan: is there a way to attach docstring to a macro after defining it

3:51 Raynes: Well, it requires sacrificing a child, but yes.

3:51 You'd have to modify the var in place to add the :doc metadata.

3:51 But 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

3:55 arcatan: :)

3:56 dpathakj: what situation are you in that this problem came up?

3:59 arcatan: i was trying to add one macro's docstring to another macro

3:59 asked that before i igured out ^{:doc } works.

4:09 i guess there's nothing around for re-exporting things from other namespaces? (appararently like defalias that used to be in clojure-contrib)

5:19 clj_newb_2345: http://docs.datomic.com/getting-started.html <- is this tutorial available as a *.clj rather than a bunch of commands ot type into bin/shell

5:22 sojacques: Hello everyone, I am looking for advice regarding a relatively simple database interacting app that I just started

5:23 I tried googling, but couldn't find anything to help me generate routes or simple crud operations, so I'm asking here

5:23 clj_newb_2345: use datomic

5:23 it solves all db problems

5:24 sojacques: does such a thing exist? or is this something that goes against idiomatic clojure ways?

5:24 what makes datomic so good? I was considering a sql store because of simple reporting & all that

5:24 vijaykiran: sojacques: there's no rails like scuffolding stuff AFAIK

5:25 s4muel: sojacques: if you're looking for Clojure's "Rails", no, there isn't one -- and it wouldn't really be very idiomatic.

5:25 sojacques: I'm not looking for rails, but as I saw compojure and korma, I thought that maybe someone made something to generate code

5:25 I'm against the idea of a monolithic framework, and more looking for simple tools

5:26 vijaykiran: nope, I do it by hand - some notes here: http://www.vijaykiran.com/tags/clojure/

5:26 sojacques: vijaykiran: thanks for the answer anyways!

5:26 s4muel: sojacques: compojure + liberator for RESTy things? Luminus, perhaps?

5:27 sojacques: wow, liberator looks impressive

5:27 thanks a lot guys

5:27 clj_newb_2345: how does "lein repl" and "lein trampoline repl" differ, and how do I get nrepl.el to start emacs in the 2nd mode

5:29 s4muel: lein tramopline kills the original leiningen jvm process after running whatever you want to run (in this case, a repl)

5:29 s/tramopline/trampoline/

5:30 vijaykiran: clj_newb_2345: can't you connect using nrepl and specify 127.0.0.1 and whatever the port from emacs ?

5:39 sojacques: followup 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

5:39 so I can learn why lisps are good

5:40 can anyone lead me towards what's good with clojure for generating code?

5:40 jave: hello

5:41 sojacques: damn that feels horrible to ask questions that are probably very beginner level

5:41 vijaykiran: sojacques: so you want to learn about macros ?

5:41 sojacques: I don't think code generating code is the same as scaffolding ...

5:42 noidi: sojacques, http://pragprog.com/magazines/2011-07/growing-a-dsl-with-clojure

5:42 maybe that could help

5:42 jave: I 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

5:43 sojacques: sorry, 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

5:43 connecting to a db and operating sql is fine

5:43 vijaykiran: jave: how does this look : https://github.com/technomancy/clojure-http-client

5:44 sojacques: but the rest is what I don't know

5:44 vijaykiran: sojacques: then it isn't a macro exploration per se - AFAIK

5:45 sojacques: if you have the "result" code, you can work your way up ..

5:46 sojacques: vijaykiran: 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"

5:46 vijaykiran: sojacques: of course, edn

5:46 sojacques: Please feel free to tell me if I'm totally misled

5:47 wow

5:47 vijaykiran: sojacques: 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

5:48 sojacques: and work in "reverse"

5:48 sojacques: this is what I would like to do, yes

5:48 can I treat this code as some list that I would just generate?

5:48 lists*

5:48 vijaykiran: yup

5:48 sojacques: woah

5:48 vijaykiran: that's LISt Processing

5:49 a.k.a LISP

5:49 * sojacques enlighten

5:49 sojacques: but those lists are full of keywords and the like, won't the compiler scream all the way?

5:49 well I'll try anyways, now I got the direction

5:49 thanks

5:49 jave: vijaykiran: thanks, i followed the link, and they in turn recomended this, which seems nice: https://github.com/dakrone/clj-http

5:50 vijaykiran: sojacques: good luck :)

5:50 sojacques: you just quote the forms

5:51 sojacques: alright, 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

5:52 thanks a lot

5:53 jave: another 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?

5:54 vijaykiran: jave: pomegranate should be it.

5:54 jave: also, see http://thinkrelevance.com/blog/2013/06/04/clojure-workflow-reloaded

5:56 jave: thanks

5:57 im a bit rusty with clojure, it seems.

8:03 llasram: jave: Use alembic: https://github.com/pallet/alembic

8:33 sheldonh: i'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/

8:36 llasram: sheldonh: 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

8:37 sheldonh: llasram: argh! like a splat in the languages i'm used to. okay thanks!

8:37 llasram: sheldonh: Np. Something else to note in your function is that Clojure has what's called "nil punning"

8:38 The `nil` value isn't *identical* to an empty list (like it is in some Lisps), but you can generally treat it as one

8:38 So 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

8:38 sheldonh: llasram: i thought i was asking whether "the one optional argument called b was given?" :)

8:40 llasram: sheldonh: Yah. For that you generally just implement multiple arities of the function

8:40 sheldonh: llasram: perhaps i should just not bother trying to do it with one function, and have (defn xreverse-general [a b] ...) and (defn xreverse [a] ...)

8:40 llasram: sheldonh: No no -- one function is the way to go. There are at least two ways to do it

8:41 sheldonh: llasram: that sounds good. reading http://clojure.org/functional_programming ... thanks!

8:42 llasram: sheldonh: If you're just getting started, I highly recommend http://www.clojurebook.com/

8:42 (the book -- not the website for the book)

8:42 sheldonh: hehe

8:45 grandy: hello, 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/

8:47 anyone have the patience to help me with this very newb oriented problem

8:48 sheldonh: llasram: lovely, 'tworks! thanks. will check out the book when i've finished congratulating myself :) http://fpaste.org/36233/

8:49 grandy: when i start lein repl will my namespaces be loaded automatically?

8:50 llasram: grandy: If you have a :main namespace it will, and the REPL will start in that namespace. Otherwise not

8:50 grandy: llasram: is there a way to ask the repl what namespace it's in?

8:50 llasram: It should be printed in the prompt. Usually starts as `user`

8:51 You can check the value of *ns* to see explicitly

8:51 grandy: llasram: hmm, it just says the namespace is user

8:52 llasram: in my project.clj file I have :main "myprojectname.core"

8:52 llasram: and when is type lein run the program works as expected

8:52 llasram: however when i type lein repl and try to manually start the program, it is not being resolved

8:54 llasram: grandy: 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

8:54 grandy: llasram: with :use ?

8:54 llasram: In the REPL, just `require` the namespace then `(in-ns 'correct.namespace.symbol)`

8:54 grandy: ahh

8:54 llasram: Or use your editor facility for the same

8:54 M-n in nrepl.el, for example

8:55 grandy: hmm ok let me try that

8:55 sheldonh: grandy: are you sure you're following that blog post? the namespace for the project.clj in the anvil-view repo is anvil-view.devel

8:55 llasram: sheldonh: I kind of hope he's not following that blog post, because when I check out the project, it explodes with missing dependencies :-)

8:56 grandy: sheldonh: 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

8:57 sheldonh: grandy: 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 :(

8:57 grandy: llasram: 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

8:57 sheldonh: yeah was going to do that too until i noticed that about the deps

8:58 so is the repl *supposed* to load a namespace other than user by default if I have added :main key to my project.clj?

9:00 vijaykiran: grandy: nope, :main is just a hint that that namespace contains main function

9:01 grandy: vijaykiran: 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...

9:01 thanks for the help, everyone

9:01 vijaykiran: grandy: https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L163

9:02 grandy: vijaykiran: ahh ok, looks like it's very well documented, i should read up

9:02 llasram: grandy: You can also pull that by running `lein sample`

9:03 grandy: llasram: ahh that's a clever feature

9:03 llasram: grandy: How are you REPL-ing? Raw `lein repl`, or nrep.el, or something else?

9:04 grandy: llasram: just raw lein repl

9:05 llasram: Weird. I definitely see that `lein repl` automatically switches to the project :main namespace.

9:05 What version of lein?

9:06 grandy: 2.1.1

9:06 llasram: That 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

9:06 grandy: llasram: hmm ok that sounds intriguing, i am using clojure mode, i'll try nrepl.el unless you have another recommendation?

9:07 llasram: grandy: Well, non-ancient. Weird, but not quite weird enough to convince me to dig much deeper :-)

9:07 Yes -- nrepl.el is definitely the way to go from emacs

9:07 Should 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

9:08 grandy: llasram: cool just installed it

9:13 ToxicFrog: Is there a convenient form for (if x x y)

9:13 llasram: ToxicFrog: (or x y) ?

9:15 ToxicFrog: llasram: thanks

10:24 grandy: quick 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:24 llasram: grandy: `doc` is actually in the `clojure.repl` namespace

10:24 grandy: llasram: ahh ok :)

10:25 llasram: grandy: But if you're using nrepl.el now, try hiting C-c C-d on a symbol

10:26 grandy: llasram: hmm do i need the symbol to be fully selected first?

10:27 llasram: grandy: You should just need to have the cursor w/in a symbol

10:27 grandy: llasram: hmm getting some kind of url class loader exception

10:27 llasram: Hmm

10:27 That's.... unfortunate

10:28 vijaykiran: grandy: some Meta .. blah blah ?

10:29 grandy: actually i noticed that it says class not found clojure.repl

10:29 llasram: Oh! Weiird. It should be auto-requiring that namespace

10:30 Try manually `require`ing it

10:30 Then C-c C-d

10:30 grandy: ahh now it works!

10:30 llasram: Well, at least it's working now...

10:30 grandy: that's fantastic.. .looks like something about my setup isn't doing the typical autorequiring

10:30 llasram: OOC, do you have anything odd in your ~/.lein/profiles.clj ?

10:30 grandy: llasram: just default everything

10:31 llasram: let me look at it, have not edited it

10:31 file doesn't exist

10:33 llasram: just curious how you set up emacs windows, do you leave one for the output of C-c C-d etc.?

10:33 (buffers)

10:34 llasram: grandy: Mostly. I've got some advice which shrinks doc windows down to be just large enough to contain the docstring

10:35 grandy: ahh ok

10:35 llasram: Emacs' default policy of wanting to hand over half the vertical space is a bit troublesome :-)

10:35 grandy: llasram: yeah agreed....

10:36 llasram: what 3 things should i learn to use nrepl for first?

10:37 llasram: Er. Let's go with -- Compilation, docstring-lookup, and running tests (via clojure-test-mode, as much technomancy wants to be able deprecate it)

10:39 Here'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:43 vijaykiran: llasram: you use eclim ?

10:43 I gave up after it started toasting emacs and my CPU

10:44 llasram: vijaykiran: 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:44 I'm not frequently doing that much Java, so I don't need to leave the eclim server running all the time :-)

10:44 But it actually worked pretty well

10:44 vijaykiran: Ah, okay - I'm mostly in IntelliJ with "enterprise" projects

10:45 llasram: I 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:46 vijaykiran: :)

11:01 rigger: vi/emacs

11:01 sublimetext2

11:02 seangrov`: ~emacs

11:02 clojurebot: emacs is an out-moded belief system

11:02 rigger: hehe

11:04 crocket: clojure.org is down

11:05 vijaykiran: crocket: work for me

11:05 works*

11:05 rigger: same

11:06 crocket: damn

11:06 Does anyone know a good clojure learning material?

11:07 vijaykiran: crocket: Oreilly Clojure book

11:07 ,clojure-book

11:07 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: clojure-book in this context, compiling:(NO_SOURCE_PATH:0:0)>

11:07 vijaykiran: meh

11:07 crocket: vijaykiran, Is it free?

11:07 vijaykiran: crocket: :) nope, but worth it

11:07 crocket: vijaykiran, I just want to skim a preview of clojure quickly.

11:08 vijaykiran: crocket: try ociweb tutorials

11:08 crocket:,google "ociweb clojure"

11:23 crocket: good

11:23 vijaykiran, clojure looks promising

11:39 kawas44: Hello

11:40 do people find stange behavior between println and printf ?

11:40 compare this two lines of code that should have the same output to me

11:41 (->> [["one" 1]] ((fn [coll] (doseq [[f i] coll] (println f i)))))

11:41 (->> [["one" 1]] ((fn [coll] (doseq [[f i] coll] (printf "%s %s%n" f i)))))

11:42 the second example print nothing :/

11:42 noncom: how do i define a function in another namespace?

11:42 (intern)?

11:43 ,(intern 'clojure.core 'heeeey "wow")

11:43 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

11:43 dnolen: new core.async post http://swannodette.github.io/2013/08/31/asynchronous-error-handling/

11:44 noncom: dnolen: cool! gonna read it

11:45 cjfrisz: dnolen: already read

11:45 Now I just need to write some core.async code to get my head in that space

11:46 And also probably learn JS so I can appreciate not being in callback hell

11:46 kawas44: ,(->> [["one" 1]] ((fn [coll] (doseq [[f i] coll] (println f i)))))

11:46 clojurebot: one 1\n

11:46 kawas44: ,(->> [["one" 1]] ((fn [coll] (doseq [[f i] coll] (printf "%s %s%n" f i)))))

11:46 clojurebot: #<SecurityException java.lang.SecurityException: denied>

11:47 dnolen: cjfrisz: you won't want to live there for very long ;)

11:47 kawas44: ...

11:47 cjfrisz: dnolen: I was secretly going to avoid that as best as I could :-)

11:49 bbloom: cjfrisz: it's definitely worth learning javascript for the same reason it's worth learning x86 assembly

11:50 x86 isn't the best compilation target, but it's pretty damn popular

11:50 that's how i feel about javascript :-P

11:50 cjfrisz: bbloom: agreed

11:51 Though 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:10 fuz: can anyone tell if there is anything wrong with my async usage here? http://pastebin.com/jSpKq52f

12:10 i get an error when compiled down to javascript….the code works (reads and writes to the channel)

12:11 but there is always a javascript error Uncaught TypeError: Object [object Object] has no method 'call'

12:17 jave: I 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:21 kawas44: jave: look there https://github.com/TechEmpower/FrameworkBenchmarks for code example using http-kit, compojure or luminus

12:22 jave: kawas44: thanks. the last one i did was based on compojure i think

12:24 kawas44: jave: 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:26 fuz: does your code work in vanilla clojure ?

12:28 noncom: why

12:28 ,(symbol ''''i)

12:28 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to java.lang.String>

12:29 noncom: (type ''''i)

12:29 ,(type '''i)

12:29 clojurebot: clojure.lang.PersistentList

12:29 noncom: ^^

12:29 why the type is PersistentList?

12:30 fuz: kawas44, i don't know, i'll have to try that… probably shouldn't have used clojurescript specific libraries

12:31 kawas44: noncom: '(quote i) is indeed a list

12:31 noncom: ah

12:31 i see

12:32 kawas44: ,(symbol "i")

12:32 clojurebot: i

12:32 noncom: yeah, just was curious about '''

12:38 kawas44: fuz: I was just asking to know if your algo and your clojure implementation was working with vanilla clojure

12:39 fuz: because your exception gives an hint on a typo error or misuse of the language

12:39 fuz: you have an anonymous function with a go block and a boolean ?? what do you want to do in here ?

12:42 fuz: oh that was me trying to work out where the error was being raised (by inspecting the generated javascript)

12:42 it doesn't need to be there

12:42 (there true that is)

12:43 for some reason it's trying to run '.call(this)' at the end of the code…but the [object object] has no call method

12:43 so i assumed it was some part of the call was being evaluated as something it shouldn't be

12:43 call-> code ^

12:48 kawas44: Does anyone knows the difference between those two codes execution ?

12:48 ,(->> [["one" 1]] ((fn [coll] (doseq [[f i] coll] (println f i)))))

12:48 clojurebot: one 1\n

12:48 kawas44: ,(->> [["one" 1]] ((fn [coll] (doseq [[f i] coll] (printf "%s %s%n" f i)))))

12:48 clojurebot: #<SecurityException java.lang.SecurityException: denied>

12:49 kawas44: just using printf instead of println...

13:23 ToxicFrog: Eurgh this is disgusting

13:23 40 lines of HTTP POST messiness

13:26 SegFaultAX: ToxicFrog: Java?

13:27 ToxicFrog: No, clojure

13:27 But 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:28 SegFaultAX: ToxicFrog: Ugh, sorry to hear that.

13:28 ToxicFrog: I mean, this is replacing 400 lines of Lua messiness, but still, it's not pretty.

13:28 SegFaultAX: That's awful.

13:34 Synthread looks awesome.

13:52 clj_newb_2345: The monger bindings as awesome ins htat I can store CLojure data structures as Monger documents.

13:52 Howver, 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:06 callen: SegFaultAX: yes it does.

14:06 SegFaultAX: solves a problem I had been thinking about lately (I'd been experimenting with the Continuation Monad in Clojure)

14:30 jave: im trying to do a simple webapp with http-kit and compojure. How can I reload the routes, and restart the server?

14:32 atm I redefine the routes and restart a server on a new port, but thats a bit tedious

14:33 callen: jave: http://http-kit.org/migration.html#reload

14:34 jave: ah, thanks

14:37 fredyr: anybody here uses evil-mode in emacs for clojure?

14:39 i ask because i'm trying it and don't get the paredit and indentation to work reasonably

14:42 kmicu: $google evil mode paredit

14:42 lazybot: [roman/evil-paredit · GitHub] https://github.com/roman/evil-paredit

14:43 fredyr: well ldo

14:43 thats the one i've tried

14:43 dnolen: OK crazy realization of the day

14:43 SegFaultAX: This talk about HTTP performance and privacy is awesome: http://www.infoq.com/presentations/HTTP-Performance

14:43 dnolen: core.async allows you to get sensible stack traces from async code

14:46 shaungilchrist: implicitly or provides the basis for doing so?

14:48 dnolen: shaungilchrist: provides the basis for doing so, promises mangle because errors must propagate through promises machinery

14:48 useless stack traces

14:48 shaungilchrist: with core.async you can throw, thus short circuit and recover clean traces

14:48 trivially

14:50 kmicu: obviously

14:50 shaungilchrist: awesome, I just read your latest article w/ the <?

14:55 callen: dnolen: pretty cool :)

14:55 dnolen: I used core.async to demonstrate how to write reliable tests for asynchronous services and code to my coworkers yesterday :)

15:15 dnolen: callen: were they impressed?

15:17 callen: dnolen: yes but by different things depending on their experience level.

15:17 dnolen: callen: gotcha

15:17 callen: dnolen: 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:18 dnolen: callen: nice

15:18 callen: I 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:36 irctc: does anyone know how to add a list of values where some have nil?

15:40 xeqi: ##(reduce (fnil + 0 0) [1 2 3 nil 5]) or ##(reduce + (filter identity [1 2 3 nil 5]))

15:40 lazybot: (reduce (fnil + 0 0) [1 2 3 nil 5]) ⇒ 11

15:40 (reduce + (filter identity [1 2 3 ni... ⇒ 11

15:40 irctc: I was thinking just remove nils before reducing

15:40 (reduce + (remove nil? awesomelist))

15:41 xeqi: thats a better formulation of the intent with the second one

15:42 TimMc: You know what fn I keep forgetting to use? clojure.core/keep

15:43 xeqi: &(doc keep)

15:43 lazybot: ⇒ "([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:43 xeqi: &(doc filter)

15:43 lazybot: ⇒ "([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:43 TimMc: I bet most cases of (filter identity (map f xs)) are only filtering for nil and not for false, so keep would be better.

16:01 noncom: can 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:02 TimMc: I dunno, this sounds pretty nuts.

16:03 What in tarnation are you trying to do?

16:03 Brand0: L o L

16:03 noncom: TimMc: bad design, right?

16:03 TimMc: Could be, could be.

16:03 Can't actually stay to talk, but I'm curious about what you're up to.

16:04 noncom: yes, 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:04 (surely is nuts)

16:04 i do some kind of mathematical research

16:06 Brand0: emacs live anyone?

16:08 callen: Brand0: no.

16:08 noncom: "research"

16:08 sometimes it's research, sometimes you're just burning ants with a magnifying glass.

16:08 kmicu: Brand0: Ask.

16:11 arkh: can clojurescript use 'defn-' ? e.g. (defn- my-private-func [...] ...)

16:11 noncom: callen: 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:12 callen: it actually is about natural languages, but there is a subtask to analyze some programming languages too, to illustrate the differnces.

16:12 the results will look like a bunch of formulas, so not very exciting

16:14 fredyr: arkh: yes defn- works in clojurescript

16:15 arkh: fredyr: thanks - google turned up nothing (treats "defn-" as "defn") but duckduckgo found the answer right after you o.0

16:16 hfaafb: how might i stick something inbetween elements of a collection like this https://gist.github.com/samuelcferrell/6400223 ?

16:16 bbloom: arkh: don't be afraid to peek at the source! it's not that scary

16:17 rhg135: intersperse

16:17 it's a thing

16:17 interpose*

16:17 hfaafb: ty

16:17 noncom: callen: 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:27 SegFaultAX: noncom: 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:27 Because it's predicated on being able to lift a macro into runtime, which is a contradiction in terms.

16:32 noncom: SegFaultAX: 'not' possible is also an answer.

16:34 SegFaultAX: noncom: Either way it seems like a complicated way to accomplish whatever it is that you're doing.

16:34 noncom: Why do you want to replace the ns macro?

16:37 noncom: SegFaultAX: 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:37 arkh: hfaafb: I'm sure there's a better way but here's one: (interleave [1 2 3 4] (repeat -1) (repeat -1))

16:38 noncom: SegFaultAX: 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:39 SegFaultAX: replacing (ns) macro and allowing customize the behavior of namespace declaration would give much information on language self-expressivenes and self-modification characteristics

16:39 or a clear statement that this is not possible

16:39 will do too

16:39 SegFaultAX: noncom: Why do you have to reuse the name though?

16:40 Eg clojure.core/ns

16:40 You're of course free to define noncom/ns

16:40 And that can have whatever operational characteristics you're after.

16:41 noncom: SegFaultAX: 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:42 so 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:42 SegFaultAX: noncom: In the case of ns in particular, yes.

16:43 noncom: But there are other forms where that isn't the case.

16:43 Namely special forms.

16:44 hfaafb: ty arkh

16:44 SegFaultAX: noncom: Macros don't really /do/ anything. Their purpose is to take unevaluated lisp forms and produce new lisp forms.

16:45 noncom: In this case, ns isn't what's important. Only the forms that ns eventually [recursively] expands to matter.

16:45 noncom: SegFaultAX: yes, i have read about them. I am a programmer and currently I am switching to clojure from scala... wheeeew!!! :)

16:45 SegFaultAX: Some of those forms are special and therefore not open to modification like other types of clojure forms.

16:46 noncom: SegFaultAX: so far I have been unable to write a macro which could replace (ns) at the beginning of a file.

16:46 these "special forms" are language archetypes

16:46 all languages have them

16:46 SegFaultAX: Yes.

16:47 ns isn't one of them, though.

16:47 noncom: but i was unable to create a replacement for ns. could you give an example of such a replacement?

16:48 amalloy: SegFaultAX: 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:48 noncom: btw: what is ineteresting, is the relation and interaction between real and computer languages archetypes

16:48 SegFaultAX: amalloy: 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:50 noncom: amalloy: 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:50 amalloy: of course

16:51 but your "second" namespace can't *get at* your replacement macro, because it's not implicitly required/referred like ns is

16:51 noncom: amalloy: so it has to be somehow implanted to the core then?

16:52 (intern 'clojure.core ...)?

16:52 amalloy: i suppose

16:52 i dunno if that actually works

16:53 noncom: does intern work for macros?

16:53 SegFaultAX: That's why I explicitly asked if it had to reuse the same name

16:53 clojure.core/ns

16:54 If it does then that's significantly more difficult.

16:54 noncom: i 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:54 SegFaultAX: But 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:54 amalloy: SegFaultAX: even if it uses a different name i'm not so sure

16:55 there is definitely some ns-related stuff that is special-cased in the compiler

16:55 mostly related to in-ns, but refer-clojure is also a bit fiddly

16:56 SegFaultAX: Yea, 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:56 But I don't think the ns macro is special in any way other than the scope it's evaluated in, is it?

16:57 noncom: SegFaultAX: 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:57 *auto-resolve what needs to be autoresolved inside clojure.core and not outside

16:58 SegFaultAX: I 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:58 noncom: alright, 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:58 amalloy: SegFaultAX: it is special: it's one of a few symbols which, even in a namespace with no requires/refers, will resolve

16:59 noncom: oh

16:59 amalloy: eg, try (in-ns 'new-ns) +

16:59 the + doesn't resolve, but ns or in-ns would

16:59 SegFaultAX: amalloy: Ah, so the name is interned before the clojure.core is evaluated?

16:59 amalloy: no, it's not interned

16:59 noncom: ,(in-ns 'new-ns) +

16:59 clojurebot: #<Namespace new-ns>

16:59 amalloy: it's a special case in Compiler/resolveIn and a couple other places

16:59 noncom: oh damn

17:00 amalloy: noncom: in a real repl

17:00 SegFaultAX: ,((in-ns 'new-ns) +)

17:00 clojurebot: #<ClassCastException java.lang.ClassCastException: clojure.lang.Namespace cannot be cast to clojure.lang.IFn>

17:00 noncom: ,(do (in-ns 'new-ns) +)

17:00 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: + in this context, compiling:(NO_SOURCE_PATH:0:0)>

17:00 noncom: here

17:00 i got this in real repl

17:00 BUT

17:00 ,(do (in-ns 'new-ns) ns)

17:00 clojurebot: #<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.core/ns, compiling:(NO_SOURCE_PATH:0:0)>

17:01 SegFaultAX: amalloy: I see. Well then I take back my earlier statement that ns is a plain 'ol macro :)

17:01 noncom: SegFaultAX: oh and i was hoping so much...

17:01 :)

17:01 i tried reading ns source, but saw nothing special (at least to the extent of what i was able to understand from there)

17:02 SegFaultAX: noncom: That's not what makes it special.

17:03 noncom: so, 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:04 amalloy: i mean, you could start every file with (ns foo.bar (:use my.tools :only [my.ns])) (my-ns ...)

17:04 but that's not very satisfying

17:04 noncom: right

17:06 heeey looook

17:06 ,(do (in-ns 'new-nssss) in-ns)

17:06 clojurebot: #< clojure.lang.RT$1@b7c1d2>

17:07 noncom: special form

17:07 oh, too bad.

17:07 my hopes we so high for clojure

17:08 maybe it will change with clojure-in-clojure if it ever comes

17:08 SegFaultAX: noncom: The thing is, Clojure is really good for actual work. :)

17:08 So don't give up on it yet.

17:08 noncom: i know, this is my new language for work :)

17:09 and 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:10 well, 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:13 SegFaultAX: TIL: Clojure isn't a real language.

17:14 noncom: ahahah :D

17:16 sometimes 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:41 SegFaultAX: 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:42 that is how it usually happens actually..

17:42 amalloy: did your cat just step on your keyboard? quite aside from the irrelevant gender stuff, that made no sense

17:43 noncom: i 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:44 amalloy: i have two cats actually :D

17:44 how i was so dumb, torturing ns... it is late here, must be sleeping already

17:45 about the gender stuff: sorry to load you with all that linguistic terminology :D

17:50 asdf__: 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:50 or even if this makes sense

17:51 noncom: maybe you mean return a {}, not sequence?

17:52 aside from that, i would use (map).. maybe with (partial)..

17:53 (map #(partial fn-that-takes-2-args the-one-value) the-initial-collection)

17:53 asdf__: return a sequence

17:54 noncom: how can you engineer indices in a collection?

17:54 dont them simply go 0, 1, 2, 3... n?

17:54 give an example of result you want

17:55 asdf__: 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:57 noncom: ,(map #(* 2 %) '(1 2 3 4))

17:57 clojurebot: (2 4 6 8)

17:57 noncom: like that?

17:59 asdf__: Yup. that works perfectly.

18:00 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:00 noncom: asdf__: btw, maybe you find it easier use vectors instead of lists for sequences..

18:00 look

18:01 ,(map (fn [s] (* 2 s)) [1 2 3 4])

18:01 clojurebot: (2 4 6 8)

18:01 noncom: #() is a shortcut for (fn)

18:01 asdf__: either way. anything that can be indexed. That should work for both right?

18:01 noncom: asdf__: if you have sequences of numbers, then [] are preferable

18:01 i guess

18:02 yes it works for both

18:02 well, good luck! i have to go now

18:13 bbloom: dnolen: lol, mutable promises

18:14 dnolen: "hey, let's take something hard and MAKE IT HARDER"

18:23 grandy: anyone know why using a println inside a seesaw event handler causes an exception?

18:25 actually 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:26 amalloy: grandy: too many parens

18:26 grandy: amalloy: hmm

18:27 amalloy: not sure i understand, you mean i put in an extra one? or that the nesting is not allowed?

18:27 amalloy: you wrote (x) instead of x, where x is a string

18:28 grandy: amalloy: hah i think you're right :)

18:28 embarrassed now but still going to keep learning clojure

18:29 amalloy: it's a mistake everyone makes a few times

18:38 hfaafb: https://gist.github.com/samuelcferrell/6401004 is there a simpler way to map a coll across multiple functions like this?

18:39 amalloy: if they're anonymous functions, why aren't you just combining them? (map #(...) coll)

18:41 hfaafb: amalloy: i could, certainly not a bad answer but it feels weird to me to pack all my transformations into a single fn

18:41 amalloy: hfaafb: i mean, (= (map f (map g (map h coll))) (map (comp f g h) coll))

18:42 so you can do that if you want. but i'd probably write it like (for [x coll] (...do stuff with x...))

18:42 grandy: advice 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:43 hfaafb: thanks amalloy both fit nicely

19:17 coventry: Is 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:31 hyPiRion: coventry: Not a clojure function, but a java method?

19:31 ,(Pattern/quote ".-with-random\\stuff")

19:32 clojurebot: #<CompilerException java.lang.RuntimeException: No such namespace: Pattern, compiling:(NO_SOURCE_PATH:0:0)>

19:32 hyPiRion: (import 'java.util.regex.Pattern)

19:32 ,(import 'java.util.regex.Pattern)

19:32 clojurebot: java.util.regex.Pattern

19:32 hyPiRion: ,(Pattern/quote ".-with-random\\stuff")

19:32 clojurebot: "\\Q.-with-random\\stuff\\E"

19:32 hyPiRion: there

19:32 Then convert that one to a regex

19:38 coventry: Thanks, hyPiRion.

20:24 Is there a way to clone a protocol so that you can extend it without impacting other functionality using it?

20:27 bbloom: coventry: hmm… i mean, they are just data. have you tried just aliasing one?

20:27 coventry: i dunno if it would work, but (def MyProtocol TheirProtocol) might just work

20:28 coventry: 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:36 coventry: bbloom: 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:37 bbloom: ,CollReduce

20:37 clojurebot: #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: CollReduce in this context, compiling:(NO_SOURCE_PATH:0:0)>

20:37 bbloom: ,(require 'clojure.core.reducers)

20:37 clojurebot: #<FileNotFoundException java.io.FileNotFoundException: Could not locate clojure/core/reducers__init.class or clojure/core/reducers.clj on classpath: >

20:37 bbloom: ,(require 'clojure.reducers)

20:37 clojurebot: #<FileNotFoundException java.io.FileNotFoundException: Could not locate clojure/reducers__init.class or clojure/reducers.clj on classpath: >

20:38 bbloom: (require 'clojure.reflect)

20:38 ,(require 'clojure.reflect)

20:38 clojurebot: nil

20:38 bbloom: ,clojure.reflect.Reflector

20:38 clojurebot: clojure.reflect.Reflector

20:39 bbloom: weird, that's a class… hmmm

20:39 if you do (defprotocol P)

20:39 then P

20:39 i get a map

20:41 coventry: It bothers me that I can extend a protocol in any namespace, from any namespace. Does it ever become a source of confusing bugs?

20:42 bbloom: it's particularly annoying when doing interactive development. that's why most people put their protocols in a namespace by themselves

20:42 also, 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:43 it would be cool if deftype returned a curried extend-type function and defprotocol returned a curried extend-protocol function

20:43 so then you'd need either extender function as a sort of secret key to extend (this is formally called a "capability")

20:44 robink: Is it OK to use Hickory for destructuring HTML?

20:46 coventry: bbloom: 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:47 bbloom: coventry: 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:47 it's very common

20:55 amalloy: i don't think you can usefully alias protocols

20:56 if you alias just the value, then it's not mutable; if you alias the var, then changes to it ripple to the original

21:22 coventry: Is 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:24 mdupont: howdy

21:28 amalloy: not a builtin, coventry

21:28 coventry: amalloy: thanks.

21:28 amalloy: i wrote one at https://github.com/flatland/useful/blob/develop/src/flatland/useful/fn.clj#L94

21:29 coventry: Oh, great, a reason to use useful.

21:32 Oh, it has map-keys. Just what I need.

21:44 Raynes: I'm surprised that function isn't in core.

21:44 It meshes nicely with juxt.

22:08 fkey: after using reify, how do you tell if the object contains a function given it's name?

22:19 devn: why does clojure.walk have *-demo fns and other core libs don't?

22:19 for instance, clojure.zip

22:19 (note: mostly rhetorical)

22:21 i think there's always been a desire to have a (clojure.repl/examples ...)

22:21 i mean, that's why i made http://getclojure.org/

22:24 overtone has an example macro

22:46 loganlinn: Is there a good way to detect if compiling for ClojureScript vs Clojure in a crossover namespace?

23:00 devn: loganlinn: what do you mean?

Logging service provided by n01se.net