Re: s/valid? does not tell me if the data is valid as supplied
I've written a library that tries to solve this, instead of making conforms that do coercion, it uses the spec and a separated registry to conform the value (similar to what spec does to find the generators for a given spec). You can find the library at: https://github.com/wilkerlucio/spec-coerce. This way you don't complect the conformance with coercion. On Thursday, February 22, 2018 at 11:19:35 PM UTC-3, Didier wrote: > > Map specs are about attribute aggregation, not about types. >> > > I understand the design philosophy. I think that's great. What I meant I > guess is that it would be nice to also have a declarative way to relate > Types to Specs, for when Specs fall short of types. Then you'd have the > best of both world. Specs where Types fall shorts, and Types where Specs > fall shorts. > > You can effectively do this already. When you have s/keys maps which are >> sets of attributes, you can simply combine sets (base and extensions) using >> s/merge. Or when needing more polymorphism, s/multi-spec. >> > > I guess I'm talking about Types as in primitive types included. So if I > create a String type, I can describe what is the set of values for the type > using a spec. Similarly, I now know that the Type and the Spec used to > describe its possible set of values are equivalent. So I now know the > relationship between them. > > The real reason I want this is so that I can auto-generate client code in > different languages for my Specs. > > I'm thinking of it as a more generic Swagger OpenAPI specification. > > Maybe what I'm thinking off doesn't make sense, its all kind of at the > blurry idea phase in my head. > > Currently, I manually have an equivalent set of Java Classes which > correspond to the specs of my data which gets shared between Java and > Clojure systems. And I manually have functions which converts a piece of > data from a given Spec, into its Java equivalent representation and back. > I've been thinking about how I could have the equivalent Java classes be > auto-generated, as well as the conversion be automatic. The biggest > challenge is knowing what Java types would a given Spec map too. So I > thought if I my spec could have a mapping on them too, then it wouldn't be > too hard. When you write your Spec, you could associate it with an > enclosing Type, and then from the Specs I might be able to auto-generate > the Java model classes. > > Anyways, the whole thing is incubating in my head. And I can probably do > it on top of Spec if I really needed too. > > On Wednesday, 21 February 2018 18:47:20 UTC-8, Alex Miller wrote: >> >> >> On Wednesday, February 21, 2018 at 7:34:00 PM UTC-6, Didier wrote: >>> >>> I would actually love it if Spec was extended to have the concept of >>> types. >>> >> >> Map specs are about attribute aggregation, not about types. >> >> https://clojure.org/about/spec#_map_specs_should_be_of_keysets_only >> >> >>> Something where every spec could be tied to a Type, and types could be >>> constructed to have Hierarchies. >>> >> >> You can effectively do this already. When you have s/keys maps which are >> sets of attributes, you can simply combine sets (base and extensions) using >> s/merge. Or when needing more polymorphism, s/multi-spec. >> >> -- 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: Datomic query question
Thank you very much Francis, that was very helpful :) On Thu, Jun 4, 2015 at 1:21 PM Francis Avila fav...@breezeehr.com wrote: (This question is more appropriate to the datomic group: https://groups.google.com/forum/#!forum/datomic) Datomic/datalog queries always perform aggregation as a last step so the results of aggregation are unavailable to the :where clause. In other words, what you want is impossible with a single datalog query. However, this isn't SQL: the datalog query is run in the peer and all the data used for aggregation is transmitted to the peer anyway. Just filter over the results yourself with normal Clojure code. There's no advantage to expressing everything in a single query like there is in SQL. (let [db [[:t1 :track/name foo] [:l1 :lesson/track :t1] [:t2 :track/name bar] [:l2 :lesson/track :t2] [:t3 :track/name baz] [:l3 :lesson/track :t3] [:l4 :lesson/track :t3]]] (- (d/q '[:find ?track (count ?lessons) :where [?t :track/name ?track] [?lessons :lesson/track ?t]] db) (filter (fn [[_ cnt]] ( cnt 1) ;= ([baz 2]) You can also use two queries: one to get the count per track, another to get the track names (but a simple filter is less verbose): (let [db [[:t1 :track/name foo] [:l1 :lesson/track :t1] [:t2 :track/name bar] [:l2 :lesson/track :t2] [:t3 :track/name baz] [:l3 :lesson/track :t3] [:l4 :lesson/track :t3]]] (- (d/q '[:find ?t (count ?lessons) :where [?lessons :lesson/track ?t]] db) (d/q '[:find ?track ?num-lessons :in $ [[?t ?num-lessons]] :where [( ?num-lessons 1)] [?t :track/name ?track]] db))) ;= #{[baz 2]} As a side note, be aware that if your track names are not unique you may get unexpected results from your current query: (let [db [[:t1 :track/name foo] [:l1 :lesson/track :t1] [:t2 :track/name bar] [:l2 :lesson/track :t2] [:t3 :track/name foo] [:l3 :lesson/track :t3] [:l4 :lesson/track :t3]]] (d/q '[:find ?track (count ?lessons) :where [?t :track/name ?track] [?lessons :lesson/track ?t]] db)) ;= [[bar 1] [foo 3]] This is because the aggregation is done over an unaggregated result *set* (i.e. all unique values) and ?track is the same for multiple ?t. The solution is to either include ?t in the :find, or use :with. See the Datomic docs more more details: http://docs.datomic.com/query.html#sec-5-17 On Thursday, June 4, 2015 at 6:35:08 AM UTC-5, Wilker wrote: Hi, good morning. I have this query here: [:find ?track (count ?lessons) :where [?t :track/name ?track] [?lessons :lesson/track ?t] ] A lesson has a track (so a track can be on multiple lessons), and with this query I can return the track names and the number of lessons where this track is being used, all good here. But I would like to use this count information to filter, and return only tracks that are present in more than one lesson, I tried: [:find ?track (count ?lessons) :where [?t :track/name ?track] [?lessons :lesson/track ?t] [( (count ?lessons) 1)] ] Also tried: [:find ?track ?lc :where [?t :track/name ?track] [?lessons :lesson/track ?t] [(count ?lessons) ?lc] [( ?lc 1)] ] But I feel like I'm going on the wrong direction... How can I make this query works? Thanks. -- 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.
Datomic query question
Hi, good morning. I have this query here: [:find ?track (count ?lessons) :where [?t :track/name ?track] [?lessons :lesson/track ?t] ] A lesson has a track (so a track can be on multiple lessons), and with this query I can return the track names and the number of lessons where this track is being used, all good here. But I would like to use this count information to filter, and return only tracks that are present in more than one lesson, I tried: [:find ?track (count ?lessons) :where [?t :track/name ?track] [?lessons :lesson/track ?t] [( (count ?lessons) 1)] ] Also tried: [:find ?track ?lc :where [?t :track/name ?track] [?lessons :lesson/track ?t] [(count ?lessons) ?lc] [( ?lc 1)] ] But I feel like I'm going on the wrong direction... How can I make this query works? Thanks. -- 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.
calling functions that accepts keyword arguments with a map
Hi guys, I'm trying to find the best way to call a function that accepts keyword arguments (in my case it's the set-style! on Enfocus library) with a map. So, an example of the regular call: (set-style :color red :cursor pointer) I would like to call with a map (because that way I can manage the map data before using it) but I found no very easy way to do it... The best way I could found is like this: (apply set-style (flatten (seq {:color red :cursor pointer}))) But that's a bit overwhelming, I wonder if there is a simpler way to handle this situation. Thanks. -- 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: calling functions that accepts keyword arguments with a map
Good point Andy! Yeah, I'll use Francis solution, and actually I'll create a simple helper for the entire thing, as: (defn apply-map [f m] (apply f (apply concat m))) That will make the whole thing much easier, I was hoping that there was something else in the core for helping with that, but if it doesn't this simple function will do the job. Thanks again. On Fri Feb 13 2015 at 3:01:55 PM Andy Fingerhut andy.finger...@gmail.com wrote: There is a significant advantage to Francis's version when keys or values in the map are collections that flatten flattens: ;; Most likely not the behavior you want: user= (flatten (seq {:colors [red blue] :cursor-set #{pointer hand}})) (:colors red blue :cursor-set #{hand pointer}) ;; Better: user= (apply concat {:colors [red blue] :cursor-set #{pointer hand}}) (:colors [red blue] :cursor-set #{hand pointer}) Andy On Fri, Feb 13, 2015 at 9:44 AM, Francis Avila fav...@breezeehr.com wrote: Not fundamentally different from your approach: (apply set-style (apply concat {:color red :cursor pointer})) On Friday, February 13, 2015 at 11:30:44 AM UTC-6, Wilker wrote: Hi guys, I'm trying to find the best way to call a function that accepts keyword arguments (in my case it's the set-style! on Enfocus library) with a map. So, an example of the regular call: (set-style :color red :cursor pointer) I would like to call with a map (because that way I can manage the map data before using it) but I found no very easy way to do it... The best way I could found is like this: (apply set-style (flatten (seq {:color red :cursor pointer}))) But that's a bit overwhelming, I wonder if there is a simpler way to handle this situation. Thanks. -- 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. -- 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: calling functions that accepts keyword arguments with a map
I agree with you James, I prefer to just receive maps in my functions. On Fri Feb 13 2015 at 4:04:14 PM James Reeves ja...@booleanknot.com wrote: A lot of utility libraries, such as my own Medley https://github.com/weavejester/medley, have mapply functions for this exact use-case. Generally, however, I find that keyword arguments are more trouble than they're worth. You only save two characters, and give up a lot on terms of being able to easily compose and extend functions. - James On 13 February 2015 at 17:30, Wilker wilkerlu...@gmail.com wrote: Hi guys, I'm trying to find the best way to call a function that accepts keyword arguments (in my case it's the set-style! on Enfocus library) with a map. So, an example of the regular call: (set-style :color red :cursor pointer) I would like to call with a map (because that way I can manage the map data before using it) but I found no very easy way to do it... The best way I could found is like this: (apply set-style (flatten (seq {:color red :cursor pointer}))) But that's a bit overwhelming, I wonder if there is a simpler way to handle this situation. Thanks. -- 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. -- 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: transducers and async operations
Yeah, I'm going to let it go, hopefully I'll find some way of handling it on future, for now keeping the extra versions is not that bad. Thank you everyone. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Mon, Sep 22, 2014 at 6:01 PM, Leon Grapenthin grapenthinl...@gmail.com wrote: I don't see a way for a reducing function to make its return value depend on the result of another callback. On Monday, September 22, 2014 9:45:15 PM UTC+2, Wilker wrote: I understand Leon, but all that only applies on Java world... The issue here is because I depend on async stuff, in Java you always have options to do it sync, you don't need any of those callbacks at all, this is a JS API issue. So in my case I really need the async factor here, I can't avoid it. Given that, would be possible to make transducers async? I think the big deal of transducers is exactly don't having to re-write map, filter, etc... That's why I'm really trying to get then to work on this situation, unless someone knows for sure that its not possible, than I can accept the limitations and keep all my custom versions that can handle async processing... Thanks. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Mon, Sep 22, 2014 at 4:22 PM, Leon Grapenthin grapent...@gmail.com wrote: The steps of your transducer composition are depending on each other. They can only produce a result from an input if they process it synchronously. If you had !! available and would use it as you have described, you would reenforce synchronous input processing: Once you would consume an item, the code would have the exact same blocking characteristics as if the functions were returning values instead of channels. You would have gained nothing for the cost of creating overhead. On Monday, September 22, 2014 1:53:52 AM UTC+2, Wilker wrote: Because it's Node-JS environment, and that can be the same for any async Javascript, you never wanna call sync operations (like sync ajax) because they block everything... I was noticing that is a non-issue at all in Java world, since you can always read blocking into the predicate, for example: (filter (comp !! my-chan-pred)) But in Javascript that's not possible since it can't support read blocking. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Sun, Sep 21, 2014 at 8:50 PM, Leon Grapenthin grapent...@gmail.com wrote: Why would you want the the predicates and readdir to return channels? On Monday, September 22, 2014 12:14:27 AM UTC+2, Wilker wrote: Just an add, I was thinking if we could have something like a deref running during the transducers, in order to enable value unwrapping (that way we could handle channels/values in same fashion). I understand that is complicated maybe because overhead, and also more tricky into JS world were you can't deref a channel into a sync fashion. But the point remains, there is way to seamlessly handle async and sync operations using the same transducers? Or something like it. Best regards. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Sun, Sep 21, 2014 at 7:01 PM, Wilker wilke...@gmail.com wrote: Hi guys, I'm playing with transducers here, and trying out stuff just for fun, there is something that I'm kind stuck on how to approach. I understand the great abstraction that transducers provide over don't carrying about the input source type, but I'm struggling to deal with async operations into my pipeline. For example, I'm working with Node.JS async API's for file system operations, I want to stick with the async versions since I don't wanna block the event loop of Node. So, let's say I have a source with [dir, other] and I wanna create an operation that will simple filter which paths exists, are directories, and then list the `ls` of each remaining entry. So, I first created channel returning functions for the Node operations, I'll not put the code here because I don't think it's really relevant here, just consider that I have them. So, my pipeline would start looking something like this: (comp (filter exists?) (filter is-dir?) (mapcat readdir)) Of course, this doesn't works... Because `exists?`, `is-dir?` and `readdir`, all of them return channels, so the filter would always pass since a channel is always a valid value... The same applies to mapcat, it would try to concat into a channel... This is making me notice some barrier to be able to compose async operations with regular operations. Maybe would be possible to sign somehow operations to make then run async? The only viable option that I've found is with pipeline-async, which accepts an async function, but that doesn't composes with the other operations (map, filter, drop-while...) Is there already a solution to that? Or maybe I'm just doing
Re: transducers and async operations
I understand Leon, but all that only applies on Java world... The issue here is because I depend on async stuff, in Java you always have options to do it sync, you don't need any of those callbacks at all, this is a JS API issue. So in my case I really need the async factor here, I can't avoid it. Given that, would be possible to make transducers async? I think the big deal of transducers is exactly don't having to re-write map, filter, etc... That's why I'm really trying to get then to work on this situation, unless someone knows for sure that its not possible, than I can accept the limitations and keep all my custom versions that can handle async processing... Thanks. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Mon, Sep 22, 2014 at 4:22 PM, Leon Grapenthin grapenthinl...@gmail.com wrote: The steps of your transducer composition are depending on each other. They can only produce a result from an input if they process it synchronously. If you had !! available and would use it as you have described, you would reenforce synchronous input processing: Once you would consume an item, the code would have the exact same blocking characteristics as if the functions were returning values instead of channels. You would have gained nothing for the cost of creating overhead. On Monday, September 22, 2014 1:53:52 AM UTC+2, Wilker wrote: Because it's Node-JS environment, and that can be the same for any async Javascript, you never wanna call sync operations (like sync ajax) because they block everything... I was noticing that is a non-issue at all in Java world, since you can always read blocking into the predicate, for example: (filter (comp !! my-chan-pred)) But in Javascript that's not possible since it can't support read blocking. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Sun, Sep 21, 2014 at 8:50 PM, Leon Grapenthin grapent...@gmail.com wrote: Why would you want the the predicates and readdir to return channels? On Monday, September 22, 2014 12:14:27 AM UTC+2, Wilker wrote: Just an add, I was thinking if we could have something like a deref running during the transducers, in order to enable value unwrapping (that way we could handle channels/values in same fashion). I understand that is complicated maybe because overhead, and also more tricky into JS world were you can't deref a channel into a sync fashion. But the point remains, there is way to seamlessly handle async and sync operations using the same transducers? Or something like it. Best regards. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Sun, Sep 21, 2014 at 7:01 PM, Wilker wilke...@gmail.com wrote: Hi guys, I'm playing with transducers here, and trying out stuff just for fun, there is something that I'm kind stuck on how to approach. I understand the great abstraction that transducers provide over don't carrying about the input source type, but I'm struggling to deal with async operations into my pipeline. For example, I'm working with Node.JS async API's for file system operations, I want to stick with the async versions since I don't wanna block the event loop of Node. So, let's say I have a source with [dir, other] and I wanna create an operation that will simple filter which paths exists, are directories, and then list the `ls` of each remaining entry. So, I first created channel returning functions for the Node operations, I'll not put the code here because I don't think it's really relevant here, just consider that I have them. So, my pipeline would start looking something like this: (comp (filter exists?) (filter is-dir?) (mapcat readdir)) Of course, this doesn't works... Because `exists?`, `is-dir?` and `readdir`, all of them return channels, so the filter would always pass since a channel is always a valid value... The same applies to mapcat, it would try to concat into a channel... This is making me notice some barrier to be able to compose async operations with regular operations. Maybe would be possible to sign somehow operations to make then run async? The only viable option that I've found is with pipeline-async, which accepts an async function, but that doesn't composes with the other operations (map, filter, drop-while...) Is there already a solution to that? Or maybe I'm just doing it wrong and there is a better way to handle those cases? I would love to know how you guys are handling those kind of situations. Thanks. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 -- 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
transducers and async operations
Hi guys, I'm playing with transducers here, and trying out stuff just for fun, there is something that I'm kind stuck on how to approach. I understand the great abstraction that transducers provide over don't carrying about the input source type, but I'm struggling to deal with async operations into my pipeline. For example, I'm working with Node.JS async API's for file system operations, I want to stick with the async versions since I don't wanna block the event loop of Node. So, let's say I have a source with [dir, other] and I wanna create an operation that will simple filter which paths exists, are directories, and then list the `ls` of each remaining entry. So, I first created channel returning functions for the Node operations, I'll not put the code here because I don't think it's really relevant here, just consider that I have them. So, my pipeline would start looking something like this: (comp (filter exists?) (filter is-dir?) (mapcat readdir)) Of course, this doesn't works... Because `exists?`, `is-dir?` and `readdir`, all of them return channels, so the filter would always pass since a channel is always a valid value... The same applies to mapcat, it would try to concat into a channel... This is making me notice some barrier to be able to compose async operations with regular operations. Maybe would be possible to sign somehow operations to make then run async? The only viable option that I've found is with pipeline-async, which accepts an async function, but that doesn't composes with the other operations (map, filter, drop-while...) Is there already a solution to that? Or maybe I'm just doing it wrong and there is a better way to handle those cases? I would love to know how you guys are handling those kind of situations. Thanks. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 -- 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: transducers and async operations
Just an add, I was thinking if we could have something like a deref running during the transducers, in order to enable value unwrapping (that way we could handle channels/values in same fashion). I understand that is complicated maybe because overhead, and also more tricky into JS world were you can't deref a channel into a sync fashion. But the point remains, there is way to seamlessly handle async and sync operations using the same transducers? Or something like it. Best regards. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Sun, Sep 21, 2014 at 7:01 PM, Wilker wilkerlu...@gmail.com wrote: Hi guys, I'm playing with transducers here, and trying out stuff just for fun, there is something that I'm kind stuck on how to approach. I understand the great abstraction that transducers provide over don't carrying about the input source type, but I'm struggling to deal with async operations into my pipeline. For example, I'm working with Node.JS async API's for file system operations, I want to stick with the async versions since I don't wanna block the event loop of Node. So, let's say I have a source with [dir, other] and I wanna create an operation that will simple filter which paths exists, are directories, and then list the `ls` of each remaining entry. So, I first created channel returning functions for the Node operations, I'll not put the code here because I don't think it's really relevant here, just consider that I have them. So, my pipeline would start looking something like this: (comp (filter exists?) (filter is-dir?) (mapcat readdir)) Of course, this doesn't works... Because `exists?`, `is-dir?` and `readdir`, all of them return channels, so the filter would always pass since a channel is always a valid value... The same applies to mapcat, it would try to concat into a channel... This is making me notice some barrier to be able to compose async operations with regular operations. Maybe would be possible to sign somehow operations to make then run async? The only viable option that I've found is with pipeline-async, which accepts an async function, but that doesn't composes with the other operations (map, filter, drop-while...) Is there already a solution to that? Or maybe I'm just doing it wrong and there is a better way to handle those cases? I would love to know how you guys are handling those kind of situations. Thanks. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 -- 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: transducers and async operations
Because it's Node-JS environment, and that can be the same for any async Javascript, you never wanna call sync operations (like sync ajax) because they block everything... I was noticing that is a non-issue at all in Java world, since you can always read blocking into the predicate, for example: (filter (comp !! my-chan-pred)) But in Javascript that's not possible since it can't support read blocking. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Sun, Sep 21, 2014 at 8:50 PM, Leon Grapenthin grapenthinl...@gmail.com wrote: Why would you want the the predicates and readdir to return channels? On Monday, September 22, 2014 12:14:27 AM UTC+2, Wilker wrote: Just an add, I was thinking if we could have something like a deref running during the transducers, in order to enable value unwrapping (that way we could handle channels/values in same fashion). I understand that is complicated maybe because overhead, and also more tricky into JS world were you can't deref a channel into a sync fashion. But the point remains, there is way to seamlessly handle async and sync operations using the same transducers? Or something like it. Best regards. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Sun, Sep 21, 2014 at 7:01 PM, Wilker wilke...@gmail.com wrote: Hi guys, I'm playing with transducers here, and trying out stuff just for fun, there is something that I'm kind stuck on how to approach. I understand the great abstraction that transducers provide over don't carrying about the input source type, but I'm struggling to deal with async operations into my pipeline. For example, I'm working with Node.JS async API's for file system operations, I want to stick with the async versions since I don't wanna block the event loop of Node. So, let's say I have a source with [dir, other] and I wanna create an operation that will simple filter which paths exists, are directories, and then list the `ls` of each remaining entry. So, I first created channel returning functions for the Node operations, I'll not put the code here because I don't think it's really relevant here, just consider that I have them. So, my pipeline would start looking something like this: (comp (filter exists?) (filter is-dir?) (mapcat readdir)) Of course, this doesn't works... Because `exists?`, `is-dir?` and `readdir`, all of them return channels, so the filter would always pass since a channel is always a valid value... The same applies to mapcat, it would try to concat into a channel... This is making me notice some barrier to be able to compose async operations with regular operations. Maybe would be possible to sign somehow operations to make then run async? The only viable option that I've found is with pipeline-async, which accepts an async function, but that doesn't composes with the other operations (map, filter, drop-while...) Is there already a solution to that? Or maybe I'm just doing it wrong and there is a better way to handle those cases? I would love to know how you guys are handling those kind of situations. Thanks. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 -- 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: transducers and async operations
More on my playing around here, I was trying to implement async versions for the transducers, for example: (defn filter-async [pred] (fn [f1] (fn ([] (f1)) ([result] (f1 result)) ([result input] (if (!! (pred input)) (f1 result input) result) This works fine, but doesn't gives me anything new (since I could use the (comp !! pred)), so, trying to convert the previous code into: (defn filter-async [pred] (fn [f1] (fn ([] (f1)) ([result] (f1 result)) ([result input] (go (if (! (pred input)) (f1 result input) result)) This code would solve my issue, if it worked, but it doesn't (and I really don't understand why not...). But that gives this feeling of having to have extra implementations, which feels backwards of what transducers are trying to accomplish... I don't really have a solution here, that's why I would like to know if other people have got into this situation, and how you are handling it. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Sun, Sep 21, 2014 at 8:53 PM, Wilker wilkerlu...@gmail.com wrote: Because it's Node-JS environment, and that can be the same for any async Javascript, you never wanna call sync operations (like sync ajax) because they block everything... I was noticing that is a non-issue at all in Java world, since you can always read blocking into the predicate, for example: (filter (comp !! my-chan-pred)) But in Javascript that's not possible since it can't support read blocking. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Sun, Sep 21, 2014 at 8:50 PM, Leon Grapenthin grapenthinl...@gmail.com wrote: Why would you want the the predicates and readdir to return channels? On Monday, September 22, 2014 12:14:27 AM UTC+2, Wilker wrote: Just an add, I was thinking if we could have something like a deref running during the transducers, in order to enable value unwrapping (that way we could handle channels/values in same fashion). I understand that is complicated maybe because overhead, and also more tricky into JS world were you can't deref a channel into a sync fashion. But the point remains, there is way to seamlessly handle async and sync operations using the same transducers? Or something like it. Best regards. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Sun, Sep 21, 2014 at 7:01 PM, Wilker wilke...@gmail.com wrote: Hi guys, I'm playing with transducers here, and trying out stuff just for fun, there is something that I'm kind stuck on how to approach. I understand the great abstraction that transducers provide over don't carrying about the input source type, but I'm struggling to deal with async operations into my pipeline. For example, I'm working with Node.JS async API's for file system operations, I want to stick with the async versions since I don't wanna block the event loop of Node. So, let's say I have a source with [dir, other] and I wanna create an operation that will simple filter which paths exists, are directories, and then list the `ls` of each remaining entry. So, I first created channel returning functions for the Node operations, I'll not put the code here because I don't think it's really relevant here, just consider that I have them. So, my pipeline would start looking something like this: (comp (filter exists?) (filter is-dir?) (mapcat readdir)) Of course, this doesn't works... Because `exists?`, `is-dir?` and `readdir`, all of them return channels, so the filter would always pass since a channel is always a valid value... The same applies to mapcat, it would try to concat into a channel... This is making me notice some barrier to be able to compose async operations with regular operations. Maybe would be possible to sign somehow operations to make then run async? The only viable option that I've found is with pipeline-async, which accepts an async function, but that doesn't composes with the other operations (map, filter, drop-while...) Is there already a solution to that? Or maybe I'm just doing it wrong and there is a better way to handle those cases? I would love to know how you guys are handling those kind of situations. Thanks. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 -- 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
Re: transducers and async operations
On Sun, Sep 21, 2014 at 10:08 PM, Sean Corfield s...@corfield.org wrote: Hi Sean, Sorry, I don't really understood your suggestion... But let me try to make myself more clear of what I'm trying to accomplish: First let me say that I have a more Javascript background than Java, and my issue is more into ClojureScript world Javascript has a lot of async issues, specially when you are working on Node.JS world, every IO operation is async, although they have sync versions those versions block the world so I need to keep away from then, so, async callbacks is my only real options here. The first thing that I like to do in my async code is to wrap than into something that I can handle generically, in JS I used to do a lot of promises code, but now I'm core async, so I think making then single channel value just fits nice, and wrapping that way I can compose very well. Now I'm at this place, I have all those async functions that I wanna use to process my data, I wanna use those async functions, also regular functions. Before transducers, I've used the David Nolen's reactive helpers (on his blog source) to do my data processing using those channels, a good example on how I used to manage complex async pipelines are like this: (- (scan-path root/path) ; this will produce a channel that will output every file/dir path recursive from given path (r/filter-async is-file?) ; this requires async call to filter (f/filter (match-extension? #{avi mpg})) ; this will just check on the name, no async required (r/map-async read-hash-info) ; another async call, will generate a hash info from the path (r/map #(hash-map :hash %)) ; build a map from the value ) So, I like how the previous code is build, because I can really just composed from my simple sync and async functions, but all these use custom transducers you can say... Then comes Transducers that can rise the bar on the abstraction level, so I now can get rid of all those custom transducers, right? So, it just would be nice if I could get the same clean way to build my pipeline like I did before, but with transducers. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 -- 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: transducers and async operations
Hi, I did some progress here, I was able to manage to create a custom filter transducer that works seamlessly with regular values and channels and can be composed with other transducers: ; on JVM I did this using protocols, but in ClojureScript I could not make it work (some error when I tried to extend the ReadPort type), but this works as same (defn -expand [v f] (if (satisfies? cljs.core.async.impl.protocols/ReadPort v) (take! v f) (f v))) ; my filter transducer that supports async operations (defn filter-ext [pred] (fn [f1] (fn ([] (f1)) ([result] (f1 result)) ([result input] (-expand (pred input); here is the trick, so in this case I made every operation dependent on a callback, so they can be normalized (fn [v] (if v (f1 result input) result))) (let [value-chan (fn [v] (let [c (chan 1)] ; simple helper to simulate an async operation that just returns the input (put! c v) (close! c) c)) xform (comp (filter-ext value-chan) ; ok, filter async (filter-ext #(= % 2))) ; now filter sync c (chan 1 xform)] (async/onto-chan c [1 false 2 3]) (go (println (! (async/into [] c) ; prints: [2 3] I could have my extended versions of every transducer to add the support, the code is pretty much the same but has the extra step of checking for the returned value on the operation. Not sure how that could ever be integrated into regular transducers (maybe they could be extended somehow to include this feature selectively to avoid the overhead), but for now this is the best that I could came up with. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Sun, Sep 21, 2014 at 10:39 PM, Wilker wilkerlu...@gmail.com wrote: On Sun, Sep 21, 2014 at 10:08 PM, Sean Corfield s...@corfield.org wrote: Hi Sean, Sorry, I don't really understood your suggestion... But let me try to make myself more clear of what I'm trying to accomplish: First let me say that I have a more Javascript background than Java, and my issue is more into ClojureScript world Javascript has a lot of async issues, specially when you are working on Node.JS world, every IO operation is async, although they have sync versions those versions block the world so I need to keep away from then, so, async callbacks is my only real options here. The first thing that I like to do in my async code is to wrap than into something that I can handle generically, in JS I used to do a lot of promises code, but now I'm core async, so I think making then single channel value just fits nice, and wrapping that way I can compose very well. Now I'm at this place, I have all those async functions that I wanna use to process my data, I wanna use those async functions, also regular functions. Before transducers, I've used the David Nolen's reactive helpers (on his blog source) to do my data processing using those channels, a good example on how I used to manage complex async pipelines are like this: (- (scan-path root/path) ; this will produce a channel that will output every file/dir path recursive from given path (r/filter-async is-file?) ; this requires async call to filter (f/filter (match-extension? #{avi mpg})) ; this will just check on the name, no async required (r/map-async read-hash-info) ; another async call, will generate a hash info from the path (r/map #(hash-map :hash %)) ; build a map from the value ) So, I like how the previous code is build, because I can really just composed from my simple sync and async functions, but all these use custom transducers you can say... Then comes Transducers that can rise the bar on the abstraction level, so I now can get rid of all those custom transducers, right? So, it just would be nice if I could get the same clean way to build my pipeline like I did before, but with transducers. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 -- 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: transducers and async operations
Ok, I think a got into a reasonable solution :) The code first: (defn -expand [v f] (if (satisfies? cljs.core.async.impl.protocols/ReadPort v) (take! v f) (f v))) (defn async [t f args] (fn [f1] (fn ([] (f1)) ([result] (f1 result)) ([result input] (-expand (f input) (fn [v] (((apply t (cons identity args)) f1) result v))) (let [value-chan (fn [v] (let [c (chan 1)] ; simple helper to simulate an async operation that just returns the input (put! c v) (close! c) c)) xform (comp (async map value-chan) ; using async! (async filter value-chan) ; same thing with filter ) c (chan 1 xform)] (async/onto-chan c [1 false 2 3]) (go (println (! (async/into [] c) ; [1 2 3] Ok, what I did was create a transducer wrapper that relies into the wrapped transducer to take a function as the first argument (that's usually the function that needs the expanded value) and makes the proper calls for it. It worked great for the most transducers that I needed here, so, I consider a solution to my issue :) Hope it can help others that may got into similar issue. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Sun, Sep 21, 2014 at 11:29 PM, Wilker wilkerlu...@gmail.com wrote: Hi, I did some progress here, I was able to manage to create a custom filter transducer that works seamlessly with regular values and channels and can be composed with other transducers: ; on JVM I did this using protocols, but in ClojureScript I could not make it work (some error when I tried to extend the ReadPort type), but this works as same (defn -expand [v f] (if (satisfies? cljs.core.async.impl.protocols/ReadPort v) (take! v f) (f v))) ; my filter transducer that supports async operations (defn filter-ext [pred] (fn [f1] (fn ([] (f1)) ([result] (f1 result)) ([result input] (-expand (pred input); here is the trick, so in this case I made every operation dependent on a callback, so they can be normalized (fn [v] (if v (f1 result input) result))) (let [value-chan (fn [v] (let [c (chan 1)] ; simple helper to simulate an async operation that just returns the input (put! c v) (close! c) c)) xform (comp (filter-ext value-chan) ; ok, filter async (filter-ext #(= % 2))) ; now filter sync c (chan 1 xform)] (async/onto-chan c [1 false 2 3]) (go (println (! (async/into [] c) ; prints: [2 3] I could have my extended versions of every transducer to add the support, the code is pretty much the same but has the extra step of checking for the returned value on the operation. Not sure how that could ever be integrated into regular transducers (maybe they could be extended somehow to include this feature selectively to avoid the overhead), but for now this is the best that I could came up with. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Sun, Sep 21, 2014 at 10:39 PM, Wilker wilkerlu...@gmail.com wrote: On Sun, Sep 21, 2014 at 10:08 PM, Sean Corfield s...@corfield.org wrote: Hi Sean, Sorry, I don't really understood your suggestion... But let me try to make myself more clear of what I'm trying to accomplish: First let me say that I have a more Javascript background than Java, and my issue is more into ClojureScript world Javascript has a lot of async issues, specially when you are working on Node.JS world, every IO operation is async, although they have sync versions those versions block the world so I need to keep away from then, so, async callbacks is my only real options here. The first thing that I like to do in my async code is to wrap than into something that I can handle generically, in JS I used to do a lot of promises code, but now I'm core async, so I think making then single channel value just fits nice, and wrapping that way I can compose very well. Now I'm at this place, I have all those async functions that I wanna use to process my data, I wanna use those async functions, also regular functions. Before transducers, I've used the David Nolen's reactive helpers (on his blog source) to do my data processing using those channels, a good example on how I used to manage complex async pipelines are like this: (- (scan-path root/path) ; this will produce a channel that will output every file/dir path recursive from given path (r/filter-async is-file?) ; this requires async call to filter (f/filter (match-extension? #{avi mpg})) ; this will just check on the name, no async required (r/map-async read-hash-info
Re: transducers and async operations
Humm... actually, I was happy too soon... Ends up this following example doesn't work: (let [value-chan (fn [v] (let [c (chan 1)] ; simple helper to simulate an async operation that just returns the input (go (! c v) (close! c)) c)) xform (comp (async filter value-chan) ; can be used ) ; now filter sync c (chan 1 xform)] (async/onto-chan c [1 false 2 3]) (go (println (! (async/into [] c) ; got an empty list instead of [1 2 3] It seems that it only works if the channel had the value before the transducer call the `take!`, seems that unless it has the value immediately available, it doesn't works... --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Mon, Sep 22, 2014 at 12:00 AM, Wilker wilkerlu...@gmail.com wrote: Ok, I think a got into a reasonable solution :) The code first: (defn -expand [v f] (if (satisfies? cljs.core.async.impl.protocols/ReadPort v) (take! v f) (f v))) (defn async [t f args] (fn [f1] (fn ([] (f1)) ([result] (f1 result)) ([result input] (-expand (f input) (fn [v] (((apply t (cons identity args)) f1) result v))) (let [value-chan (fn [v] (let [c (chan 1)] ; simple helper to simulate an async operation that just returns the input (put! c v) (close! c) c)) xform (comp (async map value-chan) ; using async! (async filter value-chan) ; same thing with filter ) c (chan 1 xform)] (async/onto-chan c [1 false 2 3]) (go (println (! (async/into [] c) ; [1 2 3] Ok, what I did was create a transducer wrapper that relies into the wrapped transducer to take a function as the first argument (that's usually the function that needs the expanded value) and makes the proper calls for it. It worked great for the most transducers that I needed here, so, I consider a solution to my issue :) Hope it can help others that may got into similar issue. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Sun, Sep 21, 2014 at 11:29 PM, Wilker wilkerlu...@gmail.com wrote: Hi, I did some progress here, I was able to manage to create a custom filter transducer that works seamlessly with regular values and channels and can be composed with other transducers: ; on JVM I did this using protocols, but in ClojureScript I could not make it work (some error when I tried to extend the ReadPort type), but this works as same (defn -expand [v f] (if (satisfies? cljs.core.async.impl.protocols/ReadPort v) (take! v f) (f v))) ; my filter transducer that supports async operations (defn filter-ext [pred] (fn [f1] (fn ([] (f1)) ([result] (f1 result)) ([result input] (-expand (pred input); here is the trick, so in this case I made every operation dependent on a callback, so they can be normalized (fn [v] (if v (f1 result input) result))) (let [value-chan (fn [v] (let [c (chan 1)] ; simple helper to simulate an async operation that just returns the input (put! c v) (close! c) c)) xform (comp (filter-ext value-chan) ; ok, filter async (filter-ext #(= % 2))) ; now filter sync c (chan 1 xform)] (async/onto-chan c [1 false 2 3]) (go (println (! (async/into [] c) ; prints: [2 3] I could have my extended versions of every transducer to add the support, the code is pretty much the same but has the extra step of checking for the returned value on the operation. Not sure how that could ever be integrated into regular transducers (maybe they could be extended somehow to include this feature selectively to avoid the overhead), but for now this is the best that I could came up with. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Sun, Sep 21, 2014 at 10:39 PM, Wilker wilkerlu...@gmail.com wrote: On Sun, Sep 21, 2014 at 10:08 PM, Sean Corfield s...@corfield.org wrote: Hi Sean, Sorry, I don't really understood your suggestion... But let me try to make myself more clear of what I'm trying to accomplish: First let me say that I have a more Javascript background than Java, and my issue is more into ClojureScript world Javascript has a lot of async issues, specially when you are working on Node.JS world, every IO operation is async, although they have sync versions those versions block the world so I need to keep away from then, so, async callbacks is my only real options here. The first thing
Re: ANN: ClojureScript 0.0-2341, Improved Analysis Transducers
Thank you for the release. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Fri, Sep 19, 2014 at 12:49 PM, Alan Dipert a...@dipert.org wrote: Here is a bookmarklet that turns /CLJS-\d+/ text into link: https://dl.dropboxusercontent.com/u/12379861/cljsjira.html Thanks for the release! Especially CLJS-855 :-) Alan On Thursday, September 18, 2014 9:46:42 PM UTC-4, bob wrote: It would be better that the jira issues have links. On Thursday, September 18, 2014 8:23:45 PM UTC+8, David Nolen wrote:ClojureScript, the Clojure compiler that emits JavaScript source code. README and source code: https://github.com/clojure/clojurescript New release version: 0.0-2341 Leiningen dependency information: [org.clojure/clojurescript 0.0-2341] This releases comes with considerably better analysis. Vars from other namespaces are finally also verified. Protocols previously saw very little analysis support. Protocol method implementations are now checked for validity against the declared protocol. Transducers are also now in sync with Clojure 1.7.0-alpha2 Feedback welcome! ### Enhancements * transducers ### Fixes * CLJS-704: warn if protocol extended to type multiple times in extend-type * CLJS-702: warn if protocol doesn't match declared * CLJS-859: use https for the bootstrap script * CLJS-855: combinatorial code generation under advanced * CLJS-858: resolve-existing var does not check vars outside current ns * CLJS-852: same group-by as Clojure * CLJS-847: Safari toString fix * CLJS-846: preserve namespace metadata -- 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] Clojure Videos (with options for Linux users)
Nice, started watching yesterday, they are awesome. Thank you very much. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Fri, Sep 19, 2014 at 3:49 AM, Gomzee gettingerr...@gmail.com wrote: I tried to open this link (https://tbaldridge.pivotshare.com). Its not working. Can you check and let me know. On Friday, September 19, 2014 6:21:46 AM UTC+5:30, tbc++ wrote: Just wanted to throw this out there, but I've been making steady progress on my Clojure Tutorial Videos (https://tbaldridge.pivotshare.com). We're up to 43 videos with new episodes added at a rate of about 2-3 a week. Some users have expressed a desire for the raw MP4 files for use on Linux, or other platforms where flash is not optimal, so I'm also happy to announce that the videos are available via Dropbox. There's a link on the site, the price is the same, but the process is manual so there is a processing delay of 1-2 days. Thanks to everyone who's offered encouragement and feedback. And yes...transducer videos will be up *soon*. They're recorded, but you should really start by watching the video of Rich's Strange Loop talk, that he'll be giving tomorrow. /sameless ad -- 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] www.core-async.info: a new web resource for core.async
One suggestion, on the menus, like on this page: http://www.core-async.info/reference Set the cursor for pointer on those root menu elements, so the users know that it's supposed to be clickable, I took a few to realize because of the missing pointer arrow, hehe. Also, I find it a kind hard to navigate, on the first page you have to go all the way on a small link to continue to the next step, would be nice to have a general full index (like a book) and consistent buttons to navigate back/forward. Besides that, nice job, thanks for taking the effort to make it :) --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Thu, Sep 18, 2014 at 5:22 PM, Daniel Solano Gómez cloj...@sattvik.com wrote: On Thu Sep 18 12:14 2014, Ashton Kemerling wrote: That looks really nice! My only feedback is that it doesn't load at all on my iPhone. Thanks for the information. I haven't yet taken the time to make it entirely mobile-friendly, but it is however on my list of things to do. Sincerely, Daniel On Thu, Sep 18, 2014 at 1:01 PM, Daniel Solano Gómez cloj...@sattvik.com wrote: Hello, all, Over the past few months I have been working on creating some resources to help people learn to use core.async. My goal is make this the best resource available to help people get started with core.async and to document best practices for composing applications with core.async. It is still a work in progress, but it currently includes the following: 1. An introduction to channels, buffers, and basic channel operations 2. A tutorial/workshop that introduces core.async using both Clojure and ClojureScript 3. A reference section of the core.async API, including both the Clojure and ClojureScript sources Please check it out at www.core-async.info. I will continue to add more reference and tutorial material in the future. Please let me know if there is anything you would think would be useful to add. Thanks, Daniel -- 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. -- 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: Rich Hickey's Transducers talk from Strange Loop
Awesome! Thank you very much! --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Fri, Sep 19, 2014 at 5:33 PM, Bruce Durling b...@otfrom.com wrote: Alex, Thanks for getting the videos up so quickly! cheers, Bruce On Fri, Sep 19, 2014 at 9:31 PM, Alex Miller a...@puredanger.com wrote: For your enjoyment... https://www.youtube.com/watch?v=6mTbuzafcII -- 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. -- @otfrom | CTO co-founder @MastodonC | mastodonc.com See recent coverage of us in the Economist http://econ.st/WeTd2i and the Financial Times http://on.ft.com/T154BA -- 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: jetty restart failing
Nice tricks, thanks again :) --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Tue, Sep 16, 2014 at 7:51 PM, James Reeves ja...@booleanknot.com wrote: On 16 September 2014 17:06, Herwig Hochleitner hhochleit...@gmail.com wrote: 2014-09-16 17:28 GMT+02:00 James Reeves ja...@booleanknot.com: On 16 September 2014 10:13, Herwig Hochleitner hhochleit...@gmail.com wrote: The thing I do on startup: (doseq [l (.getConnectors jetty)] (.getLocalPort l)), is my solution to wait until it's come fully up. Why would this work? As far as I'm aware, both .getConnectors and .getLocalPort are unblocking. IIRC, .getLocalPort blocks in jetty9, until the port has been opened. Please excuse me for not reverifying it just now, but I'm quite sure that adding .getLocalPort solved the race condition in my test suite. Ah, they might have changed it since Jetty 7. - 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. -- 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.
it's possible to query for optional parts on many relations?
Hi I'm trying to figure if I can make some parts of my query results to be optional, for example, given the following query: [:find ?name ?age :where [?m :person/name ?name] [?m :person/age ?age]] This will return all entities that has a :person/name and :person/age. Ok, so, if I want to make the name mandatory and the age optional, I can do: [:find ?name ?age :in $ :where [?m :person/name ?name] [(get-else $ ?m :person/age 0) ?age]] Ok, so, for single values that works great, but what about this: [:find ?m ?name (vec ?url) :in $ :where [?m :person/name ?name] [?m :photos ?p] [?p :file/url ?url]] On the previous query, it fetch every person that has at least 1 photo, but not those that has no photos. How do I make to the query to return all entities that has name, having photos or not (ideally the value would be a blank list for those without photos)? Best regards. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 -- 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: it's possible to query for optional parts on many relations?
Forgot to mention, I tried the (get-else) but it raises an error about cardinality many not supported, so I guessed it doesn't works here... --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Thu, Sep 18, 2014 at 7:41 PM, Wilker wilkerlu...@gmail.com wrote: Hi I'm trying to figure if I can make some parts of my query results to be optional, for example, given the following query: [:find ?name ?age :where [?m :person/name ?name] [?m :person/age ?age]] This will return all entities that has a :person/name and :person/age. Ok, so, if I want to make the name mandatory and the age optional, I can do: [:find ?name ?age :in $ :where [?m :person/name ?name] [(get-else $ ?m :person/age 0) ?age]] Ok, so, for single values that works great, but what about this: [:find ?m ?name (vec ?url) :in $ :where [?m :person/name ?name] [?m :photos ?p] [?p :file/url ?url]] On the previous query, it fetch every person that has at least 1 photo, but not those that has no photos. How do I make to the query to return all entities that has name, having photos or not (ideally the value would be a blank list for those without photos)? Best regards. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 -- 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: it's possible to query for optional parts on many relations?
Yes I could, but I'm trying to stick on the philosophy of define your data at query time, so I would like to move all query stuff to Datomic, also, even if I don't use, I still would like to know if that's possible, I'm still very noob to Datomic and so trying stuff around. But considering all kinds of complex stuff that Datomic support, I would be surprise if that wasn't possible to do at query time... So, what I do in my queries is just fetch all fields and name then by position, it's very flexible as long as I'm able to shape my data at query time, so, if there is a way to do it, I would love to know. Thanks. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Thu, Sep 18, 2014 at 7:48 PM, Ashton Kemerling ashtonkemerl...@gmail.com wrote: Couldn't you just retrieve users and use entity to get their photos? On Thu, Sep 18, 2014 at 4:43 PM, Wilker wilkerlu...@gmail.com wrote: Forgot to mention, I tried the (get-else) but it raises an error about cardinality many not supported, so I guessed it doesn't works here... --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Thu, Sep 18, 2014 at 7:41 PM, Wilker wilkerlu...@gmail.com wrote: Hi I'm trying to figure if I can make some parts of my query results to be optional, for example, given the following query: [:find ?name ?age :where [?m :person/name ?name] [?m :person/age ?age]] This will return all entities that has a :person/name and :person/age. Ok, so, if I want to make the name mandatory and the age optional, I can do: [:find ?name ?age :in $ :where [?m :person/name ?name] [(get-else $ ?m :person/age 0) ?age]] Ok, so, for single values that works great, but what about this: [:find ?m ?name (vec ?url) :in $ :where [?m :person/name ?name] [?m :photos ?p] [?p :file/url ?url]] On the previous query, it fetch every person that has at least 1 photo, but not those that has no photos. How do I make to the query to return all entities that has name, having photos or not (ideally the value would be a blank list for those without photos)? Best regards. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 -- 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 Datomic group. To unsubscribe from this group and stop receiving emails from it, send an email to datomic+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: jetty restart failing
Thank you very much Herwig! The (.join jetty) did the trick :D --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Mon, Sep 15, 2014 at 8:50 PM, Herwig Hochleitner hhochleit...@gmail.com wrote: Feel free to steal from my jetty component: https://github.com/webnf/webnf/blob/master/server/src/clj/webnf/server/component.clj 2014-09-15 10:42 GMT+02:00 Sven Richter sver...@googlemail.com: Am Montag, 15. September 2014 00:20:21 UTC+2 schrieb Wilker: I felt that was too much for me, but I'm digging into his source codes to learn more, and he seems to do a more robust way to shut down the server: https://github.com/juxt/modular/blob/master/ modules/netty/src/modular/netty.clj This looks interesting. I just had a look into the jetty ring adapter source code and did not find a decidated stop method. Maybe it's time for a feature request? His version seems to work, but it's for Netty... I'm actually starting to consider switch to Netty just because of that. Yea, not being able to restart without having to load up the jvm again and again is really a time stealer. I am curious, why don't you use http-kit? Or why did you decide for jetty / netty? What I think is weird about that, is that if that was the case, a new (start) should work after a few seconds, but it doesn't... Jetty seems to hang on an never closes... For that my guess is that some pending operation is going on preventing it from shutting down at all... A fix could be a way to force Jetty to close and wait until it's actually closed. Maybe it's also an idea to look into the actual jetty source code and find out how they do stop the server, maybe there is a way to call that code from clojure and see what's going on there. Best Regards, Sven Thanks for the help. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Sun, Sep 14, 2014 at 6:29 PM, Sven Richter sve...@googlemail.com wrote: Hi Wilker, I have been going the same way and never really found out why this happens (I am using http-kit instead of jetty). However, one thing that I did not knew was that a refresh will delete references of vars. So if you keep your stop function somewhere and call refresh before the stop function you will not be able to stop jetty anymore and hence, when you try to start it, it is already running. I implemented my own component library, having the same problems, especially when I was using a lot of protocols / records (may have been just a coincidence) and finally found about the hara.component library. I am using this one now and seem to have less problems. But, to be honest, I cannot believe that stuarts component library is the problem, but my way of using it or coding. Of course I'd be interested too to hear other opinions. Best Regards, Sven Am Sonntag, 14. September 2014 01:32:44 UTC+2 schrieb Wilker: I forgot to post before, here is the actual error: BindException Address already in use sun.nio.ch.Net.bind0 (Net.java:-2) Also, adding a (Thread/sleep 1000) seems to increase the success rate, but would be nice to be able to really wait on Jetty to shutdown instead of using arbitrary sleep. Thanks. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Sat, Sep 13, 2014 at 8:20 PM, Wilker wilke...@gmail.com wrote: Hi, I'm trying to apply the ideas from the component library: https://github.com/stuartsierra/component My problems is being about stop/start the Jetty server, for that purpose I created this component: (defrecord WebServer [app port join? jetty log] component/Lifecycle (start [c] (log Starting jetty server...) (let [jetty (jetty/run-jetty (:handler app) {:port port :join? join?})] (log Server started at port port) (assoc c :jetty jetty))) (stop [c] (when (:jetty c) (log Stopping jetty...) (.stop (:jetty c)) (log Server stopped.)) (assoc c :jetty nil))) (defn webserver-component ([port] (webserver-component port true)) ([port join?] (map-WebServer {:port port :join? join?}))) It works, sometimes, but often I get this when I try to reset: Error starting #ExceptionInfo clojure.lang.ExceptionInfo: Error in component :server in system com.stuartsierra.component.SystemMap calling #'com.stuartsierra.component/start {:reason :com.stuartsierra.component/component-function-threw-exception, :function #'com.stuartsierra.component/start, :system-key :server, :component #cadegp.components.web_server.WebServer{:app #cadegp.components.web_app.CadegpApp{:conn #cadegp.components.database.Database{:uri datomic:free://localhost:4334/cadegp, :connection #Connection {:db-id cadegp-48d87324-7849-4255-b798-865b02ee9d9d, :index-rev 0, :basis-t 1176, :next-t 1177, :unsent-updates-queue 0, :pending-txes 0}}, :handler #reload$wrap_reload$fn__1728
Re: jetty restart failing
Thanks for the info Sven. I also found out something, after watching this presentation: https://vimeo.com/100977463 I felt that was too much for me, but I'm digging into his source codes to learn more, and he seems to do a more robust way to shut down the server: https://github.com/juxt/modular/blob/master/modules/netty/src/modular/netty.clj His version seems to work, but it's for Netty... I'm actually starting to consider switch to Netty just because of that. Like you, I don't think it's the component library issue either, I guess the issue is that `close` from Jetty closes the connection in another thread, so it returns before the server is actually closed, making it an issue to trying to restart right way (since the port is already being used...). What I think is weird about that, is that if that was the case, a new (start) should work after a few seconds, but it doesn't... Jetty seems to hang on an never closes... For that my guess is that some pending operation is going on preventing it from shutting down at all... A fix could be a way to force Jetty to close and wait until it's actually closed. Thanks for the help. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Sun, Sep 14, 2014 at 6:29 PM, Sven Richter sver...@googlemail.com wrote: Hi Wilker, I have been going the same way and never really found out why this happens (I am using http-kit instead of jetty). However, one thing that I did not knew was that a refresh will delete references of vars. So if you keep your stop function somewhere and call refresh before the stop function you will not be able to stop jetty anymore and hence, when you try to start it, it is already running. I implemented my own component library, having the same problems, especially when I was using a lot of protocols / records (may have been just a coincidence) and finally found about the hara.component library. I am using this one now and seem to have less problems. But, to be honest, I cannot believe that stuarts component library is the problem, but my way of using it or coding. Of course I'd be interested too to hear other opinions. Best Regards, Sven Am Sonntag, 14. September 2014 01:32:44 UTC+2 schrieb Wilker: I forgot to post before, here is the actual error: BindException Address already in use sun.nio.ch.Net.bind0 (Net.java:-2) Also, adding a (Thread/sleep 1000) seems to increase the success rate, but would be nice to be able to really wait on Jetty to shutdown instead of using arbitrary sleep. Thanks. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Sat, Sep 13, 2014 at 8:20 PM, Wilker wilke...@gmail.com wrote: Hi, I'm trying to apply the ideas from the component library: https://github.com/stuartsierra/component My problems is being about stop/start the Jetty server, for that purpose I created this component: (defrecord WebServer [app port join? jetty log] component/Lifecycle (start [c] (log Starting jetty server...) (let [jetty (jetty/run-jetty (:handler app) {:port port :join? join?})] (log Server started at port port) (assoc c :jetty jetty))) (stop [c] (when (:jetty c) (log Stopping jetty...) (.stop (:jetty c)) (log Server stopped.)) (assoc c :jetty nil))) (defn webserver-component ([port] (webserver-component port true)) ([port join?] (map-WebServer {:port port :join? join?}))) It works, sometimes, but often I get this when I try to reset: Error starting #ExceptionInfo clojure.lang.ExceptionInfo: Error in component :server in system com.stuartsierra.component.SystemMap calling #'com.stuartsierra.component/start {:reason :com.stuartsierra.component/component-function-threw-exception, :function #'com.stuartsierra.component/start, :system-key :server, :component #cadegp.components.web_server.WebServer{:app #cadegp.components.web_app.CadegpApp{:conn #cadegp.components.database.Database{:uri datomic:free://localhost:4334/cadegp, :connection #Connection {:db-id cadegp-48d87324-7849-4255-b798-865b02ee9d9d, :index-rev 0, :basis-t 1176, :next-t 1177, :unsent-updates-queue 0, :pending-txes 0}}, :handler #reload$wrap_reload$fn__1728 ring.middleware.reload$wrap_ reload$fn__1728@6608b223, :handler-ext #user$wrap_dev_handler user$wrap_dev_handler@7e174cba}, :port 8000, :join? false, :jetty nil, :log #core$println clojure.core$println@7a2c3090}, :system #SystemMap} Seems that it tries to start the server before it have time to shut it down. Any of you had a similar issue or know how to work around that? Thanks. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 -- 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
jetty restart failing
Hi, I'm trying to apply the ideas from the component library: https://github.com/stuartsierra/component My problems is being about stop/start the Jetty server, for that purpose I created this component: (defrecord WebServer [app port join? jetty log] component/Lifecycle (start [c] (log Starting jetty server...) (let [jetty (jetty/run-jetty (:handler app) {:port port :join? join?})] (log Server started at port port) (assoc c :jetty jetty))) (stop [c] (when (:jetty c) (log Stopping jetty...) (.stop (:jetty c)) (log Server stopped.)) (assoc c :jetty nil))) (defn webserver-component ([port] (webserver-component port true)) ([port join?] (map-WebServer {:port port :join? join?}))) It works, sometimes, but often I get this when I try to reset: Error starting #ExceptionInfo clojure.lang.ExceptionInfo: Error in component :server in system com.stuartsierra.component.SystemMap calling #'com.stuartsierra.component/start {:reason :com.stuartsierra.component/component-function-threw-exception, :function #'com.stuartsierra.component/start, :system-key :server, :component #cadegp.components.web_server.WebServer{:app #cadegp.components.web_app.CadegpApp{:conn #cadegp.components.database.Database{:uri datomic:free://localhost:4334/cadegp, :connection #Connection {:db-id cadegp-48d87324-7849-4255-b798-865b02ee9d9d, :index-rev 0, :basis-t 1176, :next-t 1177, :unsent-updates-queue 0, :pending-txes 0}}, :handler #reload$wrap_reload$fn__1728 ring.middleware.reload$wrap_reload$fn__1728@6608b223, :handler-ext #user$wrap_dev_handler user$wrap_dev_handler@7e174cba}, :port 8000, :join? false, :jetty nil, :log #core$println clojure.core$println@7a2c3090}, :system #SystemMap} Seems that it tries to start the server before it have time to shut it down. Any of you had a similar issue or know how to work around that? Thanks. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 -- 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: jetty restart failing
I forgot to post before, here is the actual error: BindException Address already in use sun.nio.ch.Net.bind0 (Net.java:-2) Also, adding a (Thread/sleep 1000) seems to increase the success rate, but would be nice to be able to really wait on Jetty to shutdown instead of using arbitrary sleep. Thanks. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Sat, Sep 13, 2014 at 8:20 PM, Wilker wilkerlu...@gmail.com wrote: Hi, I'm trying to apply the ideas from the component library: https://github.com/stuartsierra/component My problems is being about stop/start the Jetty server, for that purpose I created this component: (defrecord WebServer [app port join? jetty log] component/Lifecycle (start [c] (log Starting jetty server...) (let [jetty (jetty/run-jetty (:handler app) {:port port :join? join?})] (log Server started at port port) (assoc c :jetty jetty))) (stop [c] (when (:jetty c) (log Stopping jetty...) (.stop (:jetty c)) (log Server stopped.)) (assoc c :jetty nil))) (defn webserver-component ([port] (webserver-component port true)) ([port join?] (map-WebServer {:port port :join? join?}))) It works, sometimes, but often I get this when I try to reset: Error starting #ExceptionInfo clojure.lang.ExceptionInfo: Error in component :server in system com.stuartsierra.component.SystemMap calling #'com.stuartsierra.component/start {:reason :com.stuartsierra.component/component-function-threw-exception, :function #'com.stuartsierra.component/start, :system-key :server, :component #cadegp.components.web_server.WebServer{:app #cadegp.components.web_app.CadegpApp{:conn #cadegp.components.database.Database{:uri datomic:free://localhost:4334/cadegp, :connection #Connection {:db-id cadegp-48d87324-7849-4255-b798-865b02ee9d9d, :index-rev 0, :basis-t 1176, :next-t 1177, :unsent-updates-queue 0, :pending-txes 0}}, :handler #reload$wrap_reload$fn__1728 ring.middleware.reload$wrap_reload$fn__1728@6608b223, :handler-ext #user$wrap_dev_handler user$wrap_dev_handler@7e174cba}, :port 8000, :join? false, :jetty nil, :log #core$println clojure.core$println@7a2c3090}, :system #SystemMap} Seems that it tries to start the server before it have time to shut it down. Any of you had a similar issue or know how to work around that? Thanks. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 -- 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] lein-node-webkit-build
Hi, For you guys that are working node-webkit and Clojurescript like I'm, I created this build tool that's similar in functionality with grunt-node-webkit-build. The library still very young and missing some features that maybe very important for some people (like being able to do a more precise selection of the files to go on the build), but I decided to work on features only by demand, so, if you see something that you need, please open an issue, pull requests would be also welcome. Here is the project: https://github.com/wilkerlucio/lein-node-webkit-build Thanks. Best regards --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 -- 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: can't connect with Datomic transactor
Hi Josh, I know that I have the transactor running, creating databases works, just connecting that doesn't... I tried your solution, but I'm still getting the same error, I would like to know at least maybe a better way to debug it, the major issue is that the error messages doesn't give any clue about what's wrong... I really believe that's something with my env, but it's being really hard to track down what it is. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Mon, Sep 8, 2014 at 6:13 PM, Josh Lehman jalehma...@gmail.com wrote: Wilker, It seems that you haven't actually started the transactor. For developing, I'd recommend using lein-datomic https://github.com/johnwayner/lein-datomic. Hope that helps, -Josh On Sunday, September 7, 2014 8:06:55 PM UTC-7, Wilker wrote: Hi, I was using Datomic in memory for a few days, and now I tried to switch for a more persistent storage. First I tried just using the free, but I was getting this error: CompilerException java.lang.NoSuchMethodError: clojure.lang.SeqIterator.init(Lclojure/lang/ISeq;)V, compiling:(form-init5913779045640355531.clj:1:11) Then I tried to use pro to see if that works, but end up with same results. The funny part is, if I try to connect just after launching the transactor I get this: (def conn (d/connect uri)) CompilerException clojure.lang.ExceptionInfo: Error communicating with HOST localhost on PORT 4334 {:alt-host nil, :peer-version 2, :password ..., :username ..., :port 4334, :host localhost, :version 0.9.4894, :timestamp 1410145249419, :encrypt-channel true}, compiling:(form- init5913779045640355531.clj:1:11) Then if I run same thing again: (def conn (d/connect uri)) CompilerException java.lang.NoSuchMethodError: clojure.lang.SeqIterator.init(Lclojure/lang/ISeq;)V, compiling:(form-init5913779045640355531.clj:1:11) Running (d/create-database) works just fine (I can confirm by checking on the console). All that I get from datomic transactor log is this: 2014-09-08 00:05:24.455 INFO defaultdatomic.lifecycle - {:tid 26, :pid 58071, :host localhost, :port 4334, :encrypt-channel true, :version 0.9.4894, :timestamp 1410145524454, :event :transactor/heartbeat, :rev 198} I have no more idea about what to do to fix it... You guys know what this issue is about? Thanks. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 -- 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: can't connect with Datomic transactor
Actually, I just got an answer on the Datomic list, the problem is that I'm using Clojure 1.7.0-alpha2. So, just have to wait for a new version now. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Tue, Sep 9, 2014 at 1:12 AM, Wilker wilkerlu...@gmail.com wrote: Hi Josh, I know that I have the transactor running, creating databases works, just connecting that doesn't... I tried your solution, but I'm still getting the same error, I would like to know at least maybe a better way to debug it, the major issue is that the error messages doesn't give any clue about what's wrong... I really believe that's something with my env, but it's being really hard to track down what it is. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Mon, Sep 8, 2014 at 6:13 PM, Josh Lehman jalehma...@gmail.com wrote: Wilker, It seems that you haven't actually started the transactor. For developing, I'd recommend using lein-datomic https://github.com/johnwayner/lein-datomic. Hope that helps, -Josh On Sunday, September 7, 2014 8:06:55 PM UTC-7, Wilker wrote: Hi, I was using Datomic in memory for a few days, and now I tried to switch for a more persistent storage. First I tried just using the free, but I was getting this error: CompilerException java.lang.NoSuchMethodError: clojure.lang.SeqIterator.init(Lclojure/lang/ISeq;)V, compiling:(form-init5913779045640355531.clj:1:11) Then I tried to use pro to see if that works, but end up with same results. The funny part is, if I try to connect just after launching the transactor I get this: (def conn (d/connect uri)) CompilerException clojure.lang.ExceptionInfo: Error communicating with HOST localhost on PORT 4334 {:alt-host nil, :peer-version 2, :password ..., :username ..., :port 4334, :host localhost, :version 0.9.4894, :timestamp 1410145249419, :encrypt-channel true}, compiling:(form- init5913779045640355531.clj:1:11) Then if I run same thing again: (def conn (d/connect uri)) CompilerException java.lang.NoSuchMethodError: clojure.lang.SeqIterator.init(Lclojure/lang/ISeq;)V, compiling:(form-init5913779045640355531.clj:1:11) Running (d/create-database) works just fine (I can confirm by checking on the console). All that I get from datomic transactor log is this: 2014-09-08 00:05:24.455 INFO defaultdatomic.lifecycle - {:tid 26, :pid 58071, :host localhost, :port 4334, :encrypt-channel true, :version 0.9.4894, :timestamp 1410145524454, :event :transactor/heartbeat, :rev 198} I have no more idea about what to do to fix it... You guys know what this issue is about? Thanks. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 -- 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.
can't connect with Datomic transactor
Hi, I was using Datomic in memory for a few days, and now I tried to switch for a more persistent storage. First I tried just using the free, but I was getting this error: CompilerException java.lang.NoSuchMethodError: clojure.lang.SeqIterator.init(Lclojure/lang/ISeq;)V, compiling:(form-init5913779045640355531.clj:1:11) Then I tried to use pro to see if that works, but end up with same results. The funny part is, if I try to connect just after launching the transactor I get this: (def conn (d/connect uri)) CompilerException clojure.lang.ExceptionInfo: Error communicating with HOST localhost on PORT 4334 {:alt-host nil, :peer-version 2, :password ..., :username ..., :port 4334, :host localhost, :version 0.9.4894, :timestamp 1410145249419, :encrypt-channel true}, compiling:(form-init5913779045640355531.clj:1:11) Then if I run same thing again: (def conn (d/connect uri)) CompilerException java.lang.NoSuchMethodError: clojure.lang.SeqIterator.init(Lclojure/lang/ISeq;)V, compiling:(form-init5913779045640355531.clj:1:11) Running (d/create-database) works just fine (I can confirm by checking on the console). All that I get from datomic transactor log is this: 2014-09-08 00:05:24.455 INFO defaultdatomic.lifecycle - {:tid 26, :pid 58071, :host localhost, :port 4334, :encrypt-channel true, :version 0.9.4894, :timestamp 1410145524454, :event :transactor/heartbeat, :rev 198} I have no more idea about what to do to fix it... You guys know what this issue is about? Thanks. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 -- 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.
How to use Java library from sources
Hello, I'm trying to use this Java library on my project: https://github.com/kichik/pecoff4j But I'm still very new to the whole ecosystem, I was looking for some way to first convert this to a jar, and then to load this jar into my Leiningen project, I found a few posts on internet like this one: http://www.elangocheran.com/blog/2013/03/installing-jar-files-locally-for-leiningen-2/ But they don't cover how to build the jar from the sources in first place, and those seem a bit old. How is a good way for me to get the pecoff4j in my project? Another detail is that my project is a Leiningen plugin, so I need to have this dependency shared with the plugin users. Thanks. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 -- 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: How to use Java library from sources
Thanks guys, I'll try it out :) --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 On Tue, Sep 2, 2014 at 2:03 PM, Jony Hudson jonyepsi...@gmail.com wrote: I think if you're going to distribute a Leiningen plugin then you'll either need to publish pecoff4j to maven/clojars, or include the source in your build. Jony On Tuesday, 2 September 2014 16:07:32 UTC+1, Wilker wrote: Hello, I'm trying to use this Java library on my project: https://github.com/ kichik/pecoff4j But I'm still very new to the whole ecosystem, I was looking for some way to first convert this to a jar, and then to load this jar into my Leiningen project, I found a few posts on internet like this one: http://www.elangocheran.com/blog/2013/03/installing-jar- files-locally-for-leiningen-2/ But they don't cover how to build the jar from the sources in first place, and those seem a bit old. How is a good way for me to get the pecoff4j in my project? Another detail is that my project is a Leiningen plugin, so I need to have this dependency shared with the plugin users. Thanks. --- Wilker Lúcio http://about.me/wilkerlucio/bio Woboinc Consultant +55 81 82556600 -- 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.
partial, but instead of args + additional, get additional + args
Hi guys, I fall out in many situations that I want the partial, but inversed, a simple example: Let's say I wanna all primes bellow 2.000: (take-while (partial 2000) primes) In this case, that's ok, but I don't expressed myself write, I because I had to use the oposite of to create the partial, I wanna do something: (take-while (rpartial 2000) primes) In the case of it's ok because they are reverse of each other, but in some circustances there is no reverse function, and you finish can't be using partial, instead you do like: (take-while #( % 2000) primes) I mean, there is no such function on default that works as reversed arguments partial (appending partial arguments at end instead of beginning)? If it don't, is not a good idea to have one? --- Wilker Lúcio http://about.me/wilkerlucio/bio Kajabi Consultant +55 81 82556600 -- 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
Re: partial, but instead of args + additional, get additional + args
Hi Miekel, The main reason is because I feel it is more expressive, and I really love expressive code :) --- Wilker Lúcio http://about.me/wilkerlucio/bio Kajabi Consultant +55 81 82556600 On Thu, Oct 20, 2011 at 9:10 PM, Meikel Brandmeyer m...@kotka.de wrote: Hi, Am 21.10.2011 um 06:01 schrieb Sean Corfield: On Thu, Oct 20, 2011 at 8:15 PM, Wilker wilkerlu...@gmail.com wrote: (take-while #( % 2000) primes) I was expressing a need for exactly this function the other day on IRC. I jokingly called it 'impartial' :) What is bad about #( % 2000)? In fact I would probably write the other case as #( 2000 %) instead of using partial. The only advantages of partial are a) that it acts like #(apply 2000 %) (to stay in the example) and b) that it generates one class less compared to #(). Sincerely Meikel -- 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 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
Re: StackOverflowError in prime function
Alf, I mean it will be even better if you just generate an infinite lazy sequence that generates primes, I mean will be really more cool :) --- Wilker Lúcio http://about.me/wilkerlucio/bio Kajabi Consultant +55 81 82556600 On Thu, Sep 22, 2011 at 1:36 PM, Alf Kristian Støyle alf.krist...@gmail.com wrote: Jup, that solved the problem. Lesson learned. Thanks :) Alf On Thu, Sep 22, 2011 at 17:54, Meikel Brandmeyer (kotarak) m...@kotka.de wrote: Hi, Am Donnerstag, 22. September 2011 17:43:30 UTC+2 schrieb Alf: What am I doing wrong here, will filter/remove or something else give StackOverflowError when used incorrectly? Yes. You pile lazy seq on lazy seq on lazy seq on and then realise the first element. This kicks off a cascade which finally causes the stack overflow when your lazy seq pile is large enough. Put a doall around the remove. This will realise the seq immediatelly and the cascade cannot happen. So it should solve the issue. Sincerely Meikel -- 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 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 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
Re: advantage of dynamic typing
Another detail to remember for Clojure / other FP languagens, is that we don't have objects!, most of time we are using basic structures, and none of them has methods, in case, most of time we are expecting lists or hashes, in hashes, we most of time expect some keys to be present, and that's all... I really don't like to mix up clojure code with Java, when I really need Java, I always write some wrappers, so when I use it feels more Clojure. --- Wilker Lúcio http://about.me/wilkerlucio/bio Kajabi Consultant +55 81 82556600 On Tue, Sep 20, 2011 at 8:51 PM, Laurent PETIT laurent.pe...@gmail.comwrote: Hello, The problem I see with using types is that imposing type X and type Y for the input arguments of method f is generally imposing too much constraint. Generally, the function just needs a subset of the types characteristics, and that's where genericity disappears. I would see no problem of e.g. having a way to explicitly declare, in the public interface of the function (as opposed to derived implicitly from the current implementation detail of the function) the necessary constraints on the function arguments. And the guarantees on the function's result. Those could then allow more checks at compile time, without sacrificing genericity of the code. Using interfaces in java is a way towards that goal, though since java does not allow to retrofit existing classes into new interfaces, this generally falls short of being generic enough. Using protocols in clojure, and with the property of protocols that they are implied to be more orthogonal than to form a hierarchy, seems interesting in this area. Finally, there will still be functions which are doing the specific jobs for specific types/records/whatever = so there's certainly still merits to be able to constrain some function arguments to specific types. HTH, -- Laurent 2011/9/20 Sean Corfield seancorfi...@gmail.com On Mon, Sep 19, 2011 at 4:19 PM, Dennis Haupt d.haup...@googlemail.com wrote: an advantage i see is very, very concise code since you have no type annotations at all. the downside is that exactly this code might be unreadable - because you just have no idea what it uses and what it does without tests or documentation. I find Clojure code more readable because it is generic. Instead of some algorithm specialized by type, Clojure often deals with simpler generic algorithms that are applicable to a broader class of data structures which can also mean more reuse. Writing truly generic code in the presence of a strong type system is often harder word and tends to produce much more dense, more annotated code that I find harder to understand. Take a look at the documentation for the Scala collection library, for example (I'm not dissing Scala - I like Scala, but I don't think anyone will disagree that the auto-generated documentation based on the library type signatures is very hard to read, at least for the average developer). -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ Railo Technologies, Inc. -- http://www.getrailo.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- 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 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 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
Programmer Day
(println (apply str (map char [72 97 112 112 121 32 80 114 111 103 114 97 109 109 101 114 32 68 97 121 33]))) --- Wilker Lúcio http://about.me/wilkerlucio/bio Kajabi Consultant +55 81 82556600 -- 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
Re: Top secret clojure project names
Never say bug free, the bugs will hear... --- Wilker Lúcio http://about.me/wilkerlucio/bio Kajabi Consultant +55 81 82556600 On Thu, Sep 1, 2011 at 8:47 PM, Islon Scherer islonsche...@gmail.comwrote: I have a big clojure project at work but it's not a secret. It superseded a old java project, the clojure one is 50 times smaller, 10 times faster and bug free. They had no choice but to accept the new one =) On Sep 1, 6:54 pm, Sean Corfield seancorfi...@gmail.com wrote: On Thu, Sep 1, 2011 at 2:31 PM, JAX jayunit...@gmail.com wrote: Hi guys: I assume some of you have secret Clojure projects at work, that your bosses don't know about. LOL! That would be hard for me - every commit and every ticket update / comment is emailed to the whole project team which includes management :) It does pose an interesting question tho': how many folks are using skunkwork projects to introduce Clojure vs opening getting buy in up front? -- Sean A Corfield -- (904) 302-SEAN An Architect's View --http://corfield.org/ World Singles, LLC. --http://worldsingles.com/ Railo Technologies, Inc. --http://www.getrailo.com/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- 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 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
test a serie list
Hi Guys, I'm just starting with Clojure (finished reading Programming Clojure, from PragProg). I mean may question should be really newbie, but I'm still confused about all functional stuff... I have this test code: (def subdb-test-data {:dexter{:path fixtures/dexter.mp4,:hash ffd8d4aa68033dc03d1c8ef373b9028c} :justified {:path fixtures/justified.mp4, :hash edc1981d6459c6111fe36205b4aff6c2}}) (deftest test-compute-hash (let [{:keys [path hash]} (subdb-test-data :dexter)] (is (= hash (subdb-hash path)) hash don't match))) It's currently testing only the first video, on test-data I have the video path and the expected hash, and the test should check if hash is being generated correctly. My problem is, I wanna do somekind of loop and test each entry on test-data, all in one, I tried some (for) loops but it made the test run no assertion at all... This is my (for) trial (don't works): (deftest test-compute-hash (for [{:keys [path hash]} (vals subdb-test-data)] (is (= hash (subdb-hash path)) hash don't match))) How I can make this works? I will need to create a macro for that (I hope not...)? --- Wilker Lúcio http://about.me/wilkerlucio/bio Kajabi Consultant +55 81 82556600 -- 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
Finite lazy sequence
Hi guys, I'm writing a simple parser here, and for parsing I'm creating a lazy-sequence this way: (defn tokens-sec [string] (iterate (fn [info] (next-token info)) [0 0 string []])) but there is a problem, this sequence has a limit (that's when there are no more tokens to consume). How I stop the iteration?? How I signal that it reached the end? I tried: (defn tokens-sec [string] (iterate (fn [[_ _ string] :as info] (if ( (count string) 0) (next-token info))) [0 0 string []])) but no lucky... There is any way to signal to iterate that list reached the end? Or there is another way that I can't see to make this lazy list works this way? --- Wilker Lúcio http://about.me/wilkerlucio/bio Kajabi Consultant +55 81 82556600 -- 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
Re: Finite lazy sequence
Solved by wrapping iterate on take-while :) (defn tokens-sec [string] (take-while identity (iterate (fn [[_ _ string :as info]] (if ( (count string) 0) (next-token info))) [0 0 string []]))) --- Wilker Lúcio http://about.me/wilkerlucio/bio Kajabi Consultant +55 81 82556600 On Fri, Sep 2, 2011 at 3:46 PM, Wilker wilkerlu...@gmail.com wrote: Hi guys, I'm writing a simple parser here, and for parsing I'm creating a lazy-sequence this way: (defn tokens-sec [string] (iterate (fn [info] (next-token info)) [0 0 string []])) but there is a problem, this sequence has a limit (that's when there are no more tokens to consume). How I stop the iteration?? How I signal that it reached the end? I tried: (defn tokens-sec [string] (iterate (fn [[_ _ string] :as info] (if ( (count string) 0) (next-token info))) [0 0 string []])) but no lucky... There is any way to signal to iterate that list reached the end? Or there is another way that I can't see to make this lazy list works this way? --- Wilker Lúcio http://about.me/wilkerlucio/bio Kajabi Consultant +55 81 82556600 -- 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
Re: Land of Lisp music video
Because of you I know had to spend $40 do get this e-book :P hehe --- Wilker Lúcio http://about.me/wilkerlucio/bio Kajabi Consultant +55 81 82556600 On Fri, Sep 2, 2011 at 6:59 PM, Tassilo Horn tass...@member.fsf.org wrote: finbeu info_pe...@t-online.de writes: Just found this: http://www.youtube.com/watch?v=HM1Zb3xmvMc Awesome ... Totally. Now I'll have a earwig for weeks. Bye, Tassilo ...simple but refined, guaranteed to blow your mind... -- 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 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