#clojure log - Jul 04 2012

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

0:00 technomancy: the lanterna google code page links to https://issues.sonatype.org/browse/OSSRH-3751, which has the snapshots repo

0:00 but they really do need to make it more obvious

0:00 maybe they will once they have a release and aren't working with snapshots?

0:00 sjl: well I think they have their non-snapshots in Maven central

0:00 which I think would just magically work with lein, right?

0:01 technomancy: it's in :repositories by default, yeah

0:02 lein pprint :repositories # -> {"central" {:url "http://repo1.maven.org/maven2"} "clojars" {:url "https://clojars.org/repo/"}}

0:08 michaelr`: technomancy: pprint? a plugin?

0:08 technomancy: michaelr`: yeah, https://clojars.org/lein-pprint

0:08 good for debugging

0:09 michaelr`: good to know

0:12 btw technomancy, is there some list/registry of all lein plugins?

0:12 could be usefull

0:12 technomancy: there certainly is

0:12 https://github.com/technomancy/leiningen/wiki/Plugins

0:12 michaelr`: cool thanks

0:13 technomancy: no problem

0:13 michaelr`: wow, lots of plugins

0:13 technomancy: yeah, it's really grown =)

0:27 zawzey: hmm, does anyone have much experience mixing library versions: http://groups.google.com/group/clojure/browse_thread/thread/abddc241243a01ea/500864190706078b

0:29 so can 2 libraries with different versions exist in the same project? (aside from using lein exclusion)

0:29 technomancy: zawzey: AFIAK there's no good way to do that cleanly, you have to manually construct isolated classloaders

0:29 zawzey: technomancy: Yes, any examples of that?

0:30 technomancy: no, sorry

0:30 talios: damn you hibernate - you'll make me go even more bald than I am at this rate :(

0:31 zawzey: technomancy: No problems, it's an long-standing topic, i suppose. http://groups.google.com/group/clojure/browse_thread/thread/182f171afc49473b/297393ed49f4dffe

0:31 technomancy: zawzey: it's almost always going to be better to just make it work with a single version; doing both is going to be a huge yak shave

0:33 zawzey: technomany: True that, it's just using external libraries (with conflicting dependencies) can become a problem, guess when the time comes, just have to fork off the original lib

0:33 technomancy: hopefully the one using the older version will accept patches

0:33 zawzey: technomancy: Or just have to fork off it, if it's no longer maintained

0:33 amalloy: you could give polycosm a shot, but i'm not sure how production-ready it is

0:34 technomancy: oh right; I forgot about that

0:34 zawzey: amalloy: thanks for the headsup

0:34 amalloy: i think polycosm needs you to plan your whole application around the split classloaders ahead of time, or nearly so

0:35 technomancy: yeah, there's no way to make this work seamlessly

0:44 dnolen: Shambles_: still there?

0:44 zawzey: thanks guys, guess will need to be aware of this if we need to scale our project

0:50 amalloy: did you guys know, there's only one user in here whose name starts with Q? but we have six Xs! what is up with that?

0:51 technomancy: amalloy: it's an eXtreme channel, no surprise there

0:52 amalloy: x-clojure, for programmers too eXtreme to wait for an officially-blessed MIME-type?

0:53 hiredman: http://vimeo.com/44968627 this is great, and I want it

0:54 dnolen: well perhaps Shambles_ is gone, but porting animals.py to a vector of maps was pretty dead simple as I expected. no atoms or zippers - code looks pretty much the same - https://gist.github.com/3045400

0:54 hiredman: yeah kovasb's prez was awesome.

0:55 amalloy: summary from anyone so folks know whether to dedicate half an hour to watching a the video?

0:55 borkdude: gitrepl: a repl in which the states are bound to commit ids… and always the possibility to go back, clone, etc, who wants to implement that? ;-)

0:56 dnolen: amalloy: it's worth it, thinking about evolving the REPL

0:57 amalloy: one of most compelling reasons for data literals & CLJS IMO

0:57 technomancy: borkdude: I've wanted transactional require for a loooong time =)

0:57 hiredman: I was just thinking about this because of all the "python notebook" headlines I've been seeing around

0:59 dnolen: amalloy: session is basically just scratching the surface of what we could do.

1:01 hiredman: oh god, he has a checked in .DS_Store

1:03 arohner: I've been wanting serializable *everything* for a long time. fns, infinite seqs, etc

1:04 hiredman: *shrug* just serialize the code that generates them

1:06 borkdude: serializing infinite seqs to disk isn't a problem, as long as your disk is lazy too.

1:07 sorry, I just woke up

1:07 much too early, grrr!

1:08 sjl: just serialize them to MongoDB, they're probably get garbage collected before an fsync anyway.

1:14 amalloy: arohner: serializable-fn serializes any function whose lexical environment is serializable

1:15 arohner: amalloy: I know. but I think there's a lot of cool things that could be made if the whole environment could be serialized

1:16 amalloy: automatic serialization of any old object is basically impossible, unless all your objects are cons cells

1:18 arohner: that's a little overstated

1:18 strings, ints, clojure data structures are all serializable. I don't see why anonymous fns, refs & atoms & agents can't be

1:19 amalloy: lambdas can be, as i said with serializable-fn

1:19 arohner: in a hacky, unsupported way

1:20 I'm talking about fully supported

1:22 amalloy: refs and friends are identities, not values; how will you write them? #clj/ref [id-number current-value]? then you have to somehow keep id-numbers around between calls to the serialization mechanism, or require that your entire program state be serializable from a single root. what do you do about the circular data introduced by refs?

1:22 and that still doesn't cover things like mongodb session handles, or whatever - the whole environment isn't serializable if they aren't

1:23 and what's hacky about using the built-in customizable-serialization hook?

1:24 those problems are probably all soluble (maybe not the mongodb handles), but it's not easy

1:25 arohner: this is like arguing that C has "good enough" function pointers and OO features. serialization is a thing that isn't fully supported. Yes you can hack, but it unlocks a lot of power when those things just work

1:26 amalloy: so do what technomancy did. start a serializable-ref library, and use it until it's awesome enough to get into clojure.core

1:26 technomancy: amalloy: someone did that... alyssa kwan?

1:26 but it was a fork of clojure

1:26 amalloy: yeah, those persistent refs or whatever she called them?

1:26 technomancy: and she posted about it and nobody paid any attention =\

1:27 amalloy: technomancy: that doesn't sound like the clojure ML! surely someone showed up to tell her we don't want that?

1:27 technomancy: mwahaha

1:27 michaelr`: what did you say? i wasn't paying any attention..

1:44 cljs_newb_2302: when calling javascript functions from clojurescript functions, how is the "this" variable set?

1:48 borkdude: nice video about Session

2:12 wingy: anyone here knows what the difference between :db/id and :db/ident is in datomic?

2:12 eg. {:db/id #db/id[:db.part/user -2]

2:13 :db/ident :person.gender/female}

2:13 why id and ident at the same time .. since im using the latter as reference why do i need to specify the id

2:26 john2x: Hello, i'm following the instructions here (https://github.com/quil/quil/wiki/Installing), and have Leiningen installed and `lein deps` is done. But when I try (use 'quil.core') in the repl, I get a FileNotFoundException.

2:27 wingy: nvm i posted it in the datomic mailing list

2:28 and it seems that both are semantically identical, just that when something has a :db/ident you can refer it using the keyword instead of the id

3:12 LoganLK: every time I run lein run/repl/deps the console gets filled with "could not find artifact org.clojure:clojure:pom:1.+ in *repo name* messages, then it will successfully execute the command (eg run the project). I'm running lein2 preview7 on windows

3:12 pic of errors http://i.imgur.com/JjuWU.png . any ideas?

3:15 adu: LoganLK: are you connected to the internet

3:15 ?

3:15 LoganLK: adu: yes

3:15 adu: hmm, i donno

3:15 talios: Is that saying version 1.+?

3:16 or am I misreading it?

3:16 LoganLK: talios: it says 1.+?

3:16 but as you can see in the project I have specified the version. I have tried "1.3.0", but same thing happens

3:17 adu: LoganLK: "org.clojure:clojure:pom:1.+ in *repo name* messages"

3:17 what is your project.clj?

3:17 LoganLK: adu: http://i.imgur.com/JjuWU.png

3:17 talios: project.clj was at the top of the image

3:18 odd - looks like its trying to find org.clojure:clojure:pom:1.+ for some weird reason.

3:18 I dont use lein so maybe I'm misreading the output tho

3:19 adu: does that mean there's an object called 1, and it's trying to find it's "+" method?

3:19 that sounds like a much bigger problem misreported

3:22 amalloy: i'd guess an issue with one of your lein plugins? ask in #leiningen; it's lower-traffic so shouldn't get lost in the flood of #clojure before being noticed by someone who can help

