Re: Spy - Clojure / ClojureScript library for stubs, spies and mocks

2018-05-02 Thread Travis Daudelin
This looks great! Great timing, I was just struggling with some unit tests 
where I need a way to validate if a function was called

-- 
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] Eastwood, the Clojure lint tool, version 0.2.4 released

2017-05-31 Thread Travis Daudelin
Awesome replies everyone, thanks for the advice! Will definitely check 
these plugins out

-- 
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] Eastwood, the Clojure lint tool, version 0.2.4 released

2017-05-23 Thread Travis Daudelin
 Hi, thanks for posting this looks great!

Is there any overlap in functionality between Eastwood and Kibit 
? It's not clear to me which tool I should 
prefer nor when.

-- 
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: what tutorials exist for working at the Repl in Emacs?

2016-12-23 Thread Travis Daudelin

>
> modern setup in Emacs
>

I generally recommend https://github.com/bbatsov/prelude for newcomers to 
emacs, especially if you are interested in Clojure development. As for the 
repl, Prelude comes with CIDER out of the box and the docs for that are 
quite good: http://cider.readthedocs.io/en/latest/ 

-- 
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.


Design pattern question: how to decouple data layer from application layer in Luminus service?

2016-11-18 Thread Travis Daudelin
Hello everyone!

I am investigating Clojure and, more specifically, Luminus 
, for a new service my organization will be 
building soon. My team and I are really excited by the prospect of trying 
out something new.

There is a lot that I like about Luminus' design, but I have some concerns 
about its data-layer is implemented. To be clear, what I mean by "data 
layer" is the code that deals with querying a SQL database. As I understand 
it, Luminus uses HugSQL  and Mount 
 to dynamically construct a set of 
functions at run time and injects them into a namespace that the rest of 
the application code can then call to perform DB operations. This is very 
interesting, but I worry that this tightly couples my application code with 
the data code. For example, what if I want to mock these functions in my 
unit tests so that my tests don't need to depend on a database connection, 
or so that I can mock various DB error scenarios to test that my 
application code handles them appropriately?

Coming from a Java background, I would normally place data layer code 
behind an interface and then at run time pass an implementation of that 
interface to my application code. This allows me a lot of freedom during 
unit testing. What would an equivalent design pattern be in Luminus?

Thanks in advance for any insights!

-- 
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: Having trouble doing what I want using macros, is there a better way?

2016-06-10 Thread Travis Daudelin
On Friday, June 10, 2016 at 3:03:38 PM UTC-7, Francis Avila wrote:
>
> A higher-order function can do what this macro does: 
> https://gist.github.com/favila/ecdd031e22426b93a78f
>

Oh nice! It looks like I came up with an almost identical solution:
(defn transducing
  [f]
  (fn [reducing-fn]
(fn
  ([] (reducing-fn))
  ([result] (reducing-fn result))
  ([result input] (f result input reducing-fn)

It feels like "writing a custom transducer" should be a common use case, is 
there anything like these functions we've written that exists in the core 
library? I didn't see anything like them there or in the reducers library 
when I first started on my project.

-- 
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: Having trouble doing what I want using macros, is there a better way?

2016-06-10 Thread Travis Daudelin
Actually, I spoke too soon. It looks like completing takes in a reducing 
function and wraps it so that it meets the arity expectations of a 
transducer. While this is still super useful to my needs (thanks again!) I 
wanted to clarify for posterity that completing does not solve the issue in 
my initial post.

-- 
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: Having trouble doing what I want using macros, is there a better way?

2016-06-10 Thread Travis Daudelin


On Friday, June 10, 2016 at 11:43:04 AM UTC-7, Bobby Eickhoff wrote:
>
> But maybe the core function completing is very close to what you're 
> looking for...
>

Hmm, looking through its source I'd say it's exactly what I'm looking for. 
Thank you! 

-- 
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: Having trouble doing what I want using macros, is there a better way?

2016-06-10 Thread Travis Daudelin

>
> I think you can do what you want with existing transducers. Won't 
> map/filter/keep/etc do the trick?
>

I can't say for sure that it's not possible, but I certainly lack the 
imagination :). The logic I need to write is quite complicated and I'm 
finding it's easier to write my own transducer to have fine-grained control.

My $0.02 is only resort to macros when all else has failed. Can just higher 
> order functions and composition and injection get you closer to what you 
> want?
>

This seems to be very common feedback on this group, and I'll definitely 
take it to heart. Mostly I just wanted to check my understanding of macros 
and verify that what I want to do is / is not possible using them before 
moving on to higher order functions.

You can "capture" symbols from the surrounding context, making them 
> available to the body of your macros, the "tilde tick trick" is what you're 
> looking for there


Ah perfect! This is exactly what I was hoping would be possible. Your 
examples are right on point, thanks for educating me :)

>

-- 
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.


Having trouble doing what I want using macros, is there a better way?

2016-06-10 Thread Travis Daudelin
Hi all!

I'm current working on a project where I am ingesting events off a stream 
and processing them. There are many many steps involved in the processing 
component, so I am choosing to write the steps as a series of transducers 
(because, hey, they're super cool!). Here's the problem though, after 
writing the first 2 processing steps I'm noticing that all of them are 
going to look very similar:

(defn a-step-transducer
  []
  (fn [reducing-fn]
 (fn
   ([] (reducing-fn))
   ([result] (reducing-fn result))
   ([[guid-state processed-events :as result] event]
;; step-specific logic


Given how many steps I am planning to write, this is a ton of boilerplate! 
So, my first thought was to use a macro to abstract away all this 
boilerplate. Now, I have to admit that Clojure is my first Lisp, so I'm 
really not sure I fully understand when or why to use macros to do things. 
My current understanding is that macros are a kind of "template" for code, 
so something like this where I don't want to write the same function 
structure over and over seems like a decent use case for macros (feel free 
to correct me if I'm totally off on this). Here is my first attempt:

(defmacro deftransducer
[body]
`(fn [reducing-fn]
   (fn
 ([] (reducing-fn))
 ([result] (reducing-fn result))
 ([[guid-state processed-events :as result] event]
  ~@body

The idea here being that in body I can reference the variables defined by 
the macro like reducing-fn, result, event, etc. Of course, I quickly found 
out that this doesn't work:

storm-etl.entry-processing> (deftransducer "something")
CompilerException java.lang.RuntimeException: Can't use qualified name as 
parameter: storm-etl.entry-processing/reducing-function

Some quick googling tells me that the solution to this is to use gensyms 
for these variable names, but that would defeat the whole purpose of this 
because I want to be able to reference those variables from within the code 
that I pass to my macro. Is this an appropriate use case for macros or am I 
way off base? Is there an alternative approach that would be recommended?

-- 
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.