Re: core.async take behaviour
Thanks Timothy, that makes sense. A follow on question if you don't mind. I would like to 'take' n items off of a channel, but wait until n items are available rather than eagerly returning the way take does. Do you have any ideas on how I could achieve this? On Tuesday, 2 September 2014 22:23:10 UTC+2, tbc++ wrote: It's because into is pulling items as fast as it can from take. Sure the buffer might get full but then into takes another value allowing take to continue. Timothy On Tue, Sep 2, 2014 at 1:48 PM, cig clifford...@gmail.com javascript: wrote: Hi I was expecting the following example to park, waiting for the 'out' channel to be cleared. Could anybody explain why 'take' does not park when the output buffer size is smaller than the number of entries being taken from the input channel? (def from (to-chan [1 2 3 4 5 6 7])) (!! (into [] (take 4 from *2*))) ;; note: the output channel buffer size is 2 (less than 4 items being taken off of the 'from' channel) ;; = [1 2 3 4] -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.com javascript: Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com javascript: For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com javascript:. For more options, visit https://groups.google.com/d/optout. -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: core.async take behaviour
I'd use another channel on which I put vectors of the correct length, with an intermediate loop that takes from the first channel, accumulates until the vector has the right size, and then put the vector on the second channel. There might be a better solution with transducers, though. (Or without.) On Wednesday, 3 September 2014, cig clifford.goldb...@gmail.com wrote: Thanks Timothy, that makes sense. A follow on question if you don't mind. I would like to 'take' n items off of a channel, but wait until n items are available rather than eagerly returning the way take does. Do you have any ideas on how I could achieve this? On Tuesday, 2 September 2014 22:23:10 UTC+2, tbc++ wrote: It's because into is pulling items as fast as it can from take. Sure the buffer might get full but then into takes another value allowing take to continue. Timothy On Tue, Sep 2, 2014 at 1:48 PM, cig clifford...@gmail.com wrote: Hi I was expecting the following example to park, waiting for the 'out' channel to be cleared. Could anybody explain why 'take' does not park when the output buffer size is smaller than the number of entries being taken from the input channel? (def from (to-chan [1 2 3 4 5 6 7])) (!! (into [] (take 4 from *2*))) ;; note: the output channel buffer size is 2 (less than 4 items being taken off of the 'from' channel) ;; = [1 2 3 4] -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com javascript:_e(%7B%7D,'cvml','clojure@googlegroups.com'); Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@googlegroups.com'); For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@googlegroups.com');. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: HTTP server that supports ring handlers, but asynchronously?
Hi James, Thanks for your response! Replies inline. On 02 Sep 2014, at 18:53, James Reeves ja...@booleanknot.com wrote: Ring uses blocking I/O by default, because that's often sufficient for most web servers, and is generally easier to reason about. HTTP works best when the response is returned ASAP, which means blocking I/O typically isn't much of a bottleneck. However, since Ring 1.2, all of the standard middleware has also been available to use asynchronously, in order to support frameworks like Pedestal. So it's certainly possible to use Ring in an async environment, at least with the core Ring libs. Although HTTP Kit doesn't use core.async channels itself, the async protocol used isn't complex. You should be able to hook up core.async/take! to http-kit/send!. Something like: (defn handler [req] (httpkit/with-channel req http-ch (let [resp-ch (async-handler! req)] (httpkit/on-close (fn [_] (a/close! resp-ch))) (a/take! resp-ch (fn [resp] (httpkit/send! http-ch resp) (httpkit/close http-ch)) That’s what I wanted to do, but then I saw the warning on http-kit’s website at http://http-kit.org/server.html#channel , which states: Data is sent directly to the client, NO RING MIDDLEWARE IS APPLIED. … which leads me to believe that the send! API just totally sidesteps any middleware, and it’s not so much up to the middleware whether or not it supports asynchronous operation. Unless of course it actually works fine, and that’s simply some stale documentation? That said, I'd be wary about having HTTP clients wait around on the server. If it's just a few seconds, that seems reasonable, but any longer and you should consider redirecting to a job resource instead. Yeah, I’ve been considering that. Looking at the distribution of response times right now, 5-10s is a small, but non-negligible part of the responses. However, the point of this software is being able to give third parties capabilities (in the object-capability sense), so typically some of the requests involve secrets the caller doesn’t get to know about (like API credentials). As a result, I’m trying to be hyper-conservative in terms of stuff that can leak information. I’ll have to think more about that one :-) hth lvh signature.asc Description: Message signed with OpenPGP using GPGMail
Re: tomcat 6/7 stream closed error in ring json - works in lein ring server
(is this is the longest delay in replying ever? :)) You are right - I mistakenly thought that json-wrap-params only exposed the request params as oppose to exposing the JSONified body in the params; I thought json-wrap-body and json-wrap-params were complimentary. Now I have read the docs (https://github.com/ring-clojure/ring-json) it is clear that only one is required. Problem solved - chose one or the other. On Monday, 4 November 2013 02:46:55 UTC, James Reeves wrote: It would. I'm not sure why one fails and the other does not, unless the request object passed through Tomcat is different somehow, or unless you accidentally sent two different HTTP requests when testing. Regardless, the error message you've received is pretty clear - the JSON stream is consumed by the first JSON middleware before the second can get to up. - James On 4 November 2013 01:40, Colin Yates colin...@gmail.com javascript: wrote: Hi James, Not sure why I did that double wrapping.. However, wouldn't that also fail in Jetty? On 4 November 2013 01:02, James Reeves ja...@booleanknot.com javascript: wrote: Hi Colin, One of the compromises Ring makes for efficiency is that the body of a request is an InputStream, rather than a static string or byte array pre-loaded into memory. Because it's a stream, it can potentially be consumed by previous middleware. For some reason you have both wrap-json-body and wrap-json-params in your stacktrace: ring.middleware.json$wrap_json_body$fn__1031.invoke(json.clj:19) ring.middleware.json$wrap_json_params$fn__1035.invoke(json.clj:31) Both middleware read from the body InputStream, so one of them is going to fail when you try and read the body twice. - James On 4 November 2013 00:20, Colin Yates colin...@gmail.com javascript: wrote: Hi all, I have developed a ring/compojure app which receives and servers JSON. All is well in 'lein ring server' but as soon as I do 'lein ring uberwar' and deploy it to tomcat 6 or 7 it fails. To be explicit, the app deploys and I can view the static resources, but as soon as I issue a JSON POST I get the following error: [code] java.io.IOException: Stream closed org.apache.catalina.connector.InputBuffer.read(InputBuffer.java:325) org.apache.catalina.connector.CoyoteInputStream.read(CoyoteInputStream.java:193) sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283) sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325) sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177) java.io.InputStreamReader.read(InputStreamReader.java:184) java.io.BufferedReader.fill(BufferedReader.java:154) java.io.BufferedReader.read(BufferedReader.java:175) clojure.core$slurp.doInvoke(core.clj:6279) clojure.lang.RestFn.invoke(RestFn.java:410) ring.middleware.json$read_json.doInvoke(json.clj:12) clojure.lang.RestFn.invoke(RestFn.java:423) ring.middleware.json$wrap_json_body$fn__1031.invoke(json.clj:19) ring.middleware.json$wrap_json_params$fn__1035.invoke(json.clj:31) compojure.core$routing$fn__362.invoke(core.clj:107) clojure.core$some.invoke(core.clj:2443) compojure.core$routing.doInvoke(core.clj:107) clojure.lang.RestFn.applyTo(RestFn.java:139) clojure.core$apply.invoke(core.clj:619) compojure.core$routes$fn__366.invoke(core.clj:112) health.servlet$_service$fn__1016.invoke(servlet.clj:1) ring.util.servlet$make_service_method$fn__50.invoke(servlet.clj:126) health.servlet$_service.invoke(servlet.clj:1) health.servlet.service(Unknown Source) [/code] Any help? -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.com javascript: Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com javascript: For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.com javascript: Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com javascript: For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to a topic in the Google Groups Clojure group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/RxctbwMoOPU/unsubscribe. To unsubscribe from this group
Re: [ANN] shadow-pgsql: PostgreSQL without JDBC
Hi. Have you tried it with Amazon's redshift? Regards. Ludwik. On Thursday, 21 August 2014 19:00:11 UTC+1, Thomas Heller wrote: Hey Clojure Folk, I'm close to releasing the first alpha version of https://github.com/thheller/shadow-pgsql a native interface to PostgreSQL I wrote. Its an implementation of the native binary protocol without any intent to ever support JDBC. Mostly because that provides a bunch of features I never use, but no support for features I wanted. It is mostly Java but I will probably only use it from Clojure so that is my primary goal going forward. I think the Java bits are close to stable. I'm looking for interested beta testers and feedback. I'm bad at writing docs cause I never know where to start since there are so many features and differences to JDBC. I have an example repl session here to get started: https://github.com/thheller/shadow-pgsql/blob/master/src/examples/repl.clj I would not recommend using it on important data yet cause it might very well eat it all. My goal is to move my projects to shadow-pgsql over the next few months, so a 1.0 should not be very far off. Anyways, I'm happy to answer questions if anyone is interested. Cheers, /thomas -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [ANN] shadow-pgsql: PostgreSQL without JDBC
Hey, No. I was not aware that redshift is PostgreSQL under the hood. Based on the docs it is based on PostgreSQL 8.0.2 and might not support some features I use to get the type thing working. It might be possible to make it work but you'll probably lose most of the features I implemented shadow-pgsql for in the first place. Will give it a try just for kicks when I find the time. But my primary Goal is good old PostgreSQL. Cheers, /thomas On Wed, Sep 3, 2014 at 3:14 PM, Ludwik Grodzki grod...@gmail.com wrote: Hi. Have you tried it with Amazon's redshift? Regards. Ludwik. On Thursday, 21 August 2014 19:00:11 UTC+1, Thomas Heller wrote: Hey Clojure Folk, I'm close to releasing the first alpha version of https://github.com/ thheller/shadow-pgsql a native interface to PostgreSQL I wrote. Its an implementation of the native binary protocol without any intent to ever support JDBC. Mostly because that provides a bunch of features I never use, but no support for features I wanted. It is mostly Java but I will probably only use it from Clojure so that is my primary goal going forward. I think the Java bits are close to stable. I'm looking for interested beta testers and feedback. I'm bad at writing docs cause I never know where to start since there are so many features and differences to JDBC. I have an example repl session here to get started: https://github.com/thheller/shadow-pgsql/blob/master/src/ examples/repl.clj I would not recommend using it on important data yet cause it might very well eat it all. My goal is to move my projects to shadow-pgsql over the next few months, so a 1.0 should not be very far off. Anyways, I'm happy to answer questions if anyone is interested. Cheers, /thomas -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to a topic in the Google Groups Clojure group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/9uxhrXmufU0/unsubscribe. To unsubscribe from this group and all its topics, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: core.async take behaviour
On Wed, Sep 3, 2014 at 11:31 AM, cig clifford.goldb...@gmail.com wrote: Thanks Timothy, that makes sense. A follow on question if you don't mind. I would like to 'take' n items off of a channel, but wait until n items are available rather than eagerly returning the way take does. Do you have any ideas on how I could achieve this? Hi, I think by design core.async does not provide any information about the channel, so there is no way to know how many items are available. However I implemented something similar using the following. Where n is the number of items you want. (repeatedly n #(!! feed-chan)) If the channel is closed with less than n items in it the remaining items will be nil. Note: I just started dabbling with core.async so there is probably a better way to do this. -- - Yohan Pereira -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: HTTP server that supports ring handlers, but asynchronously?
Pedestal pedestal-service handles requests asynchronously by extending the ring standard with Interceptors, sort of a state machine queue version the wrapped handlers of ring. /Linus Den 3 sep 2014 10:35 skrev Laurens Van Houtven _...@lvh.io: Hi James, Thanks for your response! Replies inline. On 02 Sep 2014, at 18:53, James Reeves ja...@booleanknot.com wrote: Ring uses blocking I/O by default, because that's often sufficient for most web servers, and is generally easier to reason about. HTTP works best when the response is returned ASAP, which means blocking I/O typically isn't much of a bottleneck. However, since Ring 1.2, all of the standard middleware has also been available to use asynchronously, in order to support frameworks like Pedestal. So it's certainly possible to use Ring in an async environment, at least with the core Ring libs. Although HTTP Kit doesn't use core.async channels itself, the async protocol used isn't complex. You should be able to hook up core.async/take! to http-kit/send!. Something like: (defn handler [req] (httpkit/with-channel req http-ch (let [resp-ch (async-handler! req)] (httpkit/on-close (fn [_] (a/close! resp-ch))) (a/take! resp-ch (fn [resp] (httpkit/send! http-ch resp) (httpkit/close http-ch)) That’s what I wanted to do, but then I saw the warning on http-kit’s website at http://http-kit.org/server.html#channel , which states: Data is sent directly to the client, NO RING MIDDLEWARE IS APPLIED. … which leads me to believe that the send! API just totally sidesteps any middleware, and it’s not so much up to the middleware whether or not it supports asynchronous operation. Unless of course it actually works fine, and that’s simply some stale documentation? That said, I'd be wary about having HTTP clients wait around on the server. If it's just a few seconds, that seems reasonable, but any longer and you should consider redirecting to a job resource instead. Yeah, I’ve been considering that. Looking at the distribution of response times right now, 5-10s is a small, but non-negligible part of the responses. However, the point of this software is being able to give third parties capabilities (in the object-capability sense), so typically some of the requests involve secrets the caller doesn’t get to know about (like API credentials). As a result, I’m trying to be hyper-conservative in terms of stuff that can leak information. I’ll have to think more about that one :-) hth lvh -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: HTTP server that supports ring handlers, but asynchronously?
Yet another: I'm using a servlet implementation, that can be deployed in any servlet container supporting servlet api 3.0 (with async) https://github.com/webnf/webnf/tree/master/async-servlet It allows to return a function instead of a regular ring response, that will get an async context to drive the rest of the response, e.g (defn handler [req] (fn [ac] (future (as/status ac 200) (as/chunk ac body) (as/complete ac)) as/log-listener)) Caveats: It only does plain http (no websockets) and any middleware operating on the response must be compatible with this style of async response. On the plus side, it works in any recent servlet server (without tying up a thread), it seems a pretty good fit for your case of streaming back a response from a channel and middlewares that only care about the request (authorization, ...) work just fine. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: HTTP server that supports ring handlers, but asynchronously?
On 3 September 2014 09:35, Laurens Van Houtven _...@lvh.io wrote: (defn handler [req] (httpkit/with-channel req http-ch (let [resp-ch (async-handler! req)] (httpkit/on-close (fn [_] (a/close! resp-ch))) (a/take! resp-ch (fn [resp] (httpkit/send! http-ch resp) (httpkit/close http-ch)) That’s what I wanted to do, but then I saw the warning on http-kit’s website at http://http-kit.org/server.html#channel , which states: Data is sent directly to the client, NO RING MIDDLEWARE IS APPLIED. … which leads me to believe that the send! API just totally sidesteps any middleware, and it’s not so much up to the middleware whether or not it supports asynchronous operation. Unless of course it actually works fine, and that’s simply some stale documentation? It means that any middleware wrapping the handler won't affect the response. For instance, assume you have an async handler that returns a channel. (defn async-handler! [req] (let [ch (a/chan)] (go (! ch {:status 200, :headers {}, :body Hello World}) (a/close! ch)) ch)) The normal way of applying middleware is to pass the handler to a wrap-whatever function: (def async-handler! (wrap-foo (fn [req] (let [ch (a/chan)] (go (! ch {:status 200, :headers {}, :body Hello World}) (a/close! ch)) ch)) The middleware function expects the handler to return a map, not a channel, so this won't work. However, Ring supplies foo-request and foo-response functions for all the standard middleware, so you can write: (defn async-handler! [req] (let [ch (a/chan)] (go (! ch (foo-response {:status 200, :headers {}, :body Hello World})) (a/close! ch)) ch)) Using the standard wrap-foo middleware is obviously preferable the vast majority of the time, as it's less complected. - James -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
ClassCastExecption with conj on deftype
Hi all, I've defined a custom vector type and implemented various clj/cljs protocols, but now ended up hitting my head against some weird behaviour with conj (or rather cons, internally). The type defines a 2-element vector-like construct and my cons implementation would simply return a standard clojure.lang.PersistentVector with the given arg added like this: (deftype Foo [a b] clojure.lang.IPersistentCollection clojure.lang.Indexed clojure.lang.Sequential clojure.lang.ISeq clojure.lang.Seqable clojure.lang.Reversible ;; ... elided seq fn impls... (cons [_ c] [a b c])) However, attempting a conj results in an exception I don't understand: (conj (Foo. 1 2) 3) java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.ISeq at user.Foo.cons (foo.clj:13) user.Foo.cons (foo.clj:-1) clojure.lang.RT.conj (RT.java:562) clojure.core$conj.invoke (core.clj:83) ... As far as I can tell, clojure.core/conj simply calls RT.conj(coll, x), which just calls coll.cons(x): https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L604 static public IPersistentCollection conj(IPersistentCollection coll, Object x){ if(coll == null) return new PersistentList(x); return coll.cons(x); } So where in that call path is there an attempt or requirement to cast to an ISeq? I've been comparing notes (as far as this possible) with the default PersistenVector implementation, but not sure where I'm going wrong here... -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: ClassCastExecption with conj on deftype
Not a direct answer but you might want to look at https://github.com/ztellman/clj-tuple/blob/master/src/clj_tuple.clj On Wed, Sep 3, 2014 at 1:13 PM, Karsten Schmidt i...@toxi.co.uk wrote: Hi all, I've defined a custom vector type and implemented various clj/cljs protocols, but now ended up hitting my head against some weird behaviour with conj (or rather cons, internally). The type defines a 2-element vector-like construct and my cons implementation would simply return a standard clojure.lang.PersistentVector with the given arg added like this: (deftype Foo [a b] clojure.lang.IPersistentCollection clojure.lang.Indexed clojure.lang.Sequential clojure.lang.ISeq clojure.lang.Seqable clojure.lang.Reversible ;; ... elided seq fn impls... (cons [_ c] [a b c])) However, attempting a conj results in an exception I don't understand: (conj (Foo. 1 2) 3) java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.ISeq at user.Foo.cons (foo.clj:13) user.Foo.cons (foo.clj:-1) clojure.lang.RT.conj (RT.java:562) clojure.core$conj.invoke (core.clj:83) ... As far as I can tell, clojure.core/conj simply calls RT.conj(coll, x), which just calls coll.cons(x): https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L604 static public IPersistentCollection conj(IPersistentCollection coll, Object x){ if(coll == null) return new PersistentList(x); return coll.cons(x); } So where in that call path is there an attempt or requirement to cast to an ISeq? I've been comparing notes (as far as this possible) with the default PersistenVector implementation, but not sure where I'm going wrong here... -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: ClassCastExecption with conj on deftype
Hmm... since ISeq extends IPersistentCollection and overrides the latter's return type, cons must return an ISeq. So do I understand it correctly, that one *can't* have a deftype which returns itself as Seqable *and* has vector-style conj behavior (i.e. append at tail position)? K. On 3 September 2014 18:13, Karsten Schmidt i...@toxi.co.uk wrote: Hi all, I've defined a custom vector type and implemented various clj/cljs protocols, but now ended up hitting my head against some weird behaviour with conj (or rather cons, internally). The type defines a 2-element vector-like construct and my cons implementation would simply return a standard clojure.lang.PersistentVector with the given arg added like this: (deftype Foo [a b] clojure.lang.IPersistentCollection clojure.lang.Indexed clojure.lang.Sequential clojure.lang.ISeq clojure.lang.Seqable clojure.lang.Reversible ;; ... elided seq fn impls... (cons [_ c] [a b c])) However, attempting a conj results in an exception I don't understand: (conj (Foo. 1 2) 3) java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.ISeq at user.Foo.cons (foo.clj:13) user.Foo.cons (foo.clj:-1) clojure.lang.RT.conj (RT.java:562) clojure.core$conj.invoke (core.clj:83) ... As far as I can tell, clojure.core/conj simply calls RT.conj(coll, x), which just calls coll.cons(x): https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L604 static public IPersistentCollection conj(IPersistentCollection coll, Object x){ if(coll == null) return new PersistentList(x); return coll.cons(x); } So where in that call path is there an attempt or requirement to cast to an ISeq? I've been comparing notes (as far as this possible) with the default PersistenVector implementation, but not sure where I'm going wrong here... -- Karsten Schmidt http://postspectacular.com | http://toxiclibs.org | http://toxi.co.uk -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: ClassCastExecption with conj on deftype
Thanks, Kovas! I looked at it a few months ago (and now just forked it), but Zach also seems to have created a separate deftype just to support this conj-ing business (and that alone is 180 LOC...) That all seems to be a huge effort though and am wondering about simpler alternatives and/or some better detailed documentation about these matters and inter-relationships. IMHO this part of Clojure seems to be very cryptic to me... Just would like to know if this particular combination of vector-style conj behavior being self-seqable is fundamentally incompatible or if I'm missing something here? Of course, an easy solution would be to just do this: (deftype Foo [a b] (cons [this c] (seq [a b c]))) ..but that would mean any further conj-ing will happen at the head. cons as defined in IPersistentCollection has IPersistentCollection as return type (and hence would be satisfied by PersistentVector), but it's being overridden in ISeq and so wins... Makes me wonder why conj has not been kept internally separate from cons. Wouldn't this have avoided this potential for such a conflict? On 3 September 2014 18:33, kovas boguta kovas.bog...@gmail.com wrote: Not a direct answer but you might want to look at https://github.com/ztellman/clj-tuple/blob/master/src/clj_tuple.clj On Wed, Sep 3, 2014 at 1:13 PM, Karsten Schmidt i...@toxi.co.uk wrote: Hi all, I've defined a custom vector type and implemented various clj/cljs protocols, but now ended up hitting my head against some weird behaviour with conj (or rather cons, internally). The type defines a 2-element vector-like construct and my cons implementation would simply return a standard clojure.lang.PersistentVector with the given arg added like this: (deftype Foo [a b] clojure.lang.IPersistentCollection clojure.lang.Indexed clojure.lang.Sequential clojure.lang.ISeq clojure.lang.Seqable clojure.lang.Reversible ;; ... elided seq fn impls... (cons [_ c] [a b c])) However, attempting a conj results in an exception I don't understand: (conj (Foo. 1 2) 3) java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.ISeq at user.Foo.cons (foo.clj:13) user.Foo.cons (foo.clj:-1) clojure.lang.RT.conj (RT.java:562) clojure.core$conj.invoke (core.clj:83) ... As far as I can tell, clojure.core/conj simply calls RT.conj(coll, x), which just calls coll.cons(x): https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L604 static public IPersistentCollection conj(IPersistentCollection coll, Object x){ if(coll == null) return new PersistentList(x); return coll.cons(x); } So where in that call path is there an attempt or requirement to cast to an ISeq? I've been comparing notes (as far as this possible) with the default PersistenVector implementation, but not sure where I'm going wrong here... -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Karsten Schmidt http://postspectacular.com | http://toxiclibs.org | http://toxi.co.uk -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to
Almost purely functional sortable (demo)
Code - https://github.com/dar-clojure/ui/blob/master/examples/sortable/main.cljs Demo - https://dar-clojure.github.io/ui/files/sortable.html You can feed it 1000 items and it's still alive https://dar-clojure.github.io/ui/files/sortable1000.html. What do you think? :) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Almost purely functional sortable (demo)
On Mac OS X 10.8.5 + Safari 6.1.6, very nice, very slick. On Mac OS X 10.8.5 + Firefox 32.0, very frustrating, and doesn't work like it does on Safari at all. Not sure if that is a known issue or not. Andy On Wed, Sep 3, 2014 at 11:06 AM, Eldar Gabdullin eldar...@gmail.com wrote: Code - https://github.com/dar-clojure/ui/blob/master/examples/sortable/main.cljs Demo - https://dar-clojure.github.io/ui/files/sortable.html You can feed it 1000 items and it's still alive https://dar-clojure.github.io/ui/files/sortable1000.html. What do you think? :) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: ClassCastExecption with conj on deftype
One nuance to consider re: self-sequable datastructures is that on eval clojure will assume the first element is invocable, see https://github.com/ztellman/clj-tuple/issues/5 On Wed, Sep 3, 2014 at 1:51 PM, Karsten Schmidt i...@toxi.co.uk wrote: Thanks, Kovas! I looked at it a few months ago (and now just forked it), but Zach also seems to have created a separate deftype just to support this conj-ing business (and that alone is 180 LOC...) That all seems to be a huge effort though and am wondering about simpler alternatives and/or some better detailed documentation about these matters and inter-relationships. IMHO this part of Clojure seems to be very cryptic to me... Just would like to know if this particular combination of vector-style conj behavior being self-seqable is fundamentally incompatible or if I'm missing something here? Of course, an easy solution would be to just do this: (deftype Foo [a b] (cons [this c] (seq [a b c]))) ..but that would mean any further conj-ing will happen at the head. cons as defined in IPersistentCollection has IPersistentCollection as return type (and hence would be satisfied by PersistentVector), but it's being overridden in ISeq and so wins... Makes me wonder why conj has not been kept internally separate from cons. Wouldn't this have avoided this potential for such a conflict? On 3 September 2014 18:33, kovas boguta kovas.bog...@gmail.com wrote: Not a direct answer but you might want to look at https://github.com/ztellman/clj-tuple/blob/master/src/clj_tuple.clj On Wed, Sep 3, 2014 at 1:13 PM, Karsten Schmidt i...@toxi.co.uk wrote: Hi all, I've defined a custom vector type and implemented various clj/cljs protocols, but now ended up hitting my head against some weird behaviour with conj (or rather cons, internally). The type defines a 2-element vector-like construct and my cons implementation would simply return a standard clojure.lang.PersistentVector with the given arg added like this: (deftype Foo [a b] clojure.lang.IPersistentCollection clojure.lang.Indexed clojure.lang.Sequential clojure.lang.ISeq clojure.lang.Seqable clojure.lang.Reversible ;; ... elided seq fn impls... (cons [_ c] [a b c])) However, attempting a conj results in an exception I don't understand: (conj (Foo. 1 2) 3) java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.ISeq at user.Foo.cons (foo.clj:13) user.Foo.cons (foo.clj:-1) clojure.lang.RT.conj (RT.java:562) clojure.core$conj.invoke (core.clj:83) ... As far as I can tell, clojure.core/conj simply calls RT.conj(coll, x), which just calls coll.cons(x): https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L604 static public IPersistentCollection conj(IPersistentCollection coll, Object x){ if(coll == null) return new PersistentList(x); return coll.cons(x); } So where in that call path is there an attempt or requirement to cast to an ISeq? I've been comparing notes (as far as this possible) with the default PersistenVector implementation, but not sure where I'm going wrong here... -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- Karsten Schmidt http://postspectacular.com | http://toxiclibs.org | http://toxi.co.uk -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com
Re: Almost purely functional sortable (demo)
Thanks, for reporting. Fixed FF issues, now it's at least useable. среда, 3 сентября 2014 г., 22:21:17 UTC+4 пользователь Andy Fingerhut написал: On Mac OS X 10.8.5 + Safari 6.1.6, very nice, very slick. On Mac OS X 10.8.5 + Firefox 32.0, very frustrating, and doesn't work like it does on Safari at all. Not sure if that is a known issue or not. Andy On Wed, Sep 3, 2014 at 11:06 AM, Eldar Gabdullin elda...@gmail.com javascript: wrote: Code - https://github.com/dar-clojure/ui/blob/master/examples/sortable/main.cljs Demo - https://dar-clojure.github.io/ui/files/sortable.html You can feed it 1000 items and it's still alive https://dar-clojure.github.io/ui/files/sortable1000.html. What do you think? :) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.com javascript: Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com javascript: For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com javascript:. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Almost purely functional sortable (demo)
It's might be not quite clear, but everything except bangs (!) is a pure data with no state. For example, we have 3 state configurations - initial, captured and dragging. We need to listen a bunch of global events when dragging. When we are done with dragging, we just return an initial state. That's enough to detach all global listeners and do all cleanup... среда, 3 сентября 2014 г., 22:06:56 UTC+4 пользователь Eldar Gabdullin написал: Code - https://github.com/dar-clojure/ui/blob/master/examples/sortable/main.cljs Demo - https://dar-clojure.github.io/ui/files/sortable.html You can feed it 1000 items and it's still alive https://dar-clojure.github.io/ui/files/sortable1000.html. What do you think? :) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
StackOverflow TV Opportunity to Promote Clojure
StackOverflow just announced an experimental project to produce videos in its New York City office. This could be a great opportunity to polish up one of your presentations and promote Clojure to a wide audience. No speaker fees, but reasonable travel costs covered. Post: http://meta.stackoverflow.com/q/270574/1756702 Email: t...@stackoverflow.com -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[ANN] leaven and bakery - lightweight components for clojure and clojurescript
leaven [1] is a component library, much like Stuart Sierra's component, only it works for both clojure and clojurescript and is simpler. bakery [2] is a library of leaven components, for both clojure and clojurescript. An example web app [3] uses httpkit, sente, weasel, storage-atom, secretary, om-bootstrap, among other libraries. Leaven doesn't mix system definition with system instantiation. It uses an explicit system definition, defsystem, that constructs a component containing sub-components. The dependency ordering between components is explicit in defsystem. Constructing an instance of the system is done by creating an instance of the record defsystem defines. Additional protocols can be implemented on your system in the body of the defsystem. [1] https://github.com/palletops/leaven[1] [2] https://github.com/palletops/bakery[2] [3] https://github.com/palletops/bakery/example-web-app[3] signature.asc Description: PGP signature
Re: Almost purely functional sortable (demo)
It turns out lags in FF were due to phantom position animation, turning that off makes it working in FF like in Safary and Chrome. среда, 3 сентября 2014 г., 22:48:43 UTC+4 пользователь Eldar Gabdullin написал: Thanks, for reporting. Fixed FF issues, now it's at least useable. среда, 3 сентября 2014 г., 22:21:17 UTC+4 пользователь Andy Fingerhut написал: On Mac OS X 10.8.5 + Safari 6.1.6, very nice, very slick. On Mac OS X 10.8.5 + Firefox 32.0, very frustrating, and doesn't work like it does on Safari at all. Not sure if that is a known issue or not. Andy On Wed, Sep 3, 2014 at 11:06 AM, Eldar Gabdullin elda...@gmail.com wrote: Code - https://github.com/dar-clojure/ui/blob/master/examples/sortable/main.cljs Demo - https://dar-clojure.github.io/ui/files/sortable.html You can feed it 1000 items and it's still alive https://dar-clojure.github.io/ui/files/sortable1000.html. What do you think? :) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [ANN] leaven and bakery - lightweight components for clojure and clojurescript
The links in my previous post seem to not be correct: [1] https://github.com/palletops/leaven [2] https://github.com/palletops/bakery [3] https://github.com/palletops/bakery/example-web-app signature.asc Description: PGP signature
Re: [ANN] leaven and bakery - lightweight components for clojure and clojurescript
I'm not sure your [3] URL works. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: core.async take behaviour
I think that's just a partition transducer on the channel? On Wednesday, September 3, 2014 2:24:28 AM UTC-5, Gary Verhaegen wrote: I'd use another channel on which I put vectors of the correct length, with an intermediate loop that takes from the first channel, accumulates until the vector has the right size, and then put the vector on the second channel. There might be a better solution with transducers, though. (Or without.) On Wednesday, 3 September 2014, cig clifford...@gmail.com javascript: wrote: Thanks Timothy, that makes sense. A follow on question if you don't mind. I would like to 'take' n items off of a channel, but wait until n items are available rather than eagerly returning the way take does. Do you have any ideas on how I could achieve this? On Tuesday, 2 September 2014 22:23:10 UTC+2, tbc++ wrote: It's because into is pulling items as fast as it can from take. Sure the buffer might get full but then into takes another value allowing take to continue. Timothy On Tue, Sep 2, 2014 at 1:48 PM, cig clifford...@gmail.com wrote: Hi I was expecting the following example to park, waiting for the 'out' channel to be cleared. Could anybody explain why 'take' does not park when the output buffer size is smaller than the number of entries being taken from the input channel? (def from (to-chan [1 2 3 4 5 6 7])) (!! (into [] (take 4 from *2*))) ;; note: the output channel buffer size is 2 (less than 4 items being taken off of the 'from' channel) ;; = [1 2 3 4] -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- “One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.” (Robert Firth) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: ClassCastExecption with conj on deftype
Your implementation of cons in your deftype is probably being associated to the ISeq type, not IPersistentCollection. user= (deftype Foo [a b] #_= clojure.lang.IPersistentCollection #_= (cons [_ c] [a b c])) user.Foo user= (conj (Foo. 1 2) 3) [1 2 3] I think Vector supports ISeq through the Seqable interface but not directly. So your type Foo may not need it: user= (.cons [] 1) ; ok [1] user= (.first [] 1) ; ?? IllegalArgumentException No matching method found: first for class clojure.lang.PersistentVector clojure.lang.Reflector.invokeMatchingMetho On Wednesday, September 3, 2014 10:13:36 AM UTC-7, Karsten Schmidt wrote: Hi all, I've defined a custom vector type and implemented various clj/cljs protocols, but now ended up hitting my head against some weird behaviour with conj (or rather cons, internally). The type defines a 2-element vector-like construct and my cons implementation would simply return a standard clojure.lang.PersistentVector with the given arg added like this: (deftype Foo [a b] clojure.lang.IPersistentCollection clojure.lang.Indexed clojure.lang.Sequential clojure.lang.ISeq clojure.lang.Seqable clojure.lang.Reversible ;; ... elided seq fn impls... (cons [_ c] [a b c])) However, attempting a conj results in an exception I don't understand: (conj (Foo. 1 2) 3) java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to clojure.lang.ISeq at user.Foo.cons (foo.clj:13) user.Foo.cons (foo.clj:-1) clojure.lang.RT.conj (RT.java:562) clojure.core$conj.invoke (core.clj:83) ... As far as I can tell, clojure.core/conj simply calls RT.conj(coll, x), which just calls coll.cons(x): https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/RT.java#L604 static public IPersistentCollection conj(IPersistentCollection coll, Object x){ if(coll == null) return new PersistentList(x); return coll.cons(x); } So where in that call path is there an attempt or requirement to cast to an ISeq? I've been comparing notes (as far as this possible) with the default PersistenVector implementation, but not sure where I'm going wrong here... -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: StackOverflow TV Opportunity to Promote Clojure
I tried to email t...@stackoverflow.com and got delivery failure messages. On Wed, Sep 3, 2014 at 1:55 PM, A. Webb a.webb@gmail.com wrote: StackOverflow just announced an experimental project to produce videos in its New York City office. This could be a great opportunity to polish up one of your presentations and promote Clojure to a wide audience. No speaker fees, but reasonable travel costs covered. Post: http://meta.stackoverflow.com/q/270574/1756702 Email: t...@stackoverflow.com -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [ANN] leaven and bakery - lightweight components for clojure and clojurescript
dsblakewat...@gmail.com writes: I'm not sure your [3] URL works. Try https://github.com/palletops/bakery/tree/develop/example-web-app signature.asc Description: PGP signature
Re: [ANN] leaven and bakery - lightweight components for clojure and clojurescript
Yeah, I worked back to the original to find the web-app. I note that the repo seems to default to develop, which results in a lot of errors when I try to lein repl in example-web-app. (Missing clojars which are, in fact, missing.) When I switch branch to the master, I don't get those errors, but the process hangs on Compiling 'target/cljs-test/testable.js, then times out. I tried doing a lein cljsbuild once prior, then found that lein repl would work. Thanks! On Wed, Sep 3, 2014 at 2:29 PM, Hugo Duncan duncan.h...@gmail.com wrote: dsblakewat...@gmail.com writes: I'm not sure your [3] URL works. Try https://github.com/palletops/bakery/tree/develop/example-web-app -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [ANN] leaven and bakery - lightweight components for clojure and clojurescript
If I'm understanding right, the main difference between Leaven and Component is that Leaven uses *defsystem* to specify an explicit start/stop ordering, while Component uses its *using* function to define dependencies between components, and works out the ordering itself. Also, while this is a really minor thing, the naming of ILifeCycle kinda bugs me. The I prefix is an abbreviation for Interface, but ILifeCycle is a protocol. - James On 3 September 2014 21:19, Hugo Duncan h...@hugoduncan.org wrote: leaven [1] is a component library, much like Stuart Sierra's component, only it works for both clojure and clojurescript and is simpler. bakery [2] is a library of leaven components, for both clojure and clojurescript. An example web app [3] uses httpkit, sente, weasel, storage-atom, secretary, om-bootstrap, among other libraries. Leaven doesn't mix system definition with system instantiation. It uses an explicit system definition, defsystem, that constructs a component containing sub-components. The dependency ordering between components is explicit in defsystem. Constructing an instance of the system is done by creating an instance of the record defsystem defines. Additional protocols can be implemented on your system in the body of the defsystem. [1] https://github.com/palletops/leaven[1] [2] https://github.com/palletops/bakery[2] [3] https://github.com/palletops/bakery/example-web-app[3] -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [ANN] leaven and bakery - lightweight components for clojure and clojurescript
dsblakewat...@gmail.com writes: Yeah, I worked back to the original to find the web-app. I note that the repo seems to default to develop, which results in a lot of errors when I try to lein repl in example-web-app. (Missing clojars which are, in fact, missing.) A `lein install` at the top level of bakery should allow you to run on develop. When I switch branch to the master, I don't get those errors, but the process hangs on Compiling 'target/cljs-test/testable.js, then times out. I tried doing a lein cljsbuild once prior, then found that lein repl would work. Thanks for the feedback. I've updated the README accordingly. Hugo signature.asc Description: PGP signature
Re: [ANN] leaven and bakery - lightweight components for clojure and clojurescript
ja...@booleanknot.com writes: If I'm understanding right, the main difference between Leaven and Component is that Leaven uses *defsystem* to specify an explicit start/stop ordering, while Component uses its *using* function to define dependencies between components, and works out the ordering itself. Indeed. The result is a system definition that is open to extension via other protocols, and that can be instantiated without having to specify the dependencies between components at the same time, which feels more natural to me. I could be convinced about adding some sort of declarative description of inter-component dependencies to defsystem, but I'm not sure it is really necessary. Also, the fact it works with clojurescript. Also, while this is a really minor thing, the naming of ILifeCycle kinda bugs me. The I prefix is an abbreviation for Interface, but ILifeCycle is a protocol. Having used Om a fair bit recently, I was influenced by the naming of the protocols there. Hugo signature.asc Description: PGP signature
Re: [ANN] leaven and bakery - lightweight components for clojure and clojurescript
Thanks Hugo! I was just wishing for something like this for ClojureScript. I look forward to checking it out. Julio On Sep 3, 2014, at 1:19 PM, Hugo Duncan h...@hugoduncan.org wrote: leaven [1] is a component library, much like Stuart Sierra's component, only it works for both clojure and clojurescript and is simpler. bakery [2] is a library of leaven components, for both clojure and clojurescript. An example web app [3] uses httpkit, sente, weasel, storage-atom, secretary, om-bootstrap, among other libraries. Leaven doesn't mix system definition with system instantiation. It uses an explicit system definition, defsystem, that constructs a component containing sub-components. The dependency ordering between components is explicit in defsystem. Constructing an instance of the system is done by creating an instance of the record defsystem defines. Additional protocols can be implemented on your system in the body of the defsystem. [1] https://github.com/palletops/leaven[1] [2] https://github.com/palletops/bakery[2] [3] https://github.com/palletops/bakery/example-web-app[3] -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[ANN] *Extended Deadline* CFP for 2014 Scheme and Functional Programming Workshop
The paper submission deadline has been extended one week, to Friday, Sept. 12 23:59 (UTC-12). [Apologies for duplication from cross-postings.] NEW DEADLINE: 12 September 2014, 23:59 (UTC-12) WEBSITE: http://homes.soic.indiana.edu/jhemann/scheme-14/ LOCATION: Washington, DC (co-located with Clojure/conj) DATE: 19 November 2014 The 2014 Scheme and Functional Programming Workshop is calling for submissions. Submissions related to Scheme and functional programming are welcome and encouraged. Topics of interest include but are not limited to: - Program-development environments, debugging, testing - Implementation (interpreters, compilers, tools, benchmarks, etc) - Syntax, macros, and hygiene - Distributed computing, concurrency, parallelism - Interoperability with other languages, FFIs - Continuations, modules, object systems, types - Theory, formal semantics, correctness - History, evolution and standardization of Scheme - Applications, experience and industrial uses of Scheme - Education - Scheme pearls (elegant, instructive uses of Scheme) We also welcome papers related to dynamic or multiparadigmatic languages and programming techniques. Full papers are due 12 September 2014. Authors will be notified by 10 October 2014. Camera-ready versions are due 24 October 2014. All deadlines are 23:59 (UTC-12, Anywhere on Earth). For more information, please see: http://homes.soic.indiana.edu/jhemann/scheme-14/ Jason Hemann Organizer, Scheme '14 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [ANN] Taoensso library updates / 2014 September
Thanks Sun, appreciate all your input on v2.7 - cheers! :-) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.