3:22 LoganLK: amalloy: no lein plugins :( thanks

5:25 ro_st: muhoo: i gave you a link to a clojurescript starter template. now i can't find it. do you have the link handy?

5:25 scratch that, just found it

5:40 wingy: how do i convert this line to one without read-string? @(d/transact conn (read-string "[{:db/id #db/id[:db.part/user -1000001], :item/name \"Item 1\"}]"))

5:40 Is there a way to do that even though it's using a reader literal?

5:56 lewis1711: TEttinger: you think THIS language is better than scheme?

5:56 really?

5:58 TEttinger: hi lewis1711. yes.

5:59 clgv: wingy: afaik yes. just write normal clojure and add the reader literal

6:00 lewis1711: what's THIS?

6:02 lewis1711: lol

6:02 clgv: clojure

6:02 clgv: just wanted to know what language you are talking about ^^

7:16 clojure-newcomer: Hi guys, I am trying to simplify the key names on my datomic entity so I can use them with Noir… currently getting 'Can't let qualified name' with keys like ':my entity/name', any ideas ? I thought of using rename-keys but get an AbstractMethodError as I am working with a 'datomic.query.EntityMap'

7:33 ro_st: argh. so i'm using midje to test my database layer fns. as part of the fns that write data, i timestamp stuff, so i know when created/when updated

7:33 i'm mocking all the data out in my midje test, but i'm not sure how to write my checker to see that some test data that was written is coming back out correctly, because the data coming out has been timestamped

7:37 got it

7:38 holy crap midje is cool

8:26 ordnungswidrig: does 1.3 use type hints on record fields?

8:28 clgv: ordnungswidrig: only primitive type hints - 1.2 did so as well

8:29 ordnungswidrig: clgv: (defrecord Foo [^Integer foo]) macro-expands to a deftype* where no typehints are visible

8:30 ,(macroexpand-1 '(defrecord Foo [^Integer foo]))

8:30 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

8:30 clgv: ordnungswidrig: type hints are metadata which is "eaten" by the reader. you have too look at the metadat of the symbol

8:31 ordnungswidrig: which symbol? Foo is a class, so no metadata is available

8:32 clgv: no Foo is a symbol in the expanded defrecord macro

8:32 ordnungswidrig: clgv: there's (deftype* Foo user.Foo [foo __meta __extmap] :implements ...)

8:32 clgv: if you want to know whether your type hint succeeded you can use a decompiler like JD-GUI

8:33 ordnungswidrig: clgv: so the compiler uses the type hints extracted by the reader?

8:33 clgv: ordnungswidrig: yes. and Foo carries metadata which is not printed.

8:33 ordnungswidrig: clgv: How can I access this metadata, then?

8:33 clgv: why would you want to do that?

8:34 ordnungswidrig: I wondered if there is runtime access to the typehints

8:34 So I suppose this is only possible when doing AOT

8:34 ro_st: (meta thing)

8:34 (:type (meta thing)) *shoots from the hip*

8:35 ordnungswidrig: ro_st: *target missed*

8:35 clgv: no there is no Runtime access if you have the compiled defrecord

8:36 you can access it in the expanded macro though

8:36 ordnungswidrig: clgv: no there is no type hint in the expanded macro

8:38 clgv: ordnungswidrig: there is! try: (-> '(defrecord Foo [^int a b c]) macroexpand-1 (nth 2) (nth 3) first meta)

8:39 took a bit to get the navigation in the expansion done ;)

8:39 ordnungswidrig: clgv: *doh*

8:40 clgv: ordnungswidrig: type hints or metadata in general, will never appear in macroexpand.

8:41 you could write a specialized print method to show them

8:41 mystiiq: I am using clj-ssh in my project, i've got this line: (:use [cljaws core helpers] [clj-ssh.ssh]) and it tells me that Could not locate clj_ssh/ssh__init.class or clj_ssh/ssh.clj on classpath:

8:41 what am I doing wrong

8:42 in my another project I only got (:use [clj-ssh.ssh]) and it works

8:43 ordnungswidrig: clgv: I missed that the __meta field actually contains the metadata

8:43 clgv: or has it attached

8:44 clgv: ordnungswidrig: no, the __meta field will contain only metadata that was assigned to an instance of your Foo record

8:46 ordnungswidrig: try that to see the typehint on the fields (binding [*print-dup* true] (-> '(defrecord Foo [^int a b c]) macroexpand-1 pr-str))

8:46 => "(clojure.core/let [] (deftype* Foo user.Foo [^int a b c __meta __extmap] ..."

8:52 wingy: clgv: it doesn;t work

8:52 tried this one: @(d/transact conn [{:db/id 17592186045796, :item/name \"Item 1\"})

8:52 i mean this one: @(d/transact conn [{:db/id 17592186045796, :item/name \"Galaxy Tab 3\"}])

8:53 damn .. let me make it better

8:53 clgv: but read-string should not differ much from how a source file is read or the REPL reads

8:54 wingy: you should make the test minimal: skip the transaction code

8:55 wingy: https://gist.github.com/3047203

8:57 but i think the # read literal is used by read-string

8:57 it does some magic on it

8:57 oh it worked

8:58 @(d/transact conn [{:db/id 17592186045796, :item/name "Galaxy Tab 3"}])

8:58 without the back slashes :)

8:58 clgv: thx for the test minimal hint :)

8:59 ro_st: how's the clojure going, wingy

8:59 you killin' it?

9:02 clgv: wingy: btw in your examples you only use namespace-prefixed-keywords, no reader literals

9:04 wingy: ro_st: very fun. using it together with datomic

9:04 world's best database

9:06 clgv: yeah i forgot the #

9:06 @(d/transact conn [{:db/id #db/id[:db.part/user -1000001], :item/name "Galaxy Tab 2"}]) ;; gave an error

9:07 ill just use the read-string til i get more about how clojure works

9:07 clgv: thats probably because [:db.part/user -1000001] is wrong

9:08 wingy: it cant

9:08 its just a keyword and a nr

9:08 nothing wrong syntatically

9:09 what i get is a clojure error: #<RuntimeException java.lang.RuntimeException: Unmatched delimiter: ]>

9:09 clgv: and the function handling #db/id expects a vector of those two things?

9:09 wingy: oh yeah

9:09 must be it

9:10 reader literal was used to make it more convenient

9:10 ill just use the read-string for now

9:11 cant find my ways around clojure 100% yet

9:11 clgv: did you read any of the books?

9:21 wingy: clgv: im still in Clojure Programming

9:21 didn't read all of it though since I realized i have to play with clojure a little to get familiar with the basics first before i jump into macros, records etc

9:22 have to apply an iterative style even on learning .. that's the best method i think

9:25 ro_st: wingy, found the clojure koans yet?

9:27 wingy: ro_st: what does koans mean?

9:28 ro_st: https://github.com/functional-koans/clojure-koans/

9:31 clgv: why not 4clojure.com ?

9:33 wingy: wow didnt know about all these starter kits

9:33 ill do the koan first

9:37 ro_st: why not both? :-)

9:37 there's labrepl too

9:37 what's nice about clojure-koans is you do it in your editor of choice

9:37 nice for getting comfy with emacs

9:37 clgv: wingy: 4clojure only helps a bit when you start with the Elementary problems. it's more to test your clojure skills^^

9:38 you should do the more difficult problems of 4clojure in your own IDE as well ;)

9:41 wingy: so cool .. clojure-koans autodetects changes :)

9:43 already learned my first lesson

9:43 (1 1 1) works :)

9:43 clgv: &(1 1 1)

9:43 lazybot: java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn

9:44 wingy: is i mean (= 1 1 1) :)

9:44 btw .. (= 2 2/1 2) .. how come that 1/2 works .. is it syntatic sugar over prefix mode?

9:45 Vinzent: wingy, no, it's ratios. Cool, yeah?

9:45 wingy: oh right forgot that

9:45 yeah clojure (lisp) is so cool!

9:46 it beats other langs by light years

9:46 i will never go back..ever!

9:47 Vinzent: ;)

9:47 wingy: i rather die

9:47 yes

9:49 tbaldridge: wingy: http://xkcd.com/224/

9:51 wingy: :)

9:51 clgv: wingy: http://xkcd.com/297/

9:51 wingy: i think i would like clojure more though

9:52 haha

9:52 () power

9:54 not= is the same as != it seems

9:55 is there a reason not to use != instead? or is it just a matter of taste?

9:55 i mean != in other langs

9:57 clgv: wingy: well there is also: not, when-not, if-not ...

10:10 wingy: clojure koans was really fun

10:11 more fun than reading a lot without doing code

10:11 even though i try to play with it in repl

10:13 i cant wait for light table to come out and help us with the live doc .. too many functions to remember and having to look all up (arity, desc, examples) is taking a lot of efforts

10:19 apparently you can use (first []) on a vector

10:20 Scriptor: wingy: as in (first [1 2 3])

10:20 mybuddymichael: ,(first [3 4 7])

10:20 clojurebot: 3

10:20 Scriptor: that's because first calls seq on its argument(s)

10:21 er, make that just one argument

10:21 so it converts the vector into a seq, and then gets the result of calling its first() method

10:22 wingy: note this line https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L567

10:23 wingy: Scriptor: but how do i know this without looking at source

10:23 first only works on sequences

10:23 and vector is not a sequence

10:24 the doc doesn't clarify this

10:24 how do you know what functions work on what structures

10:24 Scriptor: wingy: had a discussion on this a few days ago! Basically first works on *seqables*, not just seqs

10:25 and vector is a seqable, because it supports the creation of a seq from the vector

10:25 dnolen: wingy: it does, it says it calls seq on it's argument.

10:25 metellus: ,(doc seq)

10:25 clojurebot: "([coll]); Returns a seq on the collection. If the collection is empty, returns nil. (seq nil) returns nil. seq also works on Strings, native Java arrays (of reference types) and any objects that implement Iterable."

10:25 metellus: sorry

10:25 ,(doc first)

10:25 clojurebot: "([coll]); Returns the first item in the collection. Calls seq on its argument. If coll is nil, returns nil."

10:25 metellus: a vec is a collection

10:25 so first should work

10:28 wingy: for the most part, clojure functions will work as you expect them to. Vectors have first elements, so it makes sense that first works on them. There may be minor differences in how things work when they are ambiguous (like conj), but you can find them out quickly in a repl

10:30 wingy: ok so the "sequences" to the left means "seqables" as well http://clojuredocs.org/quickref/shortdesc/Clojure%20Core

10:30 clgv: wingy: well for questions like that you should progress in your book ;)

10:31 Scriptor: wingy: that section is for both collections *and* sequences

10:31 so a hashmap is a collection, but not a sequence

10:31 wingy: there was a link i forgot to save .. where they listed tables for differences between sequences and collections

10:31 dnolen: wingy: all the clojure collections are seqable.

10:33 wingy: Scriptor: yeah but _first_ was found below Sequences section

10:33 clgv: wingy: I would continue reading the book, saves you time ;)

10:33 wingy: the first function is _seq_ .. that means it returns seqable and not a sequence?

10:34 clgv: yeah i will .. after the koans :)

10:34 but if it returns seqable then why not call that section Seqable and not Sequence

10:34 its ambiguous

10:35 clgv: first returns the element at position 0 or nil

10:35 wingy: clgv: i mean the first function below that section is seq :)

