#clojure logs

2012-11-11

00:23akrHi! How can I add extra jars in java classpath?
00:23akrI am using leiningen
00:24akrA SO thread mentioned that if I should create a lib/ directory and put my jars there they will be automatically available
00:28akhudekakr: did you try that? I suspect it's correct, though I was under the impression that the lib directory was cleared out when you do a lein clean. Perhaps that's changed with lein2 though.
00:29akhudekI usually just install jars into my local maven repository.
00:29akhudekwith this http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
00:30akrI will try to put them in local m2 repo
03:33Instdoes anyone use haskell here?
03:33Insthow does clojure compare to haskell?
05:07doomlorddoes clojure have a predicate to tell if 2 variables are of the same type; and possibly by extention to tell if a collection is homogeneous
05:10dspp,(instance? clojure.lang.Sequential [])
05:10clojurebottrue
05:10wingyi dont think that was what he wanted
05:11wingyhe wanna look if "a" and "b" is of the same type
05:15dsppyeah, i know
05:15dspp,(instance? clojure.lang.Sequential [] [] [])
05:15clojurebottrue
05:15dspp,(instance? clojure.lang.Sequential [] [] \t)
05:15clojurebottrue
05:15dspp(type [])
05:15dspp,(type [])
05:15clojurebotclojure.lang.PersistentVector
05:16dspp,(every? #(instance? clojure.lang.PersistentVector %) '([] [] [] [] \c))
05:16clojurebotfalse
05:16dspp,(every? #(instance? clojure.lang.PersistentVector %) '([] [] [] [] []))
05:16clojurebottrue
05:16dspptadaaa
05:37pyrhi
05:37pyrIs the process for submitting to sub-projects the same than for clojure ? (i.e: JIRA + contributor agreement ?)
05:38pyrI have a PR for tools.cli
05:55doomlord,(typeof "foo")
05:55clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: typeof in this context, compiling:(NO_SOURCE_PATH:0)>
05:55doomlordok instance and type do it
06:19sunkencityrylehis there some way I can filter for not nil without writing (filter #(not (nil? %)) arr)
06:20shachafWhat don't you like about writing that?
06:20shachaf(comp not nil?) == #(not (nil? %))
06:21edlothiol(remove nil? arr)
06:21edlothiol(filter (complement nil?) arr)
06:21sunkencityrylehah, that's better
06:21shachafThat works.
06:21jakubHnil is interpreted as false so also this would work
06:21jakubH,(filter identity [1 nil 3])
06:21clojurebot(1 3)
06:22jakubHthough there are certainly nicer ways
06:22jakubHremove is nicer
06:22sunkencityrylehremove makes it as simple as it should be
06:23sunkencityrylehthanks
06:30sunkencityrylehI want to find the smallest thing in a list with a function. I can do this with apply (apply min-key #(Math/abs %) [-3 1 4]), but how can I transform the code so that it doesn't bork on an empty list? I could use if of course, but is there some other way?
06:33raeksunkencityryleh: what is the smallest value of the empty list? :)
06:33raeksunkencityryleh: one way could be to add a smallest possible value to the collection
06:35raekanother way could be to make a check for the empty list and return a special value
06:35sunkencityrylehraek: yep, i'm checking for empty list now, because I have to handle it specially anyway I just realized
06:36raek(defn smallest-number [coll] (if-not (seq coll) :no-such-value (apply min-key #(Math/abs %) coll)))
06:36raek(defn smallest-number [coll] (apply min-key #(Math/abs %) (cons 0 coll)))
06:37sunkencityrylehyep, Im going with the if-not thing
06:37raek"(if (empty? coll) ..." looks slightly better...
06:37sunkencityrylehwriting a textile -> hiccup tool so I need to find next closest token
06:37clojurebothiccup is http://tinyurl.com/426og7n
07:05Netfeedhi, i have these two macros: http://pastebin.com/avf6zz4W and i have a "problem", i'd like to define a function (defn select-first [sql & binds] (first (select sql binds))), but it doesn't work, this works though (defmacro select-first [sql & binds] `(first (select ~sql ~@binds))) but it feels overkill, how can i get the first case to work?
07:12hcumberdalecemerick not here ;(
07:14joegalloNetfeed: Since you've defined it as sql & binds, you'd want to (apply select sql binds) so that the binds would be carried through correctly.
07:14joegalloHowever.
07:14joegalloYou can't do that with a macro since apply works on functions, no macros.
07:15Netfeedoh, so i have to stick with the latter?
07:16joegalloIt works, it's not wrong to do it that way. I'd recommend you carry on with writing useful software and not worry about it. ;)
07:16Netfeedheh, ok, thanks
07:16joegalloThat said, it's a fine demonstration of the infectious nature of macros, so maybe make a note of that.
07:18Netfeedbut it's so handy :)
07:19hcumberdaleI can't catch slingshot exceptions, don't know why
07:19hcumberdaletried a lot,... (try+ (catch Exception e _ ...
07:19hcumberdale(try (catch Exception e _
07:19hcumberdale...
07:21hcumberdalehttps://www.refheap.com/paste/6538
07:21hcumberdaleany ideas?
07:28joegalloi think they're throwables, not exceptions?
07:32hcumberdalejoegallo how to catch them?
07:32joegallo(catch Throwable t ...)
07:33joegalloThat said, that would be hugely overkill.
07:33hcumberdaleLets try
07:34joegalloMaybe peek around cemerick's library and see what he does? Catching Throwable is almost certainly not what he intends, and it's certainly not what Steve G intended with slingshot.
07:34joegalloYou're supposed to catch it based on the contents of the thrown map, per the documentation on slingshot.
07:34hcumberdaleYes joegallo! But friend does not behave as expected
07:34hcumberdaleWhen I browse a route like /user and I am not logged in the exception/throwable is fired
07:35hcumberdaleBut it does not get caught
07:35hcumberdaleno ":unauthorized-handler" is called
07:36hcumberdaleit seems it does not care if there is such a handler or not
07:36hcumberdale(catch Throwable e (print "NOT AUTH!"))) << also throws the exception
07:37hcumberdaleIt does not get caught
07:38joegalloI'm guessing your catch expression isn't in the right location, then.
07:48ro_stis there a way to get a seq of all a fn's args from inside the fn body without using :as in the arg vector?
08:17ambrosebs,(instance? clojure.lang.Sequential [] [] [])
08:17clojurebottrue
08:17ambrosebswtf?
08:18ambrosebsWhy doesn't this throw an arity error?
08:19ambrosebsThere's probably some inlining deep in the Compiler for instanceof optimisation.
08:20ambrosebsWell, there is, but not sure if that's the issue.
08:21ambrosebsSeems like a known issue http://stackoverflow.com/questions/13176400/clojure-instance-single-argument
08:24joegalloappears to me that instance? is defined in terms of the relatively primitive fn at line 42 of core.clj, rather than the more featureful fn defined at line 3989
08:24joegalloso yeah, no arity checking
08:24joegalloat least, that's my quick read of it
08:28hcumberdalemhh
08:29hcumberdale(defroutes ring-app
08:29hcumberdale ;; requires user role
08:29hcumberdale (compojure/context "/user" request
08:29hcumberdale (try (friend/wrap-authorize user-routes #{::user})
08:29hcumberdale (catch Throwable e (print "NOT AUTH!"))))
08:29hcumberdaleThe exception should be thrown by wrap-authorize?
08:29hcumberdaleright
08:30hcumberdale?!
08:30hcumberdalehttps://github.com/cemerick/friend/blob/master/src/cemerick/friend.clj#L302
08:30joegalloor does wrap authorize return a fn that will later do the checking?
08:30joegallothat appears to be what it does, based on what you linked me to
08:30joegallosooo... yeah, wrong spot.
08:31hcumberdalewhy wrong spot?
08:31hcumberdaleit calls throw-unauthorized
08:31joegallono it doesn't.
08:31joegalloit returns a fn that will do so later.
08:31joegallowell outside of the context of your try/catch.
08:31hcumberdalewhere exactly does that happen
08:31ambrosebsjoegallo: I think the stackoverflow answer has the right idea. The compiler emits an InstanceOfExpr without checking the number of arguments to instance?
08:31joegalloline 299
08:32joegalloa defn that return a fn
08:32hcumberdaleyeah, i've seen that. But where is it evaluated?
08:32joegallohcumberdale: i'm sure i don't know, somewhere else in the bowels or your app
08:32joegallos/or/of/
08:33joegalloambrosebs: sure, sounds reasonable.
08:34hcumberdalejoegallo, but then it seems like a bug in friend
08:34joegallono, that's how ring works
08:35hcumberdalebut why is default-unauthorized-handler not called
08:35hcumberdalesince it is build to catch unauthorized requests
08:36hcumberdalehttps://github.com/cemerick/friend/blob/master/src/cemerick/friend.clj#L196
08:36hcumberdaleWhy must a user be auth'ed to call the unauthorized-handler ?
08:37hcumberdaleAlso redirect-unauthorized does not work
08:37hcumberdaleThe exception bubbles up, no handling by friend as it is expected
08:37flying_rhinohello guys
08:37hcumberdalehi flying_rhino ;)
08:38joegallohcumberdale: i think you need to also be calling authenticate somewhere -- which i'm not sure you are. you keep pointing to parts of it, but it doesn't appear that it's ever called as a result of wrap-authorize (i think).
08:39joegalloit seems like your pretty lost here, and i've never read or worked with friend before, so my suggestion is that you look for some existing code elsewhere that uses friend that you can use as an example
08:39hcumberdaleI'll refheap the whole program, sek
08:40joegalloor that you wait for cemerick to come on and see if he can give you a hand
08:40hcumberdalehttps://www.refheap.com/paste/6540
08:40hcumberdalejoegallo, i searched for existing applications. Can't find any
08:41hcumberdalethat work with compojure as in the examples and with wrap-auth...
08:41joegalloi think wrap-authorize is only for when you've already used authenticate as earlier middleware
08:41joegallowhich you haven't
08:41hcumberdalehttps://www.refheap.com/paste/6540#L-42
08:41joegallobut again, this is my very first read of this library, which i've never used, so yeah...
08:41hcumberdaleI've
08:42joegallookay, missed that. anyway, best of luck, but i've got nothing.
08:42hcumberdale./ping cemerick << yesterday he said bbl. Haven't seen him since then
08:44flying_rhinoanyone ever tried to implement immutable entity systems in clojure?
08:44hcumberdaleflying_rhino like datomic ?
08:47flying_rhinoI don't know what is datomic, but Component Entity System is, in short, extremely data driven method of developing games. You have bunch of structs (components) that you manipulate using Systems. It looks a little like relational database and separates data from code.
08:48flying_rhinoIt is usually done in mutable languages
08:48flying_rhino*imperative languages
08:49flying_rhinothis link explains the whole thing http://t-machine.org/index.php/2007/09/03/entity-systems-are-the-future-of-mmog-development-part-1/
08:49hcumberdaleIs there such an existing sytem for LISP?
08:50flying_rhinoit is popular for mmorpgs, but can be used for other games as well.
08:50flying_rhinodunno
08:50flying_rhinoI could implement one but I am asking around first.
08:51flying_rhinoon the face of it it does look like immutability could help a lot but I am far from experienced functional programmer.
08:53hcumberdalejoegallo, got it working
08:53hcumberdale;)
08:53hcumberdalewhat is a mmorpg for example?ß
08:53hcumberdalewow?
08:53joegallohcumberdale: what was it?
08:54joegalloalso, nice work!
08:54hcumberdalejoegallo, i am not sure ;(
08:54joegalloargh
08:54hcumberdaledone lein2 clean and lein2 run
08:54hcumberdaleand the code I posted runs 1:1
08:54hcumberdalecrazy ;(
08:55joegalloi feel totally unsatisfied :)
08:57hcumberdalehad the same problems before with another lein2 project
08:58hcumberdalebut it was not the auth that lagged
08:58joegallooh, maybe you're getting killed by aot?
08:58joegalloand that classes you're aoting are stale and out of date wrt the clj files you're editing?
08:59hcumberdalehttp://stackoverflow.com/questions/8291910/noclassdeffounderror-with-clojure-tools-logging
08:59hcumberdaleHad the same issue, lein clean, and then lein deps, and then lein compile fixed it
09:00hcumberdaleThis whole AOT thing sucks
09:00winkclassic: writing (> 0 x) instead of (> x 0) and then reading up on the clojure type system for 30min, questioning sanity
09:01callenhcumberdale: remember, you *could* be wrangling with cabal.
09:01wingydatomic supports couchbase!
09:01callenwingy: I won't use it until it supports kyoto cabinet.
09:02wingysounds exotic
09:02callenthats_the_joke.jpg
09:03wingyi just know one thing
09:03wingyno aws!
09:03hcumberdaleWhy wingy?
09:03hcumberdaleBecause of the big aws fallout ;)
09:04callenyou say that as if there was only one.
09:04hcumberdaleI've seen only one callen
09:04callenAWS US-East has gone down many times.
09:04wingybecause they do everything
09:04hcumberdalemy blog was down, hosted on heroku
09:04wingybut nothing innovative
09:04callenThe real trick is to just let US-East continue to vanguard the scalability issues
09:04callenand just use US-West or something other AZ
09:05hcumberdaleBut it's not possible to choose with heroku
09:05hcumberdale+ mongohq, they are also using aws
09:05callenhcumberdale: your choice of master for your sharecropping isn't my problem.
09:05ferdIs there something similar to "tree-seq" but parallelizable? (therefore, non-lazy)?
09:05ferd...that is, I want it to call my "children" function in parallel to keep expanding the tree concurrently
09:05callenI'm just making it explicit that it isn't the entirety of AWS that goes down, it's usually just US-East which is a detail that can be exploited.
09:06hcumberdalecallen, thx for the info
09:06hcumberdaleUS-West = same price as US-East ?
09:07callenhcumberdale: mostly yes, if you mean Oregon
09:08callenNorthern California is slightly more expensive.
09:08hcumberdaleHave you production applications running on aws?
09:08callenIf you're using AWS, caring about expense is a bit like caring about getting wet while swimming across the channel.
09:08hcumberdale;)
09:08callenhcumberdale: I've built more than one production system on AWS, although I try to use it as little as possible these days.
09:09hcumberdalecallen: what's the best alternative?
09:09callenthat's like asking what's the best car.
09:09callenDepends entirely on what you're doing. There are still some use-cases that AWS is superior at.
09:10callenfor my part, I favor a mix of VPSs and renting dedicated hardware.
09:11hcumberdaleyes callen, I think that's a good idea and you might reach less outtakes
09:11hcumberdaleBut you have to worry about to OS/Updates/Maintenance
09:11hcumberdaleEvil bad hackers ;)
09:11callenwhat you just said makes no sense.
09:11callennothing about that changes when you're using AWS.
09:12callenyou do understand that EC2 is just a VPS, right?
09:12callenevil bad hackers. *snorts*
09:12hcumberdaleBut when you use heroku and services over EC2, they care for you
09:13cmnbut that's something different; you were asking about AWS, not heroku
09:13cmnIIRC engineyard provide a similar service and are based on rackspace
09:13hcumberdaleHeroku is based on AWS so server failure effects both
09:14cmnyes
09:14cmnbut that wasn't the conversation
09:14callenthat also means that if AWS goes down, you're fucked anyway, heroku or no.
09:14hcumberdale;) yes.
09:14hcumberdalehttp://www.engineyard.com/ << no clojure
09:14callenit was with extreme pleasure that I was one of the few startup people I knew that didn't experience any downtime during the AWS blip.
09:15cmnheroku are starting to roll out some servers on the west coast
09:15callenhcumberdale: ...and? Nobody's trying to sell you on anything in particular.
09:15hcumberdaleown servers cmn?
09:15cmnno
09:15callenheroku isn't going to stop using EC2.
09:15callenTheir devops infrastructure is heavily tied into it.
09:15callenthey're stuck with Amazon.
09:16callenincidentally this is why I refused to use AMIs when I used AWS more heavily. It meant that switching away was just a matter of repointing scripts, instead of having to rebuild the automation stack.
09:18hcumberdalemhh..
09:18hcumberdaleIs there any real competitor to EC2/AWS?
09:18callenbits and pieces.
09:19callenRackspace, Azure in the large. In the small, Linode et al.
09:19cmnbut it all depends on what you need
09:19callenThere are plenty of companies that offer one-off things like MongoHQ that are analogous to AWS RDS.
09:19hcumberdaleRackspace cloud is really new, isn't it?
09:20cmnand what if it isn't?
09:20cmnAWS isn't new
09:20callenhcumberdale: do you have something in particular you are aiming for?
09:22hcumberdalecallen, just want to hear about your experience with the solutions/providers. I've discovered the problems with heroku/mongohq and AWS a few weeks ago
09:22callenyour needs seem pretty low level. You could truck along with "whatever" for hosting a blog.
09:22Licenserhcumberdale joyent
09:22winkI've been bitten by AWS performance once, badly. Still a bit cautious to see the positive aspecs :(
09:25hcumberdaleYes the requierements for a blog are really low-level. I'm interested in big applications running on EC2
09:25hcumberdaleSeems to most hosting companies tend to sell vservers now as 'cloud'
09:25Licensershould take a look http://joyent.com/ :) they are pretty awesome
09:25callenI've built big clusters, but I need something specific to really be able to tell you what's up and down.
09:26callenI'm not going to exposit aimlessly in IRC about what I do and do not like about AWS.
09:28hcumberdaleNever heard about joyent, website looks interesting. Licenser, have you any clojure applications running there?
09:29Licenserhcumberdale nope but I am using the underlying hypervisor for my stuff - where I also run java applications (just no clojure)
09:29Licenserbut java works great and so should clojure then
09:35jonasenI'm trying to release a new version of Kibit but I seem to have messed up. Could someone try the new [lein-kibit "0.0.5"] and see if it works?
09:38winkjonasen: $ lein kibit Check :dependencies and :repositories for typos. It's possible the specified jar is not in any repository. If so, see "Free-floating Jars" under http://j.mp/repeatability Could not resolve dependencies
09:39wink$ cat ~/.lein/profiles.clj
09:39wink{:user {:plugins [[lein-kibit "0.0.5"]]}}
09:55pyrwouldn't it be cool to have a ns construct that would let you pull in a standard config (require's, use's, import's etc)
10:02joegallopyr: http://code.google.com/p/clj-nstools/
10:03pyrah, nice
10:04jonasenwink: I think I got it working now, could you try [lein-kibit "0.0.7"] instead?
10:05winkjonasen: yes, and the results hurt my feelings! :)
10:05winkgood reminder to use it on this project
10:05jonasenwink: Thanks alot!
10:07pyrjoegallo: for that type of functionality I would be hesitant to bring in a new dep
10:08joegallothen i guess you don't get that functionality. :(
10:08pyryup
10:12_ulises,(doc list*)
10:12clojurebot"([args] [a args] [a b args] [a b c args] [a b c d & ...]); Creates a new list containing the items prepended to the rest, the last of which will be treated as a sequence."
10:12_ulises,(doc list)
10:12clojurebot"([& items]); Creates a new list containing the items."
10:13_ulises,(list? (list* (set '(a b c))))
10:13clojurebotfalse
10:13_uliseshum
10:13_ulises,(list? (list (set '(a b c))))
10:13clojurebottrue
10:13_ulises,(list (set '(a b c)))
10:13clojurebot(#{a c b})
10:13_ulises(set '(a b c))
10:14_ulises,(set '(a b c))
10:14clojurebot#{a c b}
10:14_ulises,(list* (set '(a b c)))
10:14clojurebot(a c b)
10:14_ulisessorry for spam
10:14raekthe name for list* is a bit misleading. it produces an ISeq, not an IPersistentList
10:15_ulisesoh!
10:15_ulisesraek: thanks!
10:15raek(list* x y z some-seq) is like (cons x (cons y (cons z some-seq)))
11:31si14hi, guys. Is there any example of Java usage from Leiningen repl?
11:32Licensersi14 I think it's the same as in all clojure
11:32Licensera simple example would be (System/exit 0)
11:33si14Licenser: I don't understand the thing with Classpath and such.
11:33Licenserah okay, that kind of stuff, to be honest - I've no clue :(
11:34ChongLisi14: what don't you get about classpath?
11:34si14ok, I've added project.clj; added java-source-paths to it; I have foobar.java in that path and when I do something like (import Foobar) I get "no such file"
11:35ChongLiI think you need to compile your java first
11:35ChongLiinto a jar
11:40_ulisessi14: not just that, you have to import packagename.othername.ClassName
11:42si14oh, I've managed to make it work! :) updated Lein and lein javac did the work.
11:43si14_ulises: well, what if have just a simple class in my java-source-paths (no packages there)? it seems to work as (import 'TOTP) and (TOTP/main (into-array String [])) , am I missing something?
11:44_ulisessi14: that should work too, but remember that the default package in Java is discouraged
11:44augustlis it possible to create a map where the values are eval-ed when read?
11:45si14_ulises: so I should create some directory structure, rename my class and import it under that name?
11:45augustlperhaps something that implements IPersistentMap
11:46_ulisessi14: I'm not saying you *should* do anything :)
11:46_ulisessi14: just regurgitating what I know and have read
11:47_ulisesaugustl: you could have closures as values? and then just call them as fns?
11:47_ulises,((:foo {:foo (fn [] "foo")}))
11:47si14_ulises: you definitely have more knowledge than me in this field, so your advices counts as something I should do :)
11:47clojurebot"foo"
11:48_ulisessi14: well, the default package name is discouraged in java (standard practise) but this doesn't mean you shouldn't do it; I'd probably advise you to organise your code using packages and namespaces mainly because you'll be reading that code later on and will thank your former-self
11:50si14_ulises: got it, thanks :)
11:52_ulisessi14: sure
12:06konr_trabWhat's that function that is like comp but from left to right?
12:07jackdangerkonr_trab: are you looking for `partial`?
12:07konr_trabjackdanger: hmm, I think not...
12:10_uliseskonr_trab: what are you trying to achieve?
12:11konr_trab_ulises: I'm just writing a composite function to be used in a map; it's more convenient to append its posterior functions to the right
12:12augustl_ulises: ended up using delays, based on your suggestion, thanks :)
12:13_ulisesaugustl: cool!
12:13_uliseskonr_trab: so you'd need to reverse the flow to use comp?
12:13augustl_ulises: I'll hopefully get to present this to the unconference, if you're going to the conj ;)
12:13_ulisesaugustl: neat! I can't make it this year though :(
12:14augustlaww
12:14konr_trab_ulises: yes, and I thought there was already a function for it
12:14_uliseskonr_trab: not sure there is unfortunately
12:46erwagasoreI am doing koans and I am stuck on multimethod, need help to understand?
12:47erwagasoreAnybody!
12:47tomojanyone?
12:47clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
12:48gauravagcould someone help me in understanding this >> "(iterate f[x] :foo)"
12:48erwagasoreHere is the function
12:49erwagasore(defmulti diet (fn [x] (:eater x)))
12:49erwagasore(defmethod diet :herbivore [a] (str "$1 eats veggies." a))
12:49erwagasore(defmethod diet :carnivore [a] (str "$1 eats animals." a))
12:49erwagasore(defmethod diet :default [a] (str "I don't know what $1 eats." a))
12:49erwagasoreand this is how I am calling it (diet {:species "lion" :name "Simba" :eater :carnivore})
12:50erwagasorewhat would be the enswer?
12:50gauravagerwagasore: isn't this from clojure koan
12:50gauravags*
12:50gauravagam doing that just now..
12:50erwagasoregauravag yes it is!
12:50erwagasoreGreat, can u share?
12:51tomojthe dispatch value is (:eater {:species "lion" :name "Simba" :eater :carnivore})
12:51erwagasoreJust want to understand. Everything I am putting is not passing the test.
12:51tomoj:carnivore
12:52tomojbut str doesn't do interpolation like that
12:52gauravag (diet {:species "lion" :name "Simba" :age 1 :eater :carnivore})
12:52gauravag"Simba eats animals."
12:52tomojalso, the argument to the methods, a, is the map
12:53erwagasoregauravag does it work?
12:53tomojyou need to get the :name out
12:53gauravagit worked for me..
12:53gauravagI am on
12:53gauravag**ex 14 by the way
12:54tomojuse str like this: (str "foo's value is:" foo)
12:54erwagasoreNo it is the example 09
12:54tomojno $ interpolation
12:54gauravag(defmethod diet :carnivore [a] (str (get a :name) " eats animals."))
12:55erwagasoreThat is not what I have
12:55erwagasore(str "$1 eats animals.")
12:56tomojyou gave him the answer :(
12:56erwagasoreWhat do u mean?
12:57erwagasoreOh!
12:57erwagasoreHahahahahaha!
12:57tomojnote (= (:name a) (get a :name))
12:58gauravagtomoj: oops..
12:58tomojwell, only part of the answer
13:00gauravagbut I think this is the part where the power of defining dsl's is most prominent in clojure
13:09rodnaph_with enlive is it possible to do multiple transformations in a single match? ie. [:div.foo] [(content "this) (set-attr "that")] (but that doesn't work obv)
13:11tomojgauravag: (iterate f[x] :foo) looks like an error
13:12gauravagtomoj: what would be the correct way?
13:12tomojdunno what it's trying to do
13:12gauravag(take 100 (iterate (fn [x] :foo) :foo))
13:12tomojoh
13:13raekrodnaph_: well, you could repeat the selector like this: [:div.foo] (content "this) [:div.foo] (set-attr "that")
13:13gauravagwhich prints a set of 100 :foo
13:13tomoji.e. (repeat 100 :foo)
13:13ebaxtrodnaph_: You can use the do-> macro
13:13gauravagyup.. but I wanted to try it using iterate..
13:13raekif the transformation functions always return a single new node maybe you can use 'comp': [:div.foo] (comp (content "this") (set-attr "that"))
13:14gauravagbut the redundant mention of :foo din't seem right to me..
13:14tomoj(fn [x] :foo) is also (constantly :foo)
13:14tomojwell (iterate identity :foo) works too
13:15gauravagtomoj: awesome.. so what is identity?
13:15tomoj(fn [x] x)
13:15gauravagin that context am I passing identity procedure with a parameter :foo inside iterate?
13:16tomojyeah
13:16tomoj(iterate identity :foo) is a seq (:foo (identity :foo) (identity (identity :foo)) ...)
13:16rodnaph_ebaxt: will try that thanks.
13:17gauravagtomoj: cool.. many thanks.. :)
13:36dissipatehi
13:39gauravagwhat is the clojure way of solving this?
13:39gauravag (= "Rich Hickey aka The Clojurer aka Go Time aka Macro Killah"
13:39gauravag (let [[first-name last-name & aliases]
13:39gauravag (list "Rich" "Hickey" "The Clojurer" "Go Time" "Macro Killah")]
13:39gauravag (str first-name " " last-name (for [alias aliases] (" aka " alias)))))
13:46erwagasore(iterate __ :foo)
13:51ivanhow do I nrepl-load-current-buffer when I have a new nREPL connection?
13:51ivanit always says "Namespace not found" until I close and reopen the .clj file
13:56SgeoHow do I make a .DLL visible to my Leiningen project?
13:59ivanhm, why is it that when I do (ns otherns) and then (ns user) in nREPL, I lose everything I've added to user?
14:00ivanoh, I think it's just spitting old exceptions at me now
14:00ivanoh, duh. never mind.
14:01ivandebugging lack of pst by calling (pst)...
14:05ivanin other news I've been so braindamaged by Python that I thought I'd be able to do (user/pst) from another namespace after (use)ing it in user
14:25sjlIs slurp supposed to add a trailing newline even if the file doesn't contain one, or is that a bug?
14:27AimHereIt doesn't do it for me
14:27AimHereClojure 1.4
14:28sjlhm
14:28sjlmaybe Vim is messing with me then
14:43Sgeohttp://clojuredocs.org/clojure_core/clojure.core/locking
14:43SgeoWhat is the "monitor" of a thing, and how do I know if an object has one?
14:45mudgeanybody here know how to use fs.compression/zip ?
14:46mudgeor how do I zip compress files using clojure? is there an existing clojure library for this?
15:04augustlmudge: I'd just use a java lib for that
15:08joroI've repeatedly end up constructing maps like ... (if (is-good e) (assoc m :e e) m). Is there better way to do this?
15:08callenjoro: well you could make a predicate assoc function that passes a predicate checker and automatically returns the assoc'd map if the predicate returns true
15:09callenjoro: in a less abstract fashion, if it's a common pattern for specific data, you can just abstract the concrete form of this.
15:09callenjoro: some specifics about how frequent this is, how much the patterns have in common, etc would be helpful.
15:13joroI'm transforming stuff in mongodb on a wire. There is lot of stuff that resembles like this: (if (> new-comments 0) (assoc bare-ex :newComments new-comments) bare-ex)))
15:14joroI was wondering that if there is a binding form (like map destructuring) that would make this easier
15:20tomoj(test-> bare-ex (> new-comments 0) (assoc :newComments new-comments))
15:20tomojin 1.5.0-beta1
15:23callenjoro: are you looking for something like what tomoj demonstrated, or something else? please be specific.
15:26bbloomtest-> is extremely useful!
15:27bbloomsaw cond-> in codeq, which i think is basically the same thing. said to myself: "why the hell didn't i think of that?" :-)
15:29jorowhat is the third argument of test->?
15:34sunkencityrylehmmmm… multimethods. cleaning up some code with multi methods. this is good stuff.
15:35callensunkencityryleh: example? :D
15:35callensunkencityryleh: also, love the name.
15:36SgeoSuppose I'm writing an event-based library
15:36SgeoWould it make sense to expose to event handlers a *stop-handling* function that they can call to remove itself from the list of event handlers?
15:37sunkencityrylehcallen: I had an array of hashes and a fn as one of the keys, now I have the methods separate and just switch on a key. I send in the same hash but I have added some match data to it. This is beginning to look like pythons OO.
15:41callenSgeo: I hate to punt the ball like this, but this is something you'd really want to look into by examining Lamina.
15:42callenmy initial instinct is "no" unless a specific use-case cries out for it.
15:43SgeoPretty sure that some use cases cry out for a nice way to have an event handler remove itself, but not sure if that's the best way to do it
15:43ivanSgeo: well, what else could you do?
15:44SgeoI could pass the function into the handler like an argument, or I could just have the function I call to set up the handler return the function to stop handling, and whenever I want a handler to remove itself, use promises to make it accessible to the handler
15:45SgeoLast one's inconvenient to use raw but could be a building block'
15:45raekSgeo: I think so. some network protocols have commands that form temporary "dialogs". in those cases you might want to use a state machine that listens for certain commands, but only for a limited lifetime
15:46raekone example is the IRC login process
15:46SgeoI'm thinking more ... IRC-bot-like thing except for a particular 3d world
15:47ivanthis could become a mess with code reloading
15:47SgeoAh, hmm
15:47raekI like how IObservable does it in .net: when you subscribe you get an instance of IDisposable back. when you call dispose on it, it deregisters the callback
15:48raekno need to carry around ids/keys like in Clojure's add-watch/remove-watch
15:49SgeoWhat sees the IDisposable?
15:50raekthe code that registers the callback
15:50SgeoAh
15:50SgeoWell, the question is how to make the callback itself be able to deregister itself
15:50SgeoIt's easy enough to return to the registrating code a function that will deregister the callback
15:50raekah
15:51raekin Haskell, you could let the callback close on the result of the subscribe operation :)
15:52raekbut in Clojure variable bindings have to be causal...
15:54raekSgeo: what is your library like compared to Lamina, Cljque, and RX in .Net?
15:55SgeoHaven't looked at Cljque
15:56SgeoThere's an event for when someone says something, an event for when someone joins, someone leaves, etc. etc.
15:56SgeoSomeone clicks something
15:58raekI wonder if anyone has made a Clojure library for Functional Reactive Programming...
15:59mudgehow do a load a file from disk into a lazy byte array?
16:00raekmudge: Clojure (and Java) does not have any type for lazy byte arrays. you could make a lazy sequence of bytes, though...
16:01mudgeraek: thanks
16:01callenmudge: why does it need to be lazy?
16:01mudgecallen: well I need to read a file into a byte array --- if the file is large then I need to load the entire file into memory, but if it is lazy then I don't
16:02mudgecallen: that's my theory anyway
16:02SgeoEven Haskell discourages lazy I/O
16:02mudgeSgeo: why?
16:03raekmudge: how will you process the bytes?
16:03raekmudge: anyway, if you need a lazy byte seq, you can do it like this: https://gist.github.com/661631
16:03Sgeomudge, because the time of closing the file might be unknown, what if you close it too early, or never close it, etc.'
16:03mudgereak: I'm making one zip file of various files.
16:03raekpass it an input stream, for example one created by clojure.java.io/input-stream
16:04raekin Clojure you can wrap the whole code that will potentially touch the seq in a with-open form
16:05raekthe problem lies in the "that will potentially touch the seq" of course...
16:08raekSgeo: does Haskell discourage lazy I/O in general or only "lazy resource management"?
16:08Sgeoraek, hmm, not sure
16:09mudgewhat's the best way to read a binary file into a byte array?
16:10raekmudge: use the methods of the java.io.InputStream class
16:10mudgeRaek: okay, thanks
16:13raekmudge: you can use the gist I linked previously as an example. just replace the (lazy-cat ...) part with whatever you need to do with the bytes
16:13tomoj(let [out (java.io.ByteArrayOutputStream.)] (io/copy in out) (.toByteArray out))
16:13tomoj??
16:13lazybottomoj: Definitely not.
16:14augustlany suggestions for a in-process database that stores to a specified path in a local file system?
16:14augustldatomic free fits that description, right?
16:14mudgeraek: can you send me the URL again?
16:14tomojdatomic free is not exactly in-process
16:14augustlnew to the JVM so not sure what's available
16:14tomojthe free transactor is a separate process
16:14raekmudge: sure: https://gist.github.com/661631
16:14augustltomoj: hmm, I thought the transactor local storage was in-process
16:14augustlah I see
16:15tomojin process you only get memory 'storage'
16:15raektomoj's version does the same thing, but reads the whole file into one big array
16:15raekmudge: are you using the java classes for the zipping?
16:15augustltomoj: I see
16:16mudgeraek: I am via this library: https://github.com/Raynes/fs/blob/master/src/fs/compression.clj
16:16tomojtheoretically you should be able to run the free transactor in the same process, I think
16:16tomojbut it is not supported yet
16:16mudgeraek: i'm using the file system clojure library
16:16tomojyou don't get a pom for the free transactor
16:17mudgereak: for zipping I have to get the bytes of each file and associate it with a file name
16:17augustltomoj: hmm I see
16:17augustltomoj: I'll be shipping uberjars/uberwars so a pom isn't that important actually
16:17raekmudge: wait, there's a better example in the clojure source: https://github.com/clojure/clojure/blob/master/src/clj/clojure/java/io.clj#L296
16:17augustlit's a standalone application that you just start with java -jar ...
16:17SomelauwI just installed leiningen through package manager, but what does it need a lot of dependencies?
16:18mudgethanks raek
16:18Somelauwalso it needs clojure as a dependency, whereas its goal is to install leiningen
16:18tomojaugustl: well, you could try adding all the jars in the transactor lib/ (manually - no pom), and then you'd have to figure out how to start it
16:18raekmudge: using the java api (which fs uses) you can do this by looping and reading/writing fixed sized arrays
16:18augustltomoj: I'll investigate, thanks
16:19mudgeraek: so that the entire file doesn't have to be read into memory?
16:19mudgeat the same time
16:19raekmudge: yes
16:19mudgeraek: that sounds good
16:20tomojlooks like there is a transactor pom hidden in datomic pro
16:20raekmudge: I'm not sure if/how 'fs' can do this. Raynes (the author) is frequently in this channel, so maybe you can ask him directly
16:21mudgeraek: okay, thanks
16:21mudgeRaynes: you around?
16:21raekmudge: you can probably find an example that does what you want written in Java somewhere and then translate it into Clojure
16:22mudgeraek: that is a good idea, I'll search for that now
16:23raekmudge: the approach would basically look like this:
16:23amalloyman, java.util.zip. what a mess
16:23raekyeah...
16:24raekopen output zip file. for each file: open input stream from file, open output stream to zip entry, copy data in chunks (clojure.java.io/copy does this)
16:24mudgeraek: amalloy: seems like the best zip function would be a function that takes a filename and a directory name and zips everything in the directory to the file name
16:24amalloymudge: why bother if you want something that generic? just shell out to tar+gzip, or zip, or whatever
16:25amalloyzipping directories is a solved problem :P
16:25raekmudge: if you can rely on certain executables being available where you run the progeam, perhaps it's simpler to just use an external program
16:25amalloy(but i bet you apache commons io has a decent java solution)
16:25mudgeraek, amalloy, yea sounds good
16:27mudgeamalloy: is apache commons in the maven website repository?
16:27mudgesorry if I sound silly, i'm just getting into all this
16:27amalloycertainly
16:28amalloymost reasonable java libs are, and especially those run by the people who run maven
16:31raekmudge: an example of how to use the zip classes (in Java): https://gist.github.com/4056327
16:31SomelauwWhen doing % lein run
16:31raekit only writes a single file, but I think you get the idea
16:31Somelauw"No :main namespace specified in project.clj" is what I get.
16:32mudgeraek: i get the idea, thanks
16:34Somelauwnvm, I think I got it to work
16:35SomelauwWell I added to project.clj ":main myproject.core", so that should work?
16:36SomelauwBut I get Exception in thread "main" java.lang.RuntimeException: java.lang.ClassNotFoundException: myproject.core
16:38Somelauwfixed it
16:38raekSomelauw: and you have a file called src/myproject/core.clj ?
16:39callenis anyone here familiar with the template inheritance structure Refheap uses with Stencil?
16:39callenI'm finding it a little difficult to track everything that's going on.
16:39Somelauwraek: yes, i only forgot to create a -main method in that file
16:39Somelauwor actually I named it main- instead
16:40sunkencityrylehJust finished a little clojure project for converting textile to hiccup. It *seems* to work, but I'll have to test it out for real.
16:40callensunkencityryleh: write a fuzzer.
16:40sunkencityrylehI'd love to get some feedback on what I could do better in the code
16:40sunkencityrylehhttps://github.com/sunkencity/dr-textile-and-mr-hiccup/blob/master/src/dr_textile_and_mr_hiccup/core.clj
16:40callensunkencityryleh: oh that explains the multimethods. But seriously, write a fuzzer that generates valid textfile.
16:41callentextile*
16:41sunkencityrylehwhat's a fuzzier?
16:41callensunkencityryleh: http://en.wikipedia.org/wiki/Fuzz_testing
16:41callenI use it all the time in my unit-testing. It bares a measure of resemblance to how QuickCheck works, although it's a lot more specific.
16:42sunkencityrylehah, like the test quickcheck
16:42callen'ish.
16:51augustlis there a public version of this around? https://github.com/ring-clojure/ring/blob/860fbdd825b4fbe83ec67dad4009ce7bc0b0117a/ring-jetty-adapter/src/ring/adapter/jetty.clj#L12
16:51augustlwant to create a servlet for my ring handler, without actually starting a server in the same step
17:00dissipatewhat's the quickest and easiest way to get started learning clojure?
17:02jorodissipate: I bought Emerick's "P in C", and started writing a mid-sized clojure program.
17:03dissipatejoro, link to book?
17:04jorothere might be other good books also around, I chose that by reviews and pragmatism
17:04Bronsadissipate: http://www.clojurebook.com/
17:05dissipateBronsa, are you sure that isn't a reference book?
17:05Bronsayeah.
17:06jorothe most difficulties I've had in error handling, debuggin, and lately, debugging stm stuff.
17:07joromaybe tooling is an issue, if you are not used to emacs?
17:07callendissipate: it's not a reference book.
17:08callenThe main issue I've been having with Clojure, and yeah, I know this is silly...HTML templating
17:08callenStencil, Enlive, and Hiccup all make me deeply unhappy.
17:10dissipateclojure doesn't seem to have many web frameworks available for it. that could be a bonus actually. :D
17:10joroI'm quite happy with ring, compojure, and pure REST
17:11Raynesdissipate: There are no 'reference' books for Clojure.
17:11dissipateRaynes, that's strange
17:12rodnaph_callen: that's surprising to hear. i really liked hiccup, but have fallen for enlive over it now.
17:12RaynesI'm not sure how.
17:12dissipaterodnaph_, are you doing web programming with clojure?
17:13rodnaph_yeah, pretty much everything i've done with clojure is web focused (or at least has a web frontend)
17:13dissipaterodnaph_, interesting
17:14rodnaph_dissipate: i'm finding compojure + enlive a really great combination. for UI and API stuff
17:14RaynesEnlive gives me hives. I'm partial to mustache.
17:14dissipaterodnaph_, what are the benefits of web programming in clojure vs. say a python framework like django?
17:14callenrodnaph_: I've only been able to make progress thanks to Raynes' refheap as a reference for how to do the mixture of partials in Stencil.
17:15callenrodnaph_: I still find mustache to be pretty freakin' weak compared to Jinja though.
17:15Raynes<3
17:15RaynesI think the fact that it is weak is why I like it. Simple is nice.
17:15callenRaynes: no seriously, playing "follow along" with refheap has been a MASSIVE boon to making a web app in Clojure. I've not had any serious breakage since I started simply because I was able to learn from your code.
17:16dissipatewhat are the benefits of doing web apps in clojure?
17:16RaynesHappy to hear it.
17:16tomojenlive seems simpler
17:16callenwell the weakness means falling back to defining partials in terms of Clojure code. The iterable behavior is questionable too. That's more coupling between HTTP runtime/template-side than I like to see.
17:16Raynesdissipate: The benefits are that you get to use Clojure instead of Python.
17:16callendissipate: for me? Almost none. Purely pedagogical. Web apps are what I know.
17:16rodnaph_dissipate: i've never used django, but have lots of other frameworks in various languages, and the benefit i find is purely clojure. if you feel more comfortable with frameworks then maybe it's not right for you.
17:16callendissipate: I'm 1000% more productive in Python/Flask/Jinja than I am in Clojure right now. Might change eventually.
17:16RaynesAnd if you ask "what are the benefits of Clojure over Python", I'm going to find you and cause you harm.
17:17callenmy python stack isn't more productive because of Python, it's more productive because of Flask and Jinja.
17:17dissipateRaynes, yikes!
17:17Raynes:p
17:17callenNoir sorta'ish covers the Flask use-case, but Jinja still isn't really provided for yet.
17:17callenMonger is a perfectly acceptable replacement for MongoEngine (better, even)
17:17dissipateRaynes, i'm coming from Python, but i'm very interested in the benefits of pure functions and transactional state memory
17:17callenso the biggest hits to my productivity come from unfamiliarity and the lack of a jinja equivalent.
17:17RaynesI want a driver for rethinkdb.
17:18callendissipate: I'm only here for the Lisp.
17:18rodnaph_when you're comfortable with clojure, i think the simplicity is refreshing. i've found what i thought made me productive in other frameworks, i simply don't need in clojure.
17:18callenRaynes: writing a driver for rethinkdb could be interesting, since it has like 3 different query langs.
17:18callenI'm an ex-CL'er trying to get back on the horse, so to speak.
17:18dissipaterodnaph_, how easy is it to become 'comfortable' with clojure? :O
17:18Raynescallen: I've got taking a shot at it on my TODO list.
17:18winkanyone seen any clues how to do it? I wondered if they're even open to 3rd-party-drivers
17:19Rayneswink: It looks like it is done over sockets. You can look at the implementations in the repo.
17:19callenRaynes: I use MongoDB as well, I see you're as excited as I am about replacing MongoDB? :P
17:19Raynescallen: I'm excited about not having to hear people bitch because I use mongodb.
17:19RaynesThat's about it.
17:19dissipatecallen, what's wrong with MongoDB?
17:19rodnaph_dissipate: i won't lie, i found moving to FP a bit of a struggle. but mostly because i was overcomplicating things in my mind i think. use it 100% on a project and i reckon within a week you'll be flowing.
17:20callenRaynes: who complains?
17:20RaynesLots of people.
17:20winkRaynes: ok, I failed to find a repo. *very* cursory glance it seems. thanks :)
17:20callenRaynes: you made a free pastebin designed for Clojure users. Is that what they bitch about? refheap using it?
17:20rodnaph_dissipate: (but then throwing out everything you did a week later, hehe)
17:20callendissipate: a lot of stuff that matters about 10% of the time.
17:20Raynescallen: Mostly long discussions about how terrible mongodb is whenever I've ever mentioned how refheap uses it.
17:20dissipatei'm using mongodb for a small project
17:21dissipatei like the flexibility
17:21callenRaynes: Refheap is the sort of thing MongoDB is perfect for, thugh.
17:21RaynesWhich I am completely and utterly uninterested in, given that mongo works fine for this project.
17:21callendissipate: it's great for that. Just don't suggest using it at work.
17:21dissipatecallen, someone is already using it at work. :P
17:21winkrefheap isn't supposed to be a consistent transactional DB though :P
17:21callenI use it at my startup, but that's due to 1. Legacy code 2. I know the trade-offs and it doesn't matter for us.
17:22dissipatesomeone is using MongoLabs at work actually
17:22callenyou know of all the trade-offs that bother me with MongoDB, I have to say that transactions has come up for me approximately zero times.
17:22Raynescallen: https://github.com/weavejester/comb An old templating lib.
17:22dissipateare the complaints with mongodb related to scalability or what?
17:22unnalicallen: it's come up for us about a hundred times. I think it really just depends on your domain/what you're doing.
17:23callenRaynes: I managed to get things working with stencil, thanks to you refheap/views folder, but it feels a bit creaky. As if I'm going to run into pain later if I need to spread out my template inheritance or something.
17:23callenunnali: yeah I work in consumer web apps, so for me it just rarely if ever matters.
17:23callenunnali: knowing that the option isn't available is...disconcerting to say the least.
17:23Raynescallen: Admittedly, refheap's templates are a mess that could probably be cleaned up.
17:23callenthe thought of having to implement a lock-batch-unlock mechanism makes me weep.
17:24Raynescallen: Jinja looks interesting. Has a built in sandboxed execution environment. Why is that useful?
17:24callenRaynes: they were a little hard to follow until I understood that you were implementing a partials system on top of Mustache's pseudo-partials system.
17:24RaynesDo people not sanitize user input?
17:24callenRaynes: having it baked into the templating system does a lot to prevent issues.
17:25RaynesMustache partials are less useful than doing it in the Clojure code itself.
17:25callenRaynes: the best way to explain Jinja is to realize that I am rarely writing templates except as an initial "example" showing what the name of the data getting injected looks like, then handing it off to the frontend guy.
17:25callenRaynes: the blocks/template inheritance system in Jinja is something the frontend guy can understand and work with without bugging me
17:25RaynesRight, makes sense. I don't have a frontend guy for my personal projects.
17:25callenRaynes: having to reach into my Clojure code is highly sub-optimal.
17:26callenRaynes: right, but that's a common issue in clojure projects. No accommodation/thought for division of labor.
17:26RaynesI had to work with a frontend guy for the first time a while back.
17:26RaynesI was like an encyclopedia answering questions.
17:27akhudekIn an ideal world, the frontend and backend would both be clojure. ;-)
17:27callenRaynes: how do you mean?
17:27callenakhudek: not really, people specialize their knowledge into HTML/CSS/JS because those are subjects that often merit their own hooman in larger projects.
17:27callenlearning clojure is, frankly, out of the question.
17:27RaynesI mean he asked me lots of questions. Lots and lots of questions. It wasn't actually a website, but an API that he had to implement a frontend for.
17:28akhudekcallen: HTML/CSS/CLJS. Just replace Javascript with ClojureScript. I don't see why learning clojure is out of the question for a javascript programmer, but not for a java programmer.
17:28RaynesAnyways, Jinja looks cool. I might argue with the "Jinja is Beautiful" tagline, but nonetheless..
17:30callenakhudek: you know what, give it a whirl. See how the JS dev reacts.
17:31callenRaynes: Jinja is something that came out of the post-PHP/JSP era. In that context, it's heaven itself.
17:31RaynesClojureScript seems like a tiny bit of a pain in the ass to use. Unless those js devs really hate js and really would rather use Clojure, I don't think you'll have much luck.
17:32dissipatewhat is clojurescript used for?
17:32rodnaph_i've only started using enlive today, but it really feels like an improvements on templating "languages"
17:32Raynesdissipate: It's a Clojure implementation that compiles to Javascript.
17:33dissipateinteresting
17:33dissipatesounds like coffeescript
17:33akhudekcallen: I've taught two student javascript programmers clojure. It wasn't too hard. And Raynes, JS devs seem to really like Coffeescript. I don't think they are opposed to new languages in general.
17:33callenakhudek: I'm talking about working with experienced professionals who have a lot invested in their skillset
17:33callenakhudek: not undergrand randos with time to burn.
17:35akhudekcallen: the argument is still the same as any other experienced developer. You may as well advocate the same thing about Java and thus people shouldn't learn clojure.
17:35callenerm, no.
17:35callenBackend is different. You can use anything you want there.
17:35callenYou will never ever ever escape HTML/CSS/JS on the frontend in web.
17:35clojurebotHuh?
17:35callenyou can try to hide it with coffeescript, cljs, or whatever, but you'll never fully escape it.
17:35callenNot even close.
17:36callenakhudek: you're just grasping at straws now. Let it go.
17:36dissipatecallen, how did google escape it? JS is not an official google language. :P
17:36matt444I have a deeply nested vector that I would like to "reach into" and modify. What functions should I be using?
17:36callendissipate: they didn't, JS is a large component of their work.
17:37callendissipate: I know a Google employee who's one of the principals on AngularJS.
17:37dissipatecallen, did they not 'escape' via GWT?
17:37callenno, that failed horribly.
17:37amalloymatt444: update-in and assoc-in
17:37callenthey still use it in bits and pieces, especially on older properties.
17:37callenThey abandoned it for newer projects.
17:37dissipategoogle is using pure JS on new projects?
17:37dissipateyikes
17:37matt444amalloy, assoc-in is the one I was thinking, thanks!
17:37callenthe Google Closure ecosystem is a more accurate representation of how they do things.
17:37dissipatehere comes Dart!
17:37akhudekcallen: if your argument is that compiling to JS is bad in general, I suspect there are many that would disagree.
17:37callenakhudek: no, that's not my argument.
17:38callenakhudek: jesus, stop making shit up just to try to make an argument you don't have the experience to be making.
17:38RaynesEh
17:38RaynesYou don't really have to be so harsh.
17:38callenI don't like having words put in my mouth just so people can make themselves look less stupid at my expense.
17:39RaynesI'm pretty sure the channel is here for discussion.
17:39dissipateakhudek, it is bad. JS is the bain of web programming.
17:39callenEspecially on IRC when it's textual and there's really no excuse. You can take your time to read what I said before tossing random stabs at getting the advantage.
17:39callendissipate: bane.
17:39callendissipate: bain is a name.
17:39dissipatecallen, you are right, bane. :P
17:40callenRaynes: you're right, that was too harsh, but I lost interest in the argument several lines prior. Despite that, I get dragged back in because I have to fend off obviously ridiculous assertions as to what I meant so I don't look like the complete ass he was trying to make me into.
17:40callenRaynes: I'll attempt to fend off the ridiculousness with a more polite and cheerful tone in future.
17:40RaynesSounds good.
17:40dissipatehas anyone 'big player' in web considered using a browser virtual machine that can run byte code compiled from many different languages? e.g. the Parrot VM
17:41callendissipate: impractical.
17:41dissipatecallen, how so?
17:41callendissipate: well for one thing, a browser VM runtime has been done, it was called Flash.
17:42amalloycallen: nobody could put words in your mouth if you weren't constantly starting arguments unrelated to clojure in here
17:42callendissipate: for another, you'd be introducing an immense amount of complexity for little gain. Performance is another concern.
17:42dissipatecallen, so what is the solution? javascript is clearly a problem.
17:43callenamalloy: to my credit, I was originally talking about stencil, hiccup, and enlive. The general subject of front-end work eventually nose-dived into what you saw.
17:43callendissipate: I don't agree with the premise.
17:43dissipatecallen, JS is perfectly fine? :O
17:43callenthat's not the way I'd put it.
17:44callenI think JS is fine for what it's meant to do and that compiling into it from things like cljs is a fine way to ameliorate the pain if you don't like JS.
17:44callenor coffeescript, or roy, fay, etc.
17:44dissipatecallen, the problem with JS is that it sucks for building larger apps
17:45callendissipate: what large apps have you built?
17:45RaynesThis is why I never argue about javascript.
17:46dissipatecallen, i'm currently working on electrosim.com, a browser based schematic capture and simulator for electrical engineers.
17:46callenWhether or not JS scales up to a large project depends a great deal on factors that have little do with JS. Like testing, linting, code standards, libraries, etc. That's true of any programming language and any project.
17:46callendissipate: the Google Closure ecosystem shows some good ways to scale JS up for larger projects.
17:47tomojwhat a coincidence
17:47callentomoj: ?
18:05cshell_Is lein 2.0 backwards compatible with 1.7.x projects?
18:22akhudekcshell_: no, but there is some package that will try to auto-update a project to some extent
18:24Raynescshell_: No, but every project you'll ever care about (except your own, I guess) has updated.
18:25akhudekcshell_: https://github.com/technomancy/leiningen/wiki/Upgrading
18:26cshell_thanks guys - I'm trying to work on the IDEA Leiningen Plugin and trying to figure out if I should support both 1.7+ and 2.0
18:26cshell_or if I should just support 2.0
18:26RaynesI'd just support 2.0.
18:27cshell_Yeah, that would make my life easier - and I could just tell people how to update their current projects from 1.7 to 2.0
18:27RaynesSupporting 1.7 encourages continued using 1.7 which we shouldn't do, and opens up a huge can of annoying worms for you.
18:27cshell_good point
18:27RaynesBut really, pretty much nobody is still using 1.7, so I think you're safe.
18:27akhudekAlso, as Raynes said, there are very very few 1.7 projects still around.
18:27RaynesEclipse, for example, uses lein2 I think.
18:28amalloyRaynes: spinning laziness as community activism since 2011
18:28RaynesDamn right.
18:29cshell_Okay great, I'll go with 2.0 then - the leiningen-core library makes my life a lot easier as well
18:29RaynesMy life skills include landscaping and making people feel like their laziness is beneficial in the end.
18:35cshellI guess the only people using 1.7 are those who are still using the leiningen plugin in IDEA :)
18:36SgeoUgh, the C wrapper I'm wrapping takes callbacks as functions, and any sane Clojurey API, which I intend to make, would take the callback as a function, but the JNAerated Java, of course, doesn't.
18:49Hodappwellll, I had to go all the way to Emacs to get Clojure support that would (1) give me syntax highlighting in the editor, (2) let me send expressions in the editor buffer to a REPL, and (3) let me type things in the REPL
18:49Hodappbut I'm finally there
18:51RaynesYou could get that from Light Table too.
18:51RaynesPretty sure Eclipse makes it easy as well.
18:51RaynesAnd there is catnip.
18:51mudgeRaynes: hi!! I've been using your file system clojure library today
18:51HodappRaynes: Eclipse & Counterclockwise gave me a bunch of crashy bullshit.
18:52Raynesmudge: Yo.
18:52HodappRaynes: It worked okay for a bit, and then it didn't.
18:52RaynesHodapp: That's okay, I don't like Eclipse either.
18:52HodappRaynes: It's nice for Java stuff. At least as far as Java stuff goes.
18:52RaynesBut if you don't dig Emacs, give light table a shot. It isn't perfect, but it's making excellent progress.
18:52HodappI'm liking Emacs, actually. But I did watch the video on Light Table months and months back and it looks like some very cool software.
18:53RaynesCatnip looks pretty neat too, if you just want a Clojure editor.
18:53mudgeRyanes: I was looking at using the zip function in fs.compression but it looks like I need to load the entire files into byte arrays for use by make-zip-stream, does this sound right?
18:53akhudekHodapp: I'm one of the few here who like IDEA + La Clojure.
18:53Hodappakhudek: I had mixed luck with IDEA.
18:54Raynesakhudek: The file contents have to be either strings or byte arrays.
18:54RaynesEr.
18:54Raynesmudge: ^
18:55RaynesBut having to load the entire file into memory sounds bad.
18:55Raynesmudge: I would expect that your byte array could be lazy. At least, I hope that's the case. I didn't actually write those functions.
18:56RaynesHaving to load entire files into memory is a bug, so open an issue about it if it turns out to be the case.
18:56mudgeRaynes: I see
19:01mudgeRaynes: okay thanks. Well make-zip-stream expects arguments like this: [[filename1 content1][filename2 content2]...] and the content1 variable is passed to ZipOutputStream.write() which expects a Java byte array, which I'm thinking can't be lazy because Java byte arrays are not lazy
19:01RaynesUgh, an actual byte array.
19:01RaynesYeah, this is the devil.
19:08mudgeRaynes:, raek: I wrote my own implementation of zip that makes a zip file of all files in a directory: https://gist.github.com/4056821
19:16gfrederickshas clojure.java.jdbc had major breaking changes since the contrib days?
19:31winkgfredericks: hm, it's definitely different, can't say how different
19:37gfredericksis it possible to tell lein not to do anything with the internet even though my project has snapshots?
19:48TheShellfishMemeI'm trying to learn clojure at the moment. To understand macros better I decided to make one that makes all calls to '*' return x times the result. I first wrote the code that does this directly with a fixed
19:48TheShellfishMemehit wrong button :/
19:50TheShellfishMeme… with a fixed multiplier. then I tried to convert it into a macro, but I keep getting a IllegalArgumentException Don't know how to create ISeq from: clojure.lang.Symbol clojure.lang.RT.seqFrom (RT.java:494) error no matter how much I simplify it. Can someone help me and point me in the right direction? Code: http://pastebin.com/2VApsqnp
19:52tmciverTheShellfishMeme: Well, you forgot a name for the macro.
19:52TheShellfishMemeyeah I just realized that as well
19:53TheShellfishMeme*facepalm*
19:54TheShellfishMemethanks :)
19:54tmcivernp. It happens to the best of us.
19:55gfredericks(defn println [& args] (apply clojure.core/println (if *facepalm* (concat args ["duh."]) args)))
20:02mattiswhat is the preferred way to talk to a socket from Clojure? I see quite a few using the Java classes directly, but clojure.java.io looks more functional
20:17TheShellfishMemenow I have the problem that it says "Can't let qualified name" http://pastebin.com/kQbq0Ac0. I tried to do some research into what causes this, but I don't think I quite got it yet. Ignoring that this is nothing one would actually want to do in a real program, what is it that causes this error and how can I get around it?
20:18cshellchange * in the binding to *#
20:19cshell(defmacro moretimes [times body] `(let[*# #(apply * (conj %& ~times))] ~body))
20:20TheShellfishMemebut then it doesn't seem to do anything. something else I missed there?
20:20cshellwhat do you expect (moretimes 2 (* 1 2)) to expand to?
20:22TheShellfishMemeactually it does what I want but it's getting late and I didn't notice the "1" in there.
20:22TheShellfishMemeor does it?
20:23TheShellfishMemeactually I wanted (moretimes 2 (* 2 2)) to expand to (let[* #(apply * (conj %& 2))] (* 2 2))
20:23TheShellfishMemewhich should evaluate to 8
20:24TheShellfishMemebut (moretimes 2 (* 2 2)) evaluates to 4, so I guess something isn't working there
20:24cshellwhy are you shadowing the clojure/core/* operator?
20:25gfrederickshe's messin with macros
20:25gfredericksyou either want to shadow with (let [~'* ...] ...) or you want to use with-redefs, depending on your exact goal
20:25TheShellfishMemebecause I have no idea what I am doing :) needed to find some kind of example use for them, so I came up with this
20:26gfredericksTheShellfishMeme: did you want the effect to be just in the code that's lexically inside of moretimes?
20:26gfredericksor all code executed even indirectly?
20:26TheShellfishMemeyes exactly
20:26TheShellfishMemejust inside moretimes
20:26gfredericksthen you want to shadow with (let [~'* ...] ...)
20:26gfredericksthat causes any * inside the macro to refer to your local function instead of the clojure.core var
20:27TheShellfishMemehah, perfect. thanks a lot
20:27gfredericksit's syntactically ornery because that sort of thing is rarely what you want to do in a macro
20:27gfredericks(shadowing)
20:29TheShellfishMemeyes, I thought so. felt weird writing this code, but I needed some kind of thing to implement. just reading about macros didn't really help the understanding
20:30cshellJust think of macros as functions that return Clojure code
20:30tmciverTheShellfishMeme: you realize that you don't need to shadow * here; you could replace it with something like my-sym# everywhere.
20:31tmciveror my-times#, say.
20:31TheShellfishMemeyes I do understand that. but I learned a lot more doing it the ugly way :)
20:34TheShellfishMemeI swear I'll never use this kind of thing in real code
20:35Iceland_jackOnly in imaginary code
20:38gfredericksor at worst complex code
20:41TheShellfishMemecomplex code is an integral part of lambda calculus
20:42TheShellfishMeme*I'll show myself out*
20:43TheShellfishMemeanyway, thanks for your help.
20:43penryuI've seen both (cons foo (lazy-seq ....)) and (lazy-seq (cons foo ...)) forms; which is better/best? or what are the caveats of each?
20:44gfredericksthe latter won't evaluate foo until needed
20:45gfredericksif foo already exists I don't know any reason to use the latter
20:45penryuso not even the head of the returned seq will be eval'd until needed?
20:45gfredericksthere's probably something though. I always don't think of something.
20:45gfredericksright
20:45gfrederickslazy-seq just thunks everything and does nothing until you need it to
20:46penryuokay. that makes sense.
20:46penryuso the latter is closer to haskell, iiuc
20:47gfredericksI spose
20:47penryuhrm. that comparison seems less and less useful the more I think about it.
20:48gfredericks:)
20:49gfredericksclojure: it's like haskell but only for lists some of the time
20:51amalloygfredericks: ##(realized? (iterate inc 1)) is one reason you might prefer the latter
20:51lazybotjava.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.IPending
20:51gfredericksI was half considering mentioning that 85% of the time that I miss something amalloy or hiredman will point it out
20:51rafb3would like feedback on this content about functional programming I've been working on for a talk...
20:52rafb3https://github.com/rafaelbandeira3/The_Stateless_Server_pt-BR/blob/master/the_stateless_server_en.markdown
20:52rafb3feel invited to comment on it there
20:54penryuamalloy: are you referring to the change in behavior of (realized? (iterate inc 1)) and (realized? (rest (iterate inc 1)))?
20:54amalloyyeah
20:55penryugood point
20:55penryuso that's two points in favor of the lazy-seq-over-cons routine
20:57gfrederickswell it's a conceivable reason to use that; I don't think it's a reason to prefer it generally
20:59penryuin the case of iterate, it's not really important either way, I believe. if the seeding of the sequence were expensive, you might choose one or the other to try to perform/delay the operation as desired
20:59penryuand indeed, all the docs use cons->lazy-seq
21:00penryubut the argument for consistency is a strong one, but maybe not very important in practice?
21:01gfredericksconsistent with what? most sequences don't respond to realized?
21:01gfrederickse.g., lists
21:01penryugood point
21:02gfredericksit only makes sense in a context where laziness is expected for some odd reason
22:21cshellCan anyone tell me why (drop-while #(not= % "--to-dir") '("myprj" "--to-dir" "c:/temp/yyy11")) returns ("--to-dir" "c:/temp/yyy11")?
22:22cshell,(drop-while #(not= % "--to-dir") '("myprj" "--to-dir" "c:/temp/yyy11"))
22:22clojurebot("--to-dir" "c:/temp/yyy11")
22:24cshell,(take-while #(not= % "--to-dir") '("myprj" "--to-dir" "c:/temp/yyy11"))
22:24clojurebot("myprj")
22:25cshell,#(not= "c:/temp/yyy11" "--to-dir")
22:25clojurebot#<sandbox$eval85$fn__86 sandbox$eval85$fn__86@6fc1049d>
22:25cshell,(#(not= "c:/temp/yyy11" "--to-dir"))
22:25clojurebottrue
22:29cshellohhh.starting from the first item
22:29cshelloops