2012-12-02
| 01:40 | Sgeo | Is there already a library providing Lamina with a monadic interface? |
| 01:40 | Sgeo | If not, I'll go write one |
| 01:56 | tomoj | Sgeo: I haven't seen one. what would you get out of it, `for` for channels, and anything much more? |
| 01:56 | Sgeo | Well, currently only going to do result-channels |
| 01:56 | Sgeo | But I think `for` for result-channels is a cool thing |
| 01:57 | Sgeo | lift is pretty good too, but Lamina might have that already, I didn't check |
| 02:39 | tomoj | Sgeo: lamina sort of already has that I think? |
| 02:39 | tomoj | oh, no, it got removed in the perf branch iirc |
| 02:39 | Sgeo | o.O what was it? |
| 02:40 | tomoj | the async macro |
| 02:40 | tomoj | (async (let [x a-result-ch y b-result-ch] [x y])) |
| 02:42 | tomoj | cljque's `on` |
| 02:42 | tomoj | except `async` did more, e.g. I think (async (f a-result-ch)) passed the result to f, not the result-ch |
| 02:43 | tomoj | https://github.com/ztellman/lamina/wiki/Async-Programming |
| 02:43 | tomoj | the bottom example is kinda funny to me |
| 02:43 | tomoj | why isn't it (async (doseq [msg ch] (handle-message ch))) ? |
| 02:45 | tomoj | er, (handle-message msg) of course |
| 03:16 | brainproxy | just saw asterline's netty-ring-adapter, any thoughts on when to favor something like that instead of jetty? |
| 05:00 | TEttinger | ,(doseq [j (range 4)] (doseq [i (range 4)] (print "*")) (print)) |
| 05:00 | clojurebot | **************** |
| 05:00 | TEttinger | &(doseq [j (range 4)] (doseq [i (range 4)] (print "*")) (print)) |
| 05:00 | lazybot | ⇒ ****************nil |
| 05:00 | TEttinger | huh, the bot I am running gets execution timeouts when it evals that code |
| 05:01 | TEttinger | &(doseq [j (range 4)] (doseq [i (range 10)] (print "*")) (print)) |
| 05:01 | lazybot | ⇒ ****************************************nil |
| 05:04 | nightfly_ | I'm getting java.lang.NoClassDefFoundError when I try and import an abstract java class or any of it's decendants. The source file definitely exists and lein is compiling a .class for it. Is there some special symantics for dealing with abstract classes I'm missing or what? |
| 05:08 | borkdude | nightfly_ in this case it always helps to print a directorly listing on refheap, or better yet, the project on github |
| 05:08 | borkdude | nightfly_ and your project.clj -- not that I know the answer, but this usually helps people to find the error more quickly |
| 05:08 | mpenet | Sgeo: see pipeline/run-pipeline it's probably what you are looking for |
| 05:09 | Sgeo | Except for needing to use merge-results and then unpack the result from that in the next stage? |
| 05:09 | mpenet | there is a merge-result fn I think |
| 05:10 | mpenet | nm |
| 05:10 | mpenet | yes, you have to do that manually |
| 05:10 | nightfly_ | borkdude: Well, most of the code is the decompiled code for minecraft so I can't really put it up anywhere... The only addition to my project.clj is :java-source-paths ["src/java"] and concrete classes are importing as expected. |
| 05:13 | mpenet | Sgeo: another option is to use restart/complete and use a pipeline like a loop that updates the state at every step |
| 05:13 | Sgeo | restart/complete? |
| 05:13 | mpenet | lamina.core/restart lamina.core/complete |
| 05:14 | Sgeo | Another option: Make it compatible with an existing macro that does pretty cool things. |
| 06:23 | wei_ | is anyone using friend with noir and if so, how did you define the logout function? |
| 06:30 | muhoo | wei_: i did, i don't remember how i did that though |
| 06:30 | muhoo | nice work on the jida thing btw |
| 06:30 | wei_ | thanks |
| 06:31 | muhoo | it looks like i just did ((friend/logout identity) |
| 06:31 | muhoo | (defpage "/logout" ... ((friend/logout identity) |
| 06:32 | wei_ | oh, didn't realize that would work. I thought you needed to pass in a handler. |
| 06:32 | muhoo | with a (response/status 200....) after that |
| 06:32 | Raynes | Chris Granger should pay me for this shit. |
| 06:32 | muhoo | Raynes: which shit? |
| 06:32 | Raynes | Up at 5:30AM trying to get a noir release out, updating his crappy website with unqualified uses and shit. |
| 06:32 | Raynes | I'm going to ridicule him for these uses. |
| 06:33 | Raynes | He also uses TWO libraries that both have single segment namespaces. |
| 06:33 | wei_ | haha. thanks for maintaining it, raynes |
| 06:33 | Raynes | And I had to switch to a new library for markdown and guess what? It uses single segment nses too. |
| 06:33 | wei_ | that and jayq |
| 06:33 | muhoo | :-( |
| 06:33 | Raynes | I want to kill myself for even using these libraries. |
| 06:34 | muhoo | IIRC, somre of the uses in noir override core functions too |
| 06:34 | muhoo | some |
| 06:34 | Apage43 | heh, I use conch + some command line markdown program for markdown in the things I've done that use markdown from clojure |
| 06:35 | wei_ | noir is very opinionated. |
| 06:35 | Raynes | Noir is very annoying. |
| 06:35 | wei_ | :P |
| 06:36 | Raynes | If Chris wasn't a buddy, I'd never even try to maintain it. |
| 06:37 | muhoo | it's very big of you to pick up that task. |
| 06:37 | muhoo | i'd say he owes you. |
| 06:37 | Raynes | He'll pay me back with liquor when I turn 21. |
| 06:37 | wei_ | yes, thanks for wading through it. I've been very productive using it lately |
| 06:38 | muhoo | go to louisiana, drink there. |
| 06:40 | muhoo | ugh, my information is out of date. louisiana is 21 now too. whole country is. http://en.wikipedia.org/wiki/U.S._history_of_alcohol_minimum_purchase_age_by_state sorry bro, things were different in my day. |
| 06:41 | Sgeo | single segment namespaces? |
| 06:41 | Apage43 | (ns blah) as opposed to (ns thing.blah) |
| 06:41 | Sgeo | oh |
| 06:42 | Sgeo | Uh, I take it that that's disliked for some reason? |
| 06:42 | Raynes | https://groups.google.com/forum/?fromgroups#!topic/clojure/gOffhotk25Y |
| 06:42 | Apage43 | causes issues, yeah |
| 06:42 | Raynes | For lots of reasons. |
| 06:42 | Raynes | One, it's broken, two, people should at least try to use unique namespaces. |
| 06:43 | gfredericks | like ##(format "ns-%d" (rand-int 10000000))? |
| 06:43 | lazybot | ⇒ "ns-4153793" |
| 06:43 | muhoo | namespaces didn't make my life as miserable as the copious use of macros did. or the non-functional storing of local state in atoms. or, whatever, i enjoyed noir until i didn't anymore. |
| 06:46 | wei_ | muhoo: thanks, your suggestion above worked for me |
| 06:47 | muhoo | great. i'm going to have to integrate friend with some kind of json or edn service soon, so i'll refamiliarize with it |
| 06:47 | wei_ | ah, i have it working with fetch |
| 06:48 | muhoo | cool, in that jida project? |
| 06:48 | wei_ | nope, another project. this example helped: https://github.com/xeqi/friend-fetch-example |
| 06:48 | Sgeo | Is Friend usable with non-web services? |
| 06:49 | wei_ | although I'm going to update that example with a working log-out |
| 06:50 | wei_ | Sgeo: I've only used it for web, although it claims to support "multiple workflows" |
| 06:51 | wei_ | muhoo: did you use friend with a session store in your last project? that's not working for me yet |
| 06:51 | muhoo | wei_: i used couchdb as a session store, iirc |
| 06:52 | muhoo | had to do some massive hacks/fixes to the couch session store lib though |
| 06:53 | wei_ | i'm using mongo. other than the lib, did you do anything more than specify :session-store in noir.server/start? |
| 06:55 | wei_ | (thanks) |
| 06:56 | muhoo | ah, i never integrated that in production. it's sitting in a dead branch. wasn't confident in it. |
| 06:57 | muhoo | but it was easy, just https://www.refheap.com/paste/7211 |
| 06:59 | muhoo | so the production app is using a memory store, apparently. but, yes, just :session-store and off you go. |
| 07:00 | wei_ | that's what I have too, with monger. it's creating the session records but not authenticating the user when they come back. |
| 07:00 | wei_ | will investigate further |
| 07:01 | muhoo | doing more reading, the reason i didn't integrate it is because i got the idea that having session store come back through a json round trip to a network data store was insane. |
| 07:02 | muhoo | looks like just keeping it in ram was going to be fine, and i was going to add in the aging middleware so as to not burn up ram |
| 07:03 | muhoo | also, i was using google auth, so if the server restarted, and the memory wiped out, google would reauth them transparently, and the users didn't see any glitch. |
| 07:05 | muhoo | and i wasn't doing anything really stateful on the server side anyway. |
| 07:05 | wei_ | i see. memory store works great for your use case |
| 07:35 | sqiudz | what would be the shortest way to change [0 0 0] 1 [2 2 2] into [0 0 0 1 2 2 2] ? |
| 07:36 | borkdude | sqiudz (fn [a b c] (concat a [b] c)) |
| 07:36 | hyPiRion | &((fn [& r] (flatten (apply concat r))) [0 0 0] 1 [2 2 2]) |
| 07:36 | lazybot | java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long |
| 07:36 | sqiudz | borkdude: so just convert the single val to a single vector val and then use concat? |
| 07:37 | borkdude | ,( (fn [a b c] (concat a [b] c)) [0 0 0] 1 [2 2 2]) |
| 07:37 | clojurebot | (0 0 0 1 2 ...) |
| 07:37 | hyPiRion | &((fn [& r] (flatten (apply reduce into r))) [0 0 0] 1 [2 2 2]) |
| 07:37 | lazybot | clojure.lang.ArityException: Wrong number of args (4) passed to: core$reduce |
| 07:37 | borkdude | sqiudz yes |
| 07:37 | hyPiRion | Arrh, I'm too old for this. |
| 07:37 | hyPiRion | ,(flatten (conj [0 0 0] 1 [2 2 2])) |
| 07:37 | clojurebot | (0 0 0 1 2 ...) |
| 07:38 | hyPiRion | Is the idea. |
| 07:38 | sqiudz | im getting the illegalArgumentException though |
| 07:39 | hyPiRion | sqiudz: For which? borkdude's should work fine. |
| 07:39 | sqiudz | hyPiRion: let me try your last one |
| 07:39 | hyPiRion | ,((fn [& r] (flatten (reduce conj r))) [0 0 0] 1 [2 2 2]) |
| 07:39 | clojurebot | (0 0 0 1 2 ...) |
| 07:41 | sqiudz | hyPiRion: okay the last one with flatten seems to work |
| 07:42 | Chousuke | I hope that's not a very common operation in your program :P |
| 07:42 | sqiudz | the only thing is that it converts it to a list when I wanted to keep it a vector |
| 07:42 | Chousuke | sqiudz: call vec on the result again |
| 07:42 | sqiudz | Chousuke: and yes it will be pretty common |
| 07:42 | Chousuke | then use a different data structure |
| 07:43 | sqiudz | calling vec only puts the list in [(n1 n2 n3)] |
| 07:43 | sqiudz | Chousuke: please elaborate |
| 07:43 | Chousuke | adding things in the middle of a vector is a linear operation |
| 07:43 | Chousuke | which means if you do it a lot, it will be slow |
| 07:44 | sqiudz | i', appending vectors with conj |
| 07:44 | sqiudz | isnt that different? |
| 07:44 | Chousuke | in that case you can do: |
| 07:45 | Chousuke | ,(into [1 2 3] [4 5 6]) |
| 07:45 | clojurebot | [1 2 3 4 5 ...] |
| 07:45 | Chousuke | that's not so bad, performance-wise |
| 07:45 | sqiudz | I have a single value in between |
| 07:45 | sqiudz | like [1 2 3] 4 [5 6 7] |
| 07:46 | Chousuke | well then you should do a conj first and then into |
| 07:46 | sqiudz | okay |
| 07:46 | sqiudz | then performance should be pretty good still right? |
| 07:46 | Chousuke | well, it's still linear on the size of the vector you're appending + the one conj |
| 07:46 | Chousuke | but it's better than using reduce conj and flatten and then making a new vector |
| 07:47 | sqiudz | okay, thanks. Do you think it would be possible to get it to run constant? |
| 07:47 | Chousuke | no. |
| 07:47 | hyPiRion | Constant? |
| 07:47 | clojurebot | unlink: and constantly is just a function that takes any arguments and returns whatever argument is given |
| 07:48 | borkdude | what about this one? https://www.refheap.com/paste/7216 |
| 07:48 | hyPiRion | ,(conj [1 2 3] 4) ; is constant |
| 07:48 | clojurebot | [1 2 3 4] |
| 07:48 | Chousuke | sqiudz: you can concat two lists lazily in constant time but not vectors. |
| 07:49 | hyPiRion | ,(into [1 2 3] [4 5 6]) ; O(n), where n is the size of the last vector |
| 07:49 | clojurebot | [1 2 3 4 5 ...] |
| 07:49 | sqiudz | Chousuke: ah okay. Is it true that Lists are kind of like LinkedLists in java where Arrays are like ArrayLists? |
| 07:49 | Chousuke | mmm not really. |
| 07:49 | Chousuke | arrays support random access, and conj to the tail |
| 07:49 | sqiudz | then how can I compare the two |
| 07:49 | Chousuke | lists are linear access only and conj to the front |
| 07:50 | Chousuke | neither support insertion in the middle |
| 07:50 | sqiudz | ah okay thanks very helpful |
| 07:50 | borkdude | sqiudz did you see my fn in the refheap paste? |
| 07:50 | Chousuke | also, I said arrays but I meant vectors, obviously :P |
| 07:50 | sqiudz | borkdude: no let me take a look |
| 07:50 | borkdude | it basically selects into or conj |
| 07:50 | Chousuke | sqiudz: and clojure lists and vectors are also immutable, which is quite important :) |
| 07:51 | sqiudz | yes, I guess what I did was kind of make my own array insert |
| 07:52 | Chousuke | if you need a lot of inserts in the middle of a data structure you should maybe use a finger tree or something |
| 07:52 | sqiudz | this is what I did in the end https://www.refheap.com/paste/7217 |
| 07:52 | Chousuke | but if you're fine with just appending vectors to each other then into should be okay. |
| 07:52 | sqiudz | Chousuke: So I would have to implement my own finger tree right, since I suppose clojure doesnt support them out of the box |
| 07:53 | sqiudz | that just inserts a '1' into a vector at a given index |
| 07:54 | Chousuke | sqiudz: there's a contrib library of finger trees |
| 07:54 | Chousuke | sqiudz: but you can keep on using vectors for now |
| 07:54 | Chousuke | change it later if speed is an issue |
| 07:54 | borkdude | Chousuke right, if it's not the bottleneck, why bother |
| 07:55 | Sgeo | Why does frenchy64's analyze require 1.5? |
| 07:55 | sqiudz | Chousuke: ive never used a finger tree, and while it shouldnt be a problem with speed, it might be interesting to acquaint myself with finger trees anyhow |
| 07:56 | borkdude | sqiudz or use a Java ArrayList :P |
| 07:56 | Chousuke | finger trees are weird |
| 07:56 | Chousuke | :P |
| 07:56 | sqiudz | I would rather go functional if I have the choice |
| 07:56 | borkdude | sqiudz good boy, this was only a test |
| 07:56 | sqiudz | haha |
| 07:57 | Chousuke | finger trees can actually be used to implement all kinds of weird data structures |
| 07:57 | sqiudz | I'm really loving clojure. I normally program java, and started doing haskell on the side. Haskell was fun, but it was so hard to get things done. Maybe I just need more time. After trying clojure though, everything just seems to be 'right' |
| 07:57 | sqiudz | Chousuke: do you use them often? |
| 07:58 | borkdude | sqiudz I sense that too. Clojure is made for people who want to get things done |
| 07:58 | Chousuke | nah. I just know they're capable of crazy stuff :P |
| 07:58 | Chousuke | it's a bit easier to experiment with clojure |
| 07:58 | Chousuke | haskell can be extremely productive as well but you need to understand its abstractions an type system and it's a bit of a hurdle. |
| 07:58 | Chousuke | and* |
| 07:59 | tgoossens | i have a collection: ((0 1 4 7 8 9) (0 1 2 5 8 9) (0 1 2 5 6 9) (0 3 4 7 8 9) (0 1 2 4 7 9) (0 2 5 7 8 9)) . Some of the subcollections are the complement of another (concretely: (map #(- 9 %) coll) sometimes matches another one) |
| 07:59 | tgoossens | i want to filter this collection |
| 07:59 | tgoossens | to remove the complements |
| 07:59 | tgoossens | so that in the result, no subcoll is the complement of another |
| 08:00 | tgoossens | hmm |
| 08:00 | tgoossens | maybe recursion will help me here |
| 08:00 | borkdude | Chousuke yes agree about Haskell, it's a bit of a learning curve but I have the gut feeling there must be something at the end being worth it all |
| 08:00 | Chousuke | borkdude: some of the abstractions are simply beautiful |
| 08:01 | borkdude | Chousuke I'm reading about parsing now, it looks nice - I think you could do the same in clojure though |
| 08:01 | Chousuke | even supposedly "scary" things like monads are extremely simple. Once you understand what they actually do. |
| 08:02 | Chousuke | you can actually implement monads in clojure with about 20 lines of code |
| 08:02 | Chousuke | they're not quite as convenient to use as in haskell. though. |
| 08:03 | borkdude | Chousuke I am only a Haskell n00b, but the do syntax thing, it can be applied to monadic things right? |
| 08:03 | borkdude | Chousuke I mean, do is made to make monadic composition easier? |
| 08:03 | Chousuke | do syntax is sugar for bind, yeah |
| 08:03 | sqiudz | would using monads in clojure be more of an abstraction design decision, where using Monads could improve say an API |
| 08:03 | Chousuke | borkdude: a monad is actually an abstraction that provides two operations, bind and return. |
| 08:04 | Chousuke | borkdude: do is sugar for making bind easier to use. |
| 08:04 | sqiudz | and I guess the good stuff is how you define bind |
| 08:04 | Chousuke | so everything that implements the monad abstraction gets to use do |
| 08:04 | Chousuke | because it's just bind under the covers |
| 08:04 | borkdude | Chousuke right |
| 08:05 | sqiudz | being able to implement your own bind means that you can provide a 'context' to every sequential bind that you do in a given monad |
| 08:05 | sqiudz | which is i guess why some describe monads as a context |
| 08:10 | borkdude | sqiudz I think "context" is a nice term for it |
| 08:11 | borkdude | that makes me wonder, what does the word monad actually mean… http://www.etymonline.com/index.php?term=monad <- right... |
| 08:26 | tomoj | Sgeo: you seen the pod talk? |
| 08:26 | Sgeo | tomoj, no |
| 08:29 | Sgeo | Hmm, delimc seems to use macroexpand-1 as its only macroexpansion tool |
| 08:29 | Sgeo | Which is, uh. Insufficient. |
| 08:30 | Sgeo | As far as I can tell, macroexpand-1 and macroexpand-all are not sufficient to fully macroexpand a macro and all subforms |
| 08:30 | Sgeo | There's no way to pass a lexical environment to them, so any macro that uses &env will break. |
| 08:32 | tomoj | Sgeo: maybe tools.macro's mexpand will work? |
| 08:33 | Sgeo | Just realized that macros are functions, you can call the function, and I think the function takes &env and &form as arguments |
| 08:33 | Sgeo | tomoj, or that might work |
| 08:33 | tomoj | hmm, there's no &env in that ns though |
| 08:35 | tomoj | jacking in.. aw. pom.xml. |
| 08:37 | Sgeo | ...I think I'm about to get into a flamewar on Clojuredocs |
| 08:41 | Sgeo | Is there any way to receive an email when someone comments on a Clojuredoc page |
| 08:41 | Sgeo | ? |
| 08:52 | KiPSOFT | hi all |
| 09:00 | sqiudz | hi kip |
| 09:01 | KiPSOFT | how to type class default property in clojure ? |
| 09:01 | sqiudz | how do I* |
| 09:02 | KiPSOFT | http://pastebin.com/7trq5ziM |
| 09:02 | KiPSOFT | example this pastebin |
| 09:39 | Voting | If I'm planning to work in clojurescript in the near future, is this channel where I should ask my questions? |
| 09:40 | daimrod | Voting: there is #clojurescript |
| 09:40 | jonasen | Voting: yes |
| 09:41 | Voting | Only 3 or 4 in #clojurescript... better to be here? |
| 09:43 | hyPiRion | Voting: better to be here, yes. |
| 09:43 | Voting | I'm an old hand at Lisp programming (Lisp Machines even) ... Will I clojurescript? |
| 09:43 | Voting | will I enjoy clojurescript? |
| 09:45 | AimHere | You might like it more than javascript |
| 09:50 | sqiudz | how do clojurescript and fay(haskell) compare? |
| 09:51 | Voting | Considering http://haxe.org/ - Why would I consider ClojureScript rather than a haxe, a language the provides lots of checking and portability? |
| 09:52 | Raptum | because parens |
| 09:53 | Voting | (I was not joking - what is good about javascript...) |
| 09:53 | AimHere | Voting, there's a book all about that, actually |
| 09:53 | AimHere | Admittedly, a slim one |
| 09:53 | Voting | AimHere: what book do you mean? |
| 09:54 | AimHere | Javascript: The Good Parts, by Douglas Crockford |
| 09:54 | AimHere | The thesis is that under all that terrible DOM junk, and a bunch of ugly ad-hoc warts, there's a nice, powerful, flexible language yearning to break free |
| 09:55 | Voting | AimHere: Javascript: the good parts will help me know if I want to program in Haxe or ClojureScript? |
| 09:56 | MauriceMoss42 | hey all... I've got an hypothetical question (in order to better understand how Clojure works): if I could modify Clojure so that I could prevent 'eval' from working at runtime (I'm not saying it's possible: let just pretend it is), would program not specifically using eval and not offering a REPL still work? |
| 09:56 | Voting | yes |
| 09:56 | AimHere | Not really. Clojurescript is for people who want to write something like Clojure because they don't want to write Javascript either |
| 09:56 | MauriceMoss42 | Voting: was the 'yes' for my question about eval? |
| 09:57 | Voting | MauriceMoss42: PM me if you like |
| 09:57 | Voting | MauriceMoss42: yes, I would be surprised if ... |
| 09:57 | Voting | I am wrong about that... |
| 09:57 | Voting | funcall sorts of thing may be used all over the place... |
| 09:58 | Voting | but eval should not be used beside in the repl |
| 09:58 | Voting | and when someone calls eval |
| 09:59 | AimHere | Eval is like reader macros or thermonuclear weapons. You can sneer at other languages or other countries, because you have such things and they don't, but for fucks sake, don't thing about actually USING them |
| 10:00 | Voting | But I don't know the actual implementation of clojure... I'm just talking in general about how lisps are implemented |
| 10:00 | AimHere | *think |
| 10:00 | Voting | I think reader macros can be useful in certain applications, actually. Used to know johl white, the inventor of them... |
| 10:01 | Voting | Where would you expect eval to be used where internally, MauriceMoss42 ? |
| 10:01 | MauriceMoss42 | AimHere: my question was more like: "If I'm not specifically using eval, is Clojure under the hood still using eval at runtime even if there's no repl" : ) |
| 10:02 | Voting | where would it? |
| 10:02 | MauriceMoss42 | Voting: well... you tell me : ) I'm just discovering the macro / functions (compiled to bytecode in Clojure?!) etc. and I was wondering about that specific case. |
| 10:02 | AimHere | Well you could always grep the code you're intending to use for 'eval' (and then grep for the functions that use it etc) |
| 10:03 | AimHere | As in, the underlying code for the libraries and so on |
| 10:03 | MauriceMoss42 | Voting: I mean: knowing that eval should potentially not be used anywhere at runtime unless I'm either using a REPL or specifically calling eval helps me better understand how thing works (I guess) |
| 10:03 | Voting | MauriceMoss42: A compiler for lisp... |
| 10:03 | MauriceMoss42 | AimHere: but I'd also then need to grep the built-in APIs / functions / macros... |
| 10:04 | MauriceMoss42 | Voting: (another topic) so reader macros were a late addition to lisps dialect and weren't in the "first lisp"? |
| 10:04 | Voting | MauriceMoss42: A compiler for lisp can generate code that applies functions to arguments, right? Why would the compiler need to eval? It is arranging to do that later, right? |
| 10:05 | Voting | MauriceMoss42: reader macros were not in lisp 1.5, for sure. |
| 10:08 | Voting | MauriceMoss42: and they are an obscure feature for use when you want to be able to be able to type in a data structure. Say, for example, I want to be able to type in the name of a person and have it hook into the person, stored in some lookup table or something... I want the code to be able to write out data structuers that will be readable later... you could program your entire life in lisp and never choose to use this feature and this w |
| 10:09 | Voting | (I'm speaking as a person who use to program in CommonLisp and predecessor lisps and I could be out of date here.) |
| 10:13 | MauriceMoss42 | Voting: thanks a lot for all these infos... Going back to devouring my book ("Clojure programming") : ) |
| 10:16 | hcumberdale | How to order '("/prefix/filename2.ext" "/prefix/filename1.ext" "/prefix/filename3.ext") by '("filename1" "filename2")? |
| 10:18 | gfredericks | hcumberdale: you need a function that pulls out the simple filename, then you can use sort-by |
| 10:19 | wingy | should i cache user profile pages? |
| 10:19 | hcumberdale | gfredericks: But I need the full file name as result |
| 10:19 | wingy | seems not cacheable right since GET /my-account requests should give you different pages based on what session id is |
| 10:20 | hcumberdale | wingy: why not use GET /account/username or id |
| 10:21 | hcumberdale | Or cache the results behind the decision what to put into my-account |
| 10:22 | wingy | hcumberdale: seems weird since you still need to be logged in (have the correct session data) or else GET /accounts/:id would fail |
| 10:22 | wingy | another reason might be that then someone can save the URL which gives the wrong impression that you can just click on it and be logged in |
| 10:23 | wingy | oh |
| 10:24 | hcumberdale | wingy: that shouldn't be a problem since you can check if the user is logged in and redirect |
| 10:24 | hcumberdale | do you use friend? |
| 10:24 | wingy | no |
| 10:25 | wingy | let's say that this is a bank .. is it good to have the profile page cached? |
| 10:25 | wingy | will it rise security issues? |
| 10:25 | hcumberdale | wingy: caching is not about security |
| 10:25 | hcumberdale | (server-side caching) |
| 10:26 | hcumberdale | You can just check if a user is authorized regardless if you have a cache or not |
| 10:27 | wingy | ok |
| 10:27 | wingy | i'll try with GET /account first and see if it fits |
| 10:27 | hcumberdale | just having a page which is aware of a session-id and is not good for many reasons |
| 10:27 | wingy | without caching that is |
| 10:28 | wingy | friend can help me with this kind of stuff? |
| 10:28 | hcumberdale | wingy: HTTP-GET should get a uniqe single ressource |
| 10:28 | hcumberdale | wingy: yes! |
| 10:28 | hcumberdale | There are frameworks working like GET /everything with some parameters, session awareness and so on |
| 10:29 | hcumberdale | But you should avoid that |
| 10:29 | hcumberdale | if there is a ressource you can build nice url's to directly point to it |
| 10:29 | wingy | https://github.com/cemerick/friend seems difficult to get |
| 10:29 | hcumberdale | like /accounts/john_doe |
| 10:30 | hcumberdale | wingy: yes but only because it is lacking full & complete examples |
| 10:30 | wingy | it is worth the time then? |
| 10:30 | hcumberdale | It is not hard at all if you get it working |
| 10:31 | hcumberdale | wingy: there is sandbar and friend, both good |
| 10:31 | hcumberdale | friend is more up to date, provides more features and does not come with dependencies like hiccup |
| 10:32 | hcumberdale | I've written a lot with sandbar. But now I'm going on with friend |
| 10:32 | wingy | cool didnt know about sandbar |
| 10:32 | wingy | i trust cemerick :) |
| 10:32 | wingy | up to date means everything |
| 10:35 | hcumberd` | ;) |
| 10:42 | cemerick | hcumberd`: friend will be getting much better docs soon. I finally pushed my revamp of nrepl docs recently, so friend is the last project of mine waiting in that particular queue. Thanks for your patience. :-) |
| 10:43 | borkdude | what a friend we have in cemerick |
| 10:45 | hcumberd` | cemerick: thx! I've created some working examples for friend+compojure. |
| 10:52 | wingy | yeah would better doc i would get how to use friend |
| 10:53 | wingy | please explain what/why/how |
| 10:54 | hcumberd` | wingy |
| 10:54 | hcumberd` | https://github.com/kremers/friendly |
| 10:55 | wingy | thx |
| 10:56 | wingy | hcumberd`: i also found that https://twitter.com/settings/profile is not appending your id in the URL |
| 10:56 | wingy | so i should just do GET /account |
| 10:56 | wingy | and check whatever session id to respond with |
| 10:56 | wingy | and not cache it |
| 10:58 | hcumberd` | wingy: it's kind of the interpretation of HTTP-GET |
| 10:58 | wingy | btw .. if all my pages is showing the current username in the HTML page .. then to be able to caching it I have to provide GET /page?user=123 right? |
| 10:58 | hcumberd` | If you say a the page "account" is a single unique ressource it's okay |
| 10:58 | wingy | since if i just have GET /page then i can't have them showing different usernames |
| 10:59 | hcumberd` | From the view of the user it is a unique ressource |
| 10:59 | hcumberd` | From the view of the server it's not. So its really possible to discuss |
| 11:00 | hcumberd` | wingy: There is browser-side and server-side caching possible |
| 11:00 | hcumberd` | The browser just saves the page beyond "account" |
| 11:00 | hcumberd` | The cache will work for a single user |
| 11:00 | hcumberd` | Not if he's logging out and in with another user again |
| 11:01 | hcumberd` | it is very unlikely that cache coherence will occur |
| 11:01 | hcumberd` | Because the browser will invalidate the cache |
| 11:01 | wingy | i c |
| 11:01 | wingy | so i dont need to append anything in the GET path |
| 11:01 | hcumberd` | Yes you do not need to |
| 11:01 | wingy | google isn't https://www.google.com/ shows my name |
| 11:01 | hcumberd` | But you should to comply to HTTP spec |
| 11:02 | wingy | hcumberd`: when will the browser invalidate the cache? when the session is changed? |
| 11:03 | hcumberd` | http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.3 |
| 11:03 | hcumberd` | wingy: depends on the browser |
| 11:03 | hcumberd` | IE6 will have a different mechanism |
| 11:05 | hcumberd` | wingy: you can provide cache headers in HTTP |
| 11:05 | hcumberd` | Cache-Control: max-age=1000 |
| 11:05 | wingy | yeah |
| 11:06 | p_l | also, ETags can help |
| 11:06 | hcumberd` | Or NoCache |
| 11:06 | hcumberd` | wingy: if your browser supports ETags, that's the creme |
| 11:06 | hcumberd` | creme-de-la-creme |
| 11:06 | wingy | yeah i have to read about that |
| 11:06 | hcumberd` | You can cache every ressource with it, but ETag generation is a big topic |
| 11:07 | hcumberd` | wingy: ETags are really easy. HTTP sends an additional Header ETAG:mytaghere |
| 11:07 | hcumberd` | The tag should be a uuid, generated by a checksum of the ressource |
| 11:07 | hcumberd` | resource ;) |
| 11:08 | wingy | my actual question was that if I do GET /profile and then my server will check for what user is currently logged in through session and respond with the current user profile .. if it's cached then the next GET /profile would give the same user .. so you are saying that if the user logs out the cache will be invalid .. and the next GET /profile will be re-fetched based on the new session data? |
| 11:09 | hcumberd` | wingy: It depends on how content is provided in your page |
| 11:09 | hcumberd` | Do you load specific things with javascript after page generation |
| 11:10 | wingy | no its just html |
| 11:10 | wingy | server spits out html to client |
| 11:10 | tataloo | is there any motherfucking manual for working with logical expressions and bitwise in clojure/ |
| 11:10 | tataloo | ? |
| 11:11 | wingy | lol |
| 11:11 | wingy | wanna RTFM i guess |
| 11:12 | tataloo | what the fuck is RTFM? |
| 11:12 | hcumberd` | tataloo: I don't know if there is a manual that fulfils the requirement 'motherfucking'. |
| 11:13 | tataloo | ok :( |
| 11:13 | wingy | tataloo: what you are trying to do :) |
| 11:13 | hcumberd` | http://clojure.org/data_structures |
| 11:13 | hcumberd` | There is a reference to all bitwise-* operators |
| 11:13 | hcumberd` | wingy: or what he better should do |
| 11:13 | tataloo | find the true bits in a binary using & |
| 11:16 | hcumberd` | tataloo: find the position, count,... ? |
| 11:16 | cemerick | hcumberd`: by all means, publish 'em |
| 11:17 | tataloo | seems fucking legit |
| 11:18 | hcumberd` | https://github.com/kremers/friendly |
| 11:18 | hcumberd` | That's one example ;) |
| 11:19 | hcumberd` | wingy: if you log out and log in again and the cache header does not say anything about invalidation it depends on your browser what happens |
| 11:19 | wingy | hcumberd`: ok |
| 11:20 | hcumberd` | Not all browsers comply fully to the HTTP SPEC about caching |
| 11:20 | hcumberd` | When it's likely to see errors in IE |
| 11:20 | hcumberd` | pages may work very well in FF |
| 11:20 | hcumberd` | http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13 |
| 11:20 | hcumberd` | Best you'll stick to the specification |
| 11:21 | hcumberd` | It's the only thing assuring you doing the 'right' thing |
| 11:21 | hcumberd` | (.replace thing way) |
| 11:28 | hcumberd` | wingy: If you work with cache invalidation headers like Last-Modified and a resource that is aware to a kind of 'state' like the session-id, you'll have to generate headers depending on the context. That's why a writing a single page for multiple cached results for different users is so hard to do |
| 11:29 | hcumberd` | It's much more easy to redirect on the context to a specific resource |
| 11:30 | hcumberd` | Like /my-account will forward you to /my-account/john_doe |
| 11:31 | wingy | hcumberd`: yeah |
| 11:32 | wingy | probably a better idea .. seems more correct |
| 11:32 | wingy | GET /accounts/123 |
| 11:33 | wingy | and then it checks the session id before generating |
| 11:33 | wingy | more RESTful |
| 11:34 | hcumberd` | yes |
| 11:35 | hcumberd` | Then caching is no problem. And you really have the control when to send modified headers or etags because you know when the page changed for a specific user |
| 11:36 | wingy | yeah! |
| 11:36 | hcumberd` | But the page as it is, is mostly the smallest part |
| 11:37 | hcumberd` | Bigger party are images, css, js, ... |
| 11:37 | hcumberd` | all cachable with etags |
| 11:37 | wingy | yupp |
| 11:37 | hcumberd` | if your page is really, really calculation/performance intensive you might really want to cache the whole page with etag&modified-since header |
| 11:38 | wingy | I have an anchor that do GET /logout and here is the route (GET "/logout" [] {:status 302 :headers {"Location" "/"} :session nil}) .. the issue is that after clicking it my browser is pointing to /logout still when it should be pointing to / |
| 11:38 | wingy | what is the issue? |
| 11:40 | wingy | i think the issue is jquery mobile … it's doing some magic in frontend |
| 11:40 | hcumberd` | wingy: you should use ring/redirect |
| 11:41 | hcumberd` | (GET "/admin/categories" [] (redirect "/admin/categories/")) |
| 11:42 | hcumberd` | like it's used to add a missing / |
| 11:42 | wingy | but then i can't nil the session |
| 11:42 | wingy | where is the function so i can see what its returning? |
| 11:42 | wingy | https://github.com/ring-clojure/ring/tree/master/ring-core/src/ring/middleware |
| 11:43 | wingy | https://github.com/ring-clojure/ring/blob/master/ring-core/src/ring/util/response.clj |
| 11:43 | wingy | its doing the same thing as I |
| 11:44 | MauriceMoss42 | tataloo: you mean using instead of & or 'and'? (spent quite some time debugging a piece of code where I was using 'and' instead of 'bit-and'... That's when static typing may help a little bit ; ) |
| 11:44 | hcumberd` | wingy: don't understand what exactly you mean |
| 11:45 | wingy | hcumberd`: just saying its returning the same response map as i do |
| 11:45 | MauriceMoss42 | tataloo: you mean using BIT-AND instead of & or 'and' |
| 11:45 | MauriceMoss42 | tataloo: (forgot the word 'bit-and', which may be what you're after) |
| 11:45 | tataloo | sure |
| 11:45 | hcumberd` | wingy: yes but it's build in ring functionality. Should be used if available (more readable,...) |
| 11:45 | MauriceMoss42 | tataloo: I did just use the Clojure cheatsheet as my 'manual' : ) |
| 11:46 | tataloo | yeah :) |
| 11:46 | hcumberd` | wingy: if you use friend like in the example project, you can use friend/logout |
| 11:46 | hcumberd` | It's middleware that cleans out all session information |
| 11:51 | dbs | Help please on working with multiple handlers (xmpp + noir-async). How do I make a noir/async-push whenever I receive an xmpp message? This code doesn't quite work: http://codepad.org/vGwRtwxD |
| 12:08 | borkdude | is there a function to append a line to a file, without with-open etc (pref. in clojure 1.3.0) |
| 12:10 | borkdude | probably this is just it? (defn log-line [line path] |
| 12:10 | borkdude | (with-open [wrtr (writer path :append true)] |
| 12:10 | borkdude | (.write line))) |
| 12:33 | hcumberd` | wingy: what are you currently writing? |
| 12:34 | wingy | hcumberd`: how so? |
| 12:34 | hcumberd` | users/accounts/http caching...? |
| 12:34 | hcumberd` | Shopping Website? |
| 12:34 | wingy | hcumberd`: yeah :) |
| 12:34 | wingy | thought to apply for YC next year |
| 12:34 | hcumberd` | What's YC? |
| 12:34 | wingy | hcumberd`: YCombinator |
| 12:35 | wingy | hcumberd`: and you? |
| 12:36 | hcumberd` | wingy: I've written a blog in clojure, tried a lot frameworks and ideas |
| 12:36 | wingy | link? |
| 12:36 | clojurebot | your link is dead |
| 12:37 | wingy | clojurebot: yeah . but perhaps not his |
| 12:37 | clojurebot | excusez-moi |
| 12:37 | wingy | clojurebot: shut up |
| 12:37 | clojurebot | Pardon? |
| 12:37 | hcumberd` | https://github.com/kremers/cblog |
| 12:37 | wingy | you look happy :) |
| 12:38 | wingy | from Germany? |
| 12:38 | hcumberd` | yes |
| 12:38 | wingy | cool .. huge market |
| 12:39 | hcumberd` | happy? impressions->go ? |
| 12:39 | wingy | the pic |
| 12:40 | hcumberd` | ahh github |
| 12:40 | hcumberd` | yes, it was taken in hamburg on a ship |
| 12:41 | hcumberd` | the market is huge, depending where in Germany you live |
| 13:07 | TimMc | clojurebot: forget your link |is| dead |
| 13:07 | clojurebot | I forgot that your link is dead |
| 13:08 | hcumberd` | !link google.de |
| 13:10 | Raptum | as someone whom is coming from scheme/CL and hasn't used java in a few years, would it really be all that worth my time to run through a refresher course on java again before pursuing the clojure path? |
| 13:10 | TimMc | Raptum: If you've used Java at all in the past, probably not. |
| 13:10 | Raptum | cool. |
| 13:11 | TimMc | Clojure uses some newer standard-library features such as the executors framework, but you likely won't need to know anything about that dependency. |
| 13:11 | Raptum | anything massive i'm going to miss from the other lisps? |
| 13:11 | Raptum | CL in particular |
| 13:12 | TimMc | Full numeric tower. |
| 13:13 | TimMc | Clojure relies on JVM numerics, which has some weirdness re: hashing, and in version 1.3 abandoned autopromoting math as a default. |
| 13:14 | TimMc | e.g. ##(take 4 (range Long/MAX_VALUE Double/POSITIVE_INFINITY)) used to work |
| 13:14 | lazybot | java.lang.ArithmeticException: integer overflow |
| 13:14 | Raptum | ah |
| 13:15 | TimMc | &(take 4 (iterate inc' Long/MAX_VALUE)) |
| 13:15 | lazybot | ⇒ (9223372036854775807 9223372036854775808N 9223372036854775809N 9223372036854775810N) |
| 13:15 | TimMc | inc', +', *', etc. are the new autopromoting numeric ops |
| 13:15 | TimMc | Clojure likes to use longs by default anyway, so it mostly doesn't matter. |
| 13:16 | TimMc | I don't think I've actually needed BigInteger (BigInt?) once. |
| 13:17 | sqiudz | what's the best way to write tail-recursive functions in clojure? |
| 13:18 | hcumberd` | loop,recur |
| 13:21 | sqiudz | okay. is loop functional? |
| 13:21 | dbs | any pointers on working with multiple handlers? |
| 13:22 | hcumberd` | sqiudz: yes |
| 13:30 | borkdude | hcumberd` sqiudz there's only some issues about recur, I don't know what this problem is called, but you can't guarantee which recur belongs to which loop or fn |
| 13:31 | borkdude | sqiudz in case you use macro's… forgot what this problem is called though |
| 13:33 | sqiudz | borkdude: I dont use macros, so this shouldnt be a problem right? |
| 13:38 | borkdude | sqiudz in general it works |
| 13:39 | borkdude | sqiudz personally I never ran into problems |
| 13:47 | DaReaper5 | Does anyone know how to or if i can return file (of ANY type) with ring on a clojure server |
| 13:47 | borkdude | when I connect to an nrepl server and have a nrepl repl in emacs, how do I eval code from some source file? |
| 13:48 | borkdude | C-x C-e says: lisp-eval-last-sexp is void... |
| 13:48 | DaReaper5 | Here is a list of mime types but none of them make sense for ANY type of file: https://github.com/mmcgrana/ring/blob/master/ring-core/src/ring/util/mime_type.clj |
| 13:49 | sqiudz | borkdude: did you change the namespace in the repl for you file? |
| 13:49 | borkdude | sqiudz I switched to the buffer with the source file |
| 13:49 | borkdude | then I want to eval, just like in slime/swank setup |
| 13:50 | borkdude | nrepl connecting works |
| 13:50 | borkdude | evaluating from the repl in emacs also |
| 13:50 | borkdude | but not from a source file |
| 13:51 | sqiudz | try C-c M-n first |
| 13:51 | DaReaper5 | Does anyone know how to or if i can return file (of ANY type) with ring on a clojure server |
| 13:51 | borkdude | sqiudz undefined |
| 13:52 | sqiudz | are you running in nREPL mode? |
| 13:52 | borkdude | I'm using nrepl 1.5 btw. I don't know if the .clj buffer knows about nrepl? |
| 13:52 | sqiudz | i mean nreple-interaction-mode |
| 13:53 | borkdude | sqiudz ah that's it… why do I have to turn it on manually? |
| 13:53 | sqiudz | run nrepl-interaction-mode in your clojure buffer. that will enable you to evaluate code from source |
| 13:53 | sqiudz | borkdude: not sure, i just started using the emacs version today |
| 13:53 | borkdude | ok |
| 13:53 | borkdude | :-s |
| 13:54 | sqiudz | i just added a line to my init.el that starts it anytime i open a clojure file |
| 13:54 | borkdude | sqiudz maybe I should re-open it |
| 13:54 | sqiudz | yeah maybe |
| 13:55 | borkdude | sqiudz hmm, when I re-eval a function it complains: log-line already refers to: #'twitter-service.views.welcome/log-line in namespace: user -- yes, so? |
| 13:56 | borkdude | hmm, apparently nrepl-interaction-mode doesn't know in what namespace to eval the code! |
| 13:56 | borkdude | bitten by the newness of it |
| 13:56 | sqiudz | did you do C-c M-n after starting nrepl-interaction-mode? |
| 13:56 | borkdude | maybe it does work when I re-open the file |
| 13:57 | borkdude | sqiudz I did now, but what does it do? |
| 13:57 | sqiudz | that should load your namespace into the repl |
| 13:58 | sqiudz | after having your namespace loaded, just occasionally use C-c C-k to save/reload your buffer, and you should always be synced between repl and source |
| 14:00 | sqiudz | borkdude: any luck? |
| 14:00 | borkdude | sqiudz yes tnx. these are all additional steps from slime/swank though |
| 14:02 | sqiudz | so as far as i know the process is start nrepl server(once) -> load namespace(once) -> save file/eval |
| 14:03 | borkdude | sqiudz yes, probably I ran into some edge case -- I repeat, always when I try to use some new technology I run into problems no-one ever had :-s |
| 14:03 | borkdude | what should I use when I want to .writeln to a textfile in clojure? |
| 14:04 | borkdude | dynamically rebind *out*? |
| 14:04 | sqiudz | not sure what you mean |
| 14:06 | borkdude | smth like this: https://www.refheap.com/paste/7221 |
| 14:08 | sqiudz | dont know what binding does |
| 14:12 | borkdude | sqiudz it dynamically rebinds the var *out* to a different stream |
| 14:12 | borkdude | so all subsequent calls to println will write to the different stream |
| 14:13 | borkdude | on heroku, if I want to write to a file in my application's resource folder, what (absolute) path do I use? technomancy ? |
| 14:16 | antares_ | borkdude: I don't think using absolute paths on heroku is a good idea |
| 14:17 | antares_ | borkdude: I assume current directory is a good place to write to, or ./resources |
| 14:17 | borkdude | antares_ maybe not… should I just use "resources/blah.txt"? |
| 14:18 | borkdude | a matter of trying I guess |
| 14:18 | borkdude | it seems to work |
| 14:20 | black_joe | I have a question about calling methods from within lists. |
| 14:20 | black_joe | http://pastebin.com/Z4eq2Csr |
| 14:20 | black_joe | This function returns nil on execution, but every call seems valid from println debugging. |
| 14:20 | black_joe | So, is there some special procedure when putting a Class/method function into a list? |
| 14:22 | borkdude | black_joe first of all, you will get better help when using refheap.com :P |
| 14:23 | black_joe | Sweet, I never knew about that. It has always been such a pain on Pastebin to find the Clojure highlighting |
| 14:26 | black_joe | Hmm... It's not just for Class/method. Println, when put in as ordinance's (first (first)) doesn't run either. |
| 14:27 | borkdude | black_joe some functions like println return nil, but only have a side effect |
| 14:28 | borkdude | black_joe I find your code bit hard to follow |
| 14:28 | black_joe | Right, but still. Double/parseDouble should reutrn a double. |
| 14:28 | black_joe | Sorry. It is hastily thrown together to fix a problem that arose this morning. |
| 14:29 | black_joe | What I am looking to do is have a function that assigns types to a string based on a letter in parentheses, like "4.0(d)" |
| 14:29 | borkdude | ,(Double/parseDouble "2.0") |
| 14:29 | clojurebot | 2.0 |
| 14:29 | borkdude | ,(println (Double/parseDouble "2.0")) |
| 14:29 | clojurebot | 2.0 |
| 14:30 | borkdude | ,(nil? (println (Double/parseDouble "2.0"))) |
| 14:30 | clojurebot | 2.0 |
| 14:30 | clojurebot | true |
| 14:30 | black_joe | ,(println ((second (println Double/parseDouble)) "4.0)) |
| 14:30 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading string> |
| 14:30 | black_joe | ,(println ((second (println Double/parseDouble)) "4.0")) |
| 14:30 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to find static field: parseDouble in class java.lang.Double, compiling:(NO_SOURCE_PATH:0)> |
| 14:30 | black_joe | Hmm... That could be a problem. |
| 14:31 | black_joe | Crap. I forgot to make that a literal list. |
| 14:32 | black_joe | Okay, I can confirm that this does not work: ((second '(println Double/parseDouble)) "4.0") |
| 14:32 | black_joe | So... would there be any way to call parseDouble in that fashion? |
| 14:32 | borkdude | ,(second '(println Double/parseDouble)) |
| 14:32 | clojurebot | Double/parseDouble |
| 14:33 | black_joe | ,((second '(println Double/parseDouble)) "4.0") |
| 14:33 | clojurebot | nil |
| 14:33 | black_joe | See? |
| 14:34 | borkdude | black_joe you must read that as ('Double/parseDouble "4.0") |
| 14:34 | black_joe | So it's being considered literal, then? |
| 14:34 | black_joe | What would be the correct way to call it in that fashion. |
| 14:34 | borkdude | ,('foo {'foo 2 'bar 4}) |
| 14:34 | clojurebot | 2 |
| 14:35 | borkdude | black_joe symbols look themselves up in maps (they behave as functions), that's why you get nil here |
| 14:35 | borkdude | black_joe how to convert a symbol to a method.. I would wrap the method into a function first and throw around the function |
| 14:37 | black_joe | Well, that's a bit overly complex. I will just throw an if structure together instead of having a list of functions. |
| 14:37 | black_joe | Thanks. Also, thanks for the refHeap. |
| 14:38 | borkdude | black_joe that's probably a better idea, welcome |
| 14:39 | black_joe | I just usually avoid that since it limits the scalability to work on other types. But I guess with the limited number it would be best. |
| 14:39 | apwalk | black_joe: your code works as written, when called as (apply-type "4.0(d)" [["(d)" #(Double/parseDouble %)]]) |
| 14:39 | apwalk | or as (apply-type "4.0(d)" (list (list "(d)" #(Double/parseDouble %)))) |
| 14:40 | TimMc | ,(read-string "4.0") :-P |
| 14:40 | clojurebot | 4.0 |
| 14:40 | black_joe | Hmm... Never seen "#". Guessing that's the reader macro for a function. |
| 14:40 | TimMc | black_joe: Anonymous function literals. |
| 14:40 | black_joe | Is the "%" significant? That's new to me too. |
| 14:41 | TimMc | &'#(+ % 3) |
| 14:41 | lazybot | ⇒ (fn* [p1__11288#] (+ p1__11288# 3)) |
| 14:41 | TimMc | &'#(+ %2 3) |
| 14:41 | lazybot | ⇒ (fn* [p1__11300# p2__11299#] (+ p2__11299# 3)) |
| 14:42 | black_joe | Well, glad to learn about those two. But the more I think about it, I am doing it with a cond. |
| 14:43 | black_joe | Using a list in this case could end up hurting someone calling it wrong, rather than helping them. |
| 14:45 | TimMc | black_joe: %1 (or %) through %9 are symbols captured by the fn literal reader macro. |
| 14:45 | TimMc | %& as wlel |
| 14:46 | black_joe | I am planning to read up on reader macros soon. I skipped over them in the book I read to learn Clojure. Along with destructuring. |
| 14:46 | borkdude | I usually find using (fn [] …) more pleasant to read though than #(% … %9), also #'s can't be nested |
| 14:47 | black_joe | ^ I've always used fn as well. |
| 14:47 | Mr_Bond | sometimes it is handy with #(% .. etc), to put data at some place in the middle of a function |
| 14:48 | Mr_Bond | or several levels of recursive functions |
| 14:50 | DaReaper5 | Does anyone know how to or if i can return file (of ANY type) with ring on a clojure server |
| 14:51 | borkdude | DaReaper5 I'm sorry, don't know |
| 14:51 | nightfly_ | Is there a way to get a list of all the classes in a Java package available to clojure? |
| 14:53 | Mr_Bond | nightfly_: yes, you can do it in the same way as in java, since all java classes are also available to clojure, and you can call the same methods via clojure |
| 14:54 | Mr_Bond | like the refections library, can be used for it |
| 14:54 | Mr_Bond | http://code.google.com/p/reflections/ |
| 14:57 | nightfly_ | Mr_Bond: Thanks, checking it out now |
| 14:58 | hcumberd` | Is there a JVM free clojure? |
| 14:58 | black_joe | Technically Clojurescript. |
| 14:58 | hcumberd` | I heard of clojurec but it's not 1.4 right? |
| 14:59 | hcumberd` | Clojurescript,... mhh. |
| 14:59 | hcumberd` | Is there anything like a compiler (like in LISP) |
| 14:59 | black_joe | Not that I know of, no. |
| 15:01 | Mr_Bond | hcumberd`: it runs on .net as well |
| 15:01 | Raptum | Mr_Bond: clojure does? |
| 15:02 | Mr_Bond | yes |
| 15:02 | Mr_Bond | .net and jvm |
| 15:02 | Raptum | intredasting |
| 15:02 | Mr_Bond | and javascript as mentioned |
| 15:02 | Raptum | yes of course |
| 15:02 | Mr_Bond | probably possible to get it working on llvm or such as well |
| 15:02 | Mr_Bond | well, it is possible, but a fair amount of work |
| 15:03 | Mr_Bond | and have it compiled to machinecode |
| 15:03 | hcumberd` | what is llvm? |
| 15:03 | wingy | hcumberd`: lisp on clojure |
| 15:05 | Mr_Bond | hugod: it's sortof the basis of a compiler, which you can put compilers on top of |
| 15:05 | Mr_Bond | like clang (compiler), or llvm-py (python compiler) |
| 15:05 | magnars | what's the significance of the @ in `@(d/transact conn schema-tx)` ? |
| 15:05 | wingy | hcumberd`: i meant lisp on erlang |
| 15:05 | Mr_Bond | hcumberd`: sorry, I ment to write to you |
| 15:06 | wingy | hcumberd`: http://joxa.org/ |
| 15:06 | wingy | https://github.com/schani/clojurec |
| 15:06 | wingy | the latter is not up to date it seems |
| 15:07 | Mr_Bond | clojurec looks cool |
| 15:08 | wingy | i donno .. sometimes i wished clojure was on c |
| 15:08 | wingy | not java |
| 15:08 | Mr_Bond | that would be ideal for things like raspberryPi |
| 15:08 | hcumberd` | thx 4 joxa link |
| 15:09 | hcumberd` | I like to use clojurec far more then the jvm sh** |
| 15:09 | hcumberd` | Clojure uses a bit of java syntax for string handling |
| 15:09 | hcumberd` | doesn't know how clojurec handles it |
| 15:09 | hcumberd` | It's a project I like to see evolve |
| 15:11 | Mr_Bond | the backend to files in clojure is pretty much java's File object as well |
| 15:11 | Mr_Bond | that will probably not work well either on clojurec |
| 15:12 | hcumberd` | Mhh Damn! |
| 15:13 | hcumberd` | Most things I write rely on the file handling functionality |
| 15:14 | Mr_Bond | you could create a simular interface in clojurec, but if you had to spend a lot of time re-inventing java interfaces, it might not be worth using it for the benefits of C. JVM is pretty good on many things as well, even compared to C |
| 15:15 | Raptum | ...can i write android apps in clojure? |
| 15:15 | Mr_Bond | google seems to think so: I found this: http://www.deepbluelambda.org/programming/clojure/creating-android-applications-with-clojure |
| 15:15 | hcumberd` | But it's now from ORCALE |
| 15:16 | hcumberd` | there are so many bad libs |
| 15:16 | hcumberd` | bad quality everywhere ;( |
| 15:16 | black_joe | Raptum: Yes, but it would be more sane to write the functions of your program in Clojure and the Ui / resource stuff in Java. |
| 15:16 | Raptum | ah |
| 15:16 | wingy | Mr_Bond: but then we wouldn't need java interop thus interfaces right .. the whole OOP thing |
| 15:16 | hcumberd` | OpenJDK may help |
| 15:17 | Mr_Bond | wingy: is that a good thing or bad thing? :) |
| 15:17 | wingy | no OOP! |
| 15:17 | wingy | OOP is bad |
| 15:17 | hcumberd` | -> more kind of a bad thing when you ask me |
| 15:17 | Raptum | lol |
| 15:17 | hcumberd` | lol^2 |
| 15:17 | Mr_Bond | hehe |
| 15:17 | wingy | Rich said so |
| 15:17 | Raptum | hence why this isn't #java? |
| 15:17 | borkdude | Clojure is build using an OOP language, so it can't be that bad right? ;) |
| 15:18 | Raptum | borkdude: sure it can |
| 15:18 | Raptum | oh |
| 15:18 | Raptum | oops didn't see the sarcasm |
| 15:18 | hcumberd` | Maybe I'll need a guide. How to migrate from Clojure to Java |
| 15:19 | Mr_Bond | If clojure ran outside jvm, wouldn't it just be another lisp? |
| 15:19 | hcumberd` | Mr_Bond: Clojure is more than that |
| 15:19 | hcumberd` | STM,.. |
| 15:19 | wingy | lazyness |
| 15:19 | wingy | datomic and light table! |
| 15:19 | Mr_Bond | hm yeah maybe |
| 15:19 | ivaraasen | drugs! |
| 15:20 | wingy | Rich! |
| 15:20 | Mr_Bond | ivaraasen, that sounds very norwegian-like:) |
| 15:20 | Raptum | 'baccer! |
| 15:20 | ivaraasen | Mr_Bond: probably |
| 15:20 | hcumberd` | You can feel the jvm |
| 15:20 | hcumberd` | from startup times to memory consumption |
| 15:21 | ivaraasen | speaking of drugs, I wonder what kind of drugs the guys that made this CSV file were using |
| 15:21 | Mr_Bond | ivaraasen: kult at det er flere nordmenn her :) |
| 15:21 | Mr_Bond | do you mean in a good or bad way? |
| 15:21 | wingy | but then sometimes i agree that using a platform is a good choice |
| 15:22 | Mr_Bond | maybe he was high on baby jesus |
| 15:22 | wingy | like i am using jquery mobile instead of doing native apps |
| 15:22 | ivaraasen | well, tons of filler stuff (........... everywhere), many lines are empty, not everything is aligned correctly, and some fields are split over two-three lines |
| 15:23 | Mr_Bond | ivaraasen: ah, I think that drug is trending, because last week I got an email written entirely in the Subject field. |
| 15:24 | ivaraasen | Mr_Bond: SSB har skylda for den fila, forøvrig :) |
| 15:24 | Mr_Bond | Statan! |
| 15:25 | ivaraasen | Mr_Bond: UiO or NTNU? |
| 15:25 | Mr_Bond | ivaraasen: I'm at Copyleft Solutions |
| 15:26 | ivaraasen | nice! |
| 15:27 | Mr_Bond | But working at a lisp-shop, I'm not actually a lisp-programmer. It's something I've learned for fun in my spare time, I work with system administration |
| 15:31 | ivaraasen | I mostly do Clojure for quick data hacking myself. I'm really a journalist/editor. |
| 15:32 | Raynes | Everything I say is off the record. |
| 15:33 | Raynes | I've always wanted to say that to a journalist. |
| 15:33 | hcumberd` | ;) |
| 15:35 | ivaraasen | Raynes: as far as journalists are concerned, people are always on record ;) |
| 15:35 | Raynes | I know. :( |
| 15:36 | ivaraasen | I really don't get tech journalism though |
| 15:36 | Mr_Bond | ivaraasen: cool :) |
| 15:37 | Mr_Bond | ivaraasen: do you freelance or work for some publisher? |
| 15:38 | ivaraasen | Mr_Bond: I'm planning on doing some freelance writing soon |
| 15:39 | ivaraasen | ATM I'm way too busy reading for my exams though |
| 15:41 | Raynes | ivaraasen: You can interview me whenever you like, friend. I'm all the rave everywhere. |
| 15:42 | ivaraasen | Raynes: sure thing. Refheap looks really good, btw |
| 15:42 | Raynes | <3 |
| 15:42 | ivaraasen | https://www.refheap.com/paste/62330608de0bf0a395eb59d30 |
| 15:43 | ivaraasen | horrible code, but the CSV file was even worse |
| 15:43 | Raynes | CSV. |
| 15:43 | ivaraasen | thank god we have Google Refine these days |
| 15:43 | Raynes | I've got to do some stuff with csv at work. |
| 15:44 | Raynes | Thinking about quitting and cleaning windshields instead. |
| 15:46 | ivaraasen | nobody deserves CSV, with the possible exception of Sweden |
| 15:51 | ivaraasen | the by-year function is quite handy. turns a nested map like {:a {:a1 1 :a2 2} ... :z {:a1 3 :a2 666 }} into {:a1 {:z 3 :a 1} :a2 {:z 666 :a 2}}. |
| 15:51 | ivaraasen | there's probably a built-in for that, but I couldn't find it |
| 15:53 | TimMc | "Don't quote me on this." |
| 15:54 | Mr_Bond | ivaraasen: hehe |
| 15:59 | gfredericks | does anybody know about the official supportedness of js/foo and js* in cljs? |
| 16:07 | TimMc | Is anything ever official in CLJS land? |
| 16:07 | TimMc | I haven't followed too closely, but I don't recall a 1.0 release. |
| 16:08 | mpenet | I think I have heard a few times not to use js* |
| 16:08 | TimMc | or an official doc site, which is more relevant |
| 16:08 | mpenet | js/FOO is probably here to stay otherwise you dont get access to the js world |
| 16:08 | mpenet | well the global scope |
| 16:13 | gfredericks | yeah I think that about summarizes what I've heard about the issue as well |
| 16:25 | wei_ | is there a good way to test cemerick/friend with context, similar to noir's with-noir macro? |
| 16:41 | Raptum | how could i perform something like this and flatten the resulting list? http://ideone.com/lqycdM |
| 16:43 | Raynes | Raptum: What is the end result supposed to look like? |
| 16:43 | Raptum | the same thing, but flattened; never mind, someone got it for me: http://ideone.com/IwWLgX |
| 16:44 | Raynes | Raptum: That function is in clojure.core btw. |
| 16:44 | Raptum | i know. |
| 16:44 | Raynes | Just checking. |
| 16:44 | Raptum | interlace or something |
| 16:44 | Raptum | interleave* |
| 16:46 | ivaraasen | I guess you could use mapcat vector as well, to avoid explicit recursion |
| 16:48 | gfredericks | the golden rule of clojurescript: "It's not just JavaScript!" |
| 16:49 | TimMc | ™ |
| 16:49 | nightfly_ | Java interop doesn't always seem to behave as expected. ConfigurationBuilder.setScanners(s ...) expects something that implements the Scanner interface, which ResourcesScanner does. But line 20 fails with a ClassCastException. https://www.refheap.com/paste/7225 |
| 16:49 | gfredericks | :) |
| 16:50 | bbloom | nightfly_: do you want -> or do you want 'doto ? |
| 16:51 | TimMc | Line 20 shouldn't fail on the basis of that, though. |
| 16:51 | bbloom | TimMc: you're right, didn't realize that line 19 was commented out |
| 16:52 | bbloom | nightfly_: do you have javadocs or source for any of those types? would need to look at the methods to say what's going wrong |
| 16:53 | nightfly_ | Yeah, http://reflections.googlecode.com/svn/trunk/reflections/javadoc/apidocs/index.html?org/reflections/Reflections.html |
| 16:54 | holo | hi |
| 16:54 | clojurebot | Huh? |
| 16:54 | gfredericks | does having reified types in cljs for keywords and symbols have prohibitively poor performance? |
| 16:54 | TimMc | nightfly_: varargs |
| 16:54 | TimMc | nightfly_: I could have told you that if you'd provided the message of the exception. |
| 16:54 | TimMc | ~varargs |
| 16:54 | clojurebot | varargs is a fiction of the Java compiler -- from Clojure, you'll need to pass in an array of the appropriate type. See into-array and float-array, etc. |
| 16:54 | dnolen | gfredericks: unknown, but I doubt it. |
| 16:55 | bbloom | TimMc: beat me to it :-) |
| 16:55 | gfredericks | dnolen: is that an eventual want then? |
| 16:55 | TimMc | Though actually, I could have guessed based on the method name being plural. |
| 16:55 | dnolen | gfredericks: yes |
| 16:55 | gfredericks | dnolen: with interning as well? |
| 16:56 | bbloom | gfredericks: I took a crack at it quite a while ago and couldn't quite get performance up to snuff, but that's probably my fault, not the approach |
| 16:56 | dnolen | gfredericks: that's the idea yes. |
| 16:56 | nightfly_ | TimMc: bbloom Ah! Didn't know that, thank you. |
| 16:57 | gfredericks | bbloom: do you have a branch somewhere? |
| 16:57 | bbloom | gfredericks: https://github.com/brandonbloom/clojurescript/commits/keywords-and-symbols |
| 16:58 | bbloom | gfredericks: totally hacked up attempt |
| 16:58 | gfredericks | bbloom: cool, thanks |
| 16:58 | bbloom | gfredericks: you gonna take a shot at making it work? :-) |
| 16:59 | bbloom | gfredericks: I forget now, but I *think* the main performance issue was that identical? was no longer a sufficient test and = needed to be used to support runtime keywords, symbols, etc |
| 16:59 | bbloom | because javascript doesn't have weak references |
| 16:59 | bbloom | so each runtime keyword or symbol would be a memory leak if interned, which was unacceptable |
| 16:59 | gfredericks | bbloom: oh so we don't want to intern the runtime ones as well? |
| 16:59 | gfredericks | I see |
| 16:59 | gfredericks | that is tricky then. |
| 16:59 | bbloom | yeah, really tricky |
| 17:00 | gfredericks | shouldn't that be no worse than what happens currently? |
| 17:00 | gfredericks | presumably (= kw1 kw2) checks identical? first and then walks through the strings? |
| 17:00 | gfredericks | (at least at the vm level) |
| 17:01 | bbloom | gfredericks: except there's a function call overhead (generally) as well as a protocol dispatch on not identical? |
| 17:01 | gfredericks | and interning would just give you an identical?-hit more often? |
| 17:02 | gfredericks | clj-jvm keywords use weak refs? |
| 17:03 | murphy_ | good evening! I was doing a bit of work on 4clojure.org and for the solution to problem 19 (find the last element in a sequence without using "last"), one of the reference solutions was' reduce #(-> %2) ' can someone help me understand what that means? |
| 17:03 | bbloom | gfredericks: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Keyword.java#L37 |
| 17:03 | gfredericks | bbloom: I might well play with it after tuesday; I'd like to contribute in some way or another; so far I've not exceeded too well. |
| 17:04 | murphy_ | e.g. what does the sigil "->" mean ? I read somewhere that it's some sort of stream operator, but googling for it is proving somewhat unproductive |
| 17:04 | bbloom | (doc doc) |
| 17:04 | clojurebot | "([name]); Prints documentation for a var or special form given its name" |
| 17:04 | bbloom | (doc ->) |
| 17:04 | clojurebot | "([x] [x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc." |
| 17:04 | murphy_ | woah! Thank you! |
| 17:04 | bbloom | while you're at it, if you've never read through `man man` you really ought to :-) |
| 17:04 | gfredericks | bbloom: I saw that band once |
| 17:05 | murphy_ | haha |
| 17:05 | bbloom | heh |
| 17:05 | gfredericks | only by accident though |
| 17:05 | Raynes | This is a pretty horrid use of -> for the purpose is keeping number of characters as low as possible. |
| 17:05 | gfredericks | #(-> %) is short for identity I imagine? |
| 17:05 | murphy_ | yeah, of course, but I figure it'll come into play later and I want to understand it |
| 17:05 | gfredericks | though why you'd want to (reduce identity ...) I can't imagine |
| 17:06 | bbloom | well it was %2 |
| 17:06 | gfredericks | oh right |
| 17:06 | bbloom | which seems odd too |
| 17:06 | AimHere | Well the idea is that he's just using reduce to get to the last element of a list |
| 17:06 | gfredericks | (reduce #(-> %2) ...) should be equivalent to last then? |
| 17:07 | gfredericks | but last is a shorter way to say that |
| 17:07 | AimHere | Right, but your 4clojure problem is set in a world where the 'last' command has been outlawed by Rich Hickey, in a fit of spite |
| 17:07 | gfredericks | lol |
| 17:07 | gfredericks | of course |
| 17:08 | murphy_ | hahaha |
| 17:08 | seangrove | Impressive amount of spite to do that, hah |
| 17:08 | AimHere | Clojure's collections are SOOO good, they should never ever end |
| 17:09 | TimMc | Commit message: "'last is a sign you're using the wrong data structure; removed" |
| 17:09 | bbloom | #(drop (count (butlast %)) %) |
| 17:09 | AimHere | Just evaluate them lazily |
| 17:09 | bbloom | #(first (drop (count (butlast %)) %)) |
| 17:09 | bbloom | ,(#(first (drop (count (butlast %)) %)) [1 2 3 4 5]) |
| 17:09 | clojurebot | 5 |
| 17:09 | bbloom | w00t. |
| 17:09 | TimMc | ,(reduce #(do %2) [1 2 3 4 5]) |
| 17:09 | clojurebot | 5 |
| 17:10 | TimMc | do is just as good as -> here |
| 17:10 | bbloom | ,(first (reverse [1 2 3 4 5])) |
| 17:10 | clojurebot | 5 |
| 17:10 | bbloom | i think that's shorter :-) |
| 17:10 | bbloom | and slower. |
| 17:11 | TimMc | (comp peek vec) |
| 17:12 | bbloom | anyway, gfredericks you'll also need to emit pre-interned symbols and keywords for all those known statically to be in use at compile time |
| 17:13 | ivaraasen | TimMc: or maybe even #(% (dec count %)) vec |
| 17:17 | TimMc | ,(#(% (dec count %)) vec [1 2 3 4 5]) |
| 17:17 | clojurebot | #<CompilerException clojure.lang.ArityException: Wrong number of args (2) passed to: core$dec, compiling:(NO_SOURCE_PATH:0)> |
| 17:17 | TimMc | NOPE. |
| 17:18 | TimMc | but I like your style. |
| 17:19 | ivaraasen | err, typo. sorry |
| 17:19 | ivaraasen | ,(#(% (dec (count %))) [1 2 3 4 5]) |
| 17:19 | clojurebot | 5 |
| 17:20 | ivaraasen | ,(#((into [] %) (dec (count %))) [1 2 3 4 5]) |
| 17:20 | clojurebot | 5 |
| 17:20 | ivaraasen | bulletproof version |
| 17:20 | ivaraasen | in case you get, say, a list |
| 17:21 | mpenet | ,(#(first (take-last 1 %)) [1 2 3]) |
| 17:21 | clojurebot | 3 |
| 17:21 | mpenet | it's almost cheating, ok |
| 17:22 | gfredericks | bbloom: right; and that part you didn't do? |
| 17:24 | Sgeo | http://clojuredocs.org/clojure_core/clojure.walk/macroexpand-all |
| 17:24 | Sgeo | Is there a significant chance that Cubic didn't see my quote mark? |
| 17:26 | bbloom | gfredericks: i hacked it up for perf testing: had a manual list of symbols to intern iirc |
| 17:32 | gfredericks | ah ha |
| 17:32 | holo | i'm new to tests. i just noticed i can't test a hidden function. am i supposed to not need to test them, so this wouldn't be addressed as a problem at all? |
| 17:33 | bbloom | holo: you can access privates via their vars |
| 17:34 | bbloom | (defn- secret-f [x] (inc x)) |
| 17:34 | bbloom | (#'secret-f 5) |
| 17:35 | holo | bbloom, that's super cool. thanks! |
| 17:47 | zilti | Exception in thread "main" java.io.FileNotFoundException: Could not locate clojure/tools/macro__init.class or clojure/tools/macro.clj on classpath |
| 17:47 | zilti | What might cause this error? |
| 17:48 | seangrove | technomancy: Having troubles pushing a clojur app to Heroku, getting errors that "Failed to transfer file: http://s3pository.herokuapp.com/maven-central/commons-pool/commons-pool/1.6/commons-pool-1.6.pom. Return code is: 503, ReasonPhrase:Service Unavailable: Back-end server is at capacity." |
| 17:48 | nightfly_ | Well, solved my real problem. It seems that an uncatched exception is raised when initializing a java class clojure reports it the first time and after that just doesn't acknowledge the class exists. The problem was in the java code the whole time :/ |
| 17:49 | nightfly_ | s/ an / when an / |
| 17:55 | gfredericks | the himera synonyms page claims that nested mapping over lazy seqs only traverses something once?? |
| 17:55 | lazybot | gfredericks: Definitely not. |
| 17:55 | gfredericks | And I think Sgeo was claiming that about clj-jvm yesterday (though I convinced him otherwise) |
| 17:55 | gfredericks | where does that idea come from? is there anything to it? |
| 17:56 | Sgeo | ...I thought you just convinced me that it doesn't actually save work unless you only take a part of the result |
| 17:57 | gfredericks | right |
| 17:57 | gfredericks | but it looks like fogus is saying the same thing you did |
| 17:57 | Sgeo | That's different from saying that the it's traversing multiple times |
| 17:57 | gfredericks | well you can imagine that it walks them both at the same time, but it's not an interesting thing to point out performance-wise, as I understand it |
| 17:58 | gfredericks | (it's at the top of the Lazy Sequences section here http://himera.herokuapp.com/synonym.html) |
| 17:58 | Sgeo | It is an interesting thing to point out when it comes to "now I take the first three elements from the result" |
| 17:59 | gfredericks | definitely, but his example doesn't have that characteristic |
| 17:59 | Sgeo | Well, if someone already knows about lazy lists, it's a good thing to point out |
| 18:01 | gfredericks | I wonder if it has positive effects on memory access due to locality |
| 18:05 | gfredericks | is there any decent way to use cljs-HEAD with lein-cljsbuild? checkouts doesn't seem to work since cljs isn't a lein project |
| 18:06 | wingy | is 5000 LoC much for a project |
| 18:06 | ivan | wingy: depends on if you've got multiple projects in your project |
| 18:06 | gfredericks | wingy: depends on what the project is for |
| 18:06 | wingy | ivan: No |
| 18:07 | wingy | gfredericks: its a SAAS |
| 18:07 | gfredericks | yes anything above 2744 is always too much |
| 18:08 | seangrove | Anyone else able to deploy Clojure apps to Heroku? Was going to announce Jida on the ml, but now it seems we can't push anymore, and it's down. |
| 18:09 | wingy | gfredericks: ? :) |
| 18:10 | gfredericks | wingy: delete linebreaks until you're below that threshhold. |
| 18:11 | ivan | a weird thing I've seen twice in Clojure projects now is a completely unnecessary macro that duplicates a function |
| 18:11 | ivan | not always obvious until you actually try to refactor and notice that it's 100% redundant |
| 18:13 | gfredericks | (undefmacro ...) |
| 18:13 | ivan | heh |
| 18:43 | omarkj | Hey. |
| 18:43 | omarkj | I was wondering if anyone could explain this to me (I'm new at clojure so I might be unwrapping this to the wrong expression) https://gist.github.com/4f90605e5978fd7d9db4 |
| 18:50 | omarkj | I would have expected those arrays to match that is. |
| 18:56 | omarkj | Wrong operator - sorry. |
| 19:40 | Sgeo | As much as I hate to admit it, I'm starting to see advantages to clojure.algo.monads |
| 19:41 | gfredericks | over other monadic libs or over not monads? |
| 19:41 | Sgeo | Over other monadic libs |
| 19:42 | Sgeo | Although the only other one I know of is protocol-monads |
| 19:42 | gfredericks | I haven't looked at algo.monads since I decided I understand monads more than I don't |
| 19:42 | hcumberd` | Any better way to write: (filter #(some #{(tx_basename %)} order) (filter #(= (fs/extension %) ".opt") files)) |
| 19:43 | hcumberd` | nesting filter looks wired |
| 19:43 | kaoD_ | any good source on WTF are monads? |
| 19:43 | gfredericks | hcumberd`: you can unnest with ->> at least |
| 19:43 | gfredericks | but since they're both filters |
| 19:43 | gfredericks | you could also just combine the filter functions |
| 19:43 | kaoD_ | I read it some time ago but apparently I couldn't grasp the concept, because I coudln't explain it if I tried |
| 19:43 | gfredericks | kaoD_: I read several things and they didn't really make sense until I tried to actually write some haskell code |
| 19:43 | spaceships | i wonder what they mean outside of haskell |
| 19:43 | mdeboard | Hi, I'm preparing an example illusrating agents for a presentation, and I'm having trouble articulating why my example code works the way it does. The comments on lines 21-25 are what I could use a hand with. |
| 19:43 | mdeboard | https://gist.github.com/4191817 |
| 19:43 | bbloom | kaoD_: http://www.intensivesystems.net/tutorials/monads_101.html |
| 19:44 | gfredericks | specifically I read LYAH and did a lot of project euler |
| 19:44 | gfredericks | hcumberd`: you could combine them abstractly with every-pred, or just use and |
| 19:45 | kaoD_ | gfredericks: yep, Haskell's in my huge-pile-of-thing-to-do |
| 19:45 | kaoD_ | I guess this is the perfect excuse to look into it :) |
| 19:45 | kaoD_ | bbloom: thanks |
| 19:45 | gfredericks | ~monad |
| 19:45 | clojurebot | monad is "yea, though I should walk in the valley of imperative code, I shall fear no evil, for your monad comforts me" - seen in #haskell |
| 19:45 | gfredericks | ~monad |
| 19:45 | clojurebot | monad is monads |
| 19:46 | gfredericks | ~monad |
| 19:46 | clojurebot | monad is monads |
| 19:46 | bbloom | ~monads |
| 19:46 | clojurebot | monads are http://www.bolour.com/papers/monads-through-pictures.html |
| 19:46 | gfredericks | WAT |
| 19:46 | mdeboard | Basically, WITH the `(apply await-for ...)' line, the return value is the return value of the `(touch)' fn; otherwise it's the return value of the last line of `(make-files)'. So I assume that the evaluation of `(touch)' is the last thing to be processed in this example, which is why, given time, its value is what's returned. |
| 19:46 | mdeboard | "degenerate monad producer" sounds like a job title your mother wouldn't be proud to tell peopl you have |
| 19:48 | kaoD_ | I've read like 15 definitions of "monad" |
| 19:48 | kaoD_ | and most of them are orthogonal |
| 19:48 | spaceships | a typeclass that implements bind and return :P |
| 19:48 | mdeboard | kaoD_: The guys in #haskell have a lot of jokes around people trying to define monads |
| 19:49 | mdeboard | it's a something soemthing functor something donald knuth |
| 19:49 | mdeboard | that's all I know. |
| 19:49 | kaoD_ | pffft hahahaha |
| 19:49 | Sgeo | A monad is a monoid in the category of endofunctors, what's the problem? |
| 19:49 | Sgeo | Also, a monad is like a burrito |
| 19:49 | mdeboard | astronaut* |
| 19:49 | bbloom | extremely simply: it's an interface with three functions that happen to have interesting compositional behavior |
| 19:49 | gfredericks | a comonad is like a fajita |
| 19:49 | bbloom | that's it. |
| 19:49 | Sgeo | A monad is a burrito that has eaten an astronaut. |
| 19:50 | mdeboard | nailed it. |
| 19:50 | gfredericks | a fajito that has eaten a cosmonaut |
| 19:50 | gfredericks | s/fajito/fajita/ |
| 19:50 | Sgeo | Sorry. It's just that a lot of people seem to write monad tutorials, many of which try to use analogies, and there's so many that there are jokes about them |
| 19:51 | mdeboard | Anyway, anyone have a clearer explanation of my example than I can muster? |
| 19:51 | mdeboard | https://gist.github.com/4191817 |
| 19:51 | mdeboard | lines 21-25 |
| 19:51 | kaoD_ | okay I hate y'all |
| 19:51 | gfredericks | Sgeo: in my experince every talk/article about monads starts by complaining about all the talks/articles about monads |
| 19:51 | kaoD_ | well not you all, but most of you |
| 19:51 | Sgeo | kaoD_, sorry |
| 19:52 | kaoD_ | Sgeo: don't worry, I like astronauts |
| 19:54 | Sgeo | Um, I don't see clojure.tools.macro on Clojars |
| 19:54 | Sgeo | How am I supposed to obtain it? |
| 19:54 | bbloom | ~contribs |
| 19:54 | clojurebot | No entiendo |
| 19:54 | bbloom | ~contrib |
| 19:54 | clojurebot | Monolithic clojure.contrib has been split up in favor of smaller, actually-maintained libs. Transition notes here: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go |
| 19:54 | bbloom | how do i teach clojurebot things? |
| 19:54 | bbloom | clojurebot: contribs is contrib |
| 19:54 | clojurebot | Alles klar |
| 19:54 | bbloom | ~contrib |
| 19:54 | clojurebot | Monolithic clojure.contrib has been split up in favor of smaller, actually-maintained libs. Transition notes here: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go |
| 19:55 | bbloom | ~contribs |
| 19:55 | clojurebot | contribs is contrib |
| 19:55 | bbloom | :-) |
| 19:56 | Sgeo | Should I just use it from maven? |
| 19:57 | Sgeo | Guess I can try it |
| 20:02 | tomoj | http://search.maven.org/#search%7Cga%7C1%7Ctools.macro |
| 20:03 | tomoj | e.g. for a conkeror webjump, "http://search.maven.org/#search\%7Cga\%7C1\%7C%s", maybe something similar for other browsers (?) |
| 20:03 | Sgeo | clojure.tools.macro/mexpand does NOT macroexpand inner forms |
| 20:04 | tomoj | yeah, sorry, that was misinfo |
| 20:04 | tomoj | well, you need mexpand-all |
| 20:04 | tomoj | but I think your problem with &env will still be there |
| 20:05 | Sgeo | Yes, it is. |
| 20:06 | Sgeo | But there is a way to do a (not full) macroexpansion and pass it an &env |
| 20:07 | Sgeo | user=> (#'get-env '(get-env) {'a 1}) |
| 20:07 | Sgeo | {(quote a) a} |
| 20:08 | tomoj | hmm.. consider (defmacro foo [& body] `(let [~'foo 42] ~@body)). then (foo (env-using-macro)) |
| 20:12 | Sgeo | How many forms change the &env of their bodies, and do any macros actually use the values of the &env rather than just the keys? |
| 20:13 | tomoj | I don't know how you could use the values if you wanted |
| 20:13 | tomoj | in clojurescript the &env is very useful |
| 20:13 | tomoj | and some macros will do a lot with it :( |
| 20:14 | tomoj | in clojure I think (hope?) just let* and loop* change &env |
| 20:14 | Sgeo | fn and variants too |
| 20:14 | tomoj | oh yeah |
| 20:14 | tomoj | fn*, let*, loop*? |
| 20:15 | Sgeo | What about bound-fn and variants? Do those just expand to ultimately fn*? |
| 20:15 | bbloom | Sgeo: i use both &env and &form for my CPS transform in cljs |
| 20:16 | bbloom | i need to know if a macro is expanded into a return position, for example |
| 20:16 | Sgeo | bbloom, but the question is, do you somehow change what the body sees without using let* fn* or loop* ? |
| 20:16 | Sgeo | Wait, you're already doing CPS transforms? |
| 20:16 | Sgeo | I assume you must use a macroexpander? |
| 20:17 | bbloom | Sgeo: not finished: https://github.com/brandonbloom/cljs-cps/ |
| 20:17 | bbloom | i rely on the cljs analyzer's expanding |
| 20:17 | Sgeo | (My main interest here is CPS) |
| 20:17 | Sgeo | Ah |
| 20:17 | gfredericks | is there anything published about typed-clojure for cljs yet? |
| 20:18 | bbloom | Sgeo: i don't need the CPS transform quite yet (eventually) so i put it on the back burner for now |
| 20:18 | Sgeo | It would be nice if Clojure just exposed its internal macroexpansion |
| 20:18 | bbloom | Sgeo: I was also waiting for various patches to land in cljs proper that were blocking me |
| 20:19 | bbloom | not strictly necessary, since you need the AST info to macro expand |
| 20:20 | bbloom | Sgeo: you can just run the analyzer and you get back an AST |
| 20:20 | bbloom | then simply (:form ast) |
| 20:20 | bbloom | and you've got a fully macroexpanded form |
| 20:20 | Sgeo | bbloom, what analyzer? |
| 20:20 | tomoj | so in cljs, using the analyzer on (foo (env-using-macro)) works fine |
| 20:20 | bbloom | the clojurescript analyzer |
| 20:20 | Sgeo | bbloom, was talking Clojure |
| 20:21 | bbloom | ah |
| 20:21 | bbloom | well any patches that make the clojurescript analyzer more useful for clojure code would surely be appreciated :-) |
| 20:21 | tomoj | but in clojure there is no working mexpand-all for that? |
| 20:21 | bbloom | im not as familiar with the internals of clojure itself |
| 20:21 | bbloom | dunno |
| 20:36 | tomoj | Sgeo: looks like you can do (with-bindings {clojure.lang.Compiler/LOCAL_ENV env} (macroexpand-1 form)) |
| 20:37 | tomoj | but that doesn't completely solve the problem, does it |
| 20:56 | Sgeo | tomoj, hmm, in what sense? |
| 20:57 | jkdufair | does anyone have apps deployed on heroku? mine died, unchanged, apparently due to s3pository being down |
| 20:58 | tomoj | Sgeo: you can define a (fn macroexpand-1 [form env]) which binds LOCAL_ENV to allow passing the env down, but if you macroexpand-1 something and wind up with a let*, you still have no easy way of recursively macroexpanding it |
| 21:02 | Sgeo | Determine what the env should be inside the let* and call macroexpand-1 with that on the inside? |
| 21:04 | Sgeo | I need to stop thinking about this and work on Senior Project |
| 21:24 | bbloom | did somebody mention that they were working on a toy version of datomic? |
| 21:31 | black_joe | So earlier #clojure helped me fix some problems in my language. It's now fixed for anyone that liked the sounds of it earlier. http://dymatic.github.com/MicroMarkup/ |
| 21:31 | black_joe | It's a static language for Clojure data structures. |
| 21:36 | tomoj | black_joe: seems pretty difficult to understand what it is |
| 21:38 | black_joe | It just seperates data from source files. Kind of like a database, but with lists and maps instead of tables. |
| 21:38 | Sgeo | Oh dear god "instance cool object named y that came from x" I'm scare |
| 21:38 | Sgeo | scared |
| 21:39 | black_joe | lol, inline documentation. Yup. |
| 21:40 | tomoj | what does it give you over just putting clojure data in those data files? |
| 21:41 | black_joe | Easy human readability and typing, mainly. |
| 21:41 | black_joe | And less syntax-to-content ration for large structures. |
| 21:41 | black_joe | ratio* |
| 21:41 | Sgeo | I wrote a bot in Tcl, and its configuration files are arrays |
| 21:42 | Sgeo | It makes those files very readable |
| 21:42 | Sgeo | server irc.example.com |
| 21:42 | Sgeo | channel #example |
| 21:42 | Sgeo | etc |
| 21:42 | Sgeo | It does get kind of bad in another of the files, though |
| 21:42 | bbloom | Tcl is an under appreciated language |
| 21:42 | Sgeo | feeds {abc def} |
| 21:43 | Sgeo | abc,url http://example.com |
| 21:43 | Sgeo | bbloom, Tcl is awesome |
| 21:43 | bbloom | the idea of a command-by-default language is brilliant |
| 21:43 | bbloom | just like ERB is just like a ruby file that is in template mode by default |
| 21:43 | bbloom | Tcl is a language that is in shorthand command usage mode by default |
| 21:43 | bbloom | it's clever |
| 21:45 | Sgeo | I think I would rather have top-level commands be wrapped in []. Or an id command that isn't some obtuse usage of something else |
| 21:46 | Sgeo | What I really like about Tcl is the lack of what Lispers would call special forms |
| 21:46 | Sgeo | Everything is a command |
| 21:46 | Sgeo | And you can pass code (albeit as a string, which kind of sucks) to commands, and you can generate parts of that code on the fly |
| 21:49 | seangrove | What's the best way to dynamically invoke a function name known only at runtime in cljs? |
| 21:50 | seangrove | Something like ((str service "-menu") menu-data) |
| 21:50 | bbloom | seangrove: there isn't one |
| 21:50 | bbloom | seangrove: not if you want to use advanced compilation anyway |
| 21:50 | seangrove | I could put all of the fn's into a map and call them from there, but not sure if that's best practice |
| 21:50 | seangrove | Hmm |
| 21:50 | bbloom | seangrove: yes, do that for the subset of functions you expect to call dynamically by name |
| 21:50 | bbloom | or seek an alternative approach |
| 21:50 | seangrove | ok, that works |
| 21:51 | seangrove | There will only be ~30 of them, not a big deal, just wondering |
| 21:51 | bbloom | use aset and aget |
| 21:51 | bbloom | on a (js-obj) |
| 21:52 | seangrove | Or I could do: (defn stripe-menu ...) (defn another-menu ...) (def menu-fns {:stripe stripe-menu :another :another-menu}) |
| 21:52 | seangrove | Ultimately it'd be the same performance characteristics, right? |
| 21:52 | bbloom | roughly |
| 21:52 | seangrove | No big gotchas? |
| 21:53 | bbloom | if you plan on having a never changing map, a single (def menu-fns (js-obj "stripe" stripe-menu …)) |
| 21:53 | bbloom | that would perform best, most likely |
| 21:53 | seangrove | Yeah, never changing |
| 21:53 | bbloom | aget on that |
| 21:53 | seangrove | Sounds good, thanks |
| 22:02 | seangrove | ,(doseq [item (map identity [123 123 123 ])] (fn [x] (println x ))) |
| 22:02 | clojurebot | nil |
| 22:02 | seangrove | Well, yes, that should be nil |
| 22:03 | seangrove | But it seems like the side-effects aren't carried out - println isn't called in my repl |
| 22:03 | seangrove | Ahk |
| 22:03 | seangrove | Yes, nevermind, stupid mistake |
| 22:06 | clj_newb_2345 | is it possible, through soem reflection Matic, to get from a defrecord to it's type? I.e .I have (defrecord Foo []), (defrecord a (Foo.)) ; now, given "a", I want to recover either Foo. or ->Foo |
| 22:11 | unnali | clj_newb_2345 (though absent): (class (Foo.)) does yield Foo |
| 22:11 | unnali | (which you can then call (new …) on) |
| 22:12 | Sgeo | I thought new only accepts symbols, you can't pass a dynamically found class? |
| 22:12 | Sgeo | ,(new (class [])) |
| 22:12 | clojurebot | #<CompilerException java.lang.IllegalArgumentException: Unable to resolve classname: (class []), compiling:(NO_SOURCE_PATH:0)> |
| 22:14 | unnali | Yeah, so you're right. |
| 22:14 | unnali | Not certain how one is meant to do that, but I'm sure there's a way. |
| 22:15 | Sgeo | This is why I like Tcl. |
| 22:21 | echo-area | Nrepl is much easier set up than ritz. I haven't tested if it requires as much memory as ritz though. |
| 22:34 | gfredericks | augh |
| 22:34 | gfredericks | advanced compilation is refusing to work :/ |
| 22:34 | gfredericks | (with jquery) |
| 22:34 | muhoo | externs? |
| 22:34 | gfredericks | yep |
| 22:34 | gfredericks | got the jquery externs file, have it listed in the project.clj...no evidence it's being used |
| 22:35 | gfredericks | it is in /resources/externs/jquery-1.8.js |
| 22:35 | muhoo | dunno then, sorry. |
| 22:35 | gfredericks | and the build in project.clj has {:compiler {... :externs ["externs/jquery-1.8.js"]}} |
| 22:37 | gfredericks | ah; I don't think the leaving off of /resources was a good idea |
| 22:37 | gfredericks | I think I might send a pull request for the jayq readme :) |