[ANN] CFP - ACCU 2014 Conference, 8 - 12 April 2014, Bristol, UK

2013-10-02 Thread Giovanni Asproni

Hi All,

I'm sending this on behalf of Jon Jagger, the conference Chair.

The CFP for the ACCU 2014 conference is now open. The deadline for 
sending your proposal is the 5th of November 2013.


The conference has a long tradition of high quality sessions covering 
many aspects of software development, from programming languages (e.g., 
Java, Javascript, C#, Clojure, Python, Erlang, Haskell, Ruby, Groovy, C, 
C++, etc.), and technologies (libraries, frameworks, databases, etc.) to 
subjects about the wider development environment such as testing, 
architecture and design, development process, analysis, patterns, 
project management, and softer aspects such as team building, 
communication and leadership.


The main web page is here
http://accu.org/index.php/conferences/accu_conference_2014

The full call for papers web page is here
http://accu.org/index.php/conferences/accu_conference_2014/accu2014_call_for_papers 



Regards,
Giovanni

--
Asprotunity Limited
http://asprotunity.com
Linkedin: http://www.linkedin.com/in/gasproni
Twitter: @gasproni
Mobile: +44 (0) 791 746 0453


--
Asprotunity Limited
http://asprotunity.com
Linkedin: http://www.linkedin.com/in/gasproni
Twitter: @gasproni
Mobile: +44 (0) 791 746 0453

--
--
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/groups/opt_out.


Re: Integration with Java dependency injection frameworks?

2013-10-02 Thread Cedric Greevey
Erm ... a MOOC?


On Tue, Oct 1, 2013 at 9:14 PM, Marshall Bockrath-Vandegrift 
llas...@gmail.com wrote:

 Hi all:

 I was wondering – does anyone have any experience with or patterns for
 integrating Clojure with existing Java dependency injection frameworks?
 I’m working with the LensKit framework [1] for a MOOC and it uses a
 JSR-330/javax.inject dependency-injection framework named `grapht` [2]
 for, well, everything.  In some examples dependency-injection is even
 used to provide input data file paths (!).  As far as I can tell, the
 injection happens entirely via invoking some sort of concrete,
 user-provided, annotated constructor which accepts injected instances on
 (potentially annotated) constructor parameters.

 My thoughts thus far have centered on two basic potential approaches:

 1. Implement small Java stubs with appropriately-annotated constructors
 for every injection point.  The downside is that these stubs are
 (probably) not very reusable.  Injected instances are only injected at
 the constructor parameters, so needing a different set of injected
 instances requires a different class/constructor.

 2. Dynamically generate stub classes exposing constructors which accept
 some arbitrary per-class set of inject-able parameters.  There might be
 an easier way to do it, but that’s the approach I’ve tried out thus-far
 using ASM and the Clojure dynamic class loaders to produce “Provider”
 factory classes:

 https://github.com/llasram/esfj

 The largest problem with this approach is that the actual factory
 implementation still needs to be injected somehow.  I thought about
 stashing a function in a Var linked to the class, but have instead just
 made the implementation function itself another inject-able IFn
 parameter.  This avoids namespace-abuse, but also means injecting
 Clojure implementations involves doing *more* dependency injection than
 with plain Java, which doesn’t seem right.

 Thoughts?

 [1] http://lenskit.grouplens.org/
 [2] https://github.com/grouplens/grapht

 -Marshall

 --
 --
 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/groups/opt_out.


-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to 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/groups/opt_out.


Re: how to reload Clojure files while connected to Clojurescript browser repl in Emacs?

2013-10-02 Thread George Oliver


On Sunday, September 29, 2013 8:12:23 PM UTC-7, Tim Visher wrote:

Now with nrepl's ability to have multiple sessions open at once (an 
 ability I haven't taken any advantage of personally), you should be 
 able to have a JVM nrepl open _and_ a browser repl nrepl session, both 
 of which would be modifying client and server sides of the code 
 respectively. 


Tim, yes I think this is possible (I've read that people can do this with 
vim and Eclipse), I just haven't found a good working method yet for Emacs 
and nrepl.el. And it's true I haven't really thought ahead to whether this 
workflow is a good idea or not :), but I would like to give it a try. The 
functionality in Austin enables browser refreshes while maintaining a 
connected browser repl, dealing with state is another issue. 

After reading more on the nrepl.el list I found some relevant posts, [1] 
 [2], and I was able to get things to work using 
nrepl-make-repl-connection-default though it's not that smooth (and all 
manual at the moment).

[1]  https://groups.google.com/forum/#!topic/nrepl-el/tfsHaDTsYxY
[2] https://groups.google.com/forum/#!topic/nrepl-el/9xl6yd51tbQ

-- 
-- 
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/groups/opt_out.


Re: RBAC/ACL using core.logic or similar

2013-10-02 Thread Dave Della Costa
Hi ronen,

This doesn't address your question re: how do it in pure Clojure, but as
a data point we recently implemented a wrapper for Shiro in Clojure for
use in setting policies on a ring-based web app.

