2012-12-01
| 01:09 | Sgeo__ | Is there a way for me to make my own Var$Unbound? |
| 01:09 | Sgeo__ | better yet, unbound var with no particular name |
| 01:14 | Raynes | Sgeo__: Why? |
| 01:19 | Raynes | Sgeo__: (defn who-cares [] (let [s (gensym)] (intern *ns* s) @(resolve s))) Could do something like this. You said with no particular name, but does it matter if it's a random gensym? |
| 01:20 | Raynes | You'd have to create a Var with no name to create an Unbound with no name. Not sure if that is possible. |
| 01:20 | Raynes | Wuh, I guess you can. |
| 01:21 | Raynes | Sgeo__: (clojure.lang.Var$Unbound. (clojure.lang.Var/create)) |
| 01:21 | Raynes | This seems to work. |
| 01:22 | Sgeo__ | Neat |
| 01:22 | Raynes | Now tell me why damn it. |
| 01:22 | Raynes | I can't bear the suspense. |
| 01:22 | Sgeo__ | Oh, as for the why: It seems like it might be a good way to represent a lazy value that has not been calculated yet |
| 01:22 | Sgeo__ | Or at least, semantically I feel like it makes some sort of sense |
| 01:22 | Raynes | Isn't that a promise? |
| 01:23 | Sgeo__ | How does letfn work? |
| 01:23 | Sgeo__ | Probably does make more sense to do a promise, I guess |
| 01:24 | Sgeo__ | But then you have to @ the promise, unlike with the var, where... uh, I guess you do need to deref that too unless it's storing a fn |
| 01:36 | jondavidjohn | Anyone willing to help review a clojure novice's code? .... http://codereview.stackexchange.com/q/19203/2776 |
| 01:44 | tomoj | I wonder why clj-http won't parse json bodies of responses with 'exceptional' status |
| 01:52 | muhoo | i'd use cheshire for the json parsing |
| 03:46 | philr_ | Hello friends. I have a newbie question: why don't my for loops work in core.clj? |
| 03:49 | andrewmcveigh | philr_: If you post your code that's not working (and the error if there is one) to a pastebin like refheap, we might be able to help better. |
| 03:49 | philr_ | Sure. I have a minimal example. |
| 03:49 | philr_ | Let me do that for you... |
| 03:51 | philr_ | So I made a new project with "lein new app test". Then added this to the skeleton: |
| 03:51 | philr_ | https://www.refheap.com/paste/7186 |
| 03:52 | philr_ | Now "lein run" prints "Hello, World!" and nothing else. |
| 03:53 | andrewmcveigh | OK, so... for is lazy, and as "println" doesn't return a value, and you're not using that (nil) value, (println x) is not being called. |
| 03:53 | philr_ | Aha! |
| 03:54 | philr_ | So... doseq? |
| 03:54 | andrewmcveigh | either use doseq in place of for (for "side-effecting" code) |
| 03:54 | andrewmcveigh | or, if for was to return a value, you can wrap it in doall to force the evaluation. |
| 03:55 | philr_ | doseq it is. Boy is my face red. Thanks muchly! |
| 03:55 | andrewmcveigh | no probs. |
| 04:52 | Raynes | I haven't seen your code, but that's what I'm thinking based on your description. |
| 04:53 | ucb | ah, the top level invocation is like (-> client (fn1) (fn2) ...) |
| 05:04 | Raynes | Yes, you could change it to (when client (-> client (fn1) (fn2))) |
| 05:04 | Raynes | But |
| 05:04 | ucb | sure, but fn1 might close the connection and so fn2 gets nothing to work with |
| 05:04 | Raynes | If one computation relies on the result of the last one possibly being ni… Yes. Okay. |
| 05:04 | Raynes | You want -?> then. |
| 05:04 | ucb | yeah :) |
| 05:05 | ucb | great, thanks! \o/ |
| 05:06 | bbloom | seems odd that a failed operation on a client causes nil to be returned rather than an error code or an exception or something |
| 05:07 | ucb | oh, not my choice, when the other party doesn't like a particular packet you send it it'll just close the connection |
| 05:07 | ucb | I could alternatively throw an exception in that case |
| 05:07 | philr_ | Raynes: Yep. "lein new app test". |
| 05:08 | bbloom | ucb: what is "client" ? is that a type you've created? |
| 05:08 | ucb | well, I lie, it won't just close the connection, it'll let you know it didn't like your last message and close the connection |
| 05:08 | ucb | bbloom: it's the tcp-client in the aleph library |
| 05:09 | bbloom | ucb: tcp? |
| 05:09 | bbloom | ucb: or what protocol? |
| 05:10 | ucb | bbloom: tcp, yes |
| 05:10 | Raynes | bbloom: I think I'd prefer nil over an exception. |
| 05:10 | bbloom | Raynes: I'd prefer a status code :-P |
| 05:11 | ucb | I personally prefer nil too |
| 05:11 | Raynes | bbloom: Don't know what his purpose is, etc. |
| 05:11 | Raynes | He may not need a status code. |
| 05:11 | bbloom | yeah, fair enough |
| 05:12 | ucb | well, right now I'm working on the handshake, and its outcome is binary |
| 05:12 | ucb | I'm happy getting a nil at the end if it failed |
| 05:12 | ucb | otherwise, I get the client to start sending data |
| 05:25 | abp | Hm, can I, when getting passed forms in a macro, find unresolvable symbols in the forms? lexical bindings like let must be considered. |
| 05:39 | borkdude | any general advice in here whether to upgrade to 10.8 OSX? what would I gain from it (except for incompatibility problemsn)? |
| 05:42 | ucb | borkdude: you'd upgrade your wallet to a lighter one too |
| 05:45 | Apage43 | you know, I did do the upgrade, and I can't think of anything it added that's really all that useful |
| 05:48 | Raynes | New notifications stuff. |
| 05:48 | Apage43 | right. but most of the apps I wanted notifications from worked fine with growl |
| 05:49 | Raynes | It's still a significant improvement. |
| 05:49 | Apage43 | *shrug* |
| 05:49 | Apage43 | I did get iTunes 11 |
| 05:49 | Raynes | Grown exists *because* this didn't exist. |
| 05:50 | clj_newb_2345 | how do i dfine a *.clj file that is _auto included_ into every namespace? I want to have my own defn macro (which calls the clojure.core/defn) to be the default defn in all of my code |
| 05:50 | Apage43 | I found that to be quite an improvement |
| 05:51 | Raynes | You can't. |
| 05:52 | clj_newb_2345 | I can't? |
| 05:52 | clj_newb_2345 | or someone else can't? |
| 05:53 | Raynes | You, sir, cannot. |
| 05:53 | clj_newb_2345 | can clojure.core ahckers do this? |
| 05:55 | Raynes | I don't think anybody can do this. |
| 05:56 | clj_newb_2345 | what if we got Gosling and Hickey working on it together; between rewriting Clojure and the JVM, would this be possible? |
| 05:56 | Apage43 | it's not a language issue, I mean, it's just not a featue that's there |
| 05:57 | clj_newb_2345 | what if Trovalds also joined the team so we could make changes ot the Linux kernel to support this |
| 05:57 | Apage43 | namespaces pull in clojure.core by default and don't really provide a way to change or modify that |
| 05:57 | clj_newb_2345 | and Grove joined too, so we couuld modify x86 instructions |
| 05:57 | clj_newb_2345 | hmmm |
| 05:57 | clj_newb_2345 | so basically, this wouuuld mean hacking "require" |
| 05:57 | Apage43 | (ns) |
| 05:57 | Apage43 | rather |
| 05:57 | clj_newb_2345 | hmm |
| 05:57 | Raynes | Wow. Apple Reminders is amazingly sufficient. |
| 05:58 | clj_newb_2345 | this is interesting, so I can just repalce the top of all files with |
| 05:58 | clj_newb_2345 | (my-ns ........ ) |
| 05:58 | Apage43 | well no |
| 05:58 | clj_newb_2345 | problem is, how do I get clojure to find (my-ns ... ) ? |
| 05:58 | Apage43 | because (my-ns) won't be available |
| 05:58 | clj_newb_2345 | since I need to define the function somewhere |
| 05:58 | clj_newb_2345 | fuck |
| 05:58 | Apage43 | as its not in clojure.core |
| 05:58 | clj_newb_2345 | what if I added my-ns into clojure.core? |
| 05:58 | clj_newb_2345 | then I'd be set |
| 05:59 | clj_newb_2345 | I feel like this is similar to modifying the physics of the universe in order to make a red shirt look blue |
| 05:59 | Apage43 | sure, but you'd have to make sure that happens before anything tries to load the files that use it |
| 05:59 | clj_newb_2345 | hmm |
| 05:59 | clj_newb_2345 | can I get lein to define my-ns for me? |
| 05:59 | Apage43 | i imagine that could be problematic in general, especially so if you use AOT |
| 06:00 | Apage43 | unless you're using AOT this is all mostly done at "run time" |
| 06:00 | clj_newb_2345 | I do have one gen-class |
| 06:00 | clj_newb_2345 | for a custom exception class I wrote |
| 06:00 | clj_newb_2345 | everything else is not AOT |
| 06:00 | Apage43 | anyway |
| 06:01 | Apage43 | this is all very ugly and there's probably a … slightly.. less terrible way to accomplish the same thing |
| 06:01 | clj_newb_2345 | alright |
| 06:01 | clj_newb_2345 | I could spare an extra :use line |
| 06:01 | clj_newb_2345 | at the start of every *.clj file |
| 06:01 | Apage43 | I feel like there might be some http://www.perlmonks.org/index.pl?node_id=542341 going on |
| 06:02 | clj_newb_2345 | i want to redefine defn |
| 06:02 | Apage43 | why? |
| 06:02 | clojurebot | why is the ram gone is <reply>I blame UTF-16. http://www.tumblr.com/tagged/but-why-is-the-ram-gone |
| 06:02 | clj_newb_2345 | I want something like type hints, except it'sll be "type comment" |
| 06:02 | clj_newb_2345 | i.e., it's not a thype hint, but it's just a short comment describiing the incoming type |
| 06:03 | clj_newb_2345 | so I'd like something like (defn foo [ \n a "this is a House object" \n b "this is a Car object" ] ... ) |
| 06:03 | clj_newb_2345 | that's all |
| 06:03 | clj_newb_2345 | wait wait, meant [\n a "this implements the House protocol" \n b "this impelments the Car protocol" ] |
| 06:03 | mpenet | you could just use metadata, no need to redefine things |
| 06:04 | clj_newb_2345 | use metadata on the arguments of a defn? |
| 06:04 | clj_newb_2345 | mpenet : can you paste sample code? |
| 06:04 | mpenet | on the fn itself |
| 06:04 | clj_newb_2345 | I really want the comments "inline" |
| 06:05 | Apage43 | (defn foo [^{:comment "My comment text"} arg1 ^{:comment "More comment text"} arg2]) |
| 06:05 | Apage43 | actually i think that gets thrown out |
| 06:06 | Apage43 | ah, nope |
| 06:06 | mpenet | if that's just for information as clj_newb_2345 seems to want, this would be ok |
| 06:07 | Apage43 | (meta (first (first (:arglists (meta #'foo))))) => {:comment "My comment text"} |
| 06:07 | Apage43 | &(meta #'clojure.core/+) |
| 06:07 | lazybot | ⇒ {:ns #<Namespace clojure.core>, :name +, :file "clojure/core.clj", :line 920, :arglists ([] [x] [x y] [x y & more]), :added "1.2", :inline-arities #<core$_GT_1_QMARK_ clojure.core$_GT_1_QMARK_@166f453>, :inline #<core$nary_inline$fn__3842 clojure.core$nary_... failed to paste: peer not authenticated |
| 06:07 | Apage43 | the arg metadata you attach is on the symbols in :arglists there |
| 06:08 | Apage43 | in fact, a type hint is just a metadata of the form {:tag theclass} |
| 06:08 | clj_newb_2345 | (defmacro my-defn [fname args & body] `(defn ~fname ~(apply vector (map first (partition 2 args))) ~@body)) |
| 06:08 | clj_newb_2345 | that is all I need |
| 06:08 | clj_newb_2345 | I don't use the multiple definition opption of defn |
| 06:08 | mpenet | Apage43: yes, type hints are under :tag |
| 06:09 | Apage43 | clj_newb_2345: wait, you don't even want to keep the strings? You're just throwing them out? |
| 06:10 | clj_newb_2345 | I don't wnat to keep this |
| 06:10 | clj_newb_2345 | it's purely to make it easier for me to read |
| 06:10 | clj_newb_2345 | I apologize if that was not clear. |
| 06:10 | clj_newb_2345 | thanks to evere who helped talk me out of modifying clojure.core, I like this solution more :-) |
| 06:10 | Apage43 | (defn foo [a #_"This will be ignored" b #_"so will this"] (+ a b)) |
| 06:10 | Apage43 | (foo 1 1) => 2 |
| 06:11 | clj_newb_2345 | lol |
| 06:11 | Apage43 | Prefixing a thing with #_ causes it to be ignored |
| 06:11 | clj_newb_2345 | reader macros |
| 06:11 | clj_newb_2345 | I'm an idiot |
| 06:11 | clj_newb_2345 | hmm |
| 06:11 | clj_newb_2345 | this is even better ,no need to define a new macro |
| 06:11 | Sgeo__ | ,Float/NaN |
| 06:11 | clojurebot | NaN |
| 06:13 | Apage43 | or just take the line break and use regular comments |
| 06:13 | Apage43 | instead of almost hacking up everything =P |
| 06:13 | clj_newb_2345 | man; this is brilliant |
| 06:15 | Apage43 | This is the first time I've run into a place to use #_ though |
| 06:16 | clj_newb_2345 | I like the ; more |
| 06:16 | clj_newb_2345 | now my edditor even clorizes the type |
| 06:16 | clj_newb_2345 | and I can do weird thigns like ; Hash<String, Hash<String, Animal>> |
| 06:16 | Apage43 | right. this is almost certainly what you want |
| 06:18 | clj_newb_2345 | this is fucking brilliant |
| 06:18 | clj_newb_2345 | my code looks a little weird, since many functions are now 2-3x as long (due to the args eacn on it's own line) |
| 06:18 | clj_newb_2345 | but I like it |
| 06:42 | ucb | are java integers 32 bits? (apologies if this is a stupid question) |
| 06:42 | ucb | more precisely, I'm wondering if rand-int Integer/MAX_VALUE will generate a 32-bit value |
| 06:44 | ucb | seems to be the case |
| 06:46 | Guest29562 | @ucb The Java Specification says that it is: "The integral types are byte, short, int, and long, whose values are 8-bit, 16-bit, 32-bit and 64-bit signed two's-complement integers, respectively" |
| 06:46 | ucb | Guest29562: thanks! |
| 06:54 | borkdude | what is the clojure analogue of for example liftP in Haskell? |
| 07:17 | borkdude | hmm, is this really much of an improvement…? https://www.refheap.com/paste/7187 |
| 07:18 | josteink | how do I do a case-insensitive substring search in clojure? |
| 07:18 | josteink | something akin to |
| 07:18 | josteink | (def windows (contains? os-name "windows") |
| 07:22 | andrewmcveigh | &(re-seq #"(?i)windows" "WinDOws blah blah ...") |
| 07:22 | lazybot | ⇒ ("WinDOws") |
| 07:24 | borkdude | josteink what about smth like this? https://www.refheap.com/paste/7188 |
| 07:24 | josteink | andrewmcveigh & borkdude: thanks both :) |
| 07:25 | borkdude | josteink you could do some preprocessing on the pattern to lowercase that as well |
| 07:25 | borkdude | andrewmcveigh solution is even better, always forget about re-seq |
| 07:26 | andrewmcveigh | re-seq is awesome :) |
| 07:27 | borkdude | yeah |
| 07:27 | rbarraud | Lambda is awesome; everything else is just derivative :-) |
| 07:29 | borkdude | there should be a +1 button on clojuredocs so you can look at the most popular functions ;) |
| 07:30 | borkdude | regex driven development |
| 07:30 | josteink | borkdude: that just feels dirty :) |
| 07:30 | borkdude | hehe |
| 07:33 | borkdude | re-seq and juxt… never forget about those |
| 07:38 | borkdude | (was note to self) |
| 08:55 | borkdude | Raynes hm, it only occured to me now, is your Twitter name inspired by the IO Monad? |
| 09:50 | tomoj | browser repl broken in r1535? |
| 11:40 | clojure-newb | hey guys… I'm doing : (map #(hash-map :key1 (first %) :key2 (nth % 1) :key3 (last %))) to build a hash-map out of a vector, which is fairly concise, but I don't like the nth, first and last, can I use destructuring in this form or do it another way ? |
| 11:43 | borkdude | (let [[a b c] v] #{:k1 a :k2 b :k3 c}) |
| 11:45 | jeremyheiler | &(apply hash-map [:a 1 :b 2 :c 3]) |
| 11:45 | jeremyheiler | would that work for you? |
| 11:47 | jeremyheiler | hmm no. sorry. your keys are not in yoru vector |
| 11:48 | jeremyheiler | perhaps use zipmap |
| 11:48 | jeremyheiler | ,(zipmap [:key1 :key2 :key3] [1 2 3]) |
| 11:48 | clojurebot | {:key3 3, :key2 2, :key1 1} |
| 11:49 | borkdude | ,(apply hash-map (interleave [:a :b :c] v)) |
| 11:49 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: v in this context, compiling:(NO_SOURCE_PATH:0)> |
| 11:49 | borkdude | multiple ways to go |
| 11:50 | clojure-newb | borkdude: that looks cool |
| 11:50 | borkdude | admittedly I like zipmap the best |
| 11:50 | borkdude | ,(doc zipmap) |
| 11:50 | clojurebot | "([keys vals]); Returns a map with the keys mapped to the corresponding vals." |
| 11:50 | clojure-newb | jeremyheller: thats cool too |
| 11:51 | clojure-newb | so many ways, I've got loads to learn |
| 11:51 | jeremyheiler | clojure-newb, that's what makes it fun |
| 11:52 | jeremyheiler | there's always more to discover |
| 11:52 | clojure-newb | jeremyheiler: yeah, though sometimes I spend too long making it perfect instead of working on the real problem :-) |
| 11:52 | jeremyheiler | haha, you're not alone there! |
| 12:03 | borkdude | jeremyheiler that's the risk of such a cool language.. never done refactoring ;) |
| 12:29 | abev | bye |
| 12:29 | abev | quit |
| 12:29 | abev | exit |
| 12:31 | jondavidjohn | any clojure affcianados want to give me a quick code review? I'm just learning and want to make sure I'm leaning into the strengths of the language... http://codereview.stackexchange.com/q/19203/2776 |
| 12:34 | gfredericks | ooh you could destructure decks |
| 12:34 | gfredericks | [deck1 deck2] (split-at middleish cards) |
| 12:35 | jondavidjohn | nice, so I wouldn't have to do nth |
| 12:35 | gfredericks | right |
| 12:35 | gfredericks | this thing needs line numbers |
| 12:36 | gfredericks | (->> (interleave deck1 deck2) flatten) is a somewhat superfluous use of ->> |
| 12:36 | gfredericks | it's not terrible though I can imagine liking it |
| 12:37 | gfredericks | indentation on overhand is bad |
| 12:37 | jondavidjohn | yeah, I think it reads well |
| 12:37 | gfredericks | (the if lines up with the parent let) |
| 12:37 | gtrak | do you guys know of a shortcut for ring-mock requests with session-cookies? |
| 12:38 | gfredericks | looks like you could stand to make a helper out of (partial partition-by (fn [_] (zero? (rand-int 2)))) |
| 12:38 | gfredericks | I don't think (vec cards) gets you anything |
| 12:39 | gfredericks | oh wait |
| 12:39 | gfredericks | I had to scroll to see more code |
| 12:40 | jondavidjohn | I know functions use - as a word seperator, should bindings follow the same form? |
| 12:40 | gfredericks | yeah good point |
| 12:40 | gfredericks | I hadn't noticed that |
| 12:40 | gfredericks | underscores are generally just for interop with other systems that use them |
| 12:40 | jondavidjohn | ok, cool |
| 12:41 | tmciver | jondavidjohn: I think the use of flatten in riffle is redundant. |
| 12:41 | tmciver | interleave produces a seq |
| 12:41 | tmciver | ,(interleave [1 2 3] [4 5 6]) |
| 12:41 | gfredericks | calling seq in mongean is probably unnecessary as well |
| 12:41 | clojurebot | (1 4 2 5 3 ...) |
| 12:42 | gfredericks | indentation for the ->> form in pile is bad |
| 12:42 | jondavidjohn | tmciver: the decks are chunked with partition-by |
| 12:42 | tmciver | jondavidjohn: also, it looks like you don't use card_count in overhand. |
| 12:43 | gfredericks | I think most of the recursion can be done with recur to save stack space |
| 12:44 | jondavidjohn | I tried but it was throwing an error |
| 12:44 | gfredericks | wat. |
| 12:44 | jondavidjohn | do I need to reverse the if to use recur? |
| 12:44 | gfredericks | no |
| 12:44 | gfredericks | what error? |
| 12:44 | jondavidjohn | just swap out the calls |
| 12:44 | jondavidjohn | I'll test |
| 12:45 | jondavidjohn | nice, I guess it works fine |
| 12:46 | gfredericks | though now that I think about it maybe you'd consider it more natural to use iterate |
| 12:46 | gfredericks | rather than building the iteration into the shuffling functions |
| 12:47 | gfredericks | if you really like the API you have, you could (defn mongean ([cards] ...actual work...) ([cards times] (nth (iterate mongean cards) times))) I think |
| 12:47 | jondavidjohn | ahh, nice since it's built into the lang with iterate, i'll remove the recursion |
| 12:48 | gfredericks | recursion doesn't end up being necessary in clojure very often |
| 12:48 | gfredericks | loop is a class n00b-trap |
| 12:48 | jondavidjohn | (iterate (mongean [..]) 4) seems pretty natural |
| 12:48 | gfredericks | oh no that's not quite how iterate works |
| 12:49 | gfredericks | iterate returns an infinite lazy seq of [deck (mongean deck) (mongean (mongean deck)) ...] |
| 12:49 | gfredericks | so you can use nth to get the result you want |
| 12:49 | gfredericks | the second arg to iterate is the original deck |
| 12:49 | jondavidjohn | ahh |
| 12:50 | jondavidjohn | thanks! |
| 12:51 | gfredericks | np |
| 12:51 | jondavidjohn | lots of good stuff, still really impressed with how much I could accomplish in such terse (yet understandable) code.. |
| 12:53 | tmciver | jondavidjohn: just curious, why do you do the (somewhat) complicated calculation of middleish in riffle? I would imagine you'd ideally want to used some kind of guassuan randomization of the middle position. |
| 12:54 | jondavidjohn | just my formulation of giving the splitting of the deck a reasonable margin of error based on deck size |
| 12:54 | jondavidjohn | with a minimum of 2 |
| 12:54 | jondavidjohn | totally open to a better way |
| 12:54 | tmciver | ah, I think I see. You're choosing a random card within 10% of the center of the deck? |
| 12:54 | jondavidjohn | right |
| 12:55 | tmciver | cool |
| 12:55 | jondavidjohn | is there a more idiomatic way? |
| 12:55 | gfredericks | does anybody know about future plans for the js/foo and js* forms in cljs? Are they intended to be permanent? |
| 12:56 | jondavidjohn | also, I guess it's ok to do a lot of work in my let bindings? |
| 12:56 | jondavidjohn | most of the functions' work are done there |
| 12:56 | gfredericks | jondavidjohn: it's worth checking for refactoring opportunities, but not generally terrible |
| 12:57 | tmciver | jondavidjohn: yeah, that's typical. |
| 12:57 | jondavidjohn | i find it's a side effect of immutibility |
| 12:57 | jondavidjohn | at least that's what drove me in that direction |
| 12:57 | gfredericks | jondavidjohn: yeah; I think the main tradeoff is readability; so as long as you're satisfied with that, it's ok |
| 12:58 | jondavidjohn | cool, thanks again, both of you! later! |
| 12:59 | cg_morton | Hey clojure fans. Where would you recommend to start learning for someone with coding experience but who is new to Lisps? |
| 13:00 | gfredericks | 4clojure is easy to get started with |
| 13:00 | Foxboron | cg_morton, clojure koans is awsome |
| 13:00 | Foxboron | I find them more fun then 4clojure |
| 13:01 | Foxboron | but, clojure koans needs leiningen to actually use them, so as gfredericks said, 4clojure is easier :) |
| 13:01 | cg_morton | I suspect I will want leiningen eventually |
| 13:02 | cg_morton | well anyway, I will check those out. Thanks! |
| 13:19 | jondavidjohn | gfredericks: ok... so run that iterate usage by me again? something like ... [cards times] (nth times (iterate (riffle cards) times) ? |
| 13:20 | jondavidjohn | or i mean ... [cards times] (nth times (iterate riffle cards) |
| 13:20 | jondavidjohn | O |
| 13:22 | tmciver | jondavidjohn: (nth (iterate riffle cards) times) |
| 13:23 | tmciver | to riffle the initial deck 'times' times. |
| 13:23 | gfredericks | crate's defpartial creates some interesting metadata and I'm curious if anybody understands the use case |
| 13:24 | gfredericks | jondavidjohn: just like tmciver said; also if you're interested you might enjoy pondering why ((apply comp (repeat times riffle)) cards) is equivalent |
| 13:25 | gfredericks | (I think iterate is more readable though) |
| 13:25 | jondavidjohn | I'll check it out |
| 13:25 | jondavidjohn | yeah, definitely a clean alternative to my recur |
| 13:27 | jondavidjohn | what if the iterating function has multiple arguments? |
| 13:27 | jondavidjohn | does it break down there? |
| 13:27 | gfredericks | yeah can't iterate that way |
| 13:27 | jondavidjohn | cool |
| 13:27 | gfredericks | you should be able to make it work by partially applying the rest of the args |
| 13:27 | gfredericks | like (iterate #(foo % n) cards) |
| 13:37 | hcumberdale | Hi ,) |
| 13:40 | jeremyheiler | hello, hcumberdale |
| 13:40 | muhoo | what are people using to create json services these days? wakeful? bishop? shoreleave? raw ring handlers? |
| 13:41 | muhoo | liberator? there are so many :-/ |
| 13:42 | muhoo | *sigh* |
| 13:43 | gfredericks | wakeful looks crazy-simple, which is what I wanted in this instance |
| 13:44 | gfredericks | wait it also looks weird o_O |
| 13:44 | hhutch | muhoo: i am working with shoreleave right now, i was using fetch before, i like it |
| 13:45 | gfredericks | actually I don't want json at all I want edn |
| 13:46 | hhutch | if you are using clojurescript, i recommend shoreleave-remote |
| 13:46 | gfredericks | right now I want something that's under 10 lines |
| 13:46 | gfredericks | it's just for a demo |
| 13:46 | gfredericks | shoreleave looks too serious |
| 13:47 | gfredericks | I'll do compojure if nothing else |
| 13:49 | hhutch | gfredericks: my implementation is not at all 'serious' .. have you seen this? https://github.com/robert-stuttaford/demo-enfocus-pubsub-remote.git |
| 13:49 | hhutch | that's what i've been using for reference |
| 13:50 | gfredericks | hhutch: the src/depr/server.clj has a lot of noise in it for my use; the demo is focusing on the client-side, so I just want to setup the server as basically as possible |
| 13:53 | gfredericks | does anybody know if it's possible to override lein-cljsbuild's version of CLJS via an explicit dependency and lein checkouts? |
| 13:53 | gfredericks | lein deps :tree doesn't even list cljs :/ |
| 13:56 | C-Keen | Hi! If anyone of you is visiting 29C3 in Hamburg this year, you may want to drop by at the lisper/schemer assembly. Maybe you want to spread some clojure love too by doing a workshop? Tell me or write it up on https://events.ccc.de/congress/2012/wiki/The_%28un%29employed_schemers_%26_lispers_guild. Thanks! |
| 14:22 | muhoo | shoreleave seems to have the weight of popularity behind it. but then so did/does noir, and i realized its limitations quickly enough :-/ |
| 14:23 | seangrove | muhoo: I'm using shoreleave, but haven't used noir much - what limitations did you come across? |
| 14:24 | muhoo | it uses atoms and non-functional stuff to act like django, which was nice coming from that rails-y world, but then not so much. |
| 14:24 | muhoo | also lots of macros which don't compose so well. |
| 14:25 | muhoo | shoreleave looks heavy to me, and i'm suspicious of that now. |
| 14:25 | seangrove | Intersting, good to know |
| 14:25 | muhoo | maybe i shouldn't be. |
| 14:25 | seangrove | I'm only using shoreleave pubsub right now, it's been reasonably nice |
| 14:25 | seangrove | Can't speak to anything else though |
| 14:27 | muhoo | i'll try it. i'm thinking maybe before i try to wrap my brain around some big thing, i should try to solve the problem first with low-level tools, and only move up to something heavier once i find myself with a specific need to write something, and instead of reinventing that wheel myself. |
| 14:28 | seangrove | That's always a good approach |
| 14:29 | muhoo | right now my paid work is having to live inside the brains of the people who wrote android, and it's making me crazy. so that may be coloring my feelings about other things too, and not in a good way. |
| 14:29 | seangrove | I tried to get into cljs a year ago or so without having a good understanding of js, which was a big mistake |
| 14:30 | seangrove | Maybe it'll reasonable in the future, but it was important to build several very large apps in javascript before I was able to make the jump to cljs properly |
| 14:30 | muhoo | interesting, yes, sounds like the mistake i made of trying to learn clojure without understanding java :-) |
| 14:30 | seangrove | Heh, I still don't understand Java very well, but Clojure on that side is pretty robust to shield you from it for awhile |
| 14:31 | seangrove | It'll break down eventually, but I like that you can be productive and explore without a super deep Java background |
| 14:31 | muhoo | seangrove: wait until you get to this: http://chasemerick.files.wordpress.com/2011/07/choosingtypeforms2.png?w=640 |
| 14:35 | seangrove | Well, I'm glad that story is there when needed, but it does look intimidating |
| 14:37 | muhoo | the clojurebook.com has a pretty good explanation of all that stuff. but, who knows, you could maybe get by a very long time without ever having to know it. |
| 14:37 | muhoo | mean, i still don't know X86 assembler :-) |
| 14:37 | seangrove | So far it's been reasonably easy to avoid interop beyond just insantiating basic classes |
| 14:38 | seangrove | But anyway, far more interested in cljs for the time being |
| 14:38 | seangrove | Thinking about trying to build a cljs around ember.js using the same techniques as jayq |
| 14:38 | muhoo | AVR assembler, yes. ARM assembler, yes. but x86 assembler looked so annoying to me i said i'd never learn it, and, so far, never have. |
| 14:39 | seangrove | Heh, is that what's holding you back now? |
| 14:39 | muhoo | that sounds interesting. i haven't used ember.js, but native cljs wrappers of stuff is A Good Thing. |
| 14:39 | seangrove | "Damn, if *only* I had learned x86 assembly!" |
| 14:39 | seangrove | (said few people, ever) |
| 14:40 | muhoo | if i were writing windoze viruses, maybe, then x86 assember would be necessary. but i've no interest in that world. |
| 14:41 | muhoo | avr assembler, however, is kind of fun (embedded microcontrollers), though it's been years. |
| 14:48 | seangrove | bbloom: You around? |
| 14:49 | bbloom | seangrove: what's up? |
| 14:49 | seangrove | Wanted to share: http://jida.herokuapp.com/?query-id=50b9aa72e4b0b66235465dae |
| 14:49 | bbloom | oh neat, i'll check it out |
| 14:50 | seangrove | Made some progress, but the majority of it came from wei_ |
| 14:50 | bbloom | heh, great, i'm an example :-) |
| 14:51 | muhoo | it uses bootstrap.js? |
| 14:51 | seangrove | muhoo: Yeah |
| 14:51 | seangrove | Well, not js, just the css, I think |
| 14:52 | bbloom | cool stuff |
| 14:56 | muhoo | wow dnolen@Davids-MacBook-Pro.local 738 commits! |
| 14:57 | muhoo | i dunno what kind of coffee he's drinking, but puts him far and away the most prolific committer |
| 14:57 | jonasen | seangrove: cool |
| 14:57 | p_l | muhoo: well... some git workflows create a *lot* of commits |
| 14:57 | jonasen | seangrove: http://jida.herokuapp.com/?query-id=50ba5fe7e4b0d89fb0a4ae3f |
| 14:57 | p_l | muhoo: when you divide 738 by 20~30 commits a day... |
| 14:57 | bbloom | ooo that gives me an idea. lynaghk would doing some github-style graphs for that codeq project be a good test c2po? |
| 14:58 | bbloom | test for c2po, that is |
| 14:58 | muhoo | seangrove: very nice work. |
| 15:00 | seangrove | jonasen: Oh, good query |
| 15:00 | seangrove | muhoo: Thanks, but wei_ (in here sometimes) did most of the work |
| 15:01 | seangrove | I tink it's ready to share on the mailing list |
| 15:01 | bbloom | seangrove: jonasen anyway to do an order by on that? |
| 15:01 | jonasen | bbloom: not in datalog |
| 15:02 | jonasen | seangrove: bbloom: but the webapp could support ordering by column.. which would be useful |
| 15:02 | bbloom | could be part put up in the query param too :-) |
| 15:03 | seangrove | Hmm, wonder if that would be good |
| 15:03 | seangrove | An idea anyway, I'll add it to the wiki |
| 15:04 | jonasen | seangrove: what version of datomic are you running? |
| 15:06 | seangrove | jonasen: One second, I'll check |
| 15:07 | seangrove | datomic-free-0.8.3599 |
| 15:07 | jonasen | seangrove: ok. Is it much work to update the peer library? |
| 15:08 | seangrove | I don't think so, no |
| 15:08 | seangrove | I'm actually not sure what part that is though, on reflection |
| 15:09 | seangrove | Is that the part that's running in-app, separate from the transactor? |
| 15:14 | jonasen | seangrove: in-app |
| 15:14 | jonasen | seangrove: find authors/committers http://jida.herokuapp.com/?query-id=50ba637ae4b0d89fb0a4ae40 http://jida.herokuapp.com/?query-id=50ba63d6e4b0d89fb0a4ae41 |
| 15:16 | seangrove | jonasen: Very nice! |
| 15:16 | seangrove | Why do you ask about updating the peer library? |
| 15:16 | bbloom | anybody working on getting the clojurescript analyzer running so that we can query deeper into the code? :-) |
| 15:17 | jonasen | seangrove: a recent version has some new query features I wanted to try |
| 15:18 | jonasen | bbloom: I started once, but didn't get very far. |
| 15:18 | bbloom | jonasen: what stopped you? |
| 15:19 | jonasen | bbloom: I'm also working on a java analyzer: https://github.com/jonase/codeq/tree/java |
| 15:19 | jonasen | bbloom: macros. |
| 15:20 | bbloom | hmm yes, code execution is scary :-P |
| 15:21 | bbloom | jonasen: was the issue analyzing macros in clojure code since the cljs analyzer doens't support them? |
| 15:22 | jonasen | bbloom: well, I didn't care too much about that. But getting the analyzer to run at all wasn't as easy as I expected |
| 15:22 | bbloom | jonasen: yeah, the public interface isn't exactly publicly documented |
| 15:23 | jonasen | bbloom: since codeq works on one source file at a time the cljs analyzer can't find the files it needs |
| 15:24 | bbloom | hm, i see |
| 15:26 | seangrove | jonasen: Is this the latest library? https://clojars.org/com.datomic/datomic-free |
| 15:26 | seangrove | Happy to swap it out and push |
| 15:28 | jonasen | according to https://groups.google.com/d/topic/datomic/lt9xVbZaX3s/discussion 0.8.3661 is the latest |
| 15:32 | HolyJak | How is it possible that > can be used as java.util.Comparator? Does clojure somehow convert the boolean result to −1/+1 ? I'd be glad if anybody can point me towards the anser. |
| 15:35 | seangrove | Hmm, I'm not seeing the jar for 0.8.3661 in clojars at all though. Updating Datomic on the server... |
| 15:36 | HolyJak | Clojure Programming on page 107-108 says that yes, predicates are adapted to behave as Comparators, but doesn't say where/how :-( |
| 15:40 | jonasen | seangrove: btw, how are you able to run datomic-free on Heroku. Or will you simply loose all data at any time? |
| 15:40 | seangrove | jonasen: Just the app is run on heroku, but datomic is run on a vps, along with the workers for importing git urls |
| 15:40 | jonasen | seangrove: ok |
| 15:41 | antares_ | HolyJak: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/AFunction.java#L46 |
| 15:41 | HolyJak | thanks a lot! |
| 15:42 | HolyJak | I love this channel :-) |
| 15:44 | bbloom | antares_: now I'm curious what a sneakyThrow is :-) |
| 15:44 | bbloom | https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Util.java#L183 |
| 15:44 | bbloom | nice. |
| 15:44 | bbloom | heh |
| 15:45 | bbloom | ie: turn off this blasted checked exceptions nonsense |
| 15:45 | HolyJak | bbloom: thx for providing also a pointer to the answer after having attracted my attention to it :) |
| 15:45 | antares_ | bbloom: the "least inconvenient" way to throw exceptions without specifying them in method signatures all the time http://www.jayway.com/2010/01/29/sneaky-throw/ |
| 15:47 | HolyJak | I see |
| 15:59 | bbloom | hmmm i have some source of non-determinism in my code… but i'm not sure where…. |
| 15:59 | bbloom | i don't use random |
| 15:59 | bbloom | there are no inputs |
| 16:00 | bbloom | no IO |
| 16:00 | bbloom | uses only core clojure data structures |
| 16:00 | bbloom | yet repeated execution yields varied results.... |
| 16:01 | bbloom | the only thing i can think of is that it's hashing functions differently from iteration to iteration… would that make sense? |
| 16:01 | bbloom | yeah, i guess it does… hm |
| 16:02 | bbloom | &(hash (fn [])) |
| 16:02 | bbloom | ,(hash (fn [])) |
| 16:02 | clojurebot | 1087093623 |
| 16:02 | bbloom | ,(hash (fn [])) |
| 16:02 | clojurebot | 512672660 |
| 16:02 | bbloom | that makes sense |
| 16:02 | bbloom | shouldn't be affecting my algorithm tho :-P |
| 16:05 | gfredericks | ,(hash "foo") |
| 16:05 | clojurebot | 101574 |
| 16:05 | gfredericks | ,(hash "foo") |
| 16:05 | clojurebot | 101574 |
| 16:05 | gfredericks | ,(hash (apply str (range 10000))) |
| 16:05 | clojurebot | -1524940506 |
| 16:14 | gfredericks | empty protocols are an interesting pattern |
| 16:15 | gfredericks | apparently only cljs allows it? |
| 16:15 | tomoj | 1.5.0-beta1 too, I think |
| 16:15 | gfredericks | ah |
| 16:16 | gfredericks | in clj-jvm you can extend a protocol to an interface, can't you? |
| 16:16 | bbloom | gfredericks: yeah, turns out to be useful as a sort of bit flag. i just used them for functions with metadata in cljs |
| 16:16 | bbloom | gfredericks: what use cases have you run into? |
| 16:17 | gfredericks | none, I just saw it in the CLJS code :) |
| 16:17 | tomoj | https://github.com/clojure/clojure/commit/2bc8b1f5 |
| 16:17 | gfredericks | I was initially curious if the use cases mapped to any typical OOP patterns |
| 16:17 | bbloom | gfredericks: I've seen empty interfaces before |
| 16:18 | bbloom | gfredericks: but these days that same use case is better handled by an attribute or metadata in java or c#, etc |
| 16:18 | gfredericks | I guess because I saw ASeq in the cljs code, the naming pattern of which reminds me of the abstract superclasses in clj-jvm |
| 16:18 | bbloom | what's that find-fn syntax in here again? |
| 16:18 | gfredericks | $findfn 3 4 7 |
| 16:18 | bbloom | $find-fn nil 5 '(5) |
| 16:18 | bbloom | $findfn nil 5 '(5) |
| 16:19 | bbloom | no clojurebot? :-/ |
| 16:19 | gfredericks | it's lazybot |
| 16:19 | gfredericks | and he's apparently not here |
| 16:19 | bbloom | dammit lazybot, i need you |
| 16:19 | bbloom | get off the couch |
| 16:19 | HolyJak | &(+ 1) |
| 16:19 | HolyJak | ,(+ 1) |
| 16:19 | clojurebot | 1 |
| 16:19 | bbloom | found https://github.com/Raynes/findfn |
| 16:20 | HolyJak | ,(+ 2) |
| 16:20 | clojurebot | 2 |
| 16:22 | ivaraasen | does anyone here know the current state of Incanter? seems pretty stale just by looking at the github repo. |
| 16:23 | bbloom | (find-fn tester {:a 1} nil :a 1) ;; assoc |
| 16:23 | bbloom | (find-fn tester '(:a) nil :a) ;; conj |
| 16:23 | tomoj | hmm, if I put (load-file "/home/tom/repl.clj") in my :repl-options :init, it works, but if I put the code that is in repl.clj, I get a "ClassNotFoundException: cljs.repl.browser" |
| 16:23 | bbloom | (find-fn tester #{:a} nil :a) ;; sorted-set-by |
| 16:23 | bbloom | doesn't seem right :-/ |
| 16:23 | bbloom | i need a function which yields a set |
| 16:23 | bbloom | the best i got is: |
| 16:23 | bbloom | &(set/union nil #{:a}) |
| 16:24 | bbloom | ,(set/union nil #{:a}) |
| 16:24 | clojurebot | #<CompilerException java.lang.RuntimeException: No such namespace: set, compiling:(NO_SOURCE_PATH:0)> |
| 16:24 | bbloom | ,(clojure.set/union nil #{:a}) |
| 16:24 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.set> |
| 16:24 | bbloom | *shrug* |
| 16:25 | tomoj | given what args? |
| 16:25 | tomoj | ,(clojure.set/union [1 2 3] [1 2 3]) |
| 16:25 | clojurebot | [1 2 3 1 2 ...] |
| 16:26 | tomoj | wonder if there's a good reason set and vec aren't identity when possible |
| 16:27 | bbloom | i'm doing an update-in |
| 16:27 | bbloom | (update-in some-map [some key path] set/union #{element}) |
| 16:28 | bbloom | would be nice to omit the #{} and replace set/union with set-conj or something |
| 16:28 | tomoj | where set-conj is #(conj (or #{} %1) %2)? |
| 16:28 | tomoj | er, that's backwards ofc |
| 16:29 | bbloom | yeah, basically |
| 16:29 | bbloom | i find myself needing that function frequently |
| 16:30 | ollivera | Hi, I am reading a tsv file .. doseq [line (line-seq rdr)] ... how can I extract (access) only the 2nd and 5th field in the line? |
| 16:32 | bbloom | break it down: first you need to split the line on tabs |
| 16:33 | tomoj | huh, doseq allows initial :let-bindings, for doesn't |
| 16:36 | gfredericks | tomoj: boo :( |
| 16:37 | ollivera | bbloom, how can I split the line on tabs? |
| 16:37 | gfredericks | ,(clojure.string/split "\t" "foo\tbar\tbazzy") |
| 16:37 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to java.util.regex.Pattern> |
| 16:37 | gfredericks | ,(clojure.string/split #"\t" "foo\tbar\tbazzy") |
| 16:37 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to java.util.regex.Pattern> |
| 16:37 | gfredericks | ,(clojure.string/split "foo\tbar\tbazzy" #"\t") |
| 16:37 | clojurebot | ["foo" "bar" "bazzy"] |
| 16:38 | bbloom | gfredericks: heh, i do the same thing |
| 16:38 | bbloom | i make BOTH mistakes every time haha |
| 16:38 | bbloom | sometimes i even try to write /\t/ :-P |
| 16:38 | gfredericks | lol |
| 16:38 | gfredericks | in the future we will all use eclipse and that will not happen |
| 16:39 | ivaraasen | gfredericks: might want to compile the regexp as well |
| 16:39 | gfredericks | ivaraasen: does it not get compiled by the clojure compiler? |
| 16:39 | ivaraasen | gfredericks: hm, you might be right. or maybe HotSpot does some magic |
| 16:40 | gfredericks | ,(type #"\t") |
| 16:40 | clojurebot | java.util.regex.Pattern |
| 16:40 | gfredericks | if it's a Pattern does that imply it's already compiled? |
| 16:41 | ivaraasen | isn't it compiled on the go by the regexp reader macro? |
| 16:41 | gfredericks | that's what I assumed |
| 16:41 | gfredericks | ,(type (read-stryng "#\"\t\"")) |
| 16:41 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: read-stryng in this context, compiling:(NO_SOURCE_PATH:0)> |
| 16:41 | gfredericks | ,(type (read-string "#\"\t\"")) |
| 16:41 | clojurebot | java.util.regex.Pattern |
| 16:42 | gfredericks | I don't know that it's a reader macro, since that's the most basic syntax for it |
| 16:42 | ivaraasen | OK, they're compiled at read time by the reader macro, according to the docs |
| 16:42 | gfredericks | w00p |
| 16:43 | gfredericks | clojure: always doing the right thing some of the time. |
| 16:43 | tomoj | I think they may be compiled again at compile time? |
| 16:44 | gfredericks | wat. |
| 16:44 | tomoj | but can you even have an 'uncompiled' Pattern? |
| 16:45 | gfredericks | my guess is in javaland that's a pattern represented as a string |
| 16:45 | tomoj | oh, I see, the emitter for a Pattern emits a string and then a call to compile |
| 16:45 | gfredericks | emitter? |
| 16:46 | gfredericks | the sexp->bytecode compiler? |
| 16:46 | tomoj | the byte code generator |
| 16:46 | gfredericks | huh. |
| 16:46 | gfredericks | ,(.compile #"\t") |
| 16:46 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: No matching field found: compile for class java.util.regex.Pattern> |
| 16:46 | gfredericks | oh you compile a string to a regexp |
| 16:46 | gfredericks | ,(str #"\t") |
| 16:46 | clojurebot | "\\t" |
| 16:47 | ivaraasen | but yeah, a really simple solution to getting say the 5th line of a TSV file would probably be to use clojure-csv's (parse-csv MyFile :delimiter \\t) and do a nth 5. |
| 16:49 | ivaraasen | ,(. Pattern compile "\t") |
| 16:49 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: Pattern in this context, compiling:(NO_SOURCE_PATH:0)> |
| 16:51 | TimMc | &(identical? #"foo" #"foo") |
| 16:51 | TimMc | ,(identical? #"foo" #"foo") |
| 16:51 | clojurebot | false |
| 16:52 | AWizzArd | /wii cemerik |
| 16:55 | xificurC | is there anyone kind enough to link me or explain me how to get lein working on pcbsd? |
| 16:56 | xificurC | after a lein self-install if i try to run for example "lein repl" in xterm i get a line 260: java: command not found |
| 16:58 | lynaghk | bbloom: making a codeq + c2po charts HN bait post has been on my agenda for a while = ) |
| 16:59 | bbloom | lynaghk: nice |
| 16:59 | lynaghk | bbloom: I haven't had a ton of time to play with either datomic or codeq, though |
| 17:00 | lynaghk | I don't know if you know Carlos Scheidegger at AT&T Labs at all, but he was pretty jazzed about codeq when I told him about the project |
| 17:00 | ivaraasen | xificurC: did you install OpenJDK through the AppCafe? |
| 17:00 | lynaghk | bbloom: any questions in particular you are thinking about visualizing? |
| 17:01 | bbloom | lynaghk: nah, nothing in particular |
| 17:02 | xificurC | ivaraasen: nope, thanks a lot :) Sorry for having so dumb questions and problems :( |
| 17:02 | lynaghk | bbloom: I don't know if there has been any progress on the Clojure analysis bit of codeq since it was released |
| 17:02 | xificurC | too new to this OS |
| 17:02 | lynaghk | bbloom: but I think it'd be very interesting to look at relative distributions (via histograms) of things like form depth, # of forms per fn, length of forms, &c. |
| 17:03 | lynaghk | bbloom: but when codeq was first released the analysis just looked at toplevel forms only. |
| 17:04 | bbloom | lynaghk: not much, just talking about that with somebody above. apparently macros are a pain :-) |
| 17:04 | lynaghk | bbloom: even without doing full macroexpansion I think it'd be pretty useful |
| 17:05 | lynaghk | bbloom: after all, as a programmer you're looking at the literal forms, not the fully qualified/expanded ones. |
| 17:06 | bbloom | lynaghk: yeah, but the analyzer just chokes on defmacro, i'd assume |
| 17:06 | bbloom | lynaghk: also, there was mention of the core strategy of one-file-at-a-time being insufficient |
| 17:06 | bbloom | the analyzer's moduel system is tightly coupled to gclosure right now :-/ |
| 17:07 | lynaghk | bbloom: ah. Assuming a file is well-formed EDN, couldn't you pretty easily just traverse it and do a lot of counting? |
| 17:08 | lynaghk | bbloom: that's what I'd be interested in, as a first pass. Of course, getting all of the actual semantics in there would be great too. Still though, looking at forms is much more interesting than lines. |
| 17:11 | bbloom | lynaghk: yeah, i figure lots of other people are interested, so they can push for changes to cljs :-) more interested parties outside of just those doing browser-side work is welcome |
| 17:11 | bbloom | anyway, just published an early version of https://github.com/brandonbloom/qplan |
| 17:11 | bbloom | :-) |
| 17:14 | lynaghk | bbloom: do you have your codeq playground on github?L |
| 17:15 | bbloom | lynaghk: i don't have a codeq playground :-) seangrove and somebody else does |
| 17:15 | bbloom | jida.herokuapp.com |
| 17:15 | muhoo | it's a gist, isn't it? |
| 17:15 | seangrove | Yeup, tinkering with it right now |
| 17:16 | seangrove | Should have it back up in a second |
| 17:17 | gfredericks | so you can extend a protocol to a java interface but not to another protocol; any guesses about the reasoning there? |
| 17:17 | gfredericks | is the interface functionality an unfortunate necessity but normally we want to extend to concrete types? |
| 17:18 | seangrove | Was trying to upgrade datomic for jonasen |
| 17:20 | andrewmcveigh | I just pulled master on clojure/clojurescript, cljsbuild now throws :No such var: json/pprint, compiling:(cljs/source_map.clj:142) |
| 17:20 | andrewmcveigh | Anyone know what that is? |
| 17:22 | lynaghk | seangrove: do you know of any JavaScript libraries for making textareas that have paredit? I was thinking about making something similar to your Jida project but refuse to do anything until I get a highlighted, paredit'd textarea for input |
| 17:22 | seangrove | lynaghk: Nah, I ran into the same problem, wrote a little helper for determining balanced parens, and then realize how much thought must have gone into paredit |
| 17:23 | seangrove | Re-pushing to Heroku, should be back up in a bit. cljs compilation sometimes takes ~5-7minutes though |
| 17:24 | lynaghk | seangrove: I guess you could call in the nuclear option and use Ymacs: http://www.ymacs.org/ |
| 17:25 | gfredericks | tried ymacs for 3 seconds until C-n opened a new chrome window |
| 17:25 | lynaghk | gfredericks: ah, yeah. That and I can't use other people's emacs anyway. It's kind of in the uncanny valley of textareas |
| 17:26 | seangrove | And even then, no paredit mode :) |
| 17:26 | seangrove | But I think something like emacs => llvm => emscripten... or something might eventually be a cool project |
| 17:27 | lynaghk | seangrove: oh, I hadn't thought about that route. Probably because I want to stay sane |
| 17:27 | Raynes | lynaghk: subpar for codemirror |
| 17:27 | Raynes | $google subpar codemirror |
| 17:27 | Raynes | No bot. |
| 17:27 | Raynes | I haven't had to restart him in probably 6 months. |
| 17:27 | Raynes | I literally don't even remember how. |
| 17:28 | lynaghk | Raynes: ohh, written in ClojureScript. Hip. |
| 17:28 | gfredericks | Raynes: there should be some command you can issue in #clojure that restarts him |
| 17:28 | gfredericks | $arise |
| 17:29 | Raynes | gfredericks: That's a chicken and the egg problem. If he is dead he can't respond to commands. |
| 17:29 | gfredericks | there should be a command you can issue in #clojure for chicken and egg problems |
| 17:29 | gfredericks | $hatch |
| 17:29 | Raynes | :p |
| 17:30 | muhoo | &(hatch) |
| 17:30 | lazybot | java.lang.RuntimeException: Unable to resolve symbol: hatch in this context |
| 17:30 | gfredericks | and that would be his normal response to that |
| 17:33 | Raynes | Is there an official content type for edn? |
| 17:33 | gfredericks | I saw application/edn somewhere |
| 17:33 | gfredericks | probably had something to do with fogus. That guy. |
| 17:33 | Raynes | Yeah, ring-edn uses that. |
| 17:34 | gfredericks | woah what does ring-edn do |
| 17:34 | Raynes | I have no idea. |
| 17:35 | seangrove | Raynes: Reminds me a bit of Robin Hood/Friar Tuck: http://www.vintage-computer.com/vcforum/archive/index.php/t-5628.html |
| 17:36 | gfredericks | it is very weird that the ring-edn readme example uses print-str instead of pr-str |
| 17:37 | Raynes | fogus is a terrible programmer. |
| 17:37 | Raynes | Nobody gets aware with that. |
| 17:38 | Raynes | I hate you. |
| 17:41 | andrewmcveigh | Does metadata on defmulti work in cljs? It seems to compile alright, but it seems to break in the browser by prepending the var name with self__ |
| 17:43 | seangrove | lynaghk: Ok, all better now: http://jida.herokuapp.com/?query-id=50ba63d6e4b0d89fb0a4ae41 |
| 17:44 | lynaghk | seangrove: neat. You are running datomic in process? |
| 17:44 | seangrove | Nah, it's on a server elsewhere |
| 17:44 | lynaghk | seangrove: do you have a pro copy? |
| 17:45 | seangrove | Nah, just the free one. Pro would be nice so I didn't have to worry about disk space, etc. |
| 17:45 | Sgeo__ | Suppose two libraries are combinable in some way |
| 17:45 | seangrove | But maybe I'll ask once Jida is of use to the community |
| 17:45 | Sgeo__ | As in, let's say one exports a protocol, and another exports a type that could be made to fit the protocol |
| 17:45 | lynaghk | seangrove: yeah, I have no idea what the storage characteristics are. I'd like to use datomic on S3 for fire-and-forget log all the things. |
| 17:46 | Sgeo__ | Do I just write my own library that fits them together, and put that up as a separate thing? |
| 17:46 | seangrove | Same here |
| 17:46 | muhoo | [5~[5~[5~/sb end |
| 17:46 | wink | ,(map (fn [x] (str x x)) ["a" "b"]) |
| 17:46 | clojurebot | ("aa" "bb") |
| 17:46 | wink | why is that converted to a list? |
| 17:46 | gfredericks | it's a lazy seq |
| 17:46 | gfredericks | ,(type (map (fn [x] (str x x)) ["a" "b"])) |
| 17:46 | clojurebot | clojure.lang.LazySeq |
| 17:46 | seangrove | Datomic-as-a-service would be pretty cool - it wouldn't be a good idea as a professional thing, probably, but as a tool for toy projects on Heroku, would be nice |
| 17:46 | gfredericks | seqs get printed as lists |
| 17:46 | muhoo | qplan looks interesting, but i find i can't get my brain around what it does |
| 17:46 | wink | ok, my bad. why is it not a vector still? :) |
| 17:47 | Sgeo__ | qplan? |
| 17:47 | seangrove | Unfortunately, it seems like the setup of datomic makes it pretty difficult to offer as a service, or just extremely expensive |
| 17:47 | gfredericks | wink: map always returns a lazy-seq; there is a mapv if you really need a vector, but likely you don't |
| 17:47 | lynaghk | seangrove: are you not on github? |
| 17:47 | seangrove | http://github.com/sgrove |
| 17:47 | lynaghk | seangrove: how do you mean? |
| 17:47 | Sgeo__ | wink, because it's convenient for a lot of cases, reducing the amount of work that needs to be done after multiple transforms of the sequence |
| 17:48 | Sgeo__ | Suppose you mapped f onto some sequence, and mapped g onto the result |
| 17:48 | seangrove | Jida source is here https://github.com/yayitswei/jida |
| 17:48 | lynaghk | seangrove: ugh, usability fail. I github searched you and it shows all of your repos but doesn't say "users:" on the sidebar like it used to. |
| 17:48 | gfredericks | Sgeo__: how does it reduce work unless you don't consume everything? |
| 17:48 | Sgeo__ | The underlying sequence only needs to be walked once |
| 17:48 | gfredericks | Sgeo__: there's still the intermediate seq |
| 17:48 | wink | Sgeo__: yeah, I understand it probably makes things easier |
| 17:48 | wink | I was just a bit dumbfounded now |
| 17:48 | seangrove | No problem |
| 17:48 | gfredericks | Sgeo__: I expect it's assymptotically the same as mapv |
| 17:49 | seangrove | Anyway, I was thinking a public tool like Jida could potentially be very useful for programming communities, and as a way for the Datomic Company to show off the utility, use, etc. of datomic |
| 17:49 | lynaghk | seangrove: yeah, totes. |
| 17:49 | ivaraasen | I really need to set up a datomic playground. |
| 17:49 | Sgeo__ | Hmm, I guess only consuming part of it is probably when it would act to reduce work, mostly |
| 17:50 | lynaghk | seangrove: are you getting the hash from the query string, or are you normalizing it first |
| 17:50 | gfredericks | Sgeo__: my understanding is that reducers are interesting partly because they avoid the intermediate representation |
| 17:50 | lynaghk | seangrove: e.g., (-> read-string pr-str md5sum) |
| 17:50 | bbloom | andrewmcveigh: sorry, stepped out |
| 17:50 | ivaraasen | maybe ask my professors for some petroleum big data and see what cool stuff it's capable of. |
| 17:50 | bbloom | andrewmcveigh: not sure what the source_maps thing is about, should ask dnolen |
| 17:50 | seangrove | The hash used for the query id? |
| 17:50 | lynaghk | seangrove: yeah |
| 17:50 | seangrove | It's just a mongo-db id, where the queries are stored |
| 17:51 | lynaghk | seangrove: ah, I see. |
| 17:51 | bbloom | andrewmcveigh: as for the multi metadata, you mean (defmulti ^:foo f … |
| 17:51 | bbloom | ? |
| 17:51 | seangrove | I don't know enough about managing datomic yet, so I wanted to keep all data in there essentially "stateless" |
| 17:51 | andrewmcveigh | bbloom: np, I pulled the source-maps branch I thought I was on master. |
| 17:51 | seangrove | Or always re-creatable. |
| 17:51 | bbloom | andrewmcveigh: whoops :-) ok |
| 17:51 | seangrove | Easy enough to import a dozen or more clojure repos, so even if datomic blows up and all data is lost, no big deal |
| 17:51 | lynaghk | seangrove: mind if I tweet about this project to a few people? Or will it be going on/offline for a while? |
| 17:51 | seangrove | But saved queries are much more valuable, they need to be backed up |
| 17:51 | andrewmcveigh | bbloom: yes. (defmulti ^:foo f ... |
| 17:52 | seangrove | lynaghk: Nah, we were about to send it out to the list this weekend |
| 17:52 | bbloom | andrewmcveigh: there are no vars in cljs |
| 17:52 | bbloom | andrewmcveigh: if you do that in clojure, you need to do (meta #'f) |
| 17:52 | bbloom | andrewmcveigh: (meta f) doesn't work |
| 17:53 | andrewmcveigh | bbloom: well, maybe var is not what I meant... the form (defmulti ^:foo ...) compiles to in js seems to be "munged?" to self__.f |
| 17:53 | bbloom | andrewmcveigh: give me a moment, i'll check it out |
| 17:53 | andrewmcveigh | I'm not actually trying to get at the metadata. |
| 17:54 | bbloom | andrewmcveigh: ah, ok so it should be ignored, it's just not… ill look |
| 17:54 | bbloom | andrewmcveigh: would you please file a ticket? |
| 17:54 | andrewmcveigh | bbloom: in the jira? |
| 17:54 | bbloom | andrewmcveigh: yeah |
| 17:55 | andrewmcveigh | bbloom: sure, will do. |
| 17:55 | bbloom | andrewmcveigh: well |
| 17:55 | bbloom | make sure you include a test case :-) |
| 17:55 | bbloom | because i don't see an issue here ... |
| 17:55 | bbloom | does it only affect advanced mode you said? |
| 17:56 | andrewmcveigh | I've not even checked advanced mode, I've got it on :whitespace. |
| 17:57 | bbloom | andrewmcveigh: ok, help me reproduce it |
| 17:57 | andrewmcveigh | I'll try on a fresh project. Maybe something's broke here. |
| 18:06 | gfredericks | AJAX has a lot of similarities with the IO monad doesn't it |
| 18:06 | seangrove | gfredericks: How so? |
| 18:06 | gfredericks | I'm thinking mostly of the fact that the runtime forces you to do it async |
| 18:06 | moogatronic | Having a strange issue with lein-cljsbuild: Could not locate cljs/analyzer__init.class or cljs/analyzer.clj on classpath |
| 18:07 | moogatronic | Using version 0.2.9. If i use 0.2.1 it works… Anyone see this before? |
| 18:07 | gfredericks | so therefore, like the IO monad, any composition of functions that involves async at any point must itself be asyncy |
| 18:08 | andrewmcveigh | bbloom: hmm, it seems that when the metadata is (defmulti ^:field f ...) that breaks it, whereas (defmulti ^:foo f ...) doesn't. Maybe there's a reason for that? |
| 18:10 | seangrove | Ah, got it |
| 18:10 | seangrove | Seems so, yes |
| 18:12 | bbloom | andrewmcveigh: heh ok… let me see... |
| 18:13 | andrewmcveigh | bbloom: this does it for me https://gist.github.com/4185793 |
| 18:14 | bbloom | heh ok, ticket that & i'll see what i can do… i think i know where the issue is |
| 18:15 | andrewmcveigh | bbloom: OK, will do. |
| 18:15 | Sgeo__ | defprotocol-once? |
| 18:16 | Sgeo__ | ...Why is it needed, what happens if you call defprotocol several times? |
| 18:17 | Sgeo__ | Or deftype or defrecord |
| 18:17 | Sgeo__ | With the same code? |
| 18:20 | tomoj | Sgeo__: bad things in some cases https://www.refheap.com/paste/b83f0ae013c7bcf8af2de885a |
| 18:20 | bbloom | the issue is that munge looks at some metadata on symbols, so it's a more general problem regarding the :field metadata |
| 18:20 | bbloom | andrewmcveigh: i can probably just namespace the keys.... |
| 18:21 | Sgeo__ | tomoj, oh |
| 18:21 | Sgeo__ | That... kind of sucks really badly |
| 18:21 | Sgeo__ | Reminds me of Python |
| 18:21 | bbloom | andrewmcveigh: there is probably a simpler test case too... |
| 18:22 | Sgeo__ | Seriously, I expect Clojure to play nice with modifying and changing code at runtime |
| 18:22 | Sgeo__ | Maybe I'm expecting it to be too much like CL? |
| 18:22 | bbloom | Sgeo__: others expect that too. file a bug |
| 18:23 | bbloom | andrewmcveigh: (def ^:field f identity) |
| 18:23 | tomoj | you want it to detect that the sigs are the same? |
| 18:23 | tomoj | and in case they're not, give the current behavior? |
| 18:24 | bbloom | andrewmcveigh: i can't dig into it now, but file that ticket and link me to it… either i or dnolen will take a look at it sooner or later |
| 18:24 | Sgeo__ | Hmm, not sure the exact semantics that I would want |
| 18:24 | andrewmcveigh | bbloom: ah, it even does it with def? |
| 18:24 | andrewmcveigh | bbloom: Writing it now. |
| 18:25 | andrewmcveigh | bbloom: actually (def ^:field f identity) is fine for me. |
| 18:26 | bbloom | andrewmcveigh: try to call it |
| 18:26 | andrewmcveigh | bbloom: ah, yeah. |
| 18:36 | gfredericks | Raynes: jayq contains "application/edn" as well |
| 18:36 | gfredericks | also "text/edn" and "application/clojure" and "text/clojure" |
| 18:36 | lynaghk | gfredericks, Raynes: we're using application/edn for our services that send edn over the wire. |
| 18:36 | gfredericks | so....whatever |
| 18:37 | gfredericks | is "application/json" an unfortunate name? |
| 18:41 | mpenet | gfredericks: about the async ajax monad, it is possible, it's a different definition from the one in jayq, the 2 can coexist. |
| 18:41 | andrewmcveigh | bbloom: I've submitted the ticket, but I can't seem to link it to anyone. CLJS-434 |
| 18:42 | bbloom | http://dev.clojure.org/jira/browse/CLJS-434 |
| 18:42 | gfredericks | mpenet: I just got all excited about this new view of ajax/async |
| 18:42 | bbloom | andrewmcveigh: thanks |
| 18:42 | gfredericks | mpenet: apparently jquery deferred, which I didn't previously know about, is up this alley? |
| 18:42 | mpenet | gfredericks: sometimes you want realized values between steps (allows "natural" transform with Mabye or sometimes is required depending on use case), sometimes you dont care |
| 18:43 | mpenet | it is |
| 18:43 | gfredericks | mpenet: yeah, and it occurred to me that you wouldn't want to assume independence even when you can prove it in the code, because statefulness on the server might not allow reordering |
| 18:43 | gfredericks | so it definitely ought to be explicit |
| 18:43 | mpenet | gfredericks: yup |
| 18:44 | gfredericks | it'd be a weird server that didn't allow that, but best to be safe |
| 18:44 | mpenet | gfredericks: feel free to scratch this itch, this would be welcomed in jayq with the other one |
| 18:45 | tomoj | (let [res1 (req1) res2 (req2)] [@res1 @res2]) vs (let [res1 @(req1) res2 @(req2)] [res1 res2]) |
| 18:45 | mpenet | gfredericks: it's more about the workflow in your app, ex: POST, need to wait for a response and do GET that depends on the previous post. |
| 18:45 | gfredericks | mpenet: once I get my head around it I assume it should be straightforward so I'll be happy to throw up a patch if that turns out to be the case |
| 18:45 | gfredericks | mpenet: I guess that wouldn't be so weird |
| 18:45 | mpenet | gfredericks: not at all imo |
| 18:45 | jamii | If anyone feels like proof-reading some vaguely clojure-related writing, I'd be much obliged :D |
| 18:45 | jamii | https://gist.github.com/800eaa1876dfaad4b600 |
| 18:46 | gfredericks | I think if I were doing that I'd think about having the POST return the data itself |
| 18:47 | mpenet | gfredericks: yeah, but it's maybe not that specific, maybe my example was bad, but I meant sometimes the order can be important |
| 18:48 | gfredericks | it wouldn't surprise me too badly, I just can't think of a common use case with a restful server |
| 18:49 | mpenet | if req1 fails, dont do req2, is a good enough justification imo |
| 18:49 | mpenet | well could be |
| 18:49 | gfredericks | oh that's a good point |
| 18:50 | mpenet | so the 2 versions are potentially useful |
| 18:52 | holo | hi |
| 18:54 | tomoj | if req2 needs the previous response, you could do (let [res1 @(req1)] @(req2 res1)), or make req2 accept a defer, for @((comp req2 req1)). can't decide if I like the latter |
| 18:55 | holo | i want to do something like (= type(var) <some way to represent the class constant>) how do i do the <...> thing? |
| 18:55 | gfredericks | ,Integer |
| 18:55 | holo | i mean (type var). sorry for my legacy typo |
| 18:55 | clojurebot | java.lang.Integer |
| 18:55 | tomoj | maybe you define a special comp that handles asynchrony, @((comp@ req2 req1)), and just have req2 take a response |
| 18:55 | gfredericks | ,java.util.List |
| 18:55 | clojurebot | java.util.List |
| 18:56 | gfredericks | holo: just write it ^ |
| 18:56 | gfredericks | fully qualified, or naked if you imported it |
| 18:56 | holo | oh.. i can just write.. hehe |
| 18:56 | gfredericks | tomoj: yeah that's basically how jayq already works |
| 18:56 | holo | so obvious |
| 18:57 | holo | gfredericks, thanks |
| 18:57 | gfredericks | ,(= (type {2 4}) clojure.lang.PersistentArrayMap) |
| 18:57 | clojurebot | true |
| 18:57 | gfredericks | holo: you also might like clojure.core/instance? |
| 18:58 | holo | gfredericks, yes, i like it :) thanks |
| 18:59 | tomoj | gfredericks: (then (req1) req2) ? |
| 18:59 | tomoj | er, done I guess |
| 18:59 | mpenet | tomoj: we have a let form that does that |
| 19:00 | mpenet | tomoj: let-ajax, and also let-defered |
| 19:00 | mpenet | there is an example in the jayq readme |
| 19:00 | mpenet | |
| 19:01 | tomoj | ah, if you want points |
| 19:02 | tomoj | that's pretty cool, I hadn't thought of :let/:when for dropping out of the monad |
| 19:04 | mpenet | yes I think so too, I haven't used it in my apps though. |
| 19:12 | devinus | is there a literal reader syntax for PersistentQueue yet? |
| 19:18 | seancorfield | ibdknox: you around? |
| 19:19 | seancorfield | I upgraded my Win8 VM from Release Preview to Pro and had to reinstall Java and now LightTable doesn't work again :( |
| 19:20 | tomoj | devinus: only in cljs I believe |
| 19:20 | devinus | that's disappointing |
| 19:20 | devinus | tomoj: what is it in cljs? |
| 19:20 | tomoj | #queue |
| 19:20 | tomoj | e.g. #queue[1 2 3] |
| 19:23 | dnolen | jamii: nice |
| 19:23 | gfredericks | is that a tagged literal? |
| 19:23 | tomoj | devinus: http://dev.clojure.org/jira/browse/CLJ-976 |
| 19:25 | devinus | "this needs more time" what does that mean? |
| 19:28 | bbloom | i assume he means hammock time? |
| 19:29 | bbloom | i love that i wrote a 100 lines clojure library on the jvm and then tested on cljs and it worked first try :-) |
| 19:32 | Hodapp | nice! |
| 19:32 | bbloom | it's absolutely amazing how far you can get with maps, sets, and vectors |
| 19:57 | tomoj | I wonder if we should wait until cljs depends on 1.5 to put test-> etc in there |
| 19:57 | tomoj | or maybe copy them over to cljs/core.clj in the meantime |
| 19:58 | bbloom | tomoj: probably no harm in copy pasting them over, since the goal is for cljs to eventually be self hosting |
| 19:58 | bbloom | it will need to have copy pasted defs of everything eventually... |
| 19:59 | bbloom | tomoj: submit a ticket with patch & see what dnolen says |
| 20:00 | tomoj | thankfully refer :exclude appears to not explode when you exclude something that doesn't exist |
| 20:00 | tomoj | (I'm using cljs with 1.5) |
| 20:00 | bbloom | yeah, that seems like a reasonable behavior :-) |
| 20:02 | bbloom | test-> is super useful :-) |
| 20:18 | alex_baranosky | any idea why adding this to my project file is not enough for leningen to find the needed jar for me? [org.clojure/tools.trace "0.7.5"] |
| 20:19 | alex_baranosky | is the trace jar in some odd repo? |
| 20:19 | gfredericks | alex_baranosky: in what way does it fail? it says it can't find the jar? |
| 20:20 | alex_baranosky | gfredericks: yeah, it says it can't find it in the specified repos - central, releases, clojars, snapshots |
| 20:22 | gfredericks | the sonatype repo says it only has "0.7.1" and "0.7.3" |
| 20:23 | gfredericks | so maybe there's been some failure to publish the most recent version |
| 20:24 | gfredericks | it was messed with quite recently apparently |
| 20:24 | gfredericks | maybe there's a delay |
| 20:28 | tomoj | in cljs, (zero? (inc nil)) |
| 20:28 | tomoj | guess I'm not surprised |
| 20:29 | gfredericks | I just got 1 |
| 20:29 | tomoj | oh, yeah |
| 20:29 | bbloom | tomoj: unfortunately no way to make that give you an error without losing a lot of perf |
| 20:29 | tomoj | but I wonder if writing (update-in {} ks inc) is really a user error anyway |
| 20:30 | bbloom | similar issue: (+ 5 "adsf") |
| 20:30 | Sgeo__ | Why should it be an error? |
| 20:30 | tomoj | ,(update-in {} [:foo] inc) |
| 20:31 | clojurebot | #<NullPointerException java.lang.NullPointerException> |
| 20:31 | bbloom | Sgeo__ automatic type coercion is a bug waiting to happen |
| 20:31 | bbloom | but host semantics leak through sometimes |
| 20:31 | bbloom | ,(+ 5 "adsf") |
| 20:31 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number> |
| 20:31 | Sgeo__ | tomoj, so what should I do if I want to inc the value at key :foo but if it's not there just leave it alone? |
| 20:31 | bbloom | clojurescript returns "5asdf" |
| 20:32 | bbloom | ,(update-in {} [:foo] #(inc (or % 0))) |
| 20:32 | clojurebot | {:foo 1} |
| 20:32 | p_l | bbloom: have you seen a talk called "WAT"? |
| 20:32 | bbloom | p_l: yeah |
| 20:32 | alex_baranosky | gfredericks: ahhh… I tried 0.7.4, 0.7.2 and 0.7.0 amazingly -- thanks for the info, it works |
| 20:32 | p_l | then you know why ;) |
| 20:33 | Sgeo__ | It's easy to make a monad around Lamina's result-channels |
| 20:34 | Sgeo__ | But what about Lamina channels? |
| 20:37 | bbloom | p_l: heh watched it again https://www.destroyallsoftware.com/talks/wat it's pretty funny |
| 20:37 | tomoj | I note lamina seems to have no mapcat |
| 20:38 | tomoj | oh wait |
| 20:38 | tomoj | yeah it does |
| 20:38 | tomoj | return x = (channel x); ch >>= f = (mapcat* f ch) ? |
| 20:44 | tomoj | Sgeo__: but aren't channels sorta hopeless? |
| 20:44 | Sgeo__ | hm? |
| 20:44 | clojurebot | benchmarking is https://github.com/hugoduncan/criterium |
| 20:45 | Sgeo__ | Well, do we want channels used monadically to have those semantics? |
| 20:46 | Sgeo__ | Channels are effectively FRP Events, right? Are FRP Events monads, I forget |
| 20:46 | Sgeo__ | Erm, monadic values |
| 20:47 | tomoj | yes, Event is a monad |
| 20:47 | tomoj | but channels aren't Events :) |
| 20:47 | bbloom | tomoj: Sgeo__: I know you guys are interested in FRP and dataflow and stuff.. i've been working on a less haskell-ish approach :-) |
| 20:47 | bbloom | https://github.com/brandonbloom/qplan |
| 20:48 | tomoj | interesting |
| 20:48 | tomoj | looking at the test, it reminds me of something I've been thinking about for http middleware ever since cemerick's solver for nrepl middleware |
| 20:49 | bbloom | the doc string in core.clj explains a tad of the academic bits, but see the referenced papers for real details |
| 20:49 | tomoj | guessing it's not what I think it is though |
| 20:49 | bbloom | tomoj: not familiar, link? |
| 20:49 | Sgeo | Solver for nrepl middleware? |
| 20:49 | bbloom | is the goal to just get a linearization of a dependency graph? |
| 20:49 | bbloom | ie these middle wares need these, so run these in this order? |
| 20:50 | tomoj | yeah, that's what cemerick's did |
| 20:50 | tomoj | although I am interested in more than linear stacks |
| 20:50 | bbloom | yeah, this is a bit more complex than that |
| 20:50 | bbloom | this is multi-output and multi-directional |
| 20:50 | tomoj | dunno where it is, nrepl or somewhere |
| 20:50 | bbloom | in that case you have zero or more dependencies. in this case you have N to M inputs to outputs |
| 20:51 | bbloom | with cycles |
| 20:52 | bbloom | i intend to use this (or an optimized version of it) for the basis of a data bindings system |
| 20:53 | bbloom | i have a whole bunch of half finished researchy experiments i'm going to slowly stitch together into a serious framework :-) |
| 20:53 | tomoj | so you'll have channels basically, or just event callbacks, which rerun evaluate with some new data? |
| 20:54 | bbloom | tomoj: it's not a continuous model, it's discreet |
| 20:54 | tomoj | sure, but what's the analogue of push seqs? |
| 20:55 | bbloom | tomoj: there isn't one really… |
| 20:55 | bbloom | I expect to have something more similar to the datomic model |
| 20:55 | bbloom | where you have some kind of "transaction data" so to speak |
| 20:55 | bbloom | and you modify a priority map of properties, and then re-evaluate bindings |
| 20:56 | tomoj | so a click event occurs and some handle submits a 'transaction'? |
| 20:56 | tomoj | handler |
| 20:57 | bbloom | yeah, something like that… clicking will send off a command |
| 20:57 | bbloom | the command will be expanded, like a datomic transaction function |
| 20:57 | bbloom | which occurs recursively until you have some set of primitives, like datomic has add and retract |
| 20:58 | tomoj | presumably, unlike datomic, the history will not be kept around? :) |
| 20:58 | bbloom | yeah, probably just going to keep exactly two versions: current and previous |
| 20:58 | tomoj | looks cool. I'll have to add those papers to my todo list |
| 20:58 | tomoj | for the record, I seek not a haskell-ish approach, but a clojure-ish approach :) |
| 20:59 | bbloom | hence i expanded my search beyond functional programming papers, which tend to be very haskellish |
| 21:00 | bbloom | the property models papers are collaborations with Adobe; ie C++ |
| 21:00 | bbloom | i need to think more about what an in-memory no-history version of datomic would look like |
| 21:01 | bbloom | especially with good support for ordered trees |
| 21:01 | tomoj | yeah, I keep accidentally thinking I have type classes :( |
| 21:01 | Sgeo | Yeah, I think channels are more Applicative than Monadic |
| 21:02 | tomoj | the correct applicative for Events is very weird |
| 21:02 | Sgeo | Although, sort of getting into frustrations with Clojure not using thunked I/O |
| 21:02 | Sgeo | I'm calling it thunked instead of monadic, because monadicness isn't the only interesting thing |
| 21:02 | bbloom | Sgeo: what frustrations? |
| 21:03 | Sgeo | The Clojure equivalent of println <$> somechannel should return another channel, right? |
| 21:03 | Sgeo | A channel of ... what? IO values, I would think |
| 21:03 | Sgeo | But that's not so nice and intuitive in Clojure |
| 21:04 | Sgeo | (map println [1 2 3]) isn't a lazy sequence of things you can trigger to print out a number |
| 21:04 | Sgeo | It's a lazy sequence that, as the sequence gets realized, prints stuff out |
| 21:04 | Sgeo | Which I feel is too soon |
| 21:05 | bbloom | ah yes |
| 21:05 | bbloom | clojurescript had a pr-seq interface |
| 21:05 | bbloom | which returned a lazy sequence of strings |
| 21:05 | bbloom | but it got yanked out for performance reasons |
| 21:05 | Sgeo | pr-seq is missing the point |
| 21:06 | bbloom | in what way? it isolates the IO |
| 21:06 | Sgeo | What I want is something that behaves like... (map (fn [v] (println v)) [1 2 3]) |
| 21:06 | Sgeo | Wait, no |
| 21:07 | Sgeo | (map (fn [v] #(println v)) [1 2 3]) |
| 21:07 | Sgeo | ,(map (fn [v] #(println v)) [1 2 3]) |
| 21:07 | clojurebot | (#<sandbox$eval27$fn__28$fn__29 sandbox$eval27$fn__28$fn__29@1cb02395> #<sandbox$eval27$fn__28$fn__29 sandbox$eval27$fn__28$fn__29@6ff019e9> #<sandbox$eval27$fn__28$fn__29 sandbox$eval27$fn__28$fn__29@7c354968>) |
| 21:07 | Sgeo | ,(doseq [io (map (fn [v] #(println v)) [1 2 3])] (io)) |
| 21:07 | clojurebot | 1 |
| 21:07 | clojurebot | 2 |
| 21:07 | clojurebot | 3 |
| 21:08 | bbloom | do you really need that to apply to OTHER PEOPLE's printing? or can you simply: (fn [& args] (fn [] (apply print args)) |
| 21:09 | Sgeo | It becomes relevent I think when you want to map doing IO onto things other than sequences |
| 21:09 | bbloom | Sgeo: I haven't done much with haskell outside of project euler toy apps |
| 21:10 | bbloom | so i'm not really sure how it's IO performance is achieved or how dethunkificiation occurs in the compiler or any of that fancy stuff |
| 21:11 | bbloom | nor am i really sure what benefits i get from lazy IO, other than the obvious downsides of resource leaks, motivating iterators, etc |
| 21:11 | Sgeo | lazy IO is generally discouraged in Haskell, but that's not what I'm getting at |
| 21:12 | Sgeo | Is there a function to get every other element from a list? |
| 21:12 | Sgeo | Or a lazy-seq? |
| 21:12 | tomoj | (partial take-nth 2) |
| 21:12 | Sgeo | ty |
| 21:13 | Sgeo | ,(dorun (take-nth 2 (map println [1 2 3 4]))) |
| 21:13 | clojurebot | 1 |
| 21:13 | clojurebot | 2 |
| 21:13 | clojurebot | 3 |
| 21:13 | clojurebot | 4 |
| 21:14 | Sgeo | ,(take-nth 2 (map #(str "(println " % ")") [1 2 3 4])) |
| 21:14 | clojurebot | ("(println 1)" "(println 3)") |
| 21:14 | tomoj | for me, in clojure, the answer is usually "don't put IO in a seq" |
| 21:14 | Sgeo | I want putting IO in a seq to be comfortable |
| 21:14 | Sgeo | basically |
| 21:17 | tomoj | what's uncomfortable? defining your own println that returns a function? |
| 21:18 | Sgeo | ,(doseq [io (take-nth 2 (map #(fn [] (println %)) [1 2 3 4]))] (io)) |
| 21:18 | clojurebot | 1 |
| 21:18 | clojurebot | 3 |
| 21:18 | Sgeo | tomoj, I'm sure I could write a function to take an I/O performing function and thunkify it |
| 21:19 | Sgeo | But I feel like it should be more built-in. I could also write my own dorun and doseq and for if the language didn't have them |
| 21:19 | Sgeo | Although the thunkify function probably is not as difficult to write as for |
| 21:20 | Sgeo | (fn [f] (fn [& args] (fn [] (apply f args)))) |
| 21:20 | Sgeo | I think |
| 21:22 | tomoj | guess I don't understand IO well enough to understand the benefit, given that we have no static type system |
| 21:22 | gfredericks | isn't that just identity? |
| 21:22 | gfredericks | (fn [f] f) would do the same thing more performantly? |
| 21:22 | gfredericks | oh wait nevermind :) |
| 21:23 | Sgeo | tomoj, the benefit is that you can freely pass around objects that represent performing an action, without actually performing that action until you want to |
| 21:24 | tomoj | can't you freely do that here too? difference is there's no type distinction between an action and a nullary function |
| 21:25 | Sgeo | Yes, but the standard library isn't designed with that in mind |
| 21:25 | Sgeo | There's no function for walking along a seq of nullary functions and doing them all |
| 21:25 | tomoj | right, oh well |
| 21:25 | Sgeo | For example |
| 21:27 | tomoj | I don't see the benefit in having a standard library that is designed with thunked IO in mind :) |
| 21:27 | gfredericks | I've thought about it too; if the type system can't guarantee that a function is pure, then it seems like you're just getting the worst of both worlds |
| 21:27 | Sgeo | I find thunked I/O less confusing |
| 21:28 | tomoj | (reduce side-effects! nil seq-or-reducer-of-values) |
| 21:29 | tomoj | eh. I do have IO problems. I dunno that thunked IO would solve them |
| 21:29 | Apage43 | I still don't actually get what the desired behavior is, here |
| 21:30 | Sgeo | Desired behavior is for |
| 21:30 | Sgeo | ,(dorun (take-nth 2 (map println [1 2 3 4]))) |
| 21:30 | clojurebot | 1 |
| 21:30 | clojurebot | 2 |
| 21:30 | clojurebot | 3 |
| 21:30 | Sgeo | To just print 1 then 3 |
| 21:30 | clojurebot | 4 |
| 21:30 | Apage43 | ah |
| 21:33 | Apage43 | ,(dorun (map deref (take-nth 2 (map #(delay (println %)) [1 2 3 4])))) |
| 21:33 | clojurebot | 1 |
| 21:33 | clojurebot | 3 |
| 21:33 | tomoj | hmm, but those actions only execute once |
| 21:34 | tomoj | i.e. if you dorun the same seq again, it just prints nothing |
| 21:34 | Apage43 | ,(dorun (map #(%) (take-nth 2 (map #(fn [] (println %)) [1 2 3 4])))) |
| 21:34 | clojurebot | 1 |
| 21:34 | clojurebot | 3 |
| 21:34 | tomoj | yeah, but Sgeo wants support from core :) |
| 21:34 | Apage43 | and you can (dorun (map #(%) …)) that one a second time if you want to rerun the fn |
| 21:35 | Sgeo | If I write a library for this, what functions would I actually need to write? |
| 21:36 | Sgeo | thunkify, perform, dorun, doall, any others? |
| 21:36 | Sgeo | Would be nice to write (def perform #(%)) but that shows up differently in documentation, and I'm not sure where to put the docstring |
| 21:37 | Apage43 | (def ^{:doc "I am a doc-string} somevar) |
| 21:37 | Apage43 | er |
| 21:37 | Apage43 | (def ^{:doc "I am a doc-string"} somevar) |
| 21:37 | tomoj | so reduce :: (a -> b) -> a -> IReduce b -> IO b |
| 21:37 | Apage43 | ,(meta #'+) |
| 21:37 | clojurebot | {:ns #<Namespace clojure.core>, :name +, :file "clojure/core.clj", :line 920, :arglists ([] [x] [x y] [x y & more]), ...} |
| 21:38 | Sgeo | Ugh, I'd need to include arglists too, wouldn't I |
| 21:38 | Sgeo | Clojure makes it so painful to be pointless |
| 21:38 | Sgeo | I love pointless programming |
| 21:39 | Sgeo | (Yes, I know the usual term is pointfree. I'm trying to be funny) |
| 21:39 | ChongLi | even haskell can make it painful to do pointfree style |
| 21:39 | ChongLi | if you're trying to stretch it anyway |
| 21:40 | ChongLi | there's some real gymnastics you do when there are multiple arguments |
| 21:40 | ChongLi | like the owl combinator |
| 21:41 | Sgeo | Isn't there some sort of semantic editors thingy? |
| 21:41 | gfredericks | Apage43: clojure allows docstrings on def now |
| 21:41 | Sgeo | Which I don't entirely understand, but whatever. |
| 21:41 | Apage43 | oh? Neat. |
| 21:41 | gfredericks | (def perform "This is my perform fn" #(%)) |
| 21:41 | Sgeo | ,(-> (meta #'+) keys) |
| 21:41 | clojurebot | (:ns :name :file :line :arglists ...) |
| 21:41 | tomoj | I'm working on a semantic editors library |
| 21:41 | tomoj | not going so well |
| 21:41 | Sgeo | gfredericks, it will still be called a var and not a function by documentation though I think |
| 21:42 | gfredericks | Sgeo: that'd be tool specific, right? |
| 21:42 | gfredericks | or you mean the :arglists missing and such? |
| 21:43 | Sgeo | :arglists missing, and the var thing I'm pretty sure I saw on Incanter documentation |
| 21:43 | gfredericks | ,(-> *clojure-version* var meta keys) |
| 21:43 | clojurebot | (:added :doc :ns :name :dynamic ...) |
| 21:43 | Sgeo | ztellman uses some library he wrote for importing fns from a namespace, wouldn't be necessary if def were comfortable |
| 21:45 | tomoj | you say (def foo +), and you want the :line/:file metadata to point back to clojure.core? or you just want specific parts of the metadata? :) |
| 21:46 | gfredericks | arglists would be nice |
| 21:46 | gfredericks | hmm :/ |
| 21:46 | gfredericks | arglists and doc seem problematic though |
| 21:47 | gfredericks | anything can be added manually |
| 21:50 | Sgeo | tomoj, well, would be nice to say (def foo (comp a b)), in which case there's multiple things that line and file would come from |
| 21:50 | tomoj | oh, right, even (def foo +) is doomed since + has no metadata |
| 21:50 | gfredericks | tomoj: but presumably (def foo +) is an abstraction, and taking just about anything from + would be leaky |
| 21:51 | Sgeo | Because relevant metadata like arglists is on the var and not the fn |
| 21:51 | Sgeo | If it were on the fn, comp could produce new metadata |
| 21:51 | Sgeo | For example |
| 21:51 | Sgeo | Although it would be annoying for writers of functions like that to have to do so, I guess |
| 21:52 | tomoj | the problem to me is that clojure.core can't choose for you what you want, you have to choose |
| 21:52 | tomoj | if you want a comp that passes on some particular metadata you have to write it, since there's no generally desirable way to merge the metadata, I think |
| 21:54 | tomoj | gfredericks: yeah, that's another case where clojure can't decide for you |
| 22:05 | tomoj | hmm http://okmij.org/ftp/Haskell/zip-folds.lhs |
| 22:05 | tomoj | interesting point there. since we have r/take and r/drop, we can get r/zip |
| 22:05 | tomoj | except.. that causes trouble if a reducer does IO upon reduce |
| 22:05 | tomoj | and seems likely inefficient? |
| 22:12 | devinus | can anybody explain why there seems to be a lot of mongo love in the clojure community? |
| 22:12 | devinus | am i missing something or is it just a coincidence? |
| 22:20 | gfredericks | clojure is webscale? |
| 22:26 | bbloom | devinus: probably a coincidence |
| 22:26 | bbloom | mongo has a lot of buzz, it's dynamically typed, it's pretty easy to set up.. there's probably some overlap in the style of workflows, so there's some overlap in the user bases |
| 23:06 | Apage43 | devinus: I think it's about the same as the hold it has with node/python/ruby/etc., for prettymuch the reasons bbloom said |
| 23:19 | jonasen | seangrove: http://jida.herokuapp.com/?query-id=50bad538e4b02c359b552010 |
| 23:19 | jonasen | seangrove: what happened with the datomic update? I saw you reverted it |