Clarity on Stuart Sierra's component system

2014-11-28 Thread Colin Yates
Hi all, Am I right in thinking that in order to use https://github.com/stuartsierra/component every consumer of a component must also be a component? For example, if I have a component DB and I want to use that DB in (defn blob-query [db criteria]...), do I pull the DB out of the system map an

ring-transit issue

2014-11-28 Thread Thomas
Hi, I am using the ring-transit middleware but something doesn't seem to be quite right. Below is the code on the server side: (defn get-test-data [] {:a 1 :b 2}) (defroutes app-routes (GET "/" [] (main-page)) (wrap-transit-response (GET "/test" [] (get-test-data))) (route/resources

Re: [ANN] stateful-check 0.1.0 - test stateful systems with test.check

2014-11-28 Thread Jan Stępień
Hi Carlo, Thanks for sharing! I see that generative testing of statful computations is a popular topic in the Clojure world these days; I think we've started working on our libraries nearly the same day :) https://github.com/jstepien/states All the best, Jan -- You received this message beca

Re: ring-transit issue

2014-11-28 Thread Ahmad Hammad
Remove wrap-transit-response from your routes. You need to add (wrap-transit-response) to your middleware just like you have (wrap-transit-params). The latter handles incoming request params, while the former response collections. On Friday, November 28, 2014 2:00:20 PM UTC, Thomas wrote: > > H

Re: [ANN] stateful-check 0.1.0 - test stateful systems with test.check

2014-11-28 Thread Carlo Zancanaro
Hey Jan! On Fri, Nov 28, 2014 at 06:37:06AM -0800, Jan Stępień wrote: > Thanks for sharing! I see that generative testing of statful computations > is a popular topic in the Clojure world these days; Yeah, it certainly seems to be that way. I was re-invigorated to work on stateful-check after wa

Re: Clarity on Stuart Sierra's component system

2014-11-28 Thread Max Countryman
Hi Colin, I'm by no means an expert on Component but I have used it for my last several projects. What I've discovered is where I have query functions such as yours I pass the db component through to their call sites from a component which contains the db as state. For example, I have a compone

Re: Clarity on Stuart Sierra's component system

2014-11-28 Thread James Reeves
On 28 November 2014 at 10:28, Colin Yates wrote: > > Am I right in thinking that in order to use > https://github.com/stuartsierra/component every consumer of a component > must also be a component? > Nope. > For example, if I have a component DB and I want to use that DB in (defn > blob-query

Re: Clarity on Stuart Sierra's component system

2014-11-28 Thread Colin Yates
Thanks both. James, that is what I was hoping. I guess I got a bit misled with the combination of his "Customers" example in the video, the "all or nothing" warnings and "I do not intend that application functions should receive the top-level system as an argument. Rather, functions are defined in

Re: Clarity on Stuart Sierra's component system

2014-11-28 Thread James Reeves
On 28 November 2014 at 15:20, Colin Yates wrote: > > I guess I got a bit misled with the combination of his "Customers" > example in the video, the "all or nothing" warnings and "I do not > intend that application functions should receive the top-level system > as an argument. Rather, functions ar

Re: Clarity on Stuart Sierra's component system

2014-11-28 Thread Colin Yates
Ah OK. I was confused a little about what makes a component, it isn't just state it is also about lifecycle. Imagine a "health-check" which polls some service to see if it is there, it needs the service and some ohDear notifier component but it doesn't have any state as such (or at least no state

reduced doesn't work inside reductions

2014-11-28 Thread myguidingstar
(reduce (fn [acc x] (if (> acc 10) (reduced acc) (+ acc x))) 0 (range 100)) ;; => 15 (reductions (fn [acc x] (if (> acc 10) (reduced acc) (+ acc x))) 0 (range 100)) ;; thows

Re: reduced doesn't work inside reductions

2014-11-28 Thread Nicola Mometto
This has already been fixed, and reductions will support reduced in 1.7.0. In the meantime you can use 1.7.0-alpha4. Nicola myguidingstar writes: > > > (reduce (fn [acc x] > (if (> acc 10) > (reduced acc) > (+ acc x))) > 0 > (range 100)) > ;; =>

[ANN] defprecated 0.1.0 - deprecation made easy

2014-11-28 Thread Alexander Yakushev
Hello everyone, I wrote this tiny library mostly because there was no automatic way to deprecate separate function arities in Clojure. And while I was at it, I added some commonly needed features too. So here's what *defprecated* is capable of: - adding deprecation notice to the docs - p

Re: Clarity on Stuart Sierra's component system

2014-11-28 Thread James Reeves
On 28 November 2014 at 16:02, Colin Yates wrote: > Ah OK. I was confused a little about what makes a component, it isn't > just state it is also about lifecycle. > > Imagine a "health-check" which polls some service to see if it is > there, it needs the service and some ohDear notifier component

Re: Core.async unordered pipeline-blocking ?

2014-11-28 Thread Francis Avila
I had a need for this too some time ago. It's not very hard to write yourself. Whatever trickiness there is in these functions is in handling exceptions and orchestrating shutdown. I put my version up in a gist with some other async utility functions I wrote: https://gist.github.com/favila/8e7a

Bug? with-redefs fails on functions with primitive type hints

2014-11-28 Thread Brian Marick
A Midje user reports a bug that is actually a Clojure behavior. Does it count as a bug? Consider the following: (defn test-fn [^long x] x); Note hint (defn do-something [x] (test-fn x)) (with-redefs [test-fn (fn [x] (prn :x x) x)] (do-something "non-int")) In Clo

Re: Bug? with-redefs fails on functions with primitive type hints

2014-11-28 Thread Sean Corfield
On Nov 28, 2014, at 12:59 PM, Brian Marick wrote: > A Midje user reports a bug that is actually a Clojure behavior. Does it count > as a bug? If you're mocking a function that is specifically declared to take a long (primitive), shouldn't the mocked call also be declared to take a long? (d

Re: Bug? with-redefs fails on functions with primitive type hints

2014-11-28 Thread Brian Marick
Sean Corfield wrote: If you're mocking a function that is specifically declared to take a long (primitive), shouldn't the mocked call also be declared to take a long? Midje has an idea called a "metaconstant" https://github.com/marick/Midje/wiki/Metaconstants. Metaconstants are used to docu

Re: Core.async unordered pipeline-blocking ?

2014-11-28 Thread Niels van Klaveren
Thanks so much for sharing, Francis ! It might be simple to some, but I haven't had an opportunity yet to get acquainted well enough with core.async. Clojure has so much useful libraries, but some force you to get your head around (for me) completely new paradigms which can take time. Reading y

[ANN] Clara Rules 0.7.0 Released

2014-11-28 Thread Ryan Brush
I just pushed release 0.7.0 of Clara, a forward-chaining production rule engine in Clojure. Beyond some bug fixes and performance improvements, the most significant new feature is described at [1]: support for any variable bound in a constraint is visible to arbitrary expressions in subsequent

Re: reduced doesn't work inside reductions

2014-11-28 Thread Brandon Bloom
For reference, here's the ticket: http://dev.clojure.org/jira/browse/CLJ-1185 And the commit: https://github.com/clojure/clojure/commit/b45b067f56c78b8128f57913e662d9638ee480c5 On Friday, November 28, 2014 11:19:41 AM UTC-5, Nicola Mometto wrote: > > > This has already been fixed, and reductio