10:36 i think the confusion comes in when the doc is not very clear about what is for seqable (collections) and what is for sequence (list)

10:37 metellus: is there anything that isn't for both?

10:37 tbaldridge: wingy: there's a difference between seqable and seq

10:38 seqable means it can be turned into a seq

10:38 so a list is both seqable and seq (in this case calling seq on a list is a no-op because it is a seq)

10:39 a vector is seqable as calling (seq [1 2 3]) returns an entirely different type of object.

10:39 but a vector is not a seq

10:40 I don't know if this helps at all, but these map to Java interfaces: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/ISeq.java https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Seqable.java

10:40 metellus: he knows all that; his issue is that the docs don't really explicitly say "things will work for seqables even if they say that they work for seqs"

10:40 tbaldridge: yeah that is a bit confusing.

10:41 clgv: humm not really.

10:41 wingy: ok ill just assume that everything just works for collections (seqables) .. since they will be converted into sequences

10:42 metellus: wingy: as far as I know, that will work. If you do encounter something weird, try out some examples in a repl to see what's going on

10:42 wingy: but honestly i don't enjoy confusions like these where it takes so much time to figure things out .. "Dont make me think" is a really good book explaining why you don't want unnecessary overhead for users

10:43 clgv: wingy: you could have read it in your book. you won't fin general global-scope explanations in docstrings ;)

10:43 mystiiq: how can I iterate over a map and define variables with given key and set value of that corresponding key

10:44 wingy: if there is someone here with authority/knowledge to change docs i hope these things could be cleared out to make the looking up process more enjoyable

10:44 metellus: to be fair, http://clojure.org/data_structures#Data Structures-Collections does say "Because collections support the seq function, all of the sequence functions can be used with any collection."

10:44 clgv: mystiiq: give an example

10:46 mystiiq: I read a file into a map containing config parameters and then I want to define them as a system-wire variables

10:46 clgv: mystiiq: oh. then you have to create the def statements and eval them

10:47 mystiiq: but that approach does not sound idiomatic...

10:49 wingy: metellus: yeah more fair

10:49 ill read them through

10:50 and thx for all explanations the 2nd time now :)

10:50 i think its solid with the diff :)

11:05 tbaldridge: clgv: why is that not idiomatic?

11:06 clgv: tbaldridge: global defs for config created at runtime sounds pretty wrong. there would be the option to set up something with thread local binding or such

11:07 tbaldridge: clgv: yeah, I can see that

11:08 clgv: tbaldridge: most of the time when you use eval in a function, there is a good chance you are doing it wrong, as well

11:08 tbaldridge: clvg: it depends though, if it's a config for a website, global defs would probably be preferable

11:10 so yeah, the eval version sounds bad, but what about putting defs in a seperate namespace, then reading the config file and runtime and using set! to init all the configs

11:10 clgv: tbaldridge: well thread-local bindings are propagated since 1.3

11:10 tbaldridge: no eval, but yet global defs (for stuff like db servers)

11:10 clgv: tbaldridge: and why not using thread-local bindings?

11:11 you read the config before you do anything website related, I guess

11:12 tbaldridge: the problem with using the bindings is that I then have to wrap my entire app in a (binding [])

11:13 but I'll admit can see allot of benefit to your method.

11:14 clgv: tbaldridge: well you have a single point of entry anyway, when you launch jetty&co

11:15 tbaldridge: and you could even easily overwrite config params for user-specific settings

11:18 tbaldridge: clgv, yeah, I hadn't thought of it that way. If they are propagated to sub-threads then yeah, it sounds like it would work fine. Cool I learned something today.

11:18 clgv: =)

11:19 wingy: doing clojure koans is like doing sudoku

11:19 mmarczyk: dnolen: good catch on 330, thanks!

11:19 borkdude: then sudoku must be a very nice game

11:19 wingy: someone release a clojure sudoku app for android/iphone

11:19 so i can do it on the bus

11:20 borkdude: wingy this is your next assignment

11:20 wingy: no .. i pay!

11:20 clgv: p(l)ay?

11:20 clojurebot: clojure is the brand

11:20 wingy: and pay

11:20 borkdude: 4clojure app

11:21 could be nice project

11:21 clgv: lol I would not want to program anything on a smartphone ;)

11:21 borkdude: but I don't have a smart phone either ;-)

11:21 wingy: but since it's cumbersome to type things in an iphone it would be better with alternatives as answers

11:21 borkdude: wingy I have a Nokia E71 for that

11:21 mmarczyk: dnolen: btw, could you look into cljs-319 in a free moment? bbloom's patch worked for me perfectly last time I checked and the issue is so annoying :-P

11:22 borkdude: wingy well I guess that is a smart phone, but symbian is dead

11:22 wingy at least is has a keyboard

11:24 wingy: fill in: (= (+ __ 1) 23) 1) 23 2) 31 3) 22 .. and you press a nr

11:24 no need to type

11:24 borkdude: wingy or make the game: drag the expression in the right order ;)

11:24 wingy: borkdude: yeah but your are on the bus .. and wanna learn with no typing efforts

11:25 yeah

11:25 all kind of stuff

11:25 come on .. some clojure guru who needs some time to kill

11:25 i think people would buy the app

11:25 subscription based!

11:25 borkdude: wingy just buy a macbook air or smth, so much easier

11:26 wingy: if you release new levels each month i could pay like 2 dollars each month

11:26 borkdude: but its no fun reading books all day long

11:26 you wanna play and learn just like clojure koans

11:26 borkdude: wingy that you can do on a macbook air?

11:27 wingy with a full fledged REPL and no limitations

11:27 wingy: i have a macbook pro .. but i feel it would be more fun to do it on the go

11:27 new kind of learning

11:27 borkdude: wingy yes, on the go… I do clojure while commuting sometimes

11:27 wingy: for php, ruby and other langs as well .. this is business!

11:27 i know it will be big

11:28 borkdude: haha

11:28 look at sudoku

11:28 try to release one .. you will get millions

11:28 im never wrong