We are using our own solution for checking the access policies on routes
themselves, which is wholly unrelated to Shiro.  For that matter, we
don't use anything Shiro provides (other than what it forces us to
setup, see below) relating to authentication, session or web routing,
just its authorization capabilities, and we extend their JdbcRealm
(http://shiro.apache.org/static/1.2.2/apidocs/index.html?org/apache/shiro/realm/jdbc/JdbcRealm.html)
to plug it into our system.

I'll try to lay out the pluses and minuses simply.  Pluses:

- once we figured out the architecture and where to jack-in, it was
pretty easy to wrap stuff up inside of Clojure.

- the permission check stuff in our system was basically simply wrapping
a specific method on the Subject class:
http://shiro.apache.org/static/1.2.2/apidocs/org/apache/shiro/subject/Subject.html#checkPermission(java.lang.String)
 (more here: http://shiro.apache.org/permissions.html)

- it has a really comprehensive role and permission management set of
interfaces, and if you want to set up caching for your roles and
whatnot, it's easy to extend--from a Java perspective.

- as much as you go the Shiro way, you will find it easy to implement
and extend.

Minuses:

- as much as you go the Shiro way, you will find it easy to implement
and extend.

I think that, if you already had your own authentication framework set
up, it *may* be worth looking elsewhere for a RBAC/DAC/etc. solution.
If you want something comprehensive, Shiro is definitely worth checking
out.  For us I think the jury is still out on whether or not it was
worth the trouble or not.

DD

(2013/09/29 22:16), ronen wrote:
 Hey, 
 
 I was thinking about how to approach role and permission management in
 Clojure, https://shiro.apache.org/ is one example of same a framekwork 
 
 It sounds like a problem that core.logic could solve but I'm not sure
 how to approach it
 
 Thought and ideas are welcome
 
 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/groups/opt_out.

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to 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/groups/opt_out.


Re: Parallelising over a lazy sequence - request for help

2013-10-02 Thread Paul Butcher
Alan,

Apologies for the delayed reply - I remember Iota well (there was some 
cross-fertilisation between it and foldable-seq a few months back IIRC :-)

Having said that, I don't think that Iota will help in my particular situation 
(although I'd be delighted to be proven wrong)? Given that the file I'm 
processing is an XML file, and will therefore have to pass through an XML 
parser, unless I write an XML parser on top of the reducers framework, I'm 
stuck with dealing with sequences at some point along the way?

--
paul.butcher-msgCount++

Snetterton, Castle Combe, Cadwell Park...
Who says I have a one track mind?

http://www.paulbutcher.com/
LinkedIn: http://www.linkedin.com/in/paulbutcher
MSN: p...@paulbutcher.com
AIM: paulrabutcher
Skype: paulrabutcher

On 30 Sep 2013, at 11:15, Alan Busby thebu...@gmail.com wrote:

 Sorry to jump in, but I thought it worthwhile to add a couple points; (sorry 
 for being brief)
 
 1. Reducers work fine with data much larger than memory, you just need to 
 mmap() the data you're working with so Clojure thinks everything is in memory 
 when it isn't. Reducer access is fairly sequential, not random, so spinning 
 disks work great here. 
 
 2. A 40GB XML file is very often many many smaller XML documents aggregated 
 together. It's often faster to separate each document into it's own line (via 
 various UNIX tools) and parse each line separately. I typically do something 
 like $ zcat bigxml.gz | tr '\n' ' ' | sed 's/foo/\nfoo/' | grep '^foo' 
  records.xml . 
 
 3. Check out the Iota library, https://github.com/thebusby/iota/ . I often 
 use for reducing over 100's of GB's worth of text data. It does what Jozef 
 suggests, and makes a text file a foldable collection.
 
 4. While pmap is great for advertising the power of Clojure, it's likely safe 
 to say that it should be ignored if you're actually looking for performance. 
 
 
 Hope this helps,
 Alan Busby
 
 
 
 
 -- 
 -- 
 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/groups/opt_out.

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to 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/groups/opt_out.


Re: Integration with Java dependency injection frameworks?

2013-10-02 Thread Marshall Bockrath-Vandegrift
Cedric Greevey cgree...@gmail.com writes:

 Erm ... a MOOC?

Massive Open Online Course – e.g., Coursera, edX, Udacity, etc.  This is
for the Coursera-offered version of the University of Minnesota course
on recommendation systems, but that didn’t seem particularly relevant to
the problem at hand.

-Marshall

-- 
-- 
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/groups/opt_out.


Re: Jsonify a Jdbc4Array in Clojure

2013-10-02 Thread Christian Jauvin
Ah finally, thanks John, the with-open pattern was indeed the missing 
piece: it works!

Just to summarize, here's what works for me:

(extend-type org.postgresql.jdbc4.Jdbc4Array
  json/JSONWriter
  (-write [o out]
(json/-write (.getArray o) out)))

; plus any other additional required custom JSON writers 
(java.sql.Timestamp, Date, etc)

(with-open [conn (jdbc/get-connection *db*)]
  (json/write-str
(jdbc/query {:connection conn}
[select * from table with PG array in it..])))



On Wednesday, October 2, 2013 12:06:44 AM UTC-4, John Hume wrote:

 I don't use clojure.java.jdbc, so this may be non-idiomatic or just wrong, 
 but have you tried something like

 (with-open [connection (jdbc/db-connection *db*)]
   (json/write-str
 (jdbc/query {:connection connection} 
   [SELECT * FROM...])))



 On Tue, Oct 1, 2013 at 8:13 PM, Christian Jauvin 
 cja...@gmail.comjavascript:
  wrote:

 Hi Philippe,

 The Jdbc4Array that's causing me trouble is not the outer one, 
 returned from jdbc/query: that one seems to be properly handled by 
 json/write-str.

 The problem happens with a Postgres table containing a text[] column:

 create table something (
 something_id serial primary key,
 list_of_something text[]
 )

 In that case the query returns an (inner) array for each record, and it 
 gets converted to a Jdbc4Array, which, when passed to the JSON writer, 
 causes the problem.

 Querying a table without a PG array works perfectly fine though.



 On Tuesday, October 1, 2013 4:21:33 PM UTC-4, Philippe Guillebert wrote:

 Hi, 

 You probably need to realize your query using (doall (jdbc/query ...))

 Also, I was wondering, depending on your needs, you could convert 
 Jdbc4Array into a native type (vector ?) as a post-processing function 
 of your query and forget about registering JSON writers.



 On Tue, Oct 1, 2013 at 9:00 PM, Christian Jauvin cja...@gmail.comwrote:

 Hi Roman,

 This approach works for java.sql.Timestamp, which was another type for 
 which a JSON writer wasn't defined in my case.

 For org.postgresql.jdbc4.**Jdbc4Array however, there's something 
 missing, because I get:

 *org.postgresql.util.PSQLException: This connection has been 
 closed.*

 As the person answering me on Stack Overflow suggested, it seems that 
 the resultset should be somehow processed before the connection is closed, 
 but I really don't know how to do given the construct I'm currently using:

 (json/write-str
   (jdbc/query *db*
 [SELECT * FROM ..]))

 where and how could I intercept the resultset that way? Thanks.



 On Tuesday, October 1, 2013 12:49:10 PM UTC-4, r0man wrote:

 I think you need to implement the JSONWriter protocol for the
 Jdbc4Array class, and possibly for the datatypes that are in the
 array. This for example makes the json library aware of
 java.util.Date classes. 

 (extend-type java.util.Date
   JSONWriter
   (-write [date out]
 (-write (str date) out)))

 Something like this (not tested):

 (extend-type org.postgresql.jdbc4.**Jdbc4Arra**y
   JSONWriter
   (-write [array out]
 (-write (seq (.getArray array)) out)))

 Roman
  

 On Tuesday, October 1, 2013 3:57:02 PM UTC+2, Christian Jauvin wrote:

 Hi,

 I asked this question on Stack Overflow yesterday:

 I want to jsonify the results of a query performed against a Postgres 
 table containing a column of type text[], but the problem is that 
 clojure.data.json.write-str doesn't seem to know how to handle PG 
 arrays:

 *Exception Don't know how to write JSON of class 
 org.postgresql.jdbc4.Jdbc4Array  clojure.data.json/write-generic*

  Do I have to supply a custom handler, or is there a simpler way?


 http://stackoverflow.com/**quest**ions/19103870/jsonify-a-**jdbc4a**
 rray-in-clojurehttp://stackoverflow.com/questions/19103870/jsonify-a-jdbc4array-in-clojure

 I'm asking it here in the hope of getting (maybe) a simpler solution, 
 or at least one I can implement readily, because the problem I have with 
 one of the suggestions I received (extending org.postgresql.jdbc4.**
 Jdbc4Arra**y to implement the missing function) is that I don't know 
 how to make it work with my usage pattern, which is simply:

 (json/write-str 
 (jdbc/query *db* 
 [SELECT * FROM ...]))

 How do I get the array before the connection is closed with such a 
 construct? Is there another way?

   -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.com

 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@**googlegroups.com

 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=enhttp://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 

Re: Jsonify a Jdbc4Array in Clojure

2013-10-02 Thread Christian Jauvin
Actually, re-reading the jdbc/query doc

http://clojure.github.io/java.jdbc/#clojure.java.jdbc/query

I can't find any reference to this :connection keyword param.. may I ask 
where you got it from?




On Wednesday, October 2, 2013 9:50:13 AM UTC-4, Christian Jauvin wrote:

 Ah finally, thanks John, the with-open pattern was indeed the missing 
 piece: it works!

 Just to summarize, here's what works for me:

 (extend-type org.postgresql.jdbc4.Jdbc4Array
   json/JSONWriter
   (-write [o out]
 (json/-write (.getArray o) out)))

 ; plus any other additional required custom JSON writers 
 (java.sql.Timestamp, Date, etc)

 (with-open [conn (jdbc/get-connection *db*)]
   (json/write-str
 (jdbc/query {:connection conn}
 [select * from table with PG array in it..])))



 On Wednesday, October 2, 2013 12:06:44 AM UTC-4, John Hume wrote:

 I don't use clojure.java.jdbc, so this may be non-idiomatic or just 
 wrong, but have you tried something like

 (with-open [connection (jdbc/db-connection *db*)]
   (json/write-str
 (jdbc/query {:connection connection} 
   [SELECT * FROM...])))



 On Tue, Oct 1, 2013 at 8:13 PM, Christian Jauvin cja...@gmail.comwrote:

 Hi Philippe,

 The Jdbc4Array that's causing me trouble is not the outer one, 
 returned from jdbc/query: that one seems to be properly handled by 
 json/write-str.

 The problem happens with a Postgres table containing a text[] column:

 create table something (
 something_id serial primary key,
 list_of_something text[]
 )

 In that case the query returns an (inner) array for each record, and 
 it gets converted to a Jdbc4Array, which, when passed to the JSON 
 writer, causes the problem.

 Querying a table without a PG array works perfectly fine though.



 On Tuesday, October 1, 2013 4:21:33 PM UTC-4, Philippe Guillebert wrote:

 Hi, 

 You probably need to realize your query using (doall (jdbc/query ...))

 Also, I was wondering, depending on your needs, you could convert 
 Jdbc4Array into a native type (vector ?) as a post-processing function 
 of your query and forget about registering JSON writers.



 On Tue, Oct 1, 2013 at 9:00 PM, Christian Jauvin cja...@gmail.comwrote:

 Hi Roman,

 This approach works for java.sql.Timestamp, which was another type 
 for which a JSON writer wasn't defined in my case.

 For org.postgresql.jdbc4.**Jdbc4Array however, there's something 
 missing, because I get:

 *org.postgresql.util.PSQLException: This connection has been 
 closed.*

 As the person answering me on Stack Overflow suggested, it seems that 
 the resultset should be somehow processed before the connection is 
 closed, 
 but I really don't know how to do given the construct I'm currently using:

 (json/write-str
   (jdbc/query *db*
 [SELECT * FROM ..]))

 where and how could I intercept the resultset that way? Thanks.



 On Tuesday, October 1, 2013 12:49:10 PM UTC-4, r0man wrote:

 I think you need to implement the JSONWriter protocol for the
 Jdbc4Array class, and possibly for the datatypes that are in the
 array. This for example makes the json library aware of
 java.util.Date classes. 

 (extend-type java.util.Date
   JSONWriter
   (-write [date out]
 (-write (str date) out)))

 Something like this (not tested):

 (extend-type org.postgresql.jdbc4.**Jdbc4Arra**y
   JSONWriter
   (-write [array out]
 (-write (seq (.getArray array)) out)))

 Roman
  

 On Tuesday, October 1, 2013 3:57:02 PM UTC+2, Christian Jauvin wrote:

 Hi,

 I asked this question on Stack Overflow yesterday:

 I want to jsonify the results of a query performed against a 
 Postgres table containing a column of type text[], but the problem 
 is that clojure.data.json.write-str doesn't seem to know how to 
 handle PG arrays:

 *Exception Don't know how to write JSON of class 
 org.postgresql.jdbc4.Jdbc4Array  clojure.data.json/write-generic*

  Do I have to supply a custom handler, or is there a simpler way?


 http://stackoverflow.com/**quest**ions/19103870/jsonify-a-**jdbc4a**
 rray-in-clojurehttp://stackoverflow.com/questions/19103870/jsonify-a-jdbc4array-in-clojure

 I'm asking it here in the hope of getting (maybe) a simpler 
 solution, or at least one I can implement readily, because the problem 
 I 
 have with one of the suggestions I received (extending 
 org.postgresql.jdbc4.**Jdbc4Arra**y to implement the missing 
 function) is that I don't know how to make it work with my usage 
 pattern, 
 which is simply:

 (json/write-str 
 (jdbc/query *db* 
 [SELECT * FROM ...]))

 How do I get the array before the connection is closed with such a 
 construct? Is there another way?

   -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.com

 Note that posts from new members are moderated - please be patient 
 with your first post.
 To unsubscribe from this group, send email to
 clojure+u...@**googlegroups.com

 For 

Re: Jsonify a Jdbc4Array in Clojure

2013-10-02 Thread John D. Hume
I believe it was on the clojure-docs page (linked from the
clojure.java.jdbc readme) where they talk about managing your own
connection.

The more idiomatic way may be to wrap the whole thing in some transaction
fn or macro. Sorry I'm not familiar with the API. A lot of vars are
deprecated, but their doc strings don't say what to do instead.
On Oct 2, 2013 9:05 AM, Christian Jauvin cjau...@gmail.com wrote:

 Actually, re-reading the jdbc/query doc

 http://clojure.github.io/java.jdbc/#clojure.java.jdbc/query

 I can't find any reference to this :connection keyword param.. may I ask
 where you got it from?




 On Wednesday, October 2, 2013 9:50:13 AM UTC-4, Christian Jauvin wrote:

 Ah finally, thanks John, the with-open pattern was indeed the missing
 piece: it works!

 Just to summarize, here's what works for me:

 (extend-type org.postgresql.jdbc4.**Jdbc4Array
   json/JSONWriter
   (-write [o out]
 (json/-write (.getArray o) out)))

 ; plus any other additional required custom JSON writers
 (java.sql.Timestamp, Date, etc)

 (with-open [conn (jdbc/get-connection *db*)]
   (json/write-str
 (jdbc/query {:connection conn}
 [select * from table with PG array in it..])))



 On Wednesday, October 2, 2013 12:06:44 AM UTC-4, John Hume wrote:

 I don't use clojure.java.jdbc, so this may be non-idiomatic or just
 wrong, but have you tried something like

 (with-open [connection (jdbc/db-connection *db*)]
   (json/write-str
 (jdbc/query {:connection connection}
   [SELECT * FROM...])))



 On Tue, Oct 1, 2013 at 8:13 PM, Christian Jauvin cja...@gmail.comwrote:

 Hi Philippe,

 The Jdbc4Array that's causing me trouble is not the outer one,
 returned from jdbc/query: that one seems to be properly handled by
 json/write-str.

 The problem happens with a Postgres table containing a text[] column:

 create table something (
 something_id serial primary key,
 list_of_something text[]
 )

 In that case the query returns an (inner) array for each record, and
 it gets converted to a Jdbc4Array, which, when passed to the JSON
 writer, causes the problem.

 Querying a table without a PG array works perfectly fine though.



 On Tuesday, October 1, 2013 4:21:33 PM UTC-4, Philippe Guillebert wrote:

 Hi,

 You probably need to realize your query using (doall (jdbc/query ...))

 Also, I was wondering, depending on your needs, you could convert
 Jdbc4Array into a native type (vector ?) as a post-processing
 function of your query and forget about registering JSON writers.



 On Tue, Oct 1, 2013 at 9:00 PM, Christian Jauvin cja...@gmail.comwrote:

 Hi Roman,

 This approach works for java.sql.Timestamp, which was another type
 for which a JSON writer wasn't defined in my case.

 For org.postgresql.jdbc4.**Jdbc4**Array however, there's something
 missing, because I get:

 *org.postgresql.util.PSQLException: This connection has been
 closed.*

 As the person answering me on Stack Overflow suggested, it seems that
 the resultset should be somehow processed before the connection is 
 closed,
 but I really don't know how to do given the construct I'm currently 
 using:

 (json/write-str
   (jdbc/query *db*
 [SELECT * FROM ..]))

 where and how could I intercept the resultset that way? Thanks.



 On Tuesday, October 1, 2013 12:49:10 PM UTC-4, r0man wrote:

 I think you need to implement the JSONWriter protocol for the
 Jdbc4Array class, and possibly for the datatypes that are in the
 array. This for example makes the json library aware of
 java.util.Date classes.

 (extend-type java.util.Date
   JSONWriter
   (-write [date out]
 (-write (str date) out)))

 Something like this (not tested):

 (extend-type org.postgresql.jdbc4.**Jdbc4Array
   JSONWriter
   (-write [array out]
 (-write (seq (.getArray array)) out)))

 Roman


 On Tuesday, October 1, 2013 3:57:02 PM UTC+2, Christian Jauvin wrote:

 Hi,

 I asked this question on Stack Overflow yesterday:

 I want to jsonify the results of a query performed against a
 Postgres table containing a column of type text[], but the problem
 is that clojure.data.json.write-str doesn't seem to know how to
 handle PG arrays:

 *Exception Don't know how to write JSON of class
 org.postgresql.jdbc4.Jdbc4Array  clojure.data.json/write-generic*

  Do I have to supply a custom handler, or is there a simpler way?


 http://stackoverflow.com/**questions/19103870/jsonify-a-**
 jdbc4array-in-clojurehttp://stackoverflow.com/questions/19103870/jsonify-a-jdbc4array-in-clojure

 I'm asking it here in the hope of getting (maybe) a simpler
 solution, or at least one I can implement readily, because the problem 
 I
 have with one of the suggestions I received (extending
 org.postgresql.jdbc4.**Jdbc4Array to implement the missing
 function) is that I don't know how to make it work with my usage 
 pattern,
 which is simply:

 (json/write-str
 (jdbc/query *db*
 [SELECT * FROM ...]))

 How do I get the array before the connection is 

Re: Problems starting with Clojure and Leiningen and Light Table

2013-10-02 Thread Peter Mancini
Ok, so you did not get lein working. If it were working you would not have 
problems creating a new project. I know you are eager to press forward. 
Admirable. However, it is what we call initiative without judgement. In the 
world of engineering that is considered ill-advised. So, lets get back to 
square 1.

Delete everything involving lein from your machine. Purge your path and 
other env variables of it as well. Start again.

First, validate you have Java 7.

Second, follow this again, to the letter. 
http://leiningen-win-installer.djpowell.net/

Third create a new project with lein new myproject. Change directory to 
myproject/src/myproject and see if it created a core.clj file.

If anything fails return to that step and look to see what the issue is. 
You have to be more methodical. Every time you make more than one change 
you create branching error probabilities. Do that 3 times and you have 8 
times as many possible root causes for errors. Do it more and the 
perplexity increases geometrically.

-- 
-- 
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/groups/opt_out.


my first clojure wat moment - misunderstanding or bug?

2013-10-02 Thread James Warren
I've been using Clojure for a couple months, so while I feel comfortable 
with it, I'm not certain whether some unusual behavior I encountered is a 
bug or a lack of understanding on my part.  (I suspect the latter.)

The context arose from using Clojure reflection to inspect a class 
generated by Apache Thrift http://thrift.apache.org. Such classes have a 
static, unmodifiable map describing the members of the class. I wrote a 
function to extract the keys of this map; it initially appears to work, but 
defing the results to a symbol and repeatedly using that symbol returns 
inconsistent results.

I've boiled it down to a smaller example that replicates the result: (gist 
available https://gist.github.com/jameswarren/6799309)

// Java class

public class DummyClass {
public enum DummyEnum {
FIRST, SECOND, THIRD
  }
 
  public static final MapDummyEnum, String dummyMap;
  static {
MapDummyEnum, String tmpMap = new EnumMapDummyEnum, 
String(DummyEnum.class);
tmpMap.put(DummyEnum.FIRST, first);
tmpMap.put(DummyEnum.SECOND, second);
tmpMap.put(DummyEnum.THIRD, third);
dummyMap = Collections.unmodifiableMap(tmpMap);
  }
}

// Clojure ns

(ns refbug.core
  (:import [refbug DummyClass]))
 
(defn foo [^Class c]
;; note: (into [] (keys (clojure.lang.Reflector/getStaticField c dummyMap 
works
  (keys (clojure.lang.Reflector/getStaticField c dummyMap)))
 
(def m (foo DummyClass))
(println m)
;; (#DummyEnum FIRST #DummyEnum SECOND #DummyEnum THIRD)
(println m)
;; (#DummyEnum THIRD #DummyEnum THIRD #DummyEnum THIRD)

Two different values upon successive calls using m.  Is this expected?  And if 
so, why?

Many thanks,
-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/groups/opt_out.


Re: my first clojure wat moment - misunderstanding or bug?

2013-10-02 Thread Marek Kubica
On Wed, 2 Oct 2013 14:19:31 -0700 (PDT)
James Warren jameswarr...@gmail.com wrote:

 (defn foo [^Class c]
 ;; note: (into [] (keys (clojure.lang.Reflector/getStaticField c
 dummyMap works (keys (clojure.lang.Reflector/getStaticField c
 dummyMap))) 
 (def m (foo DummyClass))
 (println m)
 ;; (#DummyEnum FIRST #DummyEnum SECOND #DummyEnum THIRD)
 (println m)
 ;; (#DummyEnum THIRD #DummyEnum THIRD #DummyEnum THIRD)
 
 Two different values upon successive calls using m.  Is this
 expected?  And if so, why?

If I see this correnctly, you use keys on a map which is just not
preserving the order of the elements.

Unless I am missing something, this behaviour is pretty much to be
expected.

regards,
Marek

-- 
-- 
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/groups/opt_out.


[Semi OT] Staples Acquires Runa to Transform Shopping Experience Through Personalization

2013-10-02 Thread Angel Java Lopez
http://online.wsj.com/article/PR-CO-20131002-904169.html
The Runa facility in San Mateo will serve as the newest Staples Lab,
following locations in Seattle and Cambridge. In the coming months Staples
plans to increase the staff in San Mateo. Candidates with backgrounds in
Clojure programming, deep learning and data science who are interested in
applying are encouraged to check Staples' careers page to view openings.

-- 
-- 
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/groups/opt_out.


Re: [Semi OT] Staples Acquires Runa to Transform Shopping Experience Through Personalization

2013-10-02 Thread Russell Whitaker
On Wed, Oct 2, 2013 at 3:53 PM, Angel Java Lopez ajlopez2...@gmail.com wrote:
 http://online.wsj.com/article/PR-CO-20131002-904169.html
 The Runa facility in San Mateo will serve as the newest Staples Lab,
 following locations in Seattle and Cambridge. In the coming months Staples
 plans to increase the staff in San Mateo. Candidates with backgrounds in
 Clojure programming, deep learning and data science who are interested in
 applying are encouraged to check Staples' careers page to view openings.


This is excellent news for Runa, congratulations to them!

-- 
Russell Whitaker
http://twitter.com/OrthoNormalRuss
http://www.linkedin.com/pub/russell-whitaker/0/b86/329

-- 
-- 
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/groups/opt_out.


Re: [ANN]: ova 0.9.6 - the bestest mutable array ever! (with lots of documentation)

2013-10-02 Thread Adam Clements
Perfect timing, I just sat down to solve this exact problem, sketched out a
vague idea of what I wanted and then saw this which does everything I
needed but better!

It's really handy for Component/Entity/System designs, as it essentially
takes care of the whole entity part of the program and allows you to query
for sets of entities affected by a given system really easily in a
threadsafe way.

Thanks!

Adam

On Mon, Sep 30, 2013 at 1:33 AM, zcaudate z...@caudate.me wrote:

 http://z.caudate.me/ova/

 ova has been designed especially for dealing with shared mutable state in
 multi-threaded applications. Clojure uses refs and atoms off the shelf to
 resolve this issue but left out methods to deal with arrays of shared
 elements. ova has been specifically designed for the following use case:


- Elements (usually clojure maps) can be added or removed from an array
- Element data are accessible and mutated from several threads.
- Array itself can also be mutated from several threads.

 Github:

 https://github.com/zcaudate/ova

 --
 --
 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/groups/opt_out.


-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to 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/groups/opt_out.


Re: Problems starting with Clojure and Leiningen and Light Table

2013-10-02 Thread Zeynel
Ok. I created a project and there is core.clj file and I also ran the 
failing tests included in the project file. One thing I noticed the 
installer didn't do is that it did not put a shortcut to closure REPL on 
the start menu. I am just starting the windows command line from the start 
menu.


On Wednesday, October 2, 2013 12:41:12 PM UTC-4, Peter Mancini wrote:

 Ok, so you did not get lein working. If it were working you would not have 
 problems creating a new project. I know you are eager to press forward. 
 Admirable. However, it is what we call initiative without judgement. In the 
 world of engineering that is considered ill-advised. So, lets get back to 
 square 1.

 Delete everything involving lein from your machine. Purge your path and 
 other env variables of it as well. Start again.

 First, validate you have Java 7.

 Second, follow this again, to the letter. 
 http://leiningen-win-installer.djpowell.net/

 Third create a new project with lein new myproject. Change directory to 
 myproject/src/myproject and see if it created a core.clj file.

 If anything fails return to that step and look to see what the issue is. 
 You have to be more methodical. Every time you make more than one change 
 you create branching error probabilities. Do that 3 times and you have 8 
 times as many possible root causes for errors. Do it more and the 
 perplexity increases geometrically.


-- 
-- 
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/groups/opt_out.


Re: [ANN] 美味しいClojure

2013-10-02 Thread Marek Kubica
On Tue, 1 Oct 2013 22:01:02 -0700 (PDT)
Nicolas Modrzyk hellon...@gmail.com wrote:

 The whole text has also been written in English, so I guess there
 could be a chance to put it out there. 
 But we have had no contacts with US/UK publishers so far.

Did you try the usual suspects like O'Reilly or PragProg? They are
surprisingly approachable.

regards,
Marek

-- 
-- 
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/groups/opt_out.


Re: [ANN] 美味しいClojure

2013-10-02 Thread Alan Busby
On Thu, Oct 3, 2013 at 9:30 AM, Marek Kubica ma...@xivilization.net wrote:

 On Tue, 1 Oct 2013 22:01:02 -0700 (PDT)
 Nicolas Modrzyk hellon...@gmail.com wrote:

  The whole text has also been written in English, so I guess there
  could be a chance to put it out there.
  But we have had no contacts with US/UK publishers so far.

 Did you try the usual suspects like O'Reilly or PragProg? They are
 surprisingly approachable.


The O'Reilly Tokyo office is on the ground floor of where Tokyo.clj is
hosted too!

-- 
-- 
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/groups/opt_out.


Re: API management in Clojure

2013-10-02 Thread Mikera
Hi Jozef,

Sounds interesting - is it open source / can you give a URL?

Design question: Why are you interpreting resources as a reducible? I can 
see that making sense for some resources, but not for others.

As for complected - be careful not to confuse this with composed. It's 
perfectly reasonable to create higher order functionality by composing 
simpler components (which is what I am proposing in this case).

On Tuesday, 1 October 2013 15:50:53 UTC+8, Jozef Wagner wrote:

 Hi,

 Your approach seems very complected to me. What I'm currently working on 
 is the following concept:
 A resource type, which can be a file, url, some remote REST/SOAP resource 
 or e.g. a kestrel queue. Each resource has URI and can be used in following 
 ways:
 - as a regular reducible collection: resource is opened when reduce/fold 
 starts and closed after reduce is finished. 
 - as a normal function: opens resource, sends data, then returns the 
 response as an above reducible.
 - in an asynchronous way, in which case the 'async open' function returns 
 two channels, one for input and other for output. closed when you close the 
 output channel. 

 It provides all features you've mentioned. API in that case will be just a 
 collection of such resources. You can put them in a map, namespace, or 
 serialize them.

 Data format which is sent/recieved is resource-specific, but it is often a 
 byte collection. You can apply formatter on a resource that translate 
 between data formats (e.g. utf-8-char, json-clj-objects)

 JW


 On Tue, Oct 1, 2013 at 5:46 AM, Mikera mike.r.an...@gmail.comjavascript:
  wrote:

 Hi all,

 I'm curious about the options for managing APIs in Clojure code in a 
 relatively idiomatic / consistent / functional way. The features I'm 
 roughly interested in are:
 - ability to wrap a remote API in a regular Clojure function
 - abstraction away from the details of how the API is implemented (REST, 
 SOAP etc.)
 - sane handling for both async and synchronous calls (ideally building on 
 core.async)
 - possible serialisation of API references (e.g. you can send an API 
 function to another machine that can then call it)
 - sane default handling for standard stuff like timeouts, errors etc?

 I'm thinking of syntax roughly like:

 (defapi foo 
   :call (fn [x] (do-rest-call http://some.host/api/foo; x other-param))
   :timeout 1000
   :async true
   :on-error (fn [ex] (handle-exception ex)))
 = [an API object, probably a defrecord-like structure that implements 
 IFn] 

 (foo hello)
 = core.asyc channel that returns result of calling foo API

 ((sync foo) hello)
 = result of synchronously calling foo API

 (async? foo)
 = true

 ((modify foo {:timeout 100}) quick hello)
 = like (foo hello) but with a shorter timeout


 Has anyone built or seen anything like this? 
 If not, would this be a useful library / contrib?

  -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 --- 
 You received this message because you are subscribed to the Google Groups 
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to clojure+u...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to 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/groups/opt_out.


Re: my first clojure wat moment - misunderstanding or bug?

2013-10-02 Thread Elias Zaretsky
Are you using Java 6 by any chance? This issue may be due to a gotcha in 
java.util.EnumMap. The implementation of the entry set iterator in EnumMap 
in Java 6 is unorthodox [1]. Its next() method always returns the same 
object, which is mutated to point to different entries in the map as the 
iterator moves forward. This explains the behavior you are observing. Try 
switching to Java 7 or make sure you call the keys function every time you 
need the sequence of keys.

[1] 
http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/util/EnumMap.java#EnumMap.EntryIterator

Thanks,
Elias.

On Wednesday, October 2, 2013 5:19:31 PM UTC-4, James Warren wrote:

 I've been using Clojure for a couple months, so while I feel comfortable 
 with it, I'm not certain whether some unusual behavior I encountered is a 
 bug or a lack of understanding on my part.  (I suspect the latter.)

 The context arose from using Clojure reflection to inspect a class 
 generated by Apache Thrift http://thrift.apache.org. Such classes have 
 a static, unmodifiable map describing the members of the class. I wrote a 
 function to extract the keys of this map; it initially appears to work, but 
 defing the results to a symbol and repeatedly using that symbol returns 
 inconsistent results.

 I've boiled it down to a smaller example that replicates the result: (gist 
 available https://gist.github.com/jameswarren/6799309)

 // Java class

 public class DummyClass {
 public enum DummyEnum {
 FIRST, SECOND, THIRD
   }
  
   public static final MapDummyEnum, String dummyMap;
   static {
 MapDummyEnum, String tmpMap = new EnumMapDummyEnum, 
 String(DummyEnum.class);
 tmpMap.put(DummyEnum.FIRST, first);
 tmpMap.put(DummyEnum.SECOND, second);
 tmpMap.put(DummyEnum.THIRD, third);
 dummyMap = Collections.unmodifiableMap(tmpMap);
   }
 }

 // Clojure ns

 (ns refbug.core
   (:import [refbug DummyClass]))
  
 (defn foo [^Class c]
 ;; note: (into [] (keys (clojure.lang.Reflector/getStaticField c 
 dummyMap works
   (keys (clojure.lang.Reflector/getStaticField c dummyMap)))
  
 (def m (foo DummyClass))
 (println m)
 ;; (#DummyEnum FIRST #DummyEnum SECOND #DummyEnum THIRD)
 (println m)
 ;; (#DummyEnum THIRD #DummyEnum THIRD #DummyEnum THIRD)

 Two different values upon successive calls using m.  Is this expected?  And 
 if so, why?

 Many thanks,
 -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/groups/opt_out.


Re: How to generalize these functions

2013-10-02 Thread Leif

I think functions like this become pretty clear if you pull out 'unfold' 
and 'fold' utilites, like:
https://github.com/Prismatic/plumbing/blob/master/src/plumbing/map.clj#L42

Their 'flatten' generates a seq [path value] pairs, and 'unflatten' turns 
that back into a map.  With these, you can write your functions

(defn to-map [kv-seq] (into {} kv-seq)) ;; utility

(defn flatten-map [m kf vf]
  (- m
   flatten
   (map (fn [[ks v]] [(kf ks) (vf v)]))
   to-map))

(defn mapf [m f  args]
  (- m
   flatten
   (map (fn [[ks v]] [ks (apply f v args)]))
   unflatten))

(defn deep-merge-with [f  ms]
  (- ms
   (map flatten)
   (map to-map)
   (reduce (fn [res m] (merge-with f res m))) ;; could use 'partial'
   unflatten))

(defn deep-merge [a b]
  (deep-merge-with (fn [x y] y) a b))

;; bonus: also useful for fns that don't return a map
(defn max-depth [m]
  (- m
   flatten
   (map (comp count first))
   (apply max 0)))

I think these fns are the same as yours.  I have not tested them in any 
significant way, though.  I am also not thinking about performance.

Hope that helps,
Leif

On Wednesday, October 2, 2013 1:05:30 AM UTC-4, Yoshinori Kohyama wrote:

 Hi clojurians.

 I have functions for nested maps.
 They obviously have a same structure.
 Does anyone teach me a way to generalize them with a macro, a function or 
 an existing API?

 (defn flatten-map [m kf vf]
   (into {}
 ((fn g [kv n]
(if (map? n)
(apply concat
  (keep (fn [[k v]] (g (conj kv k) v)) n))
(if-let [kfkv (kf kv)]
  (if-let [vfn (vf n)]
[[kfkv vfn]]
  [] m)))

 (defn deep-merge [a b]
   (reduce (fn [a [kv n]] (assoc-in a kv n))
   a
   ((fn g [kv n]
  (if (map? n)
  (apply concat
(map (fn [[k v]] (g (conj kv k) v)) n))
  [[kv n]]))
[] b)))

 (defn mapf [m f  args]
   (reduce (fn [a [kv n]] (assoc-in a kv n))
   {}
   ((fn g [kv n]
  (if (map? n)
  (apply concat
(keep (fn [[k v]] (g (conj kv k) v)) n))
  (if-let [fna (apply f n args)]
[[kv fna]])))
[] m)))

 https://gist.github.com/kohyama/6789280 (with examples as tests)

 Regards,
 Yoshinori Kohyama


-- 
-- 
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/groups/opt_out.


Re: [ANN] 美味しいClojure

2013-10-02 Thread Dave Della Costa
Speaking of, is there anything other than Tokyo.clj (which seems pretty
infrequent based on this: http://atnd.org/event/tokyoclj) going on for
Clojurians in Tokyo?   I work remotely, using Clojure, and would love to
get together more frequently with other Clojure developers if possible.
 If anyone is interested in doing something like co-working on a more
regular basis, let me know!

Cheers,
DD

(2013/10/03 9:44), Alan Busby wrote:
 On Thu, Oct 3, 2013 at 9:30 AM, Marek Kubica ma...@xivilization.net
 mailto:ma...@xivilization.net wrote:
 
 On Tue, 1 Oct 2013 22:01:02 -0700 (PDT)
 Nicolas Modrzyk hellon...@gmail.com mailto:hellon...@gmail.com
 wrote:
 
  The whole text has also been written in English, so I guess there
  could be a chance to put it out there.
  But we have had no contacts with US/UK publishers so far.
 
 Did you try the usual suspects like O'Reilly or PragProg? They are
 surprisingly approachable.
 
 
 The O'Reilly Tokyo office is on the ground floor of where Tokyo.clj is
 hosted too! 
 
 -- 
 -- 
 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/groups/opt_out.

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to 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/groups/opt_out.