Re: Next release for clojure.tools.cli? Is it dead?

2015-07-27 Thread guns
On Thu 23 Jul 2015 at 09:33:13PM -0700, Keith Irwin wrote:

 There are some handy additions committed to the tools.cli project at:

 https://github.com/clojure/tools.cli

 but there hasn’t been a release in ~1.5 years (not even a snapshot
 release).

 In fact, these commits have been sitting there for over a year.

 I’m especially interested in this one:

 http://dev.clojure.org/jira/browse/TCLI-9

 Any chance of a new release?

Sean Corfield has volunteered to be the new maintainer of tools.cli, and
knowing Sean, there will likely be a new release very soon.

Sung Pae

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


signature.asc
Description: PGP signature


Re: Twitter bot crashing on Heroku

2015-07-27 Thread Pedro Santos
Are you actually binding to a port? I didn't find it in your code.
If you don't bind to the PORT env variable, heroku will fail. If you have a
bot you may not need to bind to a port... but heroku needs that on the
default web dynos. Don't know if you can skip that validation.

On Mon, Jul 27, 2015 at 12:08 PM, Gary Verhaegen gary.verhae...@gmail.com
wrote:

 Just peeked at your code, and it seems to indeed compile everything at
 startup. I'm not quite remembering all of the details, but I remember that
 Chestnut got it right: on Heroku, you can set things up so that an uberjar
 is created on git push and then started with java -jar on startup, which is
 usually much faster. See for example:


 https://github.com/plexus/chestnut/blob/master/src/leiningen/new/chestnut/Procfile

 I *think* it was enough to declare an :uberjar-name entry in the
 prpject.clj to trigger that behaviour on Heroku, but I am not quite sure.
 You'll have to experiment a bit (or hope someone else can answer more
 definitely).

 On Monday, 27 July 2015, Gary Verhaegen gary.verhae...@gmail.com wrote:

 the error message also sugget that your process may not have started
 quickly enough. How do you deploy on heroku? Do you have a Procfile? What
 does it say? Do you prepackage on push, or recompile everything on startup?

 On Monday, 27 July 2015, Divyansh Prakash divyanshprakas...@gmail.com
 wrote:

 Hi!

 I had written a poetry generator http://yushing.herokuapp.com/
 sometime back and wanted to convert it into a Twitter bot.
 I followed this tutorial https://howistart.org/posts/clojure/1 to do
 so. You can find my code here https://github.com/divs1210/yushing-bot.

 The bot's working fine from my local machine, but sporadically crashes
 on Heroku with the following message:

 2015-07-27T10:23:06.574908+00:00 heroku[web.1]: Error R10 (Boot
 timeout) - Web process failed to bind to $PORT within 60 seconds of launch
 2015-07-27T10:23:06.574908+00:00 heroku[web.1]: Stopping process with
 SIGKILL
 2015-07-27T10:23:07.550373+00:00 heroku[web.1]: Process exited with
 status 137
 2015-07-27T10:23:07.561392+00:00 heroku[web.1]: State changed from
 starting to crashed


  Some answers on SO suggest that this is because Heroku already provides
 a port to bind to and I might be trying to bind to some other port, but
 this is not the case.

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




-- 
Pedro Santos
Home - http://psantos.zi-yu.com

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


Re: Twitter bot crashing on Heroku

2015-07-27 Thread Gary Verhaegen
the error message also sugget that your process may not have started
quickly enough. How do you deploy on heroku? Do you have a Procfile? What
does it say? Do you prepackage on push, or recompile everything on startup?

On Monday, 27 July 2015, Divyansh Prakash divyanshprakas...@gmail.com
wrote:

 Hi!

 I had written a poetry generator http://yushing.herokuapp.com/ sometime
 back and wanted to convert it into a Twitter bot.
 I followed this tutorial https://howistart.org/posts/clojure/1 to do
 so. You can find my code here https://github.com/divs1210/yushing-bot.

 The bot's working fine from my local machine, but sporadically crashes on
 Heroku with the following message:

 2015-07-27T10:23:06.574908+00:00 heroku[web.1]: Error R10 (Boot timeout)
 - Web process failed to bind to $PORT within 60 seconds of launch
 2015-07-27T10:23:06.574908+00:00 heroku[web.1]: Stopping process with
 SIGKILL
 2015-07-27T10:23:07.550373+00:00 heroku[web.1]: Process exited with
 status 137
 2015-07-27T10:23:07.561392+00:00 heroku[web.1]: State changed from
 starting to crashed


  Some answers on SO suggest that this is because Heroku already provides a
 port to bind to and I might be trying to bind to some other port, but this
 is not the case.

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 javascript:_e(%7B%7D,'cvml','clojure@googlegroups.com');
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@googlegroups.com');
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com
 javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@googlegroups.com');.
 For more options, visit https://groups.google.com/d/optout.


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


Re: Twitter bot crashing on Heroku

2015-07-27 Thread Divyansh Prakash
Thanks for the response, everyone.

My Procfile says: 

 worker: lein trampoline run


I'm not binding to any port because my app doesn't require it.
How do I do so, though? Will it be available as a part of lein-environ?


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


Twitter bot crashing on Heroku

2015-07-27 Thread Divyansh Prakash
Hi!

I had written a poetry generator http://yushing.herokuapp.com/ sometime 
back and wanted to convert it into a Twitter bot.
I followed this tutorial https://howistart.org/posts/clojure/1 to do so. 
You can find my code here https://github.com/divs1210/yushing-bot.

The bot's working fine from my local machine, but sporadically crashes on 
Heroku with the following message:

 2015-07-27T10:23:06.574908+00:00 heroku[web.1]: Error R10 (Boot timeout) 
 - Web process failed to bind to $PORT within 60 seconds of launch
 2015-07-27T10:23:06.574908+00:00 heroku[web.1]: Stopping process with 
 SIGKILL
 2015-07-27T10:23:07.550373+00:00 heroku[web.1]: Process exited with status 
 137
 2015-07-27T10:23:07.561392+00:00 heroku[web.1]: State changed from 
 starting to crashed


 Some answers on SO suggest that this is because Heroku already provides a 
port to bind to and I might be trying to bind to some other port, but this 
is not the case.

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


WebService request are not getting served properly

2015-07-27 Thread hemant gautam
On running the below mentioned code on browser I am getting Page not 
found for each type of request.
Can anybody suggest me where I am doing a mistake. 

(ns currentday.core
(:require [compojure.core :refer :all]
  [compojure.route :as route]
  [compojure.handler :as handler]
  [ring.middleware.defaults :refer :all]
  [ring.util.response :refer :all])
(:use ring.adapter.jetty))

(defn now [] 
  (new java.util.Date))

(defn say-hello []
   Hello!! everyone. I am home page of webservice.)