11:28 borkdude: wingy what would you do with all those millions, life would get very boring? ;P

11:29 wingy: so many people who wants to know programming but not thorugh reading books

11:29 and they don't wanna spend efforts in repl typing/testing everything themselves

11:29 borkdude: i would make more apps

11:29 and get billions!

11:30 dnolen: mmarczyk: I suspected something deeper was going on w/ 330

11:30 mmarczyk: I don't like the double doseq calls in 319, worth investigating removing those.

11:30 wingy: then climb up to the top of a mountain screaming .. BILL!!!!!!!!!!!!!!

11:31 mmarczyk: dnolen: re: 330, yeah, I think your commit nails it

11:32 dnolen: alternatively we could extend to "null" and "undefined" avoiding the nil? check

11:32 dnolen: probably not worth the trouble though?

11:34 dnolen: re: 319, ok, that's worth a try

11:40 dnolen: mmarczyk: I think the nil? check is sufficiently cheap. I think handling undefined at all is not worth it.

11:41 technomancy: man, I wish the clojure reader would treat nonbreaking spaces correctly =\

11:47 pepijndevos: Is there anything that prevents one from writing a multithreaded asynchronous server?

11:49 dnolen: pepijndevos: like Netty?

11:49 pepijndevos: dnolen, I don't know. Like netty? I just noticed that all these tthings like node, libev, twisted ed are all singlethreaded.

11:50 dnolen: pepijndevos: look at Netty.

11:50 pepijndevos: cool, thanks

11:50 dnolen: pepijndevos: Aleph is built on top of it.

11:51 pepijndevos: yea, aleph rocks

11:51 * pepijndevos is writing a database in C

11:53 wingy: how do i make an anonymous fn return 1

11:53 when it's run

