2011-04-09
| 00:02 | joshua__ | amalloy, Somehow I wasn't in the master branch. |
| 00:02 | amalloy | tada! |
| 00:02 | joshua__ | amalloy, All better now =). |
| 00:16 | carllerche | If I'm looking to implement an HTTP proxy (in clojure), should I be focusing on using aleph? |
| 00:23 | mec | according to joy of clojure, rest is more lazy than next, but if I need to do (seq (rest coll)) is that the same thing as (next coll)? |
| 00:23 | amalloy | $source next |
| 00:23 | sexpbot | next is http://is.gd/dijgWa |
| 00:23 | amalloy | (in short: yes) |
| 00:24 | mec | I looked at the source but its just a .next call now, i think at one point it wasnt |
| 00:26 | amalloy | mec: if you read the java source, next is (seq (rest coll) |
| 00:26 | mec | ah ok |
| 00:26 | amalloy | or just read the docstring |
| 00:26 | amalloy | &(doc next) |
| 00:26 | sexpbot | ⟹ "([coll]); Returns a seq of the items after the first. Calls seq on its argument. If there are no more items, returns nil." |
| 00:27 | amalloy | er no, i guess rest says the same thing |
| 00:27 | mec | ya ;p |
| 00:34 | livingston | can you have circular uses ? (ns a (use b)) (ns b (use a)) ? |
| 00:34 | amalloy | no |
| 00:35 | livingston | didn't think so. so, how do I get around that? (I might not actually have it, still working though) |
| 00:36 | amalloy | livingston: basically, pull out part of the cyclic dependency into a new namespace b that they both depend on |
| 00:37 | amalloy | transform that DAG into a tree |
| 00:37 | amalloy | man |
| 00:37 | amalloy | that is not a DAG. i am dumb. but the advice stands |
| 00:37 | livingston | yuch. I had a reasonable cut in my code but there are pieces that refer across them |
| 00:40 | livingston | can I use declare to forward declare something in another namespace? |
| 00:40 | amalloy | livingston: i don't believe so. (declare foo) is ~= (def foo nil) |
| 00:40 | amalloy | and you can't def someone else's namespace |
| 00:42 | livingston | i think I could if the namespace existed already?... ugh this is a pain |
| 00:47 | tomoj | you couldn't even if it did |
| 00:53 | livingston | can I signal non-Object return types on defrecord / defprotocol definitions? it keeps telling me it's seeing boolean and expecting Object (I think I have everything flagged as boolean) |
| 00:56 | amalloy | livingston: what version of clojure? i don't really keep up but i think that changes in 1.3 |
| 00:56 | livingston | I'm on 1.2 still |
| 00:57 | livingston | so soon we'll be able to set return types on protocols/defrecord that will get back to the java interface? |
| 00:58 | amalloy | i think that's always been possible for definterface |
| 00:58 | amalloy | and for...some types, you can return/pass primitive long/double values. i don't think boolean is getting in |
| 00:59 | livingston | yes it is (based on the examples I see) protocols just generate an interface too |
| 00:59 | amalloy | but i think you can set *non*-primitive hints with ^Boolean, rather than ^boolean? |
| 00:59 | livingston | ^ -- possible for definterface don't know about your second (and now third ) comment |
| 01:00 | livingston | don't know, didn't try that. I'll try again later, all of this is just to be kind to the java users and it has taken way to looong now. |
| 01:02 | mec | going to need a new book just to clarify all the 1.3 changes |
| 01:03 | livingston | that's odd I have a function with the call signature [a b & _] and when I try to make another function with this body ([x y] (foo x y)) it says unsupported call signature? |
| 01:03 | livingston | mec: yeah I've been a bit out of the loop with my head in the sand lately |
| 01:05 | mec | is it in an interface or protocol? |
| 01:06 | amalloy | livingston: code snippet? not clear what you're talking about |
| 01:06 | livingston | the protocal defines (bar [x y] [x y z]) I have the defrecord doing (bar ([x y] (foo x y)) ([x y z] (foo x y z))) |
| 01:07 | livingston | where foo is signature [x y & _] it says no binding pattern [x y] |
| 01:08 | amalloy | protocols don't support multiple arities in a single declaration. they're java-level methods |
| 01:09 | amalloy | you would need (bar [x y]) (bar [x y z]) iirc |
| 01:09 | livingston | really? I've been doing it (or at least I think I've been doing it |
| 01:09 | amalloy | i could be wrong. i don't do a lot of interop |
| 01:09 | livingston | z is optional |
| 01:10 | amalloy | either way protocols "shouldn't" have optional args really. just demand that the implementor supply a version for x y z, and then wrap a function around it that handles the optional-ness of z |
| 01:10 | livingston | well it worked with extend but not trying to instantiate it into a defrecord now |
| 01:11 | amalloy | then instead of everyone who extends the protocol having to supply N versions of bar, they all supply one and you add an extra wrapper to handle the rest: protocols love minimalism |
| 01:11 | livingston | that'd kinda suck for the java people to call the plain function but yeah.. |
| 01:12 | livingston | yeah that's kinda what I have it works great with a set of functions from clojure world it's the java world that's always a pain... |
| 01:13 | livingston | I do have some legitimate multi-signature function though and wait there are exiting java APIs that work fine that way. (addTriple s p o) (addTriple t) etc. |
| 01:14 | amalloy | mkay |
| 01:15 | livingston | I'm not saying l like those java apis but they are out there, and when you need to pick one of a dozen call signatures to hit from clojure they are really fun |
| 01:17 | amalloy | livingston: i specialize in opinionated advice about things i don't actually do, so feel free to ignore the bits that you don't like |
| 01:18 | livingston | I just know java can do it, I don't know that protocol can too |
| 01:19 | livingston | I'm also a bit grouchy this re-factor is taking forever, I haven't eaten, it's 11pm and my friends are drinking |
| 01:22 | livingston | but I just poked my head into the real world an at least the government is still running (for some definition of running) |
| 01:26 | amalloy | livingston: most governments are indeed running |
| 01:26 | livingston | our's almost just shut down. (you're not in the US are you?) |
| 01:27 | amalloy | i am, but i was objecting to the american tendency to treat the US as the only interesting country |
| 01:27 | tomoj | ..our government almost shut down? |
| 01:28 | amalloy | tomoj: squabbling over the budget |
| 01:28 | livingston | amalloy: oh. isn't it? get in line or we'll bring democracy to you lol |
| 01:28 | tomoj | too bad |
| 01:29 | amalloy | tomoj: it's all over the news. lots of name-calling across the aisle |
| 01:29 | livingston | tomoj: last minute deal. 800,000 people would have been furlowed (or whatever) it would have been a huge mess wasted time and money (it's already done enough of that) |
| 01:29 | amalloy | livingston: oh, they worked it out? |
| 01:29 | amalloy | i stopped watching once i got home |
| 01:30 | cemerick | It's always a game of chicken. |
| 01:30 | cemerick | And someone always blinks. |
| 01:30 | livingston | yeah, apparently. I should look at see what the new NIH budget is. |
| 01:30 | amalloy | cemerick: recently it's been the democrats blinking, from what i hear |
| 01:31 | cemerick | amalloy: Democrats are born with a twitch that induces it. |
| 01:31 | cemerick | Though it looks like the deal just reached is pretty even-handed. |
| 01:32 | livingston | now it says it a short term deal. is there a long term one behind it? or are we going to keep winging it every couple of weeks? |
| 01:33 | cemerick | AFAICT, it's a 1-week temporary patch, with the real thing essentially locked down. |
| 01:33 | tomoj | popular dynamics necessitate a great degree of winging, I suspect |
| 01:34 | cemerick | We're only 5 months from the start of the next fiscal year though, so "long term" is shakily-defined. |
| 01:34 | livingston | tomoj: there's no need for this. it's half way into the year. there's been stupidity on both sides long before now dragging this out. |
| 01:35 | livingston | cemerick: yeah, that's why worrying about this one is so silly. how long you think they'll go before they start to think about the next one |
| 01:35 | tomoj | I meant in general. the public doesn't have a mind of its own |
| 01:35 | justinlilly | is there something like "Practical Common Lisp" in clojure? ie: "We're going to make an X, and you'll learn clojure along the way"? |
| 01:35 | cemerick | Just wait until the round this year into 2012. Them'll be some fireworks. |
| 01:36 | justinlilly | What X is doesn't entirely matter, just that it doesn't amount to "do all of project euler, then come back to me" |
| 01:36 | amalloy | cemerick: it won't matter. the world will end six months after that, so the budget can take a back seat |
| 01:37 | cemerick | oh, right |
| 01:37 | tomoj | I am not looking forward to the hysteria |
| 01:37 | cemerick | Is this 2012 thing Mayan, Nostradomus, Jehovah's Witnesses, or a melange? |
| 01:38 | justinlilly | variatons on a theme? |
| 01:38 | amalloy | rather small-minded of you to even consider the budget, really |
| 01:38 | tomoj | the real hysteria will be humorous, but the flurry of books and tv shows and other things sold will be hard to take |
| 01:38 | livingston | justinlilly: poor guy asks an on topic question and we're talking about how stupid people are... yes there are some good tutorials (although I don't know one off the top of my head) |
| 01:38 | tomoj | I think there was some effort to translate PCL? |
| 01:39 | tomoj | or was that another book |
| 01:39 | amalloy | tomoj: little schemer, i think? |
| 01:39 | livingston | there's "casting spels" or whatever |
| 01:39 | amalloy | that's Land of Lisp, i think |
| 01:39 | tomoj | http://thinkrelevance.com/blog/2008/09/16/pcl-clojure.html |
| 01:39 | tomoj | certainly less compelling than this hypothetical one written from scratch would be |
| 01:40 | justinlilly | thx. |
| 01:48 | livingston | the reddit commentary comparing the budget the oregon trail is kinda amusing |
| 01:52 | cemerick | livingston: wha? |
| 01:52 | cemerick | No, nevermind, I don't want to know. |
| 01:54 | amalloy | cemerick: "i wish they'd all die of dysentery". i haven't read the reddit stuff, but this is at least as good |
| 01:54 | livingston | cemerick: "Spend all the money on ammunition so you can shoot at stuff, then wonder why your wagon is falling apart and everyone is dying of dysentery" |
| 01:54 | cemerick | Scholarly. |
| 01:55 | cemerick | Many thanks for the tidbit, saving my sanity in the process. :-) |
| 01:55 | cemerick | "#clojure reads reddit so you don't have to" |
| 01:57 | livingston | that would do wonders for my productivity -- so would having this @#$% refactor done |
| 01:59 | amalloy | livingston: cemerick will write it for you, in exchange for your help with reddit |
| 01:59 | amalloy | #inadreamworld |
| 01:59 | livingston | i'd much rather be reading reddit right now. actaully I'd rather be at the pub with my friends. |
| 02:01 | justinlilly | there's an interesting thing called "hacker news daily".. takes the latest top 10 posts based on total score that hasn't been on the daily list yet. |
| 02:01 | justinlilly | http://hnfluence.com/ -- also this.. which is hacker news ratings mushed with bitly clicks, tweets, etc. |
| 02:02 | cemerick | livingston: I can wish you well, at the very least. :-) |
| 02:02 | cemerick | Good night all. |
| 02:02 | livingston | oh great more distractions... |
| 02:02 | livingston | cemerick: thanks |
| 02:22 | livingston | oh finally made it (half way but enough to know the rest is good) ... good night and thanks everyone |
| 09:01 | ejackson | is there anything about map that should destroy a dynamic binding ? |
| 09:15 | ejackson | here's a gist of the unfortunate behaviour: https://gist.github.com/911386 |
| 09:17 | mrBliss` | ejackson: I've also noticed bindings are ignored in (fn ..). But I think with-redefs (1.3) will do what you're looking for. |
| 09:18 | ejackson | hmmm.... its the (fn ...) thanks. I wonder what this is about |
| 09:18 | ejackson | i'm scared to try moving my project to 1.3 |
| 09:21 | ejackson | mrBliss`: thanks, though, this puts me on the correct track |
| 09:21 | pimeys | is there some magic you have to do to get mysql connection work with clojure. I'm writing my first web app with clojure+ring, installed mysql adapter with maven (lein didn't work) and my sql query throws an error: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306 |
| 09:21 | pimeys | google doesn't find any decent answers |
| 09:22 | pimeys | I'm making a decision which language+library to use: clojure+ring or haskell+lift for my future web apps |
| 09:23 | pimeys | lisp is easier for me than haskell though... |
| 09:24 | ejackson | pimeys: it looks you don't have the jdbc mysql setup |
| 09:24 | pimeys | oh, I meant snap+haskell :) |
| 09:24 | ejackson | there is a jar you need in your classpath, let me go look quickly |
| 09:24 | pimeys | lift is for scala |
| 09:24 | pimeys | ejackson: I have some jar in my project lib |
| 09:24 | pimeys | 3304179 Apr 9 16:10 mysql-connector-java-5.5.15.jar |
| 09:25 | ejackson | yeah, that's the one |
| 09:25 | ejackson | in that case you need to diagnose the jdbc itself |
| 09:25 | ejackson | there is a util somewhere that does that |
| 09:26 | pimeys | all the other libs work just fine, but those installed without errors using leinegen, that mysql adapter is installed with maven because lein couldn't find the adapter library |
| 09:27 | ejackson | yeah, i had to jiggle and shake to make it work, but it does ! |
| 09:27 | pimeys | of course I could use postgresql, but our server has mysql already installed and configured... |
| 09:27 | ejackson | mrBliss`: the answer is bound-fn ! |
| 09:28 | pimeys | oh and also, how do you guys deploy clojure/ring apps? |
| 09:28 | ejackson | https://gist.github.com/911386 |
| 09:28 | pimeys | I'm looking for something like capistrano |
| 09:29 | ejackson | pimeys: people tend to dev with jetty and then deploy into tomcat or such |
| 09:29 | ejackson | pimeys: its a bit different. You package as a .war file and send that to tomcat |
| 09:29 | ejackson | its much less fiddling about than rubyland |
| 09:30 | pimeys | my setup would be something like this: nginx serving static html+js from the project's public dir and clojure+ring would serve only json |
| 09:30 | pimeys | so clojure listens some other port and everything is rendered with jquery/ajax |
| 09:30 | ejackson | out of my depth now, I don't do web apps :) |
| 09:49 | Scorchin | What are the best examples of taking a Java API/Lib and converting it into an idiomatic Clojure API/Lib? |
| 10:45 | x6763 | is there a way to use clojure.contrib.http.agent/http-agent with an http proxy server? |
| 11:17 | angerman | Did anyone else note reCaptcha to ask for math formulas recently? |
| 12:56 | jweiss_ | how come this doesn't work |
| 12:57 | jweiss_ | ,`{~@[:c :d]} |
| 12:57 | clojurebot | 1 |
| 12:57 | jweiss_ | on my repl i get ArrayIndexOOB |
| 12:57 | jweiss_ | i expect {:c :d} |
| 13:01 | jweiss_ | huh, i didn't realize syntax quote, unquote splicing etc don't have non-shortcut equivalents like quote. |
| 13:02 | trptcolin | ,(let [things [:c :d]] `(~@things)) |
| 13:02 | clojurebot | (:c :d) |
| 13:02 | trptcolin | jweiss: because you're trying to eval (:c :d), which is nil, and splicing that doesn't work |
| 13:03 | trptcolin | hmm, although `(~@nil) doesn't bomb, so i'm probably missing some piece |
| 13:03 | jweiss_ | trptcolin: huh, i thought that evaling [:c :d] would yield a vector literal. |
| 13:04 | trptcolin | yeah my bad, missed the vectorness of it |
| 13:05 | jweiss_ | trptcolin: this works |
| 13:06 | jweiss_ | `[~@[:c :d]] |
| 13:06 | jweiss_ | ,`[~@[:c :d]] |
| 13:06 | clojurebot | [:c :d] |
| 13:06 | jweiss_ | but trying to splice into a map literal doesn't |
| 13:06 | trptcolin | yup |
| 13:06 | trptcolin | ,{[1 2]} |
| 13:06 | clojurebot | java.lang.RuntimeException: java.lang.ArrayIndexOutOfBoundsException: 1 |
| 13:07 | trptcolin | ok, so the splicing's a red herring? :) |
| 13:07 | Raynes | I would have guessed a purple trout. |
| 13:07 | jweiss_ | trptcolin: it shouldn't be - since we're splicing it shouldn't have the square brackets around 1 2 |
| 13:08 | trptcolin | oh yeah, weird |
| 13:08 | trptcolin | so does splicing just not work inside maps? |
| 13:09 | jweiss_ | doesn't seem to. |
| 13:09 | jweiss_ | ,`{:a :b ~@[1 2] ~@[2 4]} |
| 13:09 | clojurebot | {1 2, 2 4, :a :b} |
| 13:09 | trptcolin | Raynes: maybe a green salmon |
| 13:09 | jweiss_ | that is... weird |
| 13:09 | jweiss_ | works if there are an even number of splices |
| 13:09 | dnolen | jweiss_: it has to do w/ how the reader deals with map literals. Use hash-map fn not a literal. It's been this way for a while. Don't think there's any interest in fixing that behavior. |
| 13:10 | dnolen | it's the same reason why weird syntax in (comment ...) can cause errors as well. |
| 13:11 | jweiss_ | dnolen: well the comment thing i get, once i saw it's implemented as a macro, not in the reader |
| 13:31 | Lajla | ,(print "I worship his shadow") |
| 13:31 | clojurebot | Lajla: Pardon? |
| 13:31 | Lajla | =( |
| 13:32 | Lajla | Forever alone. |
| 13:36 | dbyrne | Does anyone have experience with the clj-sandbox library? I think I might have found a bug. |
| 13:36 | dbyrne | https://gist.github.com/911545 |
| 13:40 | Borkdude | Can anyone give me a clue on why "lein deps" is going wrong? http://pastie.org/1776027 |
| 14:06 | TimMc | Lajla: I don't think clojurebot watches much TV. |
| 14:06 | TimMc | ,`{~@[:c :d]} ; why doesn't clojurebot throw an exception here? |
| 14:06 | clojurebot | 1 |
| 14:07 | TimMc | 1 is the index that is out of bounds |
| 14:07 | Lajla | TimMc, ah you know it. |
| 14:07 | TimMc | Lajla: No, I googled it. I don't watch TV either. |
| 14:07 | Lajla | Ah |
| 14:07 | Lajla | No one understands me. |
| 14:13 | Borkdude | Nobody? |
| 14:17 | TimMc | clojurebot: Do you understand Lajla? |
| 14:17 | clojurebot | Titim gan éirí ort. |
| 14:17 | TimMc | Yeah, me neither. |
| 14:17 | Lajla | Borkdude, hmm |
| 14:17 | Lajla | no |
| 14:17 | Lajla | nobody |
| 14:18 | Borkdude | I think lein downloads some conflicting libraries or smth |
| 14:18 | Borkdude | if I remove the lib folder and type 'lein', it lists me the options |
| 14:18 | Borkdude | if I do lein deps, it downloads the libs |
| 14:18 | Borkdude | and again 'lein', I get this exception: http://pastie.org/1776027 |
| 14:19 | TimMc | Yeah, that does look like lib version conflict. |
| 14:19 | TimMc | Pastie a listing of your lib folder. |
| 14:22 | Borkdude | http://pastie.org/1776146 |
| 14:22 | Borkdude | it worked on the other system I was just on |
| 14:24 | TimMc | I have to wonder if the Clojure 1.1 in your dev folder is interfering with your Clojure 1.2. |
| 14:24 | TimMc | Have you tried blowing away both lib folders, ./classes, and your ~/.m2 folder? |
| 14:25 | Borkdude | wait |
| 14:25 | Borkdude | now I did: 'lein plugin install swank-clojure 1.3.0' |
| 14:25 | Borkdude | and it all works |
| 14:27 | Borkdude | I don't know what causes it |
| 14:28 | Borkdude | but at least things work... |
| 14:29 | currentB | I'm a little shaky on my understanding of protocols, but is it possible to use them to protect arithmatic operators from nil values? |
| 14:56 | Dantas | Hello everyone !! Im thinking about develop a web application using clojure ?is there any framework , i heard about compojure? How handle the states from a crud ? |
| 15:00 | bobo | Dantas: have a look at compojure, hiccup,enlive and clojureQL for example |
| 15:01 | bobo | clojureQL should make crud stuf pretty easy |
| 15:02 | Dantas | bobo: thanks a lot !! what is cojureQL ? |
| 15:02 | bobo | for sql |
| 15:03 | Dantas | im thinking use noSQL |
| 15:03 | bobo | ok, then dont look at it =) |
| 15:03 | Dantas | but, will be on my list, thanks a lot |
| 15:13 | dnolen | finally a sane way to log from lazy sequence computations, agents! |
| 15:15 | thorwil | is there a way to shorten/make-nicer something like (map fn1 (map fn2 (whatever)))? |
| 15:15 | dnolen | thorwil: comp |
| 15:16 | dnolen | (map (comp fn1 fn2) whatever) |
| 15:17 | thorwil | nice, thanks! |
| 15:17 | Dantas | wow ! nice ! |
| 16:14 | markoman | just watched a cool presentation of simplicity from clojure.blip.tv |
| 16:15 | Dantas | is the apply function like a reduce ? |
| 16:17 | morphling | Dantas: no, but some functions (like +) use reduce internally |
| 16:18 | amalloy | mrBliss`: your advice to ejackson earlier re with-redefs seems wrong. there's nothing about (fn ...) that "ignores/destroys" bindings. the map function returns a lazy sequence immediately, and when it is forced those bindings are no longer in scope. for his example, i'd use doseq (all he wants is side effects) |
| 16:19 | joshua__ | Can you guys give me the names of a few libraries with some of the "best" Clojure code? |
| 16:30 | markoman | joshua__: maybe clojure contrib source contains some good code? |
| 16:30 | joshua__ | markoman, thanks |
| 16:30 | Raynes | http://raynes.me/hfiles/contract.jpg |
| 16:30 | thorwil | Dantas: re apply: http://stackoverflow.com/questions/1257028/why-should-i-use-apply-in-clojure |
| 16:32 | Dantas | thorwil: thanks |
| 16:34 | pdk | [16:10] <Dantas> is the apply function like a reduce ? |
| 16:35 | pdk | (apply myfn 1 2 [3 4 5]) = (myfn 1 2 3 4 5) |
| 16:35 | pdk | (reduce myfn [1 2 3 4]) = (myfn (myfn (myfn 1 2) 3) 4) |
| 16:37 | Dantas | pdk: awesome ! thanks a lot . so the apply will expand the list as arguments to the function |
| 16:37 | pdk | yeah |
| 16:37 | pdk | basically if i want to compose some of the arguments to pass to a fn within one list |
| 16:37 | pdk | and then tack them on to the arguments list inline when i call that fn |
| 16:38 | pdk | sorta like how languages like java/c++ give you varargs |
| 16:38 | pdk | i.e. void main(String... args) |
| 16:38 | Dantas | yeah, perfect |
| 16:38 | pdk | though working in the opposite direction |
| 16:38 | pdk | reduce works in pairs |
| 16:38 | pdk | it assumes the function you give it takes 2 arguments |
| 16:38 | pdk | it will call it with the first two items in the list as arguments |
| 16:39 | pdk | then call it with the result of the first call and the third item |
| 16:39 | pdk | then the result of the second call and the fourth item etc for the rest of the list |
| 16:39 | Dantas | the reduce i understand .. the problem was that i create a too simple example using the + ! (reduce + '(1 2 3)) and (apply + '(1 2 3)) |
| 16:40 | pdk | yeah using + isn't too illuminating since reducing and applying + are equivalent anyway |
| 16:40 | Dantas | yeah ! |
| 16:40 | pdk | plus iirc + with more than two args gets compiled down to a reduction with a two-argument + |
| 16:40 | amalloy | &((juxt reduce apply) (partial list '+) [1 2 3]) |
| 16:40 | sexpbot | ⟹ [(+ (+ 1 2) 3) (+ 1 2 3)] |
| 16:41 | pdk | juxt is effin magic |
| 16:41 | pdk | (doc juxt) |
| 16:41 | clojurebot | "([f] [f g] [f g h] [f g h & fs]); Alpha - name subject to change. Takes a set of functions and returns a fn that is the juxtaposition of those fns. The returned fn takes a variable number of args, and returns a vector containing the result of applying each fn to the args (left-to-right). ((juxt a b c) x) => [(a x) (b x) (c x)]" |
| 16:41 | Dantas | wow ! :D |
| 16:42 | amalloy | this is just like the example with +, but uses (list +) so you can visualize the computation it would make instead of it actually running |
| 16:42 | pdk | yeah that shows you better what the difference looks like compiled |
| 16:42 | pdk | cause you can still see the structure it's producing |
| 16:42 | pdk | doing it with just + shows you only the end result which is the same in both cases |
| 16:43 | amalloy | i think i should take that code and paste it as a new answer to every question on stackoverflow about apply vs reduce |
| 16:43 | Dantas | yeah |
| 16:43 | pdk | then you have to explain juxt and partial :p |
| 16:44 | amalloy | pdk: feh. the example will be so awe-inspiring that they'll go look everything up |
| 16:48 | markoman | is there any general data validation library available for clojure? how about data sanitazion lib? |
| 16:52 | markoman | validation as comparing given string to some function like (is-number str), (is-length str len), (is-a-member str map) and so on? |
| 16:52 | amalloy | markoman: sounds like the recently-released pretzel |
| 16:53 | amalloy | $google clojure pretzel predicate |
| 16:53 | sexpbot | First out of 35 results is: Announcement: pretzel - a predicate library + call for suggestions ... |
| 16:53 | sexpbot | http://osdir.com/ml/clojure/2011-04/msg00196.html |
| 16:53 | amalloy | wtf, osdir? google isn't first? |
| 16:54 | pdk | bot was tempted by delicious pretzels |
| 16:54 | markoman | found github for it, thanks |
| 16:58 | markoman | looks-like-email? funny |
| 16:59 | amalloy | the moment i hear that, i fear for my life |
| 17:01 | david` | man i wish i could afford to go to this clojure class in june |
| 17:02 | amalloy | $google clojure github pretzel looks-like-email |
| 17:02 | sexpbot | First out of 20 results is: Re: Announcement: pretzel - a predicate library + call for ... |
| 17:02 | sexpbot | http://osdir.com/ml/clojure/2011-04/msg00259.html |
| 17:02 | amalloy | sexpbot: i hate you |
| 17:02 | amalloy | now i have to open a browser myself |
| 17:02 | Dantas | lol |
| 17:03 | amalloy | that search on the-real-google works |
| 17:04 | amalloy | looks-like-email is never implemented right. Just Don't Do It |
| 17:08 | markoman | i guess thats why it says looks like email, not is-email |
| 17:08 | amalloy | indeed |
| 18:42 | jsnikeris | So, I'm using ring.adapter.jetty/run-jetty to start a server. It seems like if I change and re-evaluate my ring handler, I need to restart the server. Is there a better way to do this? |
| 18:45 | jsnikeris | Also, I'm trying to write a restart-server procedure. The only way I can think of to implement this is to call (.stop *server), and then redefine *server* by calling run-jetty again. However I feel like I'm doing this the wrong way. Any pointers? |
| 18:46 | amalloy | $google ring reload wrap |
| 18:46 | sexpbot | First out of 17900 results is: Clojure Web Development with Ring |
| 18:46 | sexpbot | http://mmcgrana.github.com/2010/03/clojure-web-development-ring.html |
| 18:46 | amalloy | feh |
| 18:47 | amalloy | jsnikeris: there's a wrap-reload middleware or something like that |
| 18:47 | jsnikeris | ahh thanks |
| 18:47 | jsnikeris | I'll check that out |
| 18:48 | dnolen | hmm why can't lein find this clojar? http://clojars.org/org.lpetit/net.cgrand.parsley |
| 18:48 | dnolen | is it because it's the way it's named? |
| 18:52 | amalloy | dnolen: that seems weird |
| 18:54 | amalloy | dnolen: it looks to me like one of that project's dependencies has a weird mvn repo |
| 18:54 | amalloy | Cannot find layout implementation corresponding to: 'p2' for remote repository with id: 'ccw'. for project org.lpetit:net.cgrand.parsley |
| 18:54 | amalloy | or possibly the parsley pom.xml is malformed |
| 19:56 | dnolen | anybody here mess with paredit.clj for it's Clojure parser? |
| 20:02 | amalloy | dnolen: a tiny bit |
| 20:02 | dnolen | amalloy: thoughts? opinions? |
| 20:02 | amalloy | i made it undesrstand []{} before that was added to clojure-mode |
| 20:03 | amalloy | dnolen: about what? |
| 20:03 | dnolen | amalloy: any issues using the paredit.clj parser? |
| 20:04 | amalloy | i think i misunderstood your question? did you mean, have i used code from paredit for parsing clojure in non-paredit contexts? |
| 20:08 | dnolen | amalloy: yeah |
| 20:08 | amalloy | then no, i've never done that |
| 21:19 | TimMc | I would expect the Clojure compiler to expose its AST . |
| 21:41 | tomoj | TimMc: is its AST not just the forms being compiled? |
| 21:48 | livingston | is it not possible to have multiple call signatures for a function in defprotocol / defrecord ? |
| 21:51 | livingston | I tried by putting multiple signatures on the same line e.g. (foo [x y] [x y z]) and then in the record (foo ([x y] ..) ([x y z] ...)) this croaks. if I give it two independent definitions (foo [x y]) and (foo [x y z]) it seems happier and compiles at least |
| 22:06 | amalloy | livingston: isn't that basically what i said last night? that the former doesn't work but the latter does? |
| 22:07 | livingston | amalloy: probably. I was perhaps starting to fade at that point... |
| 22:08 | amalloy | (10:04:10 PM) amalloy: protocols don't support multiple arities in a single declaration. they're java-level methods |
| 22:08 | amalloy | (10:04:26 PM) amalloy: you would need (bar [x y]) (bar [x y z]) iirc |
| 22:08 | livingston | it's weird that the protocol needs it this way (foo [x y] [x y z]) but the record needs two independent lines |
| 22:10 | livingston | yep just confirmed that (defprotocol P (foo [x] [x y])) (defrecord R [] P (foo [x] ...) (foo [x y] ...)) works |
| 22:11 | livingston | any variation on that doesn't eg defprotocol P (foo [x]) (foo [x y]) makes things mad. |
| 22:37 | amalloy | anyone know who "owns" the clojure translation of "casting SPELs in lisp"? i was just looking over it and there are some things that could use fixing |
| 22:39 | livingston | oh, did that guy from last night start looking into that? (things change a lot in developing languages, I hope they tag it with the version it was based on, or last updated with) |
| 22:49 | amalloy | livingston: i don't know. but today i remembered it being mentioned so i went to look at it |
| 22:50 | livingston | there's been a version of that around since 1.1 at least. it would be easy for there to be something 'old' in it. |
| 22:54 | amalloy | livingston: for sure. the text indicates that they're using 1.1, but i didn't find anything especially "old", just generally subpar. eg some "sample output" contains an apostrophe that wasn't present in the input that created it |
| 22:56 | livingston | amalloy: well, as long as it's documented and not too far off at least it's not a disservice. updating it would benefit the community though. |
| 22:56 | amalloy | no, of course, i don't want to badmouth it, just fix it |
| 22:57 | livingston | oh I just meant it's existence wasn't going to screw anyone new up. |
| 22:57 | amalloy | it also uses (apply concat (map (fn [x] ...))) instead of (mapcat (fn [x] ...)) in a section where they're like "here's a function for fixing up the clojure-specific aspects of the output; explaining it is beyond the scope of this book". is mapcat new? |
| 22:57 | livingston | ,(doc mapcat) |
| 22:57 | clojurebot | "([f & colls]); Returns the result of applying concat to the result of applying map to f and colls. Thus function f should return a collection." |
| 22:58 | livingston | how do you make it tell you when it showed up? |
| 22:58 | amalloy | livingston: usually i don't bother because a lot of functions lie |
| 22:58 | amalloy | but ##(meta #'mapcat) |
| 22:58 | sexpbot | ⟹ {:ns #<Namespace clojure.core>, :name mapcat, :file "clojure/core.clj", :line 2117, :arglists ([f & colls]), :added "1.0", :doc "Returns the result of applying concat to the result of applying map\n to f and colls. Thus function f should return a collection."} |
| 22:59 | livingston | it wouldn't surprise me that it's been around that long, it's a pretty core thing in a lisp. |
| 22:59 | livingston | ,(meta #'mapcat) |
| 22:59 | clojurebot | {:ns #<Namespace clojure.core>, :name mapcat, :file "clojure/core.clj", :line 2117, :arglists ([f & colls]), :added "1.0", :doc "Returns the result of applying concat to the result of applying map\n to f and colls. Thus function f should return a collection."} |
| 22:59 | livingston | just curious. |
| 23:00 | livingston | what's the difference between these two bots anyway? |
| 23:00 | amalloy | livingston: they were built from the ground up independently. there are a lot of differences |
| 23:02 | livingston | amalloy: i recall a lisp channel having something like sexpbot, but maybe I'm confused, I wonder if they are related. |
| 23:02 | livingston | why both building two, work together ;) |
| 23:02 | amalloy | livingston: lambdabot lives in #lisp, i think |
| 23:02 | livingston | AH! that's the one |
| 23:02 | amalloy | but sexpbot is in a lot of channels, so you might have found him anyway |
| 23:03 | livingston | amalloy: it's possible lambda bot is signaled with something like sexp or something that might have been the commonality |
| 23:07 | amalloy | anyway sexpbot was started by Raynes, and i joined in october or so. clojurebot is owned by hiredman |
| 23:08 | livingston | good to know. I see hiredman talk to clojurebot a lot, I figured it's probably his. |
| 23:12 | ssideris | hello... does anyone know how to pass jvm flags from leiningen? I'm trying to debug with JSwat (see http://markmail.org/message/s42sxxv6a2zshwdy ) |
| 23:13 | ssideris | the leiningen sample.project.clj has this :jvm-opts ["-Xmx1g"] |
| 23:13 | ssideris | but it's unclear whether these are applied when I do "lein swank" |
| 23:13 | amalloy | they are |
| 23:13 | livingston | that looks like it - that's sen |
| 23:13 | livingston | oop accidental enter |
| 23:15 | ssideris | amalloy: well, it seems that JSwat can't connect to the jvm, that's why I thought they weren't |
| 23:15 | ssideris | but it must be some other problem then... |
| 23:16 | amalloy | ssideris: i've used the jvm-opts setting to make the swank server accept incoming java-debugger connections, so it works |
| 23:17 | livingston | how are you setting jvm-opts? |
| 23:18 | ssideris | livingston: :jvm-opts ["-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n"] |
| 23:18 | amalloy | or it's at least supposed to |
| 23:18 | amalloy | oh, good catch livingston |
| 23:18 | livingston | that's how you'd normally do things like that but in lein given you example was a vector |
| 23:19 | livingston | I'm guessing it expects multiple string? |
| 23:19 | amalloy | i would assume so, yeah |
| 23:19 | ssideris | let me try... |
| 23:19 | amalloy | ["-Xdebug" "-Xrun..."] |
| 23:19 | ssideris | yep! that's what it is! |
| 23:19 | ssideris | thanks a lot :-) |
| 23:20 | livingston | I caught a bug in the swank mvn target this way... |
| 23:23 | livingston | ok it was my "mistake" in the first place for using extend instead of having defrecord refer to my protocols directly, but if I ever offer to fix that mistake again, just shoot me. |