(defn date-is [req]
  Today's date is:  (str (now)))

(defn get-date [req]
   (- (response (date-is))
   (content-type text/html)))

(defn add-data [a b]
   (- (response Sum of two no. is: (str (+ a b)))
   (content-type text/html)))

(defn sub-data [a b]
   (- (response Subtraction of two no. is: (str (- a b)))
   (content-type text/html)))

(defroutes my-routes
  (GET / [] Hello)
  (GET /date req (get-date [req]))
  (GET /add/:a/:b [a b] (add-data a b))
  (GET /sub/:a/:b [a b] (sub-data a b))
  (route/not-found Page not found))

(def app
  (handler/site my-routes))

(defonce server (run-jetty #'app {:port 3032 :join? false}))

-- 
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: Twitter bot crashing on Heroku

2015-07-27 Thread Gary Verhaegen
Just peeked at your code, and it seems to indeed compile everything at
startup. I'm not quite remembering all of the details, but I remember that
Chestnut got it right: on Heroku, you can set things up so that an uberjar
is created on git push and then started with java -jar on startup, which is
usually much faster. See for example:

https://github.com/plexus/chestnut/blob/master/src/leiningen/new/chestnut/Procfile

I *think* it was enough to declare an :uberjar-name entry in the
prpject.clj to trigger that behaviour on Heroku, but I am not quite sure.
You'll have to experiment a bit (or hope someone else can answer more
definitely).

On Monday, 27 July 2015, Gary Verhaegen gary.verhae...@gmail.com wrote:

 the error message also sugget that your process may not have started
 quickly enough. How do you deploy on heroku? Do you have a Procfile? What
 does it say? Do you prepackage on push, or recompile everything on startup?

 On Monday, 27 July 2015, Divyansh Prakash divyanshprakas...@gmail.com
 javascript:_e(%7B%7D,'cvml','divyanshprakas...@gmail.com'); wrote:

 Hi!

 I had written a poetry generator http://yushing.herokuapp.com/
 sometime back and wanted to convert it into a Twitter bot.
 I followed this tutorial https://howistart.org/posts/clojure/1 to do
 so. You can find my code here https://github.com/divs1210/yushing-bot.

 The bot's working fine from my local machine, but sporadically crashes on
 Heroku with the following message:

 2015-07-27T10:23:06.574908+00:00 heroku[web.1]: Error R10 (Boot timeout)
 - Web process failed to bind to $PORT within 60 seconds of launch
 2015-07-27T10:23:06.574908+00:00 heroku[web.1]: Stopping process with
 SIGKILL
 2015-07-27T10:23:07.550373+00:00 heroku[web.1]: Process exited with
 status 137
 2015-07-27T10:23:07.561392+00:00 heroku[web.1]: State changed from
 starting to crashed


  Some answers on SO suggest that this is because Heroku already provides
 a port to bind to and I might be trying to bind to some other port, but
 this is not the case.

 --
 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: What is the best way to pass log configs everywhere without a global var?

2015-07-27 Thread Gary Verhaegen
Have you guys looked at dire?

https://github.com/MichaelDrogalis/dire/blob/master/README.md

it could be used to take decomplection one step further, by not defining
monitoring things inline at all. A library author could define additional
logging namespace(s) with fns that load different levels of logging.

On Monday, 27 July 2015, Colin Yates colin.ya...@gmail.com wrote:

 I don’t have a proof of concept either but if somebody is going to put
 some effort into writing a new library I had a great idea they could
 incorporate. Continuing the ‘decomplecting’ that James started, the other
 thing that is decomplected (or actually not addressed at all) is _why_ we
 want logging to be produced. For me, I often want to see WARNING and above
 all the time and only see INFO and below if something interesting happened.
 ‘Interesting’ typically being an exception happened.

 My notion was to add an adapter which at some point (e.g. around the
 use-case service/transaction boundary) started collecting all the logs
 in-memory and if the service executed correctly would simply drop the INFO
 and below messages. However, if the service aborted (e.g. threw an
 Exception) only then would the INFO and below logs get written to disk.

 It’s so simple and useful I can’t believe nobody else has already written
 it. My excuse is good old time. Clojure, Agents, robert-hooke - couldn’t be
 easer.


 On 27 Jul 2015, at 08:28, crocket crockabisc...@gmail.com
 javascript:_e(%7B%7D,'cvml','crockabisc...@gmail.com'); wrote:

 Can I see your proof of concept on github? Is it just an idea?

 On Mon, Jul 27, 2015 at 2:27 PM, James Reeves ja...@booleanknot.com
 javascript:_e(%7B%7D,'cvml','ja...@booleanknot.com'); wrote:

 On 27 July 2015 at 05:25, crocket crockabisc...@gmail.com
 javascript:_e(%7B%7D,'cvml','crockabisc...@gmail.com'); wrote:


 How those logs are outputted is stored in a global state called log
 configuration. So, I think the separation was done.
 How else do you want to separate that?



 Traditionally, logging code is written something like:

(log/info HTTP request to (:request-method req) (:uri req))

 So the priority of the log (info) and the formatting of the log line is
 inlined into the source code.

 A less complected piece of code would separate out what we want to monitor
 (req) from how we monitor it. So inline we just write:

(monitor/monitor req :ring/request)

 This monitors the variable req and associates it with the namespaced
 keyword
 :ring/request. In our logging namespace, we can then later define how we
 want to report on that monitor:

(monitor/add-reporter
 :ring/request
 (fn [req] (log/info HTTP request to (:request-method req) (:uri
 req

 This separates *what* we want to monitor from *how* we eventually log it.
 It
 means we can do things like define a set of useful monitoring points in a
 library, and then in a separate application decide on what's important.

 - 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
 javascript:_e(%7B%7D,'cvml','clojure@googlegroups.com');
 Note that posts from new members are moderated - please be patient with
 your
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@googlegroups.com');
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups Clojure group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/clojure/9YiGAp6axcY/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 clojure+unsubscr...@googlegroups.com
 javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@googlegroups.com');.
 For more options, visit https://groups.google.com/d/optout.


 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 javascript:_e(%7B%7D,'cvml','clojure@googlegroups.com');
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@googlegroups.com');
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com
 javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@googlegroups.com');.
 For more options, visit https://groups.google.com/d/optout.


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

Re: WebService request are not getting served properly

2015-07-27 Thread hemant gautam
Hi Gary, 

You are right, the points that you mentioned are valid. Those things are 
already taken care of. I am new to Ring and Compojure so was trying out 
some stuff.
I was confused at some part, but now it got cleared and code if running as 
required.

Thanks for your time and reply.

On Monday, July 27, 2015 at 5:50:10 PM UTC+5:30, Gary Verhaegen wrote:



 On Monday, 27 July 2015, hemant gautam gomz...@gmail.com javascript: 
 wrote:

 On running the below mentioned code on browser I am getting Page not 
 found for each type of request.
 Can anybody suggest me where I am doing a mistake. 

 (ns currentday.core
 (:require [compojure.core :refer :all]
   [compojure.route :as route]
   [compojure.handler :as handler]
   [ring.middleware.defaults :refer :all]
   [ring.util.response :refer :all])
 (:use ring.adapter.jetty))

 (defn now [] 
   (new java.util.Date))

 (defn say-hello []
Hello!! everyone. I am home page of webservice.)

 (defn date-is [req]
   Today's date is:  (str (now)))

 (defn get-date [req]
(- (response (date-is))
(content-type text/html)))

 (defn add-data [a b]
(- (response Sum of two no. is: (str (+ a b)))
(content-type text/html)))

 (defn sub-data [a b]
(- (response Subtraction of two no. is: (str (- a b)))
(content-type text/html)))

 (defroutes my-routes
   (GET / [] Hello)
   (GET /date req (get-date [req]))
   (GET /add/:a/:b [a b] (add-data a b))
   (GET /sub/:a/:b [a b] (sub-data a b))
   (route/not-found Page not found))

 (def app
   (handler/site my-routes))

 (defonce server (run-jetty #'app {:port 3032 :join? false}))


 I'm not in a position to actually try that code, so I'm shooting blind. 
 Here are a few comments:

 * You do not seem to be using the ring.middleware.defaults, but instead 
 use the deprecated compojure.handler ns.
 * Your say-hello function is not used.
 * Your / route returns a String, which as far as I know is not a valid 
 ring response. Try with {:status 200 :body Hello!} instead of just a 
 string?
 * Your add and subtract handlers look like they should throw exceptions, 
 as you're calling response with 2 args and it's defined to receive a single 
 string argument.
 * From what I see here, I do not see any reason why the /date route does 
 not work.


-- 
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: WebService request are not getting served properly

2015-07-27 Thread Colin Yates
Hi Hermant, are you running this at a REPL? What URL exactly are you going to 
(http://localhost:3032/ http://localhost:3032/ should work if the server is 
running)?
 
 On 27 Jul 2015, at 10:55, hemant gautam gomze...@gmail.com wrote:
 
 On running the below mentioned code on browser I am getting Page not found 
 for each type of request.
 Can anybody suggest me where I am doing a mistake.
 
 (ns currentday.core
 (:require [compojure.core :refer :all]
   [compojure.route :as route]
   [compojure.handler :as handler]
   [ring.middleware.defaults :refer :all]
   [ring.util.response :refer :all])
 (:use ring.adapter.jetty))
 (defn now [] 
   (new java.util.Date))
 
 (defn say-hello []
Hello!! everyone. I am home page of webservice.)
 
 (defn date-is [req]
   Today's date is:  (str (now)))
 
 (defn get-date [req]
(- (response (date-is))
(content-type text/html)))
 
 (defn add-data [a b]
(- (response Sum of two no. is: (str (+ a b)))
(content-type text/html)))
 
 (defn sub-data [a b]
(- (response Subtraction of two no. is: (str (- a b)))
(content-type text/html)))
 
 (defroutes my-routes
   (GET / [] Hello)
   (GET /date req (get-date [req]))
   (GET /add/:a/:b [a b] (add-data a b))
   (GET /sub/:a/:b [a b] (sub-data a b))
   (route/not-found Page not found))
 
 (def app
   (handler/site my-routes))
 
 (defonce server (run-jetty #'app {:port 3032 :join? false}))
 
 
 -- 
 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 
 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 
 mailto:clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout 
 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: Twitter bot crashing on Heroku

2015-07-27 Thread Divyansh Prakash
Thanks for the response, everyone.

My Procfile says: 

 worker: lein trampoline run


I'm not binding to any port because my app doesn't require it.
How do I do so, though? Will it be available as a part of lein-environ?

-- 
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: WebService request are not getting served properly

2015-07-27 Thread Gary Verhaegen
On Monday, 27 July 2015, hemant gautam gomze...@gmail.com wrote:

 On running the below mentioned code on browser I am getting Page not
 found for each type of request.
 Can anybody suggest me where I am doing a mistake.

 (ns currentday.core
 (:require [compojure.core :refer :all]
   [compojure.route :as route]
   [compojure.handler :as handler]
   [ring.middleware.defaults :refer :all]
   [ring.util.response :refer :all])
 (:use ring.adapter.jetty))

 (defn now []
   (new java.util.Date))

 (defn say-hello []
Hello!! everyone. I am home page of webservice.)

 (defn date-is [req]
   Today's date is:  (str (now)))

 (defn get-date [req]
(- (response (date-is))
(content-type text/html)))

 (defn add-data [a b]
(- (response Sum of two no. is: (str (+ a b)))
(content-type text/html)))

 (defn sub-data [a b]
(- (response Subtraction of two no. is: (str (- a b)))
(content-type text/html)))

 (defroutes my-routes
   (GET / [] Hello)
   (GET /date req (get-date [req]))
   (GET /add/:a/:b [a b] (add-data a b))
   (GET /sub/:a/:b [a b] (sub-data a b))
   (route/not-found Page not found))

 (def app
   (handler/site my-routes))

 (defonce server (run-jetty #'app {:port 3032 :join? false}))


I'm not in a position to actually try that code, so I'm shooting blind.
Here are a few comments:

* You do not seem to be using the ring.middleware.defaults, but instead use
the deprecated compojure.handler ns.
* Your say-hello function is not used.
* Your / route returns a String, which as far as I know is not a valid
ring response. Try with {:status 200 :body Hello!} instead of just a
string?
* Your add and subtract handlers look like they should throw exceptions, as
you're calling response with 2 args and it's defined to receive a single
string argument.
* From what I see here, I do not see any reason why the /date route does
not work.

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


[clojure-rabbitmq] ANN Langohr 3.3.0 is released

2015-07-27 Thread Michael Klishin
Langohr [1] is a small, feature complete Clojure client for RabbitMQ. 

Release notes:
http://blog.clojurewerkz.org/blog/2015/07/27/langohr-3-dot-3-0-is-released/

1. http://clojurerabbitmq.info
--  
MK  

Staff Software Engineer, Pivotal/RabbitMQ  


-- 
You received this message because you are subscribed to the Google Groups 
clojure-rabbitmq group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure-rabbitmq+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Generating varying sized map using test.check

2015-07-27 Thread Mayank Jain

 On 27 July 2015 at 18:10, Carlo Zancanaro carlozancan...@gmail.com
 wrote:

 You're generating two random things: the map, and the subset of the keys.
 You can't generate the subset of the keys without first knowing the full
 set of keys, so bind lets you make the subset generator depend on the
 result of the map generator.

 Thanks. That makes sense.

-- 
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: Generating varying sized map using test.check

2015-07-27 Thread Carlo Zancanaro
Whoops, forgot the group on this.

On 27 July 2015 at 18:10, Carlo Zancanaro carlozancan...@gmail.com wrote:

 You're generating two random things: the map, and the subset of the keys.
 You can't generate the subset of the keys without first knowing the full
 set of keys, so bind lets you make the subset generator depend on the
 result of the map generator.

 I should also point out that shrinking isn't the only problem with your
 original function. Normally in test.check you can repeat a test case by
 providing a seed to the generator. With your original code it would be more
 difficult to repeat a test case.
 On 27/07/2015 5:14 pm, Mayank Jain firesof...@gmail.com wrote:


 It also might be helpful to know that there is already a subset generator
 available in this library
 https://github.com/gfredericks/test.chuck#generators.


 Thanks, this looks good, will check it out.


 What you've done here might appear to work, but it will get you into
 trouble when test.check starts to shrink your inputs. When test.check runs
 your generators it relies you you using it as your only source of
 randomness, and so your use of `rand-int` will cause some problems.


 Ah yes, I didn't think of shrinking.
 Thanks a lot for your help! :)



 The trick is to use the `bind` function to make a generator which
 depends on the value of another generator (in this case, to capture the
 generated map so you can call rand-subset with the correct set of keys):



  I didn't get why I had to use a bind here. What if I had only used fmap?



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


New Functional Programming Job Opportunities

2015-07-27 Thread Functional Jobs
Here are some functional programming job opportunities that were posted

recently:



Software Developer | Scala, Clojure | Spark, Solr, Agile at Elmar Reizen

http://functionaljobs.com/jobs/8848-software-developer--scala-clojure--spark-solr-agile-at-elmar-reizen



Cheers,

Sean Murphy

FunctionalJobs.com


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


[bug] Reflector can't resolve a method in a non-public generic-typed abstact class

2015-07-27 Thread Alexander Yakushev
Reproducible minimal example 
here: https://github.com/alexander-yakushev/generics-reflection-bug . Clone 
it and do `lein run`.

The example is small enough to paste it here. So we have a class called 
AbstractStorage:

abstract class AbstractStorageT {

T thingToStore;

public AbstractStorage(T thingToStore) {
this.thingToStore = thingToStore;
}

public T get() {
return thingToStore;
}

}

It is a non-public abstract generic-typed class. It's only use is to store 
some object of the type T, and give out that object when get() is called. 
Simple enough.

Then we have a concrete implementation of that class, StringStorage:

public class StringStorage extends AbstractStorageString {

public StringStorage(String thingToStore) {
super(thingToStore);
}

}

It is even simpler. It just extends the abstract class and says that the 
type of object it will hold is a String. The constructor just passes the 
call up to AbstractStorage.

Now comes the trouble. When you try to do the following from Clojure:

(.get (StringStorage. hello))

It fails with:

Exception in thread main java.lang.IllegalArgumentException: Can't call 
public method of non-public class: public java.lang.Object 
bug.AbstractStorage.get(), 
compiling:(/tmp/form-init579170128820879977.clj:1:72)
at clojure.lang.Compiler.load(Compiler.java:7239)
at clojure.lang.Compiler.loadFile(Compiler.java:7165)
at clojure.main$load_script.invoke(main.clj:275)
at clojure.main$init_opt.invoke(main.clj:280)
at clojure.main$initialize.invoke(main.clj:308)
at clojure.main$null_opt.invoke(main.clj:343)
at clojure.main$main.doInvoke(main.clj:421)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:383)
at clojure.lang.AFn.applyToHelper(AFn.java:156)
at clojure.lang.Var.applyTo(Var.java:700)
at clojure.main.main(main.java:37)
Caused by: java.lang.IllegalArgumentException: Can't call public method of 
non-public class: public java.lang.Object bug.AbstractStorage.get()
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:88)
at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:28)
at bug.core$_main.doInvoke(core.clj:9)
at clojure.lang.RestFn.invoke(RestFn.java:397)
at clojure.lang.Var.invoke(Var.java:375)
at user$eval2912.invoke(form-init579170128820879977.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6782)
at clojure.lang.Compiler.eval(Compiler.java:6772)
at clojure.lang.Compiler.load(Compiler.java:7227)
... 11 more

I tried to type-hint the call, but neither of the following work:

  (.get ^AbstractStorage (StringStorage. hello))
  (.get ^StringStorage (StringStorage. hello))

I suppose hinting to AbstractStorage should have helped, but because the 
actual class has a generic type, the classes mismatch and Reflector is 
still invoked. Any ideas what to do with this?

P.S.: As I was finishing writing this. I found the reported bug on JIRA: 
CLJ-1243 http://dev.clojure.org/jira/browse/CLJ-1243. Still, I suppose it 
will be useful to have a minimal reproducible example for this bug, and to 
remind it exists.

-- 
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: a question about Chris Zheng's Abstract Container Pattern

2015-07-27 Thread Lawrence Krubner



I guess I'm wondering why take Zheng's approach, versus something more 
direct? I'm especially reacting to this: 

One way to look at design using abstract classes (or any language feature 
for that matter) is that it is a programming contract that is strictly 
enforced by the language itself. When we inherit functionality from an 
abstract class, we make a binding contract with the compiler.

…Essentially, it mimics the structure of how abstract classes are defined 
and used in object orientated design through simple use of protocols and 
multimethods.

But why mimic such a contract? Why not just clearly write a contract, using 
a library that is meant to write contracts? I mean, why not use something 
like Typed Clojure? 






On Monday, July 27, 2015 at 1:37:41 PM UTC-4, Lawrence Krubner wrote:

 I have a question about this: 

 Servers that are running on a particular port can be tracked and stopped. 
 I have to say, this was the feature that I wanted the most, which motivated 
 the framework's design. The annoying thing about development in emacs is 
 that I have to be careful of not losing the reference to the server. Since 
 there was no way of stopping it unless the repl is restarted. I wanted to 
 implement a registery for references to running servers to be saved.

 http://z.caudate.me/the-abstract-container-pattern/

 I have the impression that he's going over the same territory as that 
 covered by Stuart Sierra, though Zheng doesn't mention Component nor 
 Sierra. But he offers this as an example of what he's after: 

 (defprotocol IRunnable (start! [system]) (stop! [system]) (restart! 
 [system]) (started? [system]) (stopped? [system]))

 That much seems similar to Sierra's system. Zheng seems to add an 
 additional layer by simulating an abstract class above his protocols. As he 
 says: 


- A single deftype acts as the *abstract container*, extending one or 
more protocols
- A set of methods defined through defmulti that is used within the 
deftype form act as *abstract methods*
- The *abstract methods* all dispatch on map keys (usually :type).


 I am curious if others have found this useful? 

 Most of the people who work with Clojure have backgrounds with Object 
 Oriented Programming, so that paradigm sometimes seems natural, or at least 
 familiar. I often think these designs are more verbose than they need to 
 be, but I am curious how others feel. 











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


a question about Chris Zheng's Abstract Container Pattern

2015-07-27 Thread Lawrence Krubner
I have a question about this: 

Servers that are running on a particular port can be tracked and stopped. 
I have to say, this was the feature that I wanted the most, which motivated 
the framework's design. The annoying thing about development in emacs is 
that I have to be careful of not losing the reference to the server. Since 
there was no way of stopping it unless the repl is restarted. I wanted to 
implement a registery for references to running servers to be saved.

http://z.caudate.me/the-abstract-container-pattern/

I have the impression that he's going over the same territory as that 
covered by Stuart Sierra, though Zheng doesn't mention Component nor 
Sierra. But he offers this as an example of what he's after: 

(defprotocol IRunnable (start! [system]) (stop! [system]) (restart! [system]
) (started? [system]) (stopped? [system]))

That much seems similar to Sierra's system. Zheng seems to add an 
additional layer by simulating an abstract class above his protocols. As he 
says: 


   - A single deftype acts as the *abstract container*, extending one or 
   more protocols
   - A set of methods defined through defmulti that is used within the 
   deftype form act as *abstract methods*
   - The *abstract methods* all dispatch on map keys (usually :type).


I am curious if others have found this useful? 

Most of the people who work with Clojure have backgrounds with Object 
Oriented Programming, so that paradigm sometimes seems natural, or at least 
familiar. I often think these designs are more verbose than they need to 
be, but I am curious how others feel. 









-- 
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 is the best way to pass log configs everywhere without a global var?

2015-07-27 Thread James Reeves
On 27 July 2015 at 08:28, crocket crockabisc...@gmail.com wrote:

 Can I see your proof of concept on github? Is it just an idea?


Well, my first attempt at this was Inquest:
https://github.com/weavejester/inquest

The idea of Inquest was to (ab)use alter-var-root to insert monitoring into
existing functions, but I quickly discovered that there were quite a few
anonymous functions I would like to monitor, as well as specific variables
inside functions. I played around with ways of wrapping functions to inject
monitoring of arguments and return values, but in the end it felt too
clumsy and complicated.

So instead, I've been considering a macro like:

(monitor key  body)

For example, if you wrote:

(let [x 10] (monitor :user/example (inc x)))

This would produce messages that look like this:

{:tag :user/example
 :timestamp 468822291902146
 :thread-id 1502
 :namespace user
 :event :enter
 :form (inc x)
 :locals {x 10}}

{:tag :user/example
 :timestamp 468822291902261
 :thread-id 1502
 :namespace user
 :event :exit
 :form (inc x)
 :locals {x 10}
 :return 11
 :duration 115}

These messages would be passed to any listeners interested in the tag
:user/example. If there were no appropriate listeners, the macro would
execute the code without any additional wrapping. I've also been
considering having the listeners declare ahead of time what keys they're
interested in, as some keys might be expensive to generate (e.g. a
:stacktrace key).

The upshot is that you'd get a whole bunch of information that you could
then narrow down to produce any output you happen to want. If you're not
interested in listening to a particular monitor, then there's minimal
performance impact (perhaps around 50ns).

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


Re: Twitter bot crashing on Heroku

2015-07-27 Thread Carin Meier
By default, Heroku sets up a web worker for your project.  Check your 
project resources.  It sounds like you have an extra web worker setup 
trying to bind to the port.

- Carin



On Monday, July 27, 2015 at 10:04:16 AM UTC-4, Divyansh Prakash wrote:

 Thanks for the response, everyone.

 My Procfile says: 

 worker: lein trampoline run


 I'm not binding to any port because my app doesn't require it.
 How do I do so, though? Will it be available as a part of lein-environ?


-- 
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: a question about Chris Zheng's Abstract Container Pattern

2015-07-27 Thread Colin Yates
I think his last sentence gives you the answer:

A warm shoutout to Tushar, Lyndon, Dean, Alan, Hank, Derek, and all the guys 
at clj-melb that gave feedback and helped flesh out this rehash of OO design.” 
(my emphasis)

He wanted an OO approach and has implemented one; specifically behaviour and 
state coupled together. I think neither Typed Clojure nor Contracts would have 
achieved this guy’s goal as they are about enforcing a contract (either the 
shape of data or effects of a fn) in the ‘functional’ paradigm; this guy 
clearly wanted something in the OO paradigm. 

Is there a ‘functional’ implementation which gives the same benefits; sure, but 
that isn’t what he wanted. Are there a bunch of ‘upgrades’ that I am sure we 
could all apply; sure, but again it seems like he was setting out with a very 
specific goal in mind and has achieved that. 

 On 27 Jul 2015, at 18:37, Lawrence Krubner lawre...@rollioforce.com wrote:
 
 I have a question about this: 
 
 Servers that are running on a particular port can be tracked and stopped. I 
 have to say, this was the feature that I wanted the most, which motivated the 
 framework's design. The annoying thing about development in emacs is that I 
 have to be careful of not losing the reference to the server. Since there was 
 no way of stopping it unless the repl is restarted. I wanted to implement a 
 registery for references to running servers to be saved.
 
 http://z.caudate.me/the-abstract-container-pattern/
 
 I have the impression that he's going over the same territory as that covered 
 by Stuart Sierra, though Zheng doesn't mention Component nor Sierra. But 
 he offers this as an example of what he's after: 
 
 (defprotocol IRunnable
   (start! [system])
   (stop!  [system])
   (restart! [system])
   (started? [system])
   (stopped? [system]))
 
 That much seems similar to Sierra's system. Zheng seems to add an additional 
 layer by simulating an abstract class above his protocols. As he says: 
 
 A single deftype acts as the abstract container, extending one or more 
 protocols
 A set of methods defined through defmulti that is used within the deftype 
 form act as abstract methods
 The abstract methods all dispatch on map keys (usually :type).
 
 I am curious if others have found this useful? 
 
 Most of the people who work with Clojure have backgrounds with Object 
 Oriented Programming, so that paradigm sometimes seems natural, or at least 
 familiar. I often think these designs are more verbose than they need to be, 
 but I am curious how others feel. 
 
 
 
 
 
 
 
 
 
 
 -- 
 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 
 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 
 mailto:clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout 
 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 1.8.0-alpha2

2015-07-27 Thread Lawrence Krubner
Off topic, but I wonder if there was ever any discussion of megarefs being 
added to Clojure?

https://github.com/cgrand/megaref


On Tuesday, July 21, 2015 at 3:30:46 PM UTC-4, Rangel Spasov wrote:

 Ok, I think someone already mentioned this - sorry. Got it to compile by 
 bumping to [potemkin 0.4.1] - thanks Zach + all : ) 

 On Tuesday, July 21, 2015 at 12:24:43 PM UTC-7, Rangel Spasov wrote:

 Hey guys,

 Getting this error with 1.8.0-alpha2, I think related to aleph (using 
 0.4.0, latest version at the moment).

 #error {

  :cause IllegalName: 
 compile__stub.aleph.http.core.aleph.http.core/HeaderMap

  :via

  [{:type clojure.lang.Compiler$CompilerException

:message java.lang.NoClassDefFoundError: IllegalName: 
 compile__stub.aleph.http.core.aleph.http.core/HeaderMap, 
 compiling:(aleph/http/core.clj:81:1)

:at [clojure.lang.Compiler analyzeSeq Compiler.java 6798]}

   {:type java.lang.NoClassDefFoundError

:message IllegalName: 
 compile__stub.aleph.http.core.aleph.http.core/HeaderMap

:at [java.lang.ClassLoader preDefineClass ClassLoader.java 654]}]

  :trace

  [[java.lang.ClassLoader preDefineClass ClassLoader.java 654]

   [java.lang.ClassLoader defineClass ClassLoader.java 758]

   [java.lang.ClassLoader defineClass ClassLoader.java 642]

   [clojure.lang.DynamicClassLoader defineClass DynamicClassLoader.java 46]

   [clojure.lang.Compiler$NewInstanceExpr compileStub Compiler.java 7815]

   [clojure.lang.Compiler$NewInstanceExpr build Compiler.java 7680]

   [clojure.lang.Compiler$NewInstanceExpr$DeftypeParser parse 
 Compiler.java 7590]

   [clojure.lang.Compiler analyzeSeq Compiler.java 6791]

   [clojure.lang.Compiler analyze Compiler.java 6592]

   [clojure.lang.Compiler analyze Compiler.java 6553]

   [clojure.lang.Compiler$BodyExpr$Parser parse Compiler.java 5929]

   [clojure.lang.Compiler$LetExpr$Parser parse Compiler.java 6247]

   [clojure.lang.Compiler analyzeSeq Compiler.java 6791]

   [clojure.lang.Compiler analyze Compiler.java 6592]

   [clojure.lang.Compiler analyze Compiler.java 6553]

   [clojure.lang.Compiler$BodyExpr$Parser parse Compiler.java 5929]

   [clojure.lang.Compiler$FnMethod parse Compiler.java 5359]

   [clojure.lang.Compiler$FnExpr parse Compiler.java 3959]

   [clojure.lang.Compiler analyzeSeq Compiler.java 6789]

   [clojure.lang.Compiler analyze Compiler.java 6592]

   [clojure.lang.Compiler eval Compiler.java 6847]

   [clojure.lang.Compiler eval Compiler.java 6839]

   [clojure.lang.Compiler load Compiler.java 7295]

   [clojure.lang.RT loadResourceScript RT.java 372]

   [clojure.lang.RT loadResourceScript RT.java 363]

   [clojure.lang.RT load RT.java 453]

   [clojure.lang.RT load RT.java 419]

   [clojure.core$load$fn__5448 invoke core.clj 5866]

   [clojure.core$load doInvoke core.clj 5865]

   [clojure.lang.RestFn invoke RestFn.java 408]

   [clojure.core$load_one invoke core.clj 5671]

   [clojure.core$load_lib$fn__5397 invoke core.clj 5711]

   [clojure.core$load_lib doInvoke core.clj 5710]

   [clojure.lang.RestFn applyTo RestFn.java 142]

   [clojure.core$apply invoke core.clj 632]

   [clojure.core$load_libs doInvoke core.clj 5749]

   [clojure.lang.RestFn applyTo RestFn.java 137]

   [clojure.core$apply invoke core.clj 632]

   [clojure.core$require doInvoke core.clj 5832]

   [clojure.lang.RestFn invoke RestFn.java 551]

   [aleph.http.server$eval9251$loading__5340__auto9252 invoke 
 server.clj 1]

   [aleph.http.server$eval9251 invoke server.clj 1]

   [clojure.lang.Compiler eval Compiler.java 6850]

   [clojure.lang.Compiler eval Compiler.java 6839]

   [clojure.lang.Compiler load Compiler.java 7295]

   [clojure.lang.RT loadResourceScript RT.java 372]

   [clojure.lang.RT loadResourceScript RT.java 363]

   [clojure.lang.RT load RT.java 453]

   [clojure.lang.RT load RT.java 419]

   [clojure.core$load$fn__5448 invoke core.clj 5866]

   [clojure.core$load doInvoke core.clj 5865]

   [clojure.lang.RestFn invoke RestFn.java 408]

   [clojure.core$load_one invoke core.clj 5671]

   [clojure.core$load_lib$fn__5397 invoke core.clj 5711]

   [clojure.core$load_lib doInvoke core.clj 5710]

   [clojure.lang.RestFn applyTo RestFn.java 142]

   [clojure.core$apply invoke core.clj 632]

   [clojure.core$load_libs doInvoke core.clj 5753]

   [clojure.lang.RestFn applyTo RestFn.java 137]

   [clojure.core$apply invoke core.clj 632]

   [clojure.core$require doInvoke core.clj 5832]

   [clojure.lang.RestFn invoke RestFn.java 457]

   [aleph.http$eval1594$loading__5340__auto1595 invoke http.clj 1]

   [aleph.http$eval1594 invoke http.clj 1]

   [clojure.lang.Compiler eval Compiler.java 6850]

   [clojure.lang.Compiler eval Compiler.java 6839]

   [clojure.lang.Compiler load Compiler.java 7295]

   [clojure.lang.RT loadResourceScript RT.java 372]

   [clojure.lang.RT loadResourceScript RT.java 363]

   [clojure.lang.RT load RT.java 453]

   [clojure.lang.RT load RT.java 419]

   [clojure.core$load$fn__5448 invoke core.clj 5866]

 

[ANN] clojure.java.jdbc 0.4.1

2015-07-27 Thread Sean Corfield
Clojure contrib library that provides JDBC wrapper.

https://github.com/clojure/java.jdbc

• Release 0.4.0 / 0.4.1 on 2015-07-26
• db-do-prepared now allows transaction? to be omitted when a 
PreparedStatement is passed as the second argument JDBC-111 - Stefan Kamphausen.
• Nested transaction checks isolation level is the same JDBC-110 - 
Donald Ball (new contributor!).
• Default PostgreSQL port; Support more dbtype/dbname variants JDBC-109.
• Drop Clojure 1.2 compatibility.

The jump from 0.3.7 to 0.4.x is because I'm dropping Clojure 1.2 compatibility.

(if anyone wonders why 0.4.0 and 0.4.1 are the same release, it was finger 
trouble while trying to run the Maven Release Build on the Clojure build 
server… sorry!)

Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

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 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 Langohr 3.3.0 is released

2015-07-27 Thread Michael Klishin
Langohr [1] is a small, feature complete Clojure client for RabbitMQ.  

Release notes:  
http://blog.clojurewerkz.org/blog/2015/07/27/langohr-3-dot-3-0-is-released/ 

1. http://clojurerabbitmq.info  
--  
MK  


-- 
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: Java 8 Lambda Interop

2015-07-27 Thread Andrew Oberstar
Thanks for the reply Gary. Sounds like I'm on as good a track as I can be
with current Clojure.

I am curious though why you say that it is unrealistic for IFn to support
arbitrary @FunctionalInterface. It certainly seems like it would require
compiler changes, but I would think that either through emitting bytecode
closer to Java 8 lambdas or through some form of type coercion it would
possible. For example, Groovy just coerces their Closures to any Single
Abstract Method type.

I'm not sure how java.util.function.* as protocols would work, but still
would require implementing for each SAM you come across. IFn as a protocol
seems to address a different interop use case. Maybe for receiving a Java
lambda you want to use as if it's a Clojure function.

Most of the Java interop from Clojure is slick (sometimes more clear than
in Java itself), it would be unfortunate to leave functions as second-class
citizens for interop. Granted, there may be a simplicity argument against
this (maybe that's why Java varargs require an explicit array?).

Andrew Oberstar

On Mon, Jul 27, 2015 at 4:16 AM Gary Verhaegen gary.verhae...@gmail.com
wrote:

 On Sunday, 26 July 2015, Andrew Oberstar ajobers...@gmail.com wrote:

 Hi,

 I'm wondering if anyone has a good approach for making calls from Clojure
 to Java APIs (e.g. Stream API) that expect a @FunctionalInterface type.

 Ideally, IFn would transparently work, but I'm guessing that requires
 some compiler changes.

 Right now, the best I can think of is a function or macro to reify a
 wrapper around a Clojure function to implement all of the usual interfaces
 from java.util.function.

 Anyone have any better ideas?

 Andrew Oberstar


 You're probably aware of this, but @FunctionalInterface is not a type,
 it's an annotation. All it does is ensure, at compile time, that the
 annotated element is an interface with a single non-default and non-static
 method. At the type-system level, it's just an interface like any other,
 and the lambda syntax is just a shorthand for an anonymous instance of a
 well-defined type.

 Since the lambda syntax is java-compiler magic, you can't access it from
 Clojure, and the most straightforward option right now is to actually know
 which type is expected, e.g.:

 user= (- (doto (java.util.ArrayList.) (.add 1) (.add 2)) (.stream) (.map
 (reify java.util.function.Function (apply [_ arg] (inc arg (.collect
 (java.util.stream.Collectors/toList)))
 [2 3]
 user=

 As neither IFn nor Function are Clojure protocols, I do indeed think
 you're best bet is a macro to essentially generate the above reify. You can
 of course do a single macro that reifies to all of the protocols that you
 need.

 I don't think it's realistic to hope that IFn will cover any arbitrary
 @FunctionalInterface, as that is Java compiler magic. It may, in the
 future, be extended to cover all of the standard ones in
 java.util.function, or even all the ones in the standard library, but it's
 not going to happen until Java 7 support is dropped. I guess the best you
 could hope for in the short term would be to have IFn changed to a protocol.

 --
 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: Java 8 Lambda Interop

2015-07-27 Thread Mikera
It could certainly be achieved in the Clojure compiler, by allowing 
(some-functional-interface .) to compile to the appropriate function 
call even if it doesn't implement IFn

It would be quite a big change though and would probably have some 
limitations, e.g.:
a) It probably wouldn't work with regular vars since it wouldn't be able to 
handle re-binding
b) You would probably have to type hint the some-functional-interface 
object in some way so that the compiler knows to do this at compile time

A less invasive option would be to just have some code to wrap functional 
interfaces in an appropriate IFn.

Worth a JIRA ticket for consideration at least?



On Tuesday, 28 July 2015 08:52:47 UTC+8, Andrew Oberstar wrote:

 Thanks for the reply Gary. Sounds like I'm on as good a track as I can be 
 with current Clojure.

 I am curious though why you say that it is unrealistic for IFn to support 
 arbitrary @FunctionalInterface. It certainly seems like it would require 
 compiler changes, but I would think that either through emitting bytecode 
 closer to Java 8 lambdas or through some form of type coercion it would 
 possible. For example, Groovy just coerces their Closures to any Single 
 Abstract Method type.

 I'm not sure how java.util.function.* as protocols would work, but still 
 would require implementing for each SAM you come across. IFn as a protocol 
 seems to address a different interop use case. Maybe for receiving a Java 
 lambda you want to use as if it's a Clojure function. 

 Most of the Java interop from Clojure is slick (sometimes more clear than 
 in Java itself), it would be unfortunate to leave functions as second-class 
 citizens for interop. Granted, there may be a simplicity argument against 
 this (maybe that's why Java varargs require an explicit array?).

 Andrew Oberstar

 On Mon, Jul 27, 2015 at 4:16 AM Gary Verhaegen gary.ve...@gmail.com 
 javascript: wrote:

 On Sunday, 26 July 2015, Andrew Oberstar ajobe...@gmail.com 
 javascript: wrote:

 Hi,

 I'm wondering if anyone has a good approach for making calls from 
 Clojure to Java APIs (e.g. Stream API) that expect a @FunctionalInterface 
 type.

 Ideally, IFn would transparently work, but I'm guessing that requires 
 some compiler changes.

 Right now, the best I can think of is a function or macro to reify a 
 wrapper around a Clojure function to implement all of the usual interfaces 
 from java.util.function.

 Anyone have any better ideas?

 Andrew Oberstar


 You're probably aware of this, but @FunctionalInterface is not a type, 
 it's an annotation. All it does is ensure, at compile time, that the 
 annotated element is an interface with a single non-default and non-static 
 method. At the type-system level, it's just an interface like any other, 
 and the lambda syntax is just a shorthand for an anonymous instance of a 
 well-defined type.

 Since the lambda syntax is java-compiler magic, you can't access it from 
 Clojure, and the most straightforward option right now is to actually know 
 which type is expected, e.g.:

 user= (- (doto (java.util.ArrayList.) (.add 1) (.add 2)) (.stream) 
 (.map (reify java.util.function.Function (apply [_ arg] (inc arg 
 (.collect (java.util.stream.Collectors/toList)))
 [2 3]
 user=

 As neither IFn nor Function are Clojure protocols, I do indeed think 
 you're best bet is a macro to essentially generate the above reify. You can 
 of course do a single macro that reifies to all of the protocols that you 
 need.

 I don't think it's realistic to hope that IFn will cover any arbitrary 
 @FunctionalInterface, as that is Java compiler magic. It may, in the 
 future, be extended to cover all of the standard ones in 
 java.util.function, or even all the ones in the standard library, but it's 
 not going to happen until Java 7 support is dropped. I guess the best you 
 could hope for in the short term would be to have IFn changed to a protocol.
  
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.com 
 javascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 --- 
 You received this message because you are subscribed to the Google Groups 
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to clojure+u...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/d/optout.



-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com

Re: Java 8 Lambda Interop

2015-07-27 Thread Andrew Oberstar
Mikera, I think you're addressing a different interop concern. I'm
particularly interested in something like this:

(- (IntStream/range 0 100) (.filter odd?) (.limit 5) (.collect
Collectors/toList))

Where odd? is a normal Clojure IFn that I want to use when calling a Java
API that expects something implementing a single-method-interface
(Predicate in this case).

Right now I need to do something like this:

(defn lambda [f] (reify Predicate (test [x] (f x

(- (IntStream/range 0 100) (.filter (lambda odd?)) (.limit 5) (.collect
Collectors/toList))

Andrew Oberstar


On Mon, Jul 27, 2015 at 8:16 PM Mikera mike.r.anderson...@gmail.com wrote:

 It could certainly be achieved in the Clojure compiler, by allowing
 (some-functional-interface .) to compile to the appropriate function
 call even if it doesn't implement IFn

 It would be quite a big change though and would probably have some
 limitations, e.g.:
 a) It probably wouldn't work with regular vars since it wouldn't be able
 to handle re-binding
 b) You would probably have to type hint the some-functional-interface
 object in some way so that the compiler knows to do this at compile time

 A less invasive option would be to just have some code to wrap functional
 interfaces in an appropriate IFn.

 Worth a JIRA ticket for consideration at least?



 On Tuesday, 28 July 2015 08:52:47 UTC+8, Andrew Oberstar wrote:

 Thanks for the reply Gary. Sounds like I'm on as good a track as I can
 be with current Clojure.

 I am curious though why you say that it is unrealistic for IFn to support
 arbitrary @FunctionalInterface. It certainly seems like it would require
 compiler changes, but I would think that either through emitting bytecode
 closer to Java 8 lambdas or through some form of type coercion it would
 possible. For example, Groovy just coerces their Closures to any Single
 Abstract Method type.

 I'm not sure how java.util.function.* as protocols would work, but still
 would require implementing for each SAM you come across. IFn as a protocol
 seems to address a different interop use case. Maybe for receiving a Java
 lambda you want to use as if it's a Clojure function.

 Most of the Java interop from Clojure is slick (sometimes more clear than
 in Java itself), it would be unfortunate to leave functions as second-class
 citizens for interop. Granted, there may be a simplicity argument against
 this (maybe that's why Java varargs require an explicit array?).

 Andrew Oberstar

 On Mon, Jul 27, 2015 at 4:16 AM Gary Verhaegen gary.ve...@gmail.com
 wrote:

 On Sunday, 26 July 2015, Andrew Oberstar ajobe...@gmail.com wrote:

 Hi,

 I'm wondering if anyone has a good approach for making calls from
 Clojure to Java APIs (e.g. Stream API) that expect a @FunctionalInterface
 type.

 Ideally, IFn would transparently work, but I'm guessing that requires
 some compiler changes.

 Right now, the best I can think of is a function or macro to reify a
 wrapper around a Clojure function to implement all of the usual interfaces
 from java.util.function.

 Anyone have any better ideas?

 Andrew Oberstar


 You're probably aware of this, but @FunctionalInterface is not a type,
 it's an annotation. All it does is ensure, at compile time, that the
 annotated element is an interface with a single non-default and non-static
 method. At the type-system level, it's just an interface like any other,
 and the lambda syntax is just a shorthand for an anonymous instance of a
 well-defined type.

 Since the lambda syntax is java-compiler magic, you can't access it from
 Clojure, and the most straightforward option right now is to actually know
 which type is expected, e.g.:

 user= (- (doto (java.util.ArrayList.) (.add 1) (.add 2)) (.stream)
 (.map (reify java.util.function.Function (apply [_ arg] (inc arg
 (.collect (java.util.stream.Collectors/toList)))
 [2 3]
 user=

 As neither IFn nor Function are Clojure protocols, I do indeed think
 you're best bet is a macro to essentially generate the above reify. You can
 of course do a single macro that reifies to all of the protocols that you
 need.

 I don't think it's realistic to hope that IFn will cover any arbitrary
 @FunctionalInterface, as that is Java compiler magic. It may, in the
 future, be extended to cover all of the standard ones in
 java.util.function, or even all the ones in the standard library, but it's
 not going to happen until Java 7 support is dropped. I guess the best you
 could hope for in the short term would be to have IFn changed to a protocol.

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.

 To post to this group, send email to clo...@googlegroups.com


 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to

 clojure+u...@googlegroups.com


 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you 

Re: ANN: ClojureScript 0.0-3308, fixes enhancements

2015-07-27 Thread Adam Morgan
After running 
lein new mies test

and then
scripts/watch

I am getting the following exception:

π  ./scripts/watch
Building ...
Reading analysis cache for 
jar:file:/Users/ajmorgan/.m2/repository/org/clojure/clojurescript/0.0-3308/clojurescript-0.0-3308-aot.jar!/cljs/core.cljs
Compiling src/test/core.cljs
Analyzing 
jar:file:/Users/ajmorgan/.m2/repository/org/clojure/clojurescript/0.0-3308/clojurescript-0.0-3308-aot.jar!/clojure/browser/repl.cljs
Analyzing 
jar:file:/Users/ajmorgan/.m2/repository/org/clojure/clojurescript/0.0-3308/clojurescript-0.0-3308-aot.jar!/clojure/browser/net.cljs
Analyzing 
jar:file:/Users/ajmorgan/.m2/repository/org/clojure/clojurescript/0.0-3308/clojurescript-0.0-3308-aot.jar!/clojure/browser/event.cljs
Analyzing 
jar:file:/Users/ajmorgan/.m2/repository/org/clojure/clojurescript/0.0-3308/clojurescript-0.0-3308-aot.jar!/cljs/repl.cljs
Compiling out/cljs/core.cljs
Using cached cljs.core out/cljs/core.cljs
Compiling out/clojure/browser/repl.cljs
Compiling out/clojure/browser/event.cljs
Compiling out/cljs/repl.cljs
Compiling out/clojure/browser/net.cljs
java.lang.NoSuchMethodError: 
cljs.js_deps.IJavaScript._closure_lib_QMARK_()Ljava/lang/Object;
at cljs.closure$rel_output_path.invoke(closure.clj:1155)
at cljs.closure$write_javascript.invoke(closure.clj:1177)
at cljs.closure$source_on_disk.invoke(closure.clj:1205)
at cljs.closure$output_unoptimized$fn__3061.invoke(closure.clj:1239)
at clojure.core$map$fn__4553.invoke(core.clj:2624)
at clojure.lang.LazySeq.sval(LazySeq.java:40)
at clojure.lang.LazySeq.seq(LazySeq.java:49)
at clojure.lang.RT.seq(RT.java:507)
at clojure.core$seq__4128.invoke(core.clj:137)
at clojure.core$filter$fn__4580.invoke(core.clj:2679)
at clojure.lang.LazySeq.sval(LazySeq.java:40)
at clojure.lang.LazySeq.seq(LazySeq.java:49)
at clojure.lang.RT.seq(RT.java:507)
at clojure.core$seq__4128.invoke(core.clj:137)
at clojure.core$map$fn__4553.invoke(core.clj:2616)
at clojure.lang.LazySeq.sval(LazySeq.java:40)
at clojure.lang.LazySeq.seq(LazySeq.java:49)
at clojure.lang.RT.seq(RT.java:507)
at clojure.core$seq__4128.invoke(core.clj:137)
at clojure.core$apply.invoke(core.clj:630)
at cljs.closure$deps_file.invoke(closure.clj:1041)
at cljs.closure$output_deps_file.invoke(closure.clj:1061)
at cljs.closure$output_unoptimized.doInvoke(closure.clj:1247)
at clojure.lang.RestFn.applyTo(RestFn.java:139)
at clojure.core$apply.invoke(core.clj:632)
at cljs.closure$build.invoke(closure.clj:1519)
at cljs.closure$watch$buildf__3163.invoke(closure.clj:1564)
at cljs.closure$watch.invoke(closure.clj:1594)
at cljs.closure$watch.invoke(closure.clj:1552)
at cljs.closure$watch.invoke(closure.clj:1547)
at cljs.build.api$watch.invoke(api.clj:182)
at user$eval2964.invoke(watch.clj:3)
at clojure.lang.Compiler.eval(Compiler.java:6782)
at clojure.lang.Compiler.load(Compiler.java:7227)
at clojure.lang.Compiler.loadFile(Compiler.java:7165)
at clojure.main$load_script.invoke(main.clj:275)
at clojure.main$script_opt.invoke(main.clj:337)
at clojure.main$main.doInvoke(main.clj:421)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.lang.Var.invoke(Var.java:379)
at clojure.lang.AFn.applyToHelper(AFn.java:154)
at clojure.lang.Var.applyTo(Var.java:700)
at clojure.main.main(main.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
at clojure.lang.Reflector.invokeStaticMethod(Reflector.java:207)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
at clojure.lang.Reflector.invokeStaticMethod(Reflector.java:207)
at user$eval5.invoke(form-init6371333665776042787.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6782)
at clojure.lang.Compiler.eval(Compiler.java:6772)
at clojure.lang.Compiler.load(Compiler.java:7227)
at clojure.lang.Compiler.loadFile(Compiler.java:7165)
at clojure.main$load_script.invoke(main.clj:275)
at clojure.main$init_opt.invoke(main.clj:280)
at clojure.main$initialize.invoke(main.clj:308)
  

Re: Java 8 Lambda Interop

2015-07-27 Thread Mikera
Ah, I get what you are doing now.

Don't think that is likely to work unless Clojure starts making IFn 
instances implement the right java.util.function.* interfaces. Which seems 
unlikely given the conservatism of Clojure development. Having said that, I 
do think it is possible, have been playing around with a little toy 
language implementation that does something similar.

I think you are better off for now writing a function or macro that allows 
you to wrap a Clojure function as a java.util.function.Predicate and lets 
you do something like:

(.filter (predicate odd?))


On Tuesday, 28 July 2015 09:53:25 UTC+8, Andrew Oberstar wrote:

 Mikera, I think you're addressing a different interop concern. I'm 
 particularly interested in something like this:

 (- (IntStream/range 0 100) (.filter odd?) (.limit 5) (.collect 
 Collectors/toList))

 Where odd? is a normal Clojure IFn that I want to use when calling a 
 Java API that expects something implementing a single-method-interface 
 (Predicate in this case).

 Right now I need to do something like this:

 (defn lambda [f] (reify Predicate (test [x] (f x

 (- (IntStream/range 0 100) (.filter (lambda odd?)) (.limit 5) (.collect 
 Collectors/toList))

 Andrew Oberstar


 On Mon, Jul 27, 2015 at 8:16 PM Mikera mike.r.an...@gmail.com 
 javascript: wrote:

 It could certainly be achieved in the Clojure compiler, by allowing 
 (some-functional-interface .) to compile to the appropriate function 
 call even if it doesn't implement IFn

 It would be quite a big change though and would probably have some 
 limitations, e.g.:
 a) It probably wouldn't work with regular vars since it wouldn't be able 
 to handle re-binding
 b) You would probably have to type hint the some-functional-interface 
 object in some way so that the compiler knows to do this at compile time

 A less invasive option would be to just have some code to wrap functional 
 interfaces in an appropriate IFn.

 Worth a JIRA ticket for consideration at least?



 On Tuesday, 28 July 2015 08:52:47 UTC+8, Andrew Oberstar wrote:

 Thanks for the reply Gary. Sounds like I'm on as good a track as I can 
 be with current Clojure.

 I am curious though why you say that it is unrealistic for IFn to 
 support arbitrary @FunctionalInterface. It certainly seems like it would 
 require compiler changes, but I would think that either through emitting 
 bytecode closer to Java 8 lambdas or through some form of type coercion it 
 would possible. For example, Groovy just coerces their Closures to any 
 Single Abstract Method type.

 I'm not sure how java.util.function.* as protocols would work, but still 
 would require implementing for each SAM you come across. IFn as a protocol 
 seems to address a different interop use case. Maybe for receiving a Java 
 lambda you want to use as if it's a Clojure function. 

 Most of the Java interop from Clojure is slick (sometimes more clear 
 than in Java itself), it would be unfortunate to leave functions as 
 second-class citizens for interop. Granted, there may be a simplicity 
 argument against this (maybe that's why Java varargs require an explicit 
 array?).

 Andrew Oberstar

 On Mon, Jul 27, 2015 at 4:16 AM Gary Verhaegen gary.ve...@gmail.com 
 wrote:

 On Sunday, 26 July 2015, Andrew Oberstar ajobe...@gmail.com wrote:

 Hi,

 I'm wondering if anyone has a good approach for making calls from 
 Clojure to Java APIs (e.g. Stream API) that expect a @FunctionalInterface 
 type.

 Ideally, IFn would transparently work, but I'm guessing that requires 
 some compiler changes.

 Right now, the best I can think of is a function or macro to reify a 
 wrapper around a Clojure function to implement all of the usual 
 interfaces 
 from java.util.function.

 Anyone have any better ideas?

 Andrew Oberstar


 You're probably aware of this, but @FunctionalInterface is not a type, 
 it's an annotation. All it does is ensure, at compile time, that the 
 annotated element is an interface with a single non-default and non-static 
 method. At the type-system level, it's just an interface like any other, 
 and the lambda syntax is just a shorthand for an anonymous instance of a 
 well-defined type.

 Since the lambda syntax is java-compiler magic, you can't access it 
 from Clojure, and the most straightforward option right now is to actually 
 know which type is expected, e.g.:

 user= (- (doto (java.util.ArrayList.) (.add 1) (.add 2)) (.stream) 
 (.map (reify java.util.function.Function (apply [_ arg] (inc arg 
 (.collect (java.util.stream.Collectors/toList)))
 [2 3]
 user=

 As neither IFn nor Function are Clojure protocols, I do indeed think 
 you're best bet is a macro to essentially generate the above reify. You 
 can 
 of course do a single macro that reifies to all of the protocols that you 
 need.

 I don't think it's realistic to hope that IFn will cover any arbitrary 
 @FunctionalInterface, as that is Java compiler magic. It may, in the 
 future, be extended to cover 

Re: Java 8 Lambda Interop

2015-07-27 Thread Sean Corfield
I think Mike was suggesting something like this:

(- (IntStream/range 0 100) (.filter ^Predicate odd?) (.limit 5) (.collect 
Collectors/toList))

and having the Clojure compiler figure out that you’re trying to cast an IFn to 
a functional interface and therefore do the magic for you. I don’t know 
whether this is even feasible (FWIW, I certainly don’t think it is desirable).

The compiler would have to know about all the possible functional interfaces in 
order to reify them behind the scenes for you (since each one has a different 
method name, so something needs to know how to get from the Java interface type 
to the method name behind it).

I’m not sure I get your use case — if you’re dealing with that much Java 
interop it seems like it might be a good idea to create a DSL (functions, maybe 
macros) that make the code cleaner and hide the low-level details of Java 
interop anyway. Besides, your example sounds like something Clojure can already 
do natively and much more cleanly. Can you perhaps give us more detailed 
motivation for what you’re trying to achieve? Perhaps there’s a cleaner way 
altogether…?

Sean

On Jul 27, 2015, at 6:53 PM, Andrew Oberstar ajobers...@gmail.com wrote:
 Mikera, I think you're addressing a different interop concern. I'm 
 particularly interested in something like this:
 
 (- (IntStream/range 0 100) (.filter odd?) (.limit 5) (.collect 
 Collectors/toList))
 
 Where odd? is a normal Clojure IFn that I want to use when calling a Java 
 API that expects something implementing a single-method-interface (Predicate 
 in this case).
 
 Right now I need to do something like this:
 
 (defn lambda [f] (reify Predicate (test [x] (f x
 
 (- (IntStream/range 0 100) (.filter (lambda odd?)) (.limit 5) (.collect 
 Collectors/toList))
 
 Andrew Oberstar
 
 
 On Mon, Jul 27, 2015 at 8:16 PM Mikera mike.r.anderson...@gmail.com 
 mailto:mike.r.anderson...@gmail.com wrote:
 It could certainly be achieved in the Clojure compiler, by allowing 
 (some-functional-interface .) to compile to the appropriate function call 
 even if it doesn't implement IFn
 
 It would be quite a big change though and would probably have some 
 limitations, e.g.:
 a) It probably wouldn't work with regular vars since it wouldn't be able to 
 handle re-binding
 b) You would probably have to type hint the some-functional-interface 
 object in some way so that the compiler knows to do this at compile time
 
 A less invasive option would be to just have some code to wrap functional 
 interfaces in an appropriate IFn.
 
 Worth a JIRA ticket for consideration at least?
 
 
 
 On Tuesday, 28 July 2015 08:52:47 UTC+8, Andrew Oberstar wrote:
 Thanks for the reply Gary. Sounds like I'm on as good a track as I can be 
 with current Clojure.
 
 I am curious though why you say that it is unrealistic for IFn to support 
 arbitrary @FunctionalInterface. It certainly seems like it would require 
 compiler changes, but I would think that either through emitting bytecode 
 closer to Java 8 lambdas or through some form of type coercion it would 
 possible. For example, Groovy just coerces their Closures to any Single 
 Abstract Method type.
 
 I'm not sure how java.util.function.* as protocols would work, but still 
 would require implementing for each SAM you come across. IFn as a protocol 
 seems to address a different interop use case. Maybe for receiving a Java 
 lambda you want to use as if it's a Clojure function. 
 
 Most of the Java interop from Clojure is slick (sometimes more clear than in 
 Java itself), it would be unfortunate to leave functions as second-class 
 citizens for interop. Granted, there may be a simplicity argument against 
 this (maybe that's why Java varargs require an explicit array?).
 
 Andrew Oberstar
 
 On Mon, Jul 27, 2015 at 4:16 AM Gary Verhaegen gary.ve...@gmail.com  
 wrote:
 On Sunday, 26 July 2015, Andrew Oberstar ajobe...@gmail.com  wrote:
 Hi,
 
 I'm wondering if anyone has a good approach for making calls from Clojure to 
 Java APIs (e.g. Stream API) that expect a @FunctionalInterface type.
 
 Ideally, IFn would transparently work, but I'm guessing that requires some 
 compiler changes.
 
 Right now, the best I can think of is a function or macro to reify a wrapper 
 around a Clojure function to implement all of the usual interfaces from 
 java.util.function.
 
 Anyone have any better ideas?
 
 Andrew Oberstar
 
 You're probably aware of this, but @FunctionalInterface is not a type, it's 
 an annotation. All it does is ensure, at compile time, that the annotated 
 element is an interface with a single non-default and non-static method. At 
 the type-system level, it's just an interface like any other, and the lambda 
 syntax is just a shorthand for an anonymous instance of a well-defined type.
 
 Since the lambda syntax is java-compiler magic, you can't access it from 
 Clojure, and the most straightforward option right now is to actually know 
 which type is expected, e.g.:
 
 user= (- 

Re: Generating varying sized map using test.check

2015-07-27 Thread Mayank Jain


 It also might be helpful to know that there is already a subset generator 
 available in this library 
 https://github.com/gfredericks/test.chuck#generators.


Thanks, this looks good, will check it out.
 

 What you've done here might appear to work, but it will get you into 
 trouble when test.check starts to shrink your inputs. When test.check runs 
 your generators it relies you you using it as your only source of 
 randomness, and so your use of `rand-int` will cause some problems.


Ah yes, I didn't think of shrinking.
Thanks a lot for your help! :)
 
 

 The trick is to use the `bind` function to make a generator which depends 
 on the value of another generator (in this case, to capture the generated 
 map so you can call rand-subset with the correct set of keys):



 I didn't get why I had to use a bind here. What if I had only used fmap?

-- 
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 is the best way to pass log configs everywhere without a global var?

2015-07-27 Thread Colin Yates
I don’t have a proof of concept either but if somebody is going to put some 
effort into writing a new library I had a great idea they could incorporate. 
Continuing the ‘decomplecting’ that James started, the other thing that is 
decomplected (or actually not addressed at all) is _why_ we want logging to be 
produced. For me, I often want to see WARNING and above all the time and only 
see INFO and below if something interesting happened. ‘Interesting’ typically 
being an exception happened.

My notion was to add an adapter which at some point (e.g. around the use-case 
service/transaction boundary) started collecting all the logs in-memory and if 
the service executed correctly would simply drop the INFO and below messages. 
However, if the service aborted (e.g. threw an Exception) only then would the 
INFO and below logs get written to disk.

It’s so simple and useful I can’t believe nobody else has already written it. 
My excuse is good old time. Clojure, Agents, robert-hooke - couldn’t be easer.


 On 27 Jul 2015, at 08:28, crocket crockabisc...@gmail.com wrote:
 
 Can I see your proof of concept on github? Is it just an idea?
 
 On Mon, Jul 27, 2015 at 2:27 PM, James Reeves ja...@booleanknot.com 
 mailto:ja...@booleanknot.com wrote:
 On 27 July 2015 at 05:25, crocket crockabisc...@gmail.com wrote:
 
 How those logs are outputted is stored in a global state called log
 configuration. So, I think the separation was done.
 How else do you want to separate that?
 
 
 Traditionally, logging code is written something like:
 
(log/info HTTP request to (:request-method req) (:uri req))
 
 So the priority of the log (info) and the formatting of the log line is
 inlined into the source code.
 
 A less complected piece of code would separate out what we want to monitor
 (req) from how we monitor it. So inline we just write:
 
(monitor/monitor req :ring/request)
 
 This monitors the variable req and associates it with the namespaced keyword
 :ring/request. In our logging namespace, we can then later define how we
 want to report on that monitor:
 
(monitor/add-reporter
 :ring/request
 (fn [req] (log/info HTTP request to (:request-method req) (:uri
 req
 
 This separates *what* we want to monitor from *how* we eventually log it. It
 means we can do things like define a set of useful monitoring points in a
 library, and then in a separate application decide on what's important.
 
 - 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 a topic in the
 Google Groups Clojure group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/clojure/9YiGAp6axcY/unsubscribe 
 https://groups.google.com/d/topic/clojure/9YiGAp6axcY/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 clojure+unsubscr...@googlegroups.com 
 mailto:clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout 
 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 
 mailto: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 
 mailto:clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en 
 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 
 mailto:clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout 
 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 

Re: Java 8 Lambda Interop

2015-07-27 Thread Gary Verhaegen
On Sunday, 26 July 2015, Andrew Oberstar ajobers...@gmail.com wrote:

 Hi,

 I'm wondering if anyone has a good approach for making calls from Clojure
 to Java APIs (e.g. Stream API) that expect a @FunctionalInterface type.

 Ideally, IFn would transparently work, but I'm guessing that requires some
 compiler changes.

 Right now, the best I can think of is a function or macro to reify a
 wrapper around a Clojure function to implement all of the usual interfaces
 from java.util.function.

 Anyone have any better ideas?

 Andrew Oberstar


You're probably aware of this, but @FunctionalInterface is not a type, it's
an annotation. All it does is ensure, at compile time, that the annotated
element is an interface with a single non-default and non-static method. At
the type-system level, it's just an interface like any other, and the
lambda syntax is just a shorthand for an anonymous instance of a
well-defined type.

Since the lambda syntax is java-compiler magic, you can't access it from
Clojure, and the most straightforward option right now is to actually know
which type is expected, e.g.:

user= (- (doto (java.util.ArrayList.) (.add 1) (.add 2)) (.stream) (.map
(reify java.util.function.Function (apply [_ arg] (inc arg (.collect
(java.util.stream.Collectors/toList)))
[2 3]
user=

As neither IFn nor Function are Clojure protocols, I do indeed think you're
best bet is a macro to essentially generate the above reify. You can of
course do a single macro that reifies to all of the protocols that you need.

I don't think it's realistic to hope that IFn will cover any arbitrary
@FunctionalInterface, as that is Java compiler magic. It may, in the
future, be extended to cover all of the standard ones in
java.util.function, or even all the ones in the standard library, but it's
not going to happen until Java 7 support is dropped. I guess the best you
could hope for in the short term would be to have IFn changed to a protocol.

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