11:53 (#('1)) ;; yields error

11:54 rkz: wingy: ' isn't a quote, it's a special form

11:57 wingy: rkz: it's a quote in '(1 2 3) ?

11:59 dnolen: wingy: you can't do that with fn literals, regardless of quote, the body of the fn literal is an expression, so you're invoking (quote 1) as a function.

11:59 rkz: wingy: that says evaluate the form without using 1 as a fuction call and 2 3 as args

11:59 Iceland_word: wingy: maybe check out http://clojuredocs.org/clojure_core/clojure.core/constantly ?

12:00 dnolen: ,((fn [] 1))

12:00 clojurebot: 1

12:00 dnolen: ,(#(do 1))

12:00 clojurebot: 1

12:00 metellus: ,(#(1))

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

12:01 rkz: ,(#(identity 1))

12:01 clojurebot: 1

12:02 wingy: cool solutions

12:17 gfredericks: ,((constantly 1))

12:17 clojurebot: 1

13:17 cmcbride: if I have a vector of maps, and I want to update a specific key in each map, whats the best way to do that?

13:18 borkdude: (mapv (fn [m] (assoc m k new)) vec-of-maps) ;; something like this?

13:19 cmcbride: yes, I forgot about mapv. Thanks

13:30 sirsublime: sup peepz

13:30 List comprehension question coming up

13:30 Say I have some seq and I know it's sorted.

13:31 And I want to do list comprehension on it, but with n values, instead of one.

13:31 So, if I have a vector [1, 2, 3, 4], then I could itterate by [1,2] and [3,4].

13:32 I don't think plain vanilla (for ..) does it.

13:32 Any tips?

13:32 cockadoodledoo: maybe partition?

13:32 http://clojuredocs.org/clojure_core/clojure.core/partition

13:33 sirsublime: (for [[x y] (partition 2 foo-list))?

13:33 I love you coc... Almost fell for that one.

13:34 cockadoodledoo: (partition 2 [ 1 2 3 4])

13:34 sirsublime: This is awesome. Thanks!

13:34 cockadoodledoo: np

14:06 TimMc: sirsublime: Also see partition-all, for future reference.

14:21 sirsublime: TimMc: Thanks!

15:06 lynaghk: dnolen: I'm playing with core.logic and the Zebra puzzle, and things take very long if I move the unify statement (milk is drunk in the middle house) past one or two membero statements. Is this because the unify nails down a lot of the free variables early on in the search or something?

15:06 dnolen: do you find you have to rearrange ordering like this to get your logic programs to complete?

15:18 pendlepants: if I have a nested map like {:recent-tracks {:track {:artist {:text "name"} :name "song name"}}}, is there a better way to get nested values than (:text (:artist (:track (:recenttracks var))))?

15:19 dnolen: pendlepants: get-in

15:19 (get-in x [:recent-tracks :track :artist :text])

15:19 pendlepants: that's perfect; thanks dnolen.

15:40 augustl: how do I add unpublished dependencies to a leiningen project? My project consists of a bunch of modules, and some of them depend on some of the others. These modules won't be published on clojars though

15:40 set up my own maven repo perhaps?

15:42 if so, any suggestion for reading material for a person that has no prior experience on the Java platform? :)

15:43 xeqi: augustl: are they just being used on one machine?

15:43 augustl: xeqi: well, I don't mind building and deploying uberwars, it's ok if you have to somehow link stuff in by hand locally or whatever

15:45 TimMc: ~repeatability

15:45 clojurebot: repeatability is crucial for builds, see https://github.com/technomancy/leiningen/wiki/Repeatability

15:46 augustl: TimMc: aww, so I have to set up a repo then

15:46 let's hope that won't take too many days of my time :P

15:46 ooh, private s3 buckets

15:49 Jayunit100_: man there is no irc for regular old java . just realized that.

15:51 yonatane: not many one liners

15:56 Shambles_: dnolen: I saw the code you posted yesterday. Thanks for doing that. I wasn't expecting it.

15:57 TimMc: Jayunit100_: ##java, but you won't be happy

15:57 dnolen: Shambles_: no problem - as I suspected using a vector allowed pretty much a direct translation

15:57 Shambles_: no atom, no zippers etc.

15:57 ssutch: when using java interop, what is the best way to run a method against an instance in let, eg: http://www.exampledepot.com/egs/java.security/GenKeyPair.html

15:58 i want to run keyGen.initialize(1024) (. keyGen initialize 1024) before using it

15:58 would i just run that as an expr in the body of the let

15:58 TimMc: Not sure what 'let has to do with it.

15:58 (.initialize keyGen 1024)

15:59 ssutch: Or even better, use doto

15:59 ssutch: TimMc it probably doesn't, this is only my 2nd day with clojure, so looking for best practices

15:59 doto, interesting, i am not familiar, i'll look it up

16:00 TimMc: (doto (KeyPairGenerator/getInstance "DSA") (.initialize 1024))

16:00 ssutch: aha!

16:00 i knew there would bea more succinct way to express that

16:00 dnolen: Shambles_: also hopefully you can see that the functional data structure support is quite good. only 2 lines that deals with managing indexes.

16:01 TimMc: ssutch: It's a good macro to use if you want to call a contructor (or similar), hammer on the object, then return it.

16:01 ssutch: that's rad, thanks TimMc

16:02 is it sane to put that in the bindings of a let in the body of a defn?

16:02 TimMc: Sure!

16:02 ssutch: (let [keygen (doto (KeyPairGenerator/getInstance "DSA") (.initialize 1024))] ...)

16:02 TimMc: You'll also see people use it to temporarily sneak in debugging statements: ##(+ 3 (doto (* 5 6) (println))), but that's just a hack.

16:02 lazybot: ⇒ 30 33

16:03 Shambles_: dnolen: I had no problem believing Clojure (being a functional language) would be good at working with data structures in a functional way. Mutation, or working around using it, is another matter. I probably have a long way to go to get my head around that. I admit to not understanding your code, but I'll stare at it and look at documentation until it sinks in.

16:03 dnolen: It's not like the original code was the cleanest written thing anyway.

16:03 dnolen: Shambles_: working mutation is just familiarity. It's easy to get frustrated if you can't rely on old habits.

16:04 using mutation is just famliarity I mean.

16:04 Shambles_: the code is a direct translation of animal.py - I didn't stray very far.

16:06 Shambles_: dnolen: The parts that are giving me trouble are the various -in operations and juxt and the like. Basically the different data structure.

16:06 dnolen: But I should be able to figure it out if I read the documentation and think about it long enough.

16:07 TimMc: <3 update-in

16:07 dnolen: Shambles_: yes, it just a vector of nodes, knowledge always starts at index 0.

16:07 Shambles_: juxt is sweet

16:07 ,((juxt inc dec) 1)

16:07 clojurebot: [2 0]

16:07 TimMc: &((juxt filter remove) odd? (range 10))

16:07 lazybot: ⇒ [(1 3 5 7 9) (0 2 4 6 8)]

16:07 Shambles_: dnolen: Not that this ever happens in this program, but I wonder how tolerant it would be of having nodes removed, since I think that'd mess the indexing up.

16:08 dnolen: Shambles_: functional thinking requires patience, but Clojure delivers a lot of tools so that you can keep code as brief as mutable versions nearly every time.

16:08 Shambles_: it's a toy, expect a toy solution.

16:13 Shambles_: even so, removing nodes doesn't pose any real challenges

16:20 wilfredh: I would like to define a macro that has the same semantics as defn, but builds a list of all the functions that have been defined with it. Should I use a var, or something else?

16:22 I'm not quite sure how to set a variable at compile time such that I can access it at run time.

16:30 ohpauleez: wilfredh: Your macro can compile down to defns, which is common for macros creating DSLs

16:32 wilfredh: https://github.com/ibdknox/noir/blob/master/src/noir/core.clj#L80

16:32 bpr: wilfredh: i would put that macro in its own namespace. Also, in that namespace would be the var with the list(s) as its value. Then define a function in the namespace that can be called at runtime to access the lists.

16:32 ohpauleez: But as a rule of thumb, you should prefer to use functions over macros whenever possible

16:33 a good solution here would be to use a decorator

16:33 bpr: wilfredh: so the macro updates the var, and the var can be read using the function.

16:33 ohpauleez: and decorate the functions outside of a defn, onto another def

16:34 wilfredh: but here is an example of exactly what you're talking about

16:34 https://github.com/shoreleave/shoreleave-remote-noir/blob/master/src/noir/shoreleave/rpc.clj

16:35 bpr: ohpauleez: unless i'm wrong i think this requires a macro. You'd have to walk the source of the function to see what functions it calls

16:35 ohpauleez: with a macro

16:35 bpr: No a decorator is appropriate, but it involves double def'ing

16:35 or adding metadata

16:35 which is probably the best idea

16:35 since you can define it with defn anyway

16:36 bpr: i agree with the metadata

16:36 ohpauleez: wilfredh: Can you use metadata, then just define one predicate function?

16:36 bpr: but how do you, check which functions are being called?

16:37 hiredman: cemerick: why is drawbridge so temperamental? I can usual send a single request via curl, where I get a response, after which I always get an empty response

16:38 ohpauleez: bpr: just use another function (higher-order) that takes a fn, and any args, and has a pre conditional constraint on approved-fn?

16:39 where the function `approved-fn?` checks the metadata of a function

16:39 bpr: i don't think he wants to write the meta-data by hand

16:39 ohpauleez: and inside the function described above, you just do an `(apply …)`

16:39 bpr: Right, so he can use a decorator, and double def

16:40 or he can write a macro

16:40 or if it's just a few, I'd write it by hand

16:41 bpr: if i understand what he wants correctly he wants to write: (def-annotated-fn foo [] (bar (baz))) and have a list defined somewhere that says (somehow) that foo calls bar and baz

16:42 ohpauleez: oh, I thought he just wanted whitelisting

16:42 I didn't know he wanted tracing

16:42 Clojure already has tracing capabilities

16:42 bpr: i coulda read it wrong

16:43 gf3: How do you guys go about playing with misc. libraries from the command line repl?

16:43 As part of no specific project?

16:45 bpr: i did read it wrong lol: he wants (def-annotated-fn bar [] ...) that would then create a list saying bar is called by foo...

16:45 but w/e

16:46 ohpauleez: gf3: You can use lein-exec or just spin up a quick one off project

16:46 https://github.com/kumarshantanu/lein-exec

16:46 bpr: it still seems to need to consider the source directly

16:47 gf3: ohpauleez: That's great, thank you

16:47 ohpauleez: gf3: Totally welcome

16:48 bagelz: why can't I do this in clojure on my phone: (for [x 1 y 1] [x y])

16:52 ohpauleez: bagelz: (for [x [1] y [1]] [x y])

16:52 for is a list comprehension

16:52 not an iteration, really

16:53 perhaps you meant (let [x 1, y 1] [x y])

17:06 bagelz: I actually meant (for [x 1 y 1] [x y])

17:06 it gives a stack overflow

17:06 do I only have 16MB in my dalvik vm?

17:09 ohpauleez: bagelz: That's an incorrect `for`

17:09 ssutch: if i want to do something like Security.addProvider(new BouncyCastleProvider()); which is a static thing that should be called only once, do i do it in the (ns ) body?

17:10 ohpauleez: see my example above

17:10 ssutch: No you do it in the file like you normally would call it

17:11 ssutch: so just amongst my defns and whatnot

17:11 ohpauleez: correct

17:11 ssutch: cool, thanks

17:11 ohpauleez: np

17:13 ssutch: sweet!

17:13 my first clojure function that does something!

17:16 augustl: those are the best functions

17:17 y3di: do/have you guys used state machines to control your applications' flow?

17:18 ohpauleez: y3di: Yes when the app can be expressed nicely as a state machine

17:19 There are a few libs (for Clojure and for CLJS), but I've never used them, just used maps and keywords for my limited use cases

17:19 y3di: ohpauleez, can you reccommend some learning materials about state machines?

17:22 ohpauleez: y3di: I don't any off the top my head - I could dig through some CS, AI or my SE books

17:22 but google turns up this video: http://video.google.com/videoplay?docid=-5837841629284334824

17:23 y3di: I learned about them a year ago in class, but theoretical cs seemed so far removed from real world coding that i didn't pay much attention to it

17:23 ohpauleez: The wikipedia page actually has some helpful links and references

17:24 ppppaul: y3di pinot does (clojurescript framework)

17:24 ohpauleez: ppppaul: that's been pulled out into its own library

17:24 ppppaul: iknow

17:24 but i don't know the name of the lib

17:25 y3di: ppppaul, didn't you used to hang out in #documentcloud all the time?

17:25 ppppaul: i still do

17:26 also hang out in couchdb and tell the devs to fix all the bugs i find

17:26 sate machines are really useful for web apps

17:26 ohpauleez: y3di: If you have a problem that can be expressed in a series of stable states with events that map to clean transitions between those states, and FSM lib could help

17:26 ppppaul: i do some state machine hacky crap with backbone

17:27 y3di: ppppaul, you should write a blogpost on your methodology

17:27 ohpauleez: I find that I model most of my systems off of event buses (like a C2 architecture) and less off of an FSM

17:27 but I model my Cucumber tests using FSMs

17:27 ppppaul: i do it in JS, so my methodology is discipline :(

17:27 y3di: event buses, never heard of that one before

17:28 ppppaul: i use event buses

17:28 ohpauleez: y3di: pub/sub stuff, same thing

17:28 y3di: oh ok

17:28 ppppaul: global/tiered event stuff

17:28 clojure has a event thing in it modelled off of mailboxes

17:28 it seems very cool

17:28 i forgot the name :(

17:28 ohpauleez: because an FSM is tightly coupled, and not open for extension, whereas C2 avoids those tradeoffs

17:30 ppppaul: i find it tricky to model events, i try to make as loosly coupled components as possible

17:31 i put everything in the event bus and hope i don't have typos or conflicts >_<

17:34 amalloy: $mail dnolen i tried binding a dynamic variable to a fresh logic variable, to make it easily accessible throughout my program (we discussed this and decided it probably ought to work). but from https://gist.github.com/3049645 it looks like that binding just creates a snapshot of the logic variable, which can't be unified with anything anymore

17:34 lazybot: Message saved.

17:38 Jayunit100_: i learned those dynamic var thingies from this https://github.com/alexott/clojure-hadoop :) its pretty cool . he sets the job context for hadoop as a dynamic global so that macros that call map/reduce functions set it beforehand.

17:40 augustl: so, just wrote this http://pastie.org/4201008 Any reusable existing module for that?

17:40 that = a ring middleware for parsing JSON on incoming requests and making sure the response is always JSON

17:41 weavejester: augustl: I have a ring-json-response and Mark has a ring-json-params. I'm planning on combining them into a ring-json library soon, but they can be used separately.

17:41 augustl: weavejester: ah cool, looking them up, thanks

17:42 amalloy: noir has wrap-json in there somewhere; probably every webapp uses one of those or writes its own

17:42 (i'm sure it's part of lib-noir now, so you don't need the whole noir thing)

17:46 augustl: thanks folks :)

17:50 want to use https://github.com/technomancy/s3-wagon-private, are there any docs anywhere for how to actually publish projects to an s3 bucket?

17:51 brehaut: i dont think i have seen that

17:51 whoops wrong window sorry

17:58 * talios points at brehaut and laughs

17:59 augustl: well that was easy, "lein deploy"

17:59 brehaut: i blame a caffeine deficiency

18:01 augustl: hmm it seems I need to have _all_ dependencies on s3 when I use that plugin

18:03 mybuddymichael: Why are Java String methods imported automatically by the REPL, and how can I see what other Java classes are automatically imported?

18:06 Anyone want to take a stab?

18:06 talios: they are?

18:07 mybuddymichael: At least with `leon repl`, yes.

18:07 lein*

18:07 ,(.toUpperCase "michael")

18:07 clojurebot: "MICHAEL"

18:07 mybuddymichael: And here too, apparently.

18:07 brehaut: mybuddymichael: those are sugar over the . special form; the methods themseves are not imported into the NS

18:08 talios: what brehaut said :)

18:08 he types faster

18:08 mybuddymichael: ,(doc .)

18:08 clojurebot: It's greek to me.

18:08 mybuddymichael: Hah.

18:08 brehaut: you'll probably have to look at clojure.org

18:09 mybuddymichael: Yep, because that doesn't make too much sense to me.

18:09 brehaut: http://clojure.org/java_interop#dot

18:09 mybuddymichael: Thanks, guys.

18:09 augustl: are there any tutorials around for s3-wagon-private?

18:09 mybuddymichael: Oh, awesome.

18:09 brehaut: Thanks.

18:09 brehaut: np

18:10 mybuddymichael: its worth reading all the pages on clojure.orgs sidebar

18:11 mybuddymichael: brehaut: Good idea. I'm actually working through Clojure Programming and JoC right now.

18:11 brehaut: those are both good resources

18:11 augustl: seems I need to understand much about how maven works in order to be able to have unpublished internal modules as dependencies of my projects

18:11 mybuddymichael: brehaut: But I have not read much from the official site.

18:12 brehaut: Other than the "features" section.

18:12 gstamp: small problem on OS/X that I was wondering if anyone might be able to help with… whenever a new JVM starts up (for instance when running clojure-jack-in) the focus moves to the new JVM. Is there anyway to stop that? It's very annoying.

18:12 mybuddymichael: brehaut: But I've heard various people mention that the official site is frequently outdated?

18:13 brehaut: its not the most timely resource

18:13 but especially for things like what the reader is doing, what various forms mean etc

18:14 its a good place to start

18:14 mybuddymichael: brehaut: Right on.

18:15 augustl: http://www.pgrs.net/2011/10/30/using-local-jars-with-leiningen/ seems to be a solution, but it means committing the jars into git

18:15 mybuddymichael: brehaut: By the way, I somehow stumbled upon your "brief over of the Clojure web stack" the other day. Helpful stuff.

18:15 brehaut: Thanks for writing it.

18:15 brehaut: thanks

18:16 FWIW in that i say that i prefer moustache; ive changed my mind and now prefer compojure

18:17 mybuddymichael: brehaut: Interesting.

18:18 brehaut: it has some features around route and request destructuring that i didnt know about that are really excellent

18:18 samaaron: MINI BEAST: https://github.com/aaron-santos/mini-beast

18:19 brehaut: samaaron: that looks amazing!

18:19 samaaron: brehaut: it's sick

18:20 it totally works too

18:20 * brehaut says goodbye to a productive morning

18:20 samaaron: haha

18:21 the insanely cool thing is that all the source for it is in Clojure

18:21 every single part

18:21 from the interface, to the MIDI events to the synthesis

18:21 augustl: any suggestions for how to set up a private maven repo for non-free local dependencies in leiningen?

18:22 seems I can just scp files to any HTTP server, would be nice to be able to "lein deploy" though

18:23 brehaut: mybuddymichael: https://github.com/weavejester/compojure/wiki/Destructuring-Syntax btw

18:24 mybuddymichael: brehaut: Sweet. Thanks.

18:37 seancorfield: augustl: have you looked at the s3-wagon stuff for private maven repos based on amazon s3 storage?

18:37 ssutch: what is the & in defn - i can't quite figure it out

18:38 enteL: hello, im using swank-clojure in emacs which works fine, but unlike with common lisp C-M-x to eval a exp isnt sending the output to the repl, anyone know how to get it do that?

18:38 seancorfield: ssutch: it's for variadic argument functions - [& more] will initialize more to a sequence of the arguments

18:38 ssutch: seancorfield thank you!

18:39 seancorfield: so [a b & more] has two required args and more is all the rest

18:39 ssutch: seancorfield excellent that helps a lot, thanks

18:47 augustl: seancorfield: yeah, only annoyance now is that it spits out a gazillion stack traces when lein resolves dependencies

18:48 basically, it seems that leiningen tries the s3 repo first for all deps, and a non-existing dep in my repo (that is, public clojars) yields an insane 404 and a stack trace

18:48 it _works_ but it's pretty annoying

18:50 fil512: lein compile isn't compiling anything--it's silently failing. thoughts?

18:50 it's almost like it doesn't know to look in the src folder...

18:52 Frozenlock: Is there a way to get every fields from a java class?

18:56 cgag: I'm trying to base64 encode something, and i found this: http://commons.apache.org/codec/index.html. How would I actually go about using this, like how would I figure out what needs to be put into leinigen? I see that someone put it on clojars, but I'd like to figure this out.

18:58 brehaut: "Yes, PHP has a better dependency manager than any other languages."

18:58 O_o

18:58 Frozenlock: cgag: This could be helpful https://github.com/clojure/data.codec/

18:59 weavejester: cgag: Ring has a base64 encode and decode based on Apache commons codec

18:59 cgag: https://github.com/ring-clojure/ring/blob/master/ring-core/src/ring/util/codec.clj

18:59 cgag: Line 53 to 61

19:01 madsy: I tried to build the "simple" example from lein-cljsbuild, but it seems that hiccup 1.0.0 is incompatible with lein-ring 0.7.0, according to the error I get and some hits on google.

19:01 Anyone knows it this is an issue with the example at github or if the error is on my end?

19:01 augustl: any tutorials out there for setting up your own nexus and using it from leiningen? Got a nexus up and running, but getting authentication errors when deploying.

19:03 weavejester: madsy: lein-ring 0.7.1 is the latest version, but 0.7.0 shouldn't be incompatible. Do you have a dependency to Ring 1.0.0 on your classpath?

19:03 madsy: Or Compojure 1.0.0

19:03 yonatane: cgag: i had problems with data.codec cutting the last character. Use apache commons codec.

19:04 cgag: weavejester, so i see that's using the commons codec library i was asking about, and i see in your project.clj you just have [commons-codec "1.6"], my question is where did that come from

19:04 i see 1.3 on clojars, but it doesn't have the same group/artifact id

19:04 madsy: weavejester: Yes, I do. Here's the project clj file for the example: https://github.com/emezeske/lein-cljsbuild/blob/master/example-projects/simple/project.clj

19:05 weavejester: cgag: From maven central. Clojars isn't the only default reposity in Leiningen :)

19:05 madsy: Update the Compojure dependency to 1.1.0 and the problem should be resolved.

19:06 madsy: Let me try that :)

19:07 yonatane: weavejester, I didn't include commons-codec in my project.clj, yet it worked anyway. Could it be because I did include ring or noir?

19:07 i just called (org.apache.commons.codec.binary.Base64/decodeBase64 input-bytes) without thinking about it

19:07 weavejester: yonatane: Yes; Ring depends on commons-codec

19:09 cgag: weavejester, i found this on maven central: http://search.maven.org/#artifactdetails%7Corg.apache.directory.studio%7Corg.apache.commons.codec%7C1.6%7Cjar, but wouldn't your leiningen entry then look like '[org.apache.directory.studio/org.apache.commons.codec "1.6"]?

19:09 yonatane: thanks

19:10 weavejester: cgag: Yes, but the library I use is: http://search.maven.org/#browse%7C-1511838660

19:10 cgag: Which is commons-codec/commons-codec

19:10 cgag: Leiningen simplifies that to commons-codec

19:13 cgag: ah guess i missed that one, thanks, i just wanted to be sure i was understanding maven/leiningen conventions

19:19 madsy: weavejester: Hm.. not sure what the cause is now. When I run "lein ring server-headless 3000" it complains about not finding the "app" ring handler in the path. But the code itself compiles fine.

19:19 weavejester: madsy: What do your :ring options in your project.clj file look like?

19:20 madsy: :ring {:handler example.routes/app}, unmodified from the example on github I linked to

19:20 weavejester: And there's a file at src/example/routes.clj ?

19:21 Oh, I see your project. Let me look

19:21 Hm, wait, you have lein-ring as a dev-dependency and not a plugin? That's wrong...

19:21 lein-ring is a plugin

19:21 madsy: The clojure source path is :source-path "src-clj", and the routes.clj lives under ./src-clj/example/routes.clj

19:21 weavejester: It's only dev-dependencies on older versions of Lein that didn't have :plugins

19:22 madsy: Yeah, but I did add lein-ring to my profiles.clj

19:22 nuno: Hello, anyone knows a beginning tutorial for clojure? (no previous programming knowledge)

19:24 weavejester: nuno: Hm, no previous programming knowledge? I'm not sure I've seen a Clojure tutorial that teaches from scratch.

19:24 amalloy: nuno: you could try 4clojure? it's not totally a standalone learn-to-program tool, but it has links to some relevant materials

19:25 nuno: ok, thanks

19:26 yonatane: there's the SICP book not completely converted to clojure: http://sicpinclojure.com/

19:26 ToxicFrog: 4clojure I really didn't like, personally - its "your answer must be a single form we can splice in" model makes some solutions unnecessarily convoluted, and a lot of the problems are just (poorly) recycled Project Euler.

19:26 And it also assumes that you're actually learning Clojure from something else.

19:26 yonatane: you will have to do some of the work yourself, reading about clojure a little to convert the samples.

19:27 seancorfield: with no prior programming background, i'd suggest http://tryclj.com/ since you can type in tutorial and it takes you thru with baby steps

19:27 weavejester: madsy: It looks like it works if the Clojure source directory is just "src", the default… It looks like it might be a bug in lein-ring.

19:27 ToxicFrog: yonatane: where do I file bug reports against sicpinclojure?

19:27 madsy: weavejester: thanks :)

19:28 yonatane: it has a github repository i think

19:28 but i have no idea

19:28 madsy: weavejester: So, uh merge the two src-clj and src-cljs directories to "src" ?

19:29 weavejester: madsy: Well, just change the src-clj to src works. But hm… which version of lein are you using?

19:29 madsy: lein 2.0.0-preview7 with openjdk 6

19:30 weavejester: madsy: Ah, I think the option might have changed in Leiningen.

19:30 madsy: In here: https://github.com/technomancy/leiningen/blob/master/sample.project.clj

19:30 madsy: It's source-paths

19:31 madsy: Followed by a vector, not source-path

19:31 madsy: aha, thanks :)

19:31 weavejester: madsy: :source-paths ["src-clj"] works

19:32 madsy: weavejester: Thanks a lot for your time. Different project using lein and lein 2 without specifying can be quite the headache.

19:33 weavejester: madsy: Yeah, there's a bit of pain switching, but worth it in the long run, I think :)

19:33 madsy: I'll be sure to double check the project-clj map keys next time

19:42 ToxicFrog: Huh. The clojure-clr 1.4.0-3.5 download is broken.

19:59 augustl: if the key :json-body is present in a map, I want to create a new map without :json-body and where :body is the value of :json-body passed through a function. Suggestions? :)

20:01 nicholasf: what's the convention for organising code in namespaces in clojure projects? It's obviously different than the java conventions?

20:01 brehaut: augustl: dissoc + assoc

20:01 augustl: brehaut: I suppose there's no specific function for this :)

20:01 thanks

20:10 amalloy: &(doc clojure.set/rename-keys)

20:10 lazybot: ⇒ "([map kmap]); Returns the map with the keys in kmap renamed to the vals in kmap"

20:10 amalloy: is close, but probably just assoc/dissoc is fine

20:16 ssutch: how would someone do a (with-connection …) sort of form?

20:16 i want to do a (with-keypair) sort of thing

20:23 rlb: ssutch: this might be more than you need, the source for with-open could be a model -- http://clojuredocs.org/clojure_core/clojure.core/with-open#source

20:28 augustl: is there a way to require a file by path and access its defs? Was thinking of using a .clj for setting config vars for my app, would be nice of the config file didn't have to define a namespace etc

20:30 ssutch: load-file?

20:30 augustl: ssutch: experimenting with it now

20:31 how does it work? It seems to "inline" it, so that any defs from the file becomes def in the file where I load-file

20:35 ssutch: augustl no idea

20:35 sorry

20:35 augustl: :)

20:36 enteL: pa/wc

20:36 oops

20:38 ssutch: rlb that doesn't quite do what i want, i am looking for more like with-connection

20:38 which defines a connection and then functions called in the body have the connection available to it

20:39 https://github.com/richhickey/clojure-contrib/blob/e2014cf11b5598a955dd5a1d6e8ce9c06f934ae8/src/main/clojure/clojure/contrib/sql.clj#L32

21:20 so i came up with this, but "keypair" is always unbound: https://gist.github.com/fc74626ef88db412d318

21:23 ah ha! https://gist.github.com/fc74626ef88db412d318 <- that fixed it

21:28 madsy: If a function in Javascript is foo.bar.baz(), can I refer to it as "(baz)" in clojurescript somehow?

21:29 How the namespaces are set up is kind of confusing :)

21:34 augustl: what's a good way to find if a map has keys in it other than keys defined in a vector, like ["foo" "bar"]?

21:36 brehaut: ,(do (use 'clojure.set) (subset? ["foo" "bar"] (keys {"foo" 1 "bar" 2 "baz" 3}))

21:36 clojurebot: #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>

21:36 brehaut: ,(do (use 'clojure.set) (subset? ["foo" "bar"] (keys {"foo" 1 "bar" 2 "baz" 3})))

21:36 clojurebot: false

21:37 brehaut: bah. something like that

21:37 augustl: neat

21:37 technomancy: ,(empty? (apply dissoc {"foo" 1 "bar" 2} ["foo" "bar"]))

21:37 clojurebot: true

21:38 brehaut: technomany wins. his actually answers the question

21:40 xeqi: &(remove #{"foo" "bar"} (keys {"foo" 1 "bar" 2 "baz"3}))

21:40 lazybot: ⇒ ("baz")

21:40 xeqi: just checking

21:43 augustl: technomancy: nice, that way I'll have the list of invalid keys too

21:51 wingy: what does 3N mean?

21:51 and 3M

21:52 brehaut: , (map class [3N 3M])

21:52 clojurebot: (clojure.lang.BigInt java.math.BigDecimal)

21:53 wingy: brehaut: i c

21:54 im not familiar with java, is there a good place to look up the differences between all the sizes of numbers?

21:56 brehaut: ,Long/MAX_VALUE

21:56 clojurebot: 9223372036854775807

21:57 brehaut: Big numbers dont have a max value

21:58 wingy: is there a matrix somewhere for fast lookup?

21:58 brehaut: probably

21:59 but you mostly only want primative longs for speed or bigints for precision

21:59 clojure defaults to performance because thats what you want in most cases

22:00 technomancy: "most" cases

22:00 amalloy: man, when do i ever want performance

22:00 wingy: so i work with longs in clojure, but when do i know i have to switch to big int?

22:00 will i get an error if clojure can't handle that math operation?

22:01 amalloy: rich has robbed me of the joy that comes from optimizing my own code

22:01 &(inc Long/MAX_VALUE)

22:01 lazybot: java.lang.ArithmeticException: integer overflow

22:01 amalloy: &(inc' Long/MAX_VALUE)

22:01 lazybot: ⇒ 9223372036854775808N

22:03 wingy: i c

22:03 so no need to know the others only: java.lang.Long and clojure.lang.BigInt ?

22:05 * nDuff tries to figure out how to interact with 3rd-party, non-GClosure-friendly javascript libraries from the clojurescript browser REPL

22:05 wingy: nDuff: tell us how it goes .. im pretty interested in that topic as well

22:06 amalloy: i can't think why you'd need to know either of those either. just use numbers, and if they happen to be an instance of Long you usually don't care

22:07 * brehaut apologizes to touching a nerve

22:07 brehaut: s/to/for/

22:08 wingy: i guess

22:09 augustl: any recommendations for mongodb libraries? Not sure what kind of abstractions I want, all I know is that I need to write and read to mongodb :)

22:10 in general I know I want a level above raw mongodb driver, I need at least data validation

22:18 xeqi: augustl: reheap.com recently moved to https://github.com/michaelklishin/monger/

22:18 *refheap

22:18 augustl: let's pretend for a second that mongodb wasn't a requirement :) Are there any databases that can be said to be "best" for Clojure (other than Datomic)?

22:19 xeqi: you work on refheap.com? Have you written your own validations and what not on top of monger?

22:19 brehaut: surely a database is best for a particular program rather than a language?

22:19 augustl: brehaut: I suppose when you leave Datomic out of the equation, that's true

22:19 or more true

22:19 brehaut: or do you mean which language has the best library sypport in clojure?

22:19 xeqi: no, but I saw a tweet about it

22:20 augustl: datomic seems to be a pretty good match for Clojure, since it has similar semantics for abstracting away time

22:20 brehaut: I guess :)

22:20 wingy: augustl: why not datomic?

22:21 augustl: wingy: because I can't use it yet, I think, it's an invite only beta isn't it?

22:21 wingy: no

22:21 just download it and play with it .. im was pretty amazed

22:21 perfect fit for clojure

22:21 xeqi: just as another data point, clojars uses sqlite3

22:21 brehaut: augustl: well, SQL has a couple of solid librarys (clojure.something.jdbc, korma (ontop of said)), i understand that mongo is well supported, and the couchdb lib (clutch) is great.

22:22 augustl: wingy: hmm, why not :)

22:22 wingy: augustl: take a look at datomic .. you probably don't want to do mongo et al. afterwards :)

22:23 augustl: wingy: it seems insane to have all the data in memory :)

22:23 wingy: you wont have all the data in the memory (if its big)

22:24 augustl: my storage requirements are dead simple though.. Just a few tables and some primary key lookups :)

22:24 wingy: perfect match :)

22:25 augustl: datomic you mean?

22:25 wingy: as far as i understand it it's using storage services (postgresql, mysql, dynamodb etc) as persistent layer .. you don't need to care about how to communicate with these

22:25 augustl: I'm considering postgres, but since datomic cna store to postgres I can consider datomic a clojure front-end to postgres, heh

22:25 wingy: just like these traditional dbs are using the filesystem to persist information

22:25 its a layer above

22:26 just the diff that you are able to choose what persistent service to use to save the data of datomic for scalability on read

22:27 but i hope they will manage the whole package one day so we don't need to isntall it manually

22:27 ToxicFrog: What would people recommend for parsing a JSON-like (but not actually JSON) language in Clojure?

22:28 wingy: just using the datomic peer lib as a lein dep and ready to go

22:28 augustl: then you wont need 3rd party abstraction layers above dbs like we use to need today for some reason

22:29 its a new way of interacting with data .. keep it local .. it will persist

22:29 brehaut: ToxicFrog: what do you mean?

22:29 augustl: damn google, queries for datomic turns into atomic

22:29 brehaut: ToxicFrog: are you wanting recommendation for parser building libraries, or a specific non-json lib?

22:29 ToxicFrog: brehaut: I have input data in a format that resembles JSON. I need to write a parser for it.

22:29 The former.

22:30 I used LPEG for this in Lua and util.parsing.combinator in Scala; what would you recommend in Clojure?

22:30 augustl: datomic breaks clojars :) https://clojars.org/search?q=datomic I just get an empty page

22:31 brehaut: ToxicFrog: probably not fnparse, because even though its quite nice, its effectively dead; the official version is not 1.3 compatible and hasnt updated in ages (there are 1.3+ forks around though)

22:31 wingy: it's travelling through time and space .. difficult to lock it in

22:31 brehaut: ToxicFrog: there are other parser combinator libraries around but im not familiar enough to talk about them. There is also cgrand's parsley library

22:31 ToxicFrog: which is its own thing

22:32 wingy: augustl: are you new to clj?

22:32 augustl: wingy: a little

22:35 ToxicFrog: parsley looks kind of heavyweight and designed for realtime syntax hilighting and the like

22:35 brehaut: yes

22:35 ToxicFrog: Valid parse tree from any input, high-speed incremental reparsing on mutable buffers

22:36 brehaut: i think that specific use case is for building parsers for editors (eg counter clockwise)

22:36 ToxicFrog: Yeah

22:36 A bit heavier than what I'm after

22:36 augustl: I wonder what most people actually do for data validation, there doesn't seem to be that many libraries for it out there

22:37 xeqi: augustl: do you have an example from somewhere else?

22:38 augustl: xeqi: ActiveRecord in Rails is something I'm already familiar with

22:38 clj-record seems similar, but not sure if the active record pattern is a good fit for clojure.. And it seems poorly documented

22:40 wingy: datomic does cost money no matter how you use it if you have more than 2 "peers" right?

22:40 which basically means two in-memory clients?

22:42 ToxicFrog: Oh man, there's a Clojure port of Parsec! Which is missing.

22:43 And fnparse is dead and parsley is overkill and that seems to be all that's available. :/

22:47 Hmm. There's Parsatron, which has a highly entertaining README and seems to be active

22:49 surial: I have a pretty weird question, not even sure if it is entirely on topic. I'm holding a talk this weekend: Hello, World! in 10 languages. I'd like to use snippets which are simple yet which let me explain some pretty profound concepts. One of the concepts I want to touch on is conc lists. (like conslists, but where both left and right are subtrees; assuming the tree is balanced, it is highly parallelizable).

22:50 The go-to language for this would probably be fortress but I know nothing about it, and can't find much either. I vaguely recall Rich wrote an implementation for clojure. Is that true?

22:50 (if yes, followup questions would be: Any idea for a nice snippet that shows em in action?)

22:53 nDuff: One thing I'm a little unclear about re: the clojurescript REPL -- how do I integrate this into a project running its own server, given as (repl/repl) tries to start its own?

22:57 foxdonut: ,(str \h \i)

22:57 clojurebot: "hi"

23:01 foxdonut: clojurebot: CPOR?

23:01 clojurebot: CPOR is Clojure Programming (O'Reilly): http://www.clojurebook.com

23:02 foxdonut: cool :)

23:04 cmajor7: how to memoize the call to "let", in this case "letrem": refheap.com/paste/3455 ? a bit confused on how will memoize recognize the same input to "do-somm"

23:04 (this is clojurescript calling into the clj server)

23:06 ssutch: my first clojure library! https://gist.github.com/3050902

23:07 string/object signing

23:08 any comments/critique would be greatly appreciated

23:15 * nDuff blinks

23:15 nDuff: java.lang.ClassCastException: ring.util.servlet.proxy$javax.servlet.http.HttpServlet$0 cannot be cast to javax.servlet.http.HttpServlet

23:18 xeqi: ssutch: (.method object) is more common; naming a file fn is asking for confusion; -> and when may be helpful functions

23:18 and why json as the serialization format?

23:19 technomancy: surial: vectors are tree-based behind the scenes, and the new reducers library lets you easily operate on them in parallel

23:19 ssutch: xeqi thanks, i'll use .method and rename fn for sure

23:19 technomancy: surial: there's a good post going into detail on the implementation of them too

23:19 ssutch: xeqi json because it's simple and works and allows you to encode maps and vectors simply

23:19 surial: technomancy: Right. A link would be fantastic. I can't think of a good way to actually show the effect, somehow, in a snippet of code. I'll have to think about it some more.

23:20 cmajor7: is there a way to memoize a "defremote" macro?

23:20 (defremote.. => http://bit.ly/M7evKV)

23:21 xeqi: ssutch: theres ##(doc pr-str) and ##(doc read-string) builtin

23:22 lazybot: (doc pr-str) ⇒ "([& xs]); pr to a string, returning it"

23:22 (doc read-string) ⇒ "([s]); Reads one object from the string s"

23:22 clojurebot: "([& xs]); pr to a string, returning it"

23:22 "([s]); Reads one object from the string s"

23:22 xeqi: hmm, that was unexpected

23:22 ssutch: haha dueling bots

23:23 do i do the (doto …) syntax correctly?

23:23 (you can reload, i just updated it

23:24 the get-csrf-token is not a compete implementation

23:25 xeqi: you can use (.initSign ...) in the doto

23:25 ssutch: remove the space then

23:26 nicholasf: hi guys

23:26 I want to look through a good clojure project to gain an idea of namespacing practices, etc. (preferably a leiningen project)

23:26 I already know about storm - what's another good example?

23:27 * nicholasf looks at compojure

23:31 ssutch: xeqi thanks a bunch

23:31 Frozenlock: Could Clojure run on a raspberry pi?

23:32 nDuff: Frozenlock: It's been done. You'd get better performance with one of the non-Java implementations, though (ie. ClojureScript)

23:32 Frozenlock: Nice!

23:33 And if I want to stay on the jvm...? Need more ram?

23:33 * nDuff doesn't recall -- it's been a while since someone reported on that experiment.

23:33 wingy: augustl: it seems like that

23:33 and if it's OS you dont have to pay at all

23:37 augustl: let's use it together

23:37 you and me!

23:42 cmajor7: is there a way to memoize a macro ?

23:46 wingy: ,(def a 1)

23:46 clojurebot: #<Exception java.lang.Exception: SANBOX DENIED>

23:47 wingy: when running: (def a 1) you get back: #'myapp.core/a

23:47 i know that # has to do with the reader (read-string) but not sure how to relate to it in this case

23:49 xeqi: ,(class #'+)

23:49 clojurebot: clojure.lang.Var

23:50 xeqi: #' gets the var instead of the value, its useful for long running stuff where the var might change

23:50 like a ring handler

23:54 wingy: right

23:56 ToxicFrog: Is the clojurebot meant to say SANBOX instead of SANDBOX?

Logging service provided by n01se.net