Questions about some-fn and every-pred (possible bug, and improvements)

2012-10-25 Thread Max Penet
Hello, 

I am trying to understand the rationale behind the current implementation 
of some-fn and every-pred, there seems to be a couple of odd things, or 
maybe that is just me misunderstanding their doc.

user ((every-pred (fn [_])))
true
user ((some-fn (fn [_])))
nil

Shouldn't the first example return false? since the first function always 
returns nil? 

I was also wondering if it would make sense to add a 0 argument version of 
these, it would make their usage with apply more convenient, and comp which 
has a smiliar signature behaves like that: 

user ((comp) true)
true

user ((some-fn) true)
; Evaluation aborted.

user ((every-pred) true)
; Evaluation aborted.

Max

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

Re: Questions about some-fn and every-pred (possible bug, and improvements)

2012-10-25 Thread Tassilo Horn
Max Penet m...@qbits.cc writes:

 user ((every-pred (fn [_])))
 true
 user ((some-fn (fn [_])))
 nil

 Shouldn't the first example return false? since the first function
 always returns nil?

No.  ((every-pred a b c) o1 o2 ...) returns true if all predicates a, b,
and c return true for all given args o1, o2, and so one.  You don't pass
any args, so this is basically (and), which also returns true.  `and` is
true if all arguments are logically true, which is trivially given when
none are provided.

 I was also wondering if it would make sense to add a 0 argument
 version of these, it would make their usage with apply more
 convenient, and comp which has a smiliar signature behaves like that:

 user ((comp) true)
 true

 user ((some-fn) true)
 ; Evaluation aborted.

 user ((every-pred) true)
 ; Evaluation aborted.

(comp) is `identity` which makes sense.  What would the semantics be for
every-pred and some-fn?  IMO, it should be

user ((some-fn) no-matter-what)
false
user ((every-pred) no-matter-what)
true

e.g. (some-cn) was equivalent to (constantly false) and (every-pred) was
equivalent to (constantly true).

Bye,
Tassilo

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


Re: Questions about some-fn and every-pred (possible bug, and improvements)

2012-10-25 Thread Max Penet
user (every? identity [])
true

I think I understand now, this might be to match the behavior of every?.

Max

On Thursday, October 25, 2012 12:31:57 PM UTC+2, Max Penet wrote:

 Hello, 

 I am trying to understand the rationale behind the current implementation 
 of some-fn and every-pred, there seems to be a couple of odd things, or 
 maybe that is just me misunderstanding their doc.

 user ((every-pred (fn [_])))
 true
 user ((some-fn (fn [_])))
 nil

 Shouldn't the first example return false? since the first function always 
 returns nil? 

 I was also wondering if it would make sense to add a 0 argument version of 
 these, it would make their usage with apply more convenient, and comp which 
 has a smiliar signature behaves like that: 

 user ((comp) true)
 true

 user ((some-fn) true)
 ; Evaluation aborted.

 user ((every-pred) true)
 ; Evaluation aborted.

 Max


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

Re: Questions about some-fn and every-pred (possible bug, and improvements)

2012-10-25 Thread Max Penet


On Thursday, October 25, 2012 12:49:32 PM UTC+2, Tassilo Horn wrote:

 Max Penet m...@qbits.cc writes: 

  user ((every-pred (fn [_]))) 
  true 
  user ((some-fn (fn [_]))) 
  nil 
  
  Shouldn't the first example return false? since the first function 
  always returns nil? 

 No.  ((every-pred a b c) o1 o2 ...) returns true if all predicates a, b, 
 and c return true for all given args o1, o2, and so one.  You don't pass 
 any args, so this is basically (and), which also returns true.  `and` is 
 true if all arguments are logically true, which is trivially given when 
 none are provided. 


Ok that makes sense. 
 


  I was also wondering if it would make sense to add a 0 argument 
  version of these, it would make their usage with apply more 
  convenient, and comp which has a smiliar signature behaves like that: 
  
  user ((comp) true) 
  true 
  
  user ((some-fn) true) 
  ; Evaluation aborted. 
  
  user ((every-pred) true) 
  ; Evaluation aborted. 

 (comp) is `identity` which makes sense.  What would the semantics be for 
 every-pred and some-fn?  IMO, it should be 

 user ((some-fn) no-matter-what) 
 false 
 user ((every-pred) no-matter-what) 
 true 


 e.g. (some-cn) was equivalent to (constantly false) and (every-pred) was 
 equivalent to (constantly true). 


Yes I understand that, the proposal was just to avoid exceptions when used 
with apply, but this could end up be bit confusing maybe, and it can be 
tested beforehand anyway. 

Max

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

Re: A Practical Optional Type System for Clojure

2012-10-25 Thread Bronsa
Hi Ambrose, great work!

I found a typo on page 14, you wrote ... equivalent to [- (U nil String]
in Typed Clojure

2012/10/25 Ambrose Bonnaire-Sergeant abonnaireserge...@gmail.com

 Hi,

 I have submitted my honours dissertation for marking, for those
 interested: https://github.com/downloads/frenchy64/papers/paper.pdf

 Corrections welcome!

 Thanks,
 Ambrose

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

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

Disconnect a downstream channel in lamina

2012-10-25 Thread Marko Topolnik
I use lamina channels in a library that maintains multiple event streams. 
The event source is the Asterisk Management Interface, whose raw events are 
processed, filtered, collated, and finally pushed into appropriate lamina 
channels.

On the client side of my library I want to expose the event streams as a 
web service. My challenge is to implement long polling: a request either 
finds events already enqueued, returning immediately; or blocks until an 
event occurs (with a timeout), then accumulates any further events for a 
short period, then returns the accumulated events. This reduces network 
overhead for the typical case of events occuring in short bursts (a single 
user action triggers several events).

I have implemented this behavior in a piece of code that occupies its 
thread for the entire duration of the request:

(require 
  [lamina.core :as m] 
  [lamina.core.graph.node :as node] 
  [lamina.core.channel :as chan])

(let [evs (node/drain (chan/emitter-node ch))
  evs (if (seq evs)
evs
(try (let [ev @(m/with-timeout POLL-TIMEOUT (m/read-channel 
ch))]
   (Thread/sleep EVENT-BURST-PERIOD)
   (conj (node/drain (chan/emitter-node ch)) ev))
 (catch TimeoutException _ nil)))]
  (vec evs))

I would instead like to do this without blocking the thread. Ideally, I'll 
use aleph to implement the web service and connect a downstream HTTP 
response channel to my library's lamina channel. What I'm missing is, how 
do I disconnect the downstream channel without breaking anything in the 
upstream channel? I want to cleanly disconnect it, let my channel enqueue 
any further events, then later connect another aleph channel, which will 
drain those events with no loss.

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

Re: A Practical Optional Type System for Clojure

2012-10-25 Thread Ambrose Bonnaire-Sergeant
Nice catch! Thanks!

On Thu, Oct 25, 2012 at 7:08 PM, Bronsa brobro...@gmail.com wrote:

 Hi Ambrose, great work!

 I found a typo on page 14, you wrote ... equivalent to [- (U nil String]
 in Typed Clojure

 2012/10/25 Ambrose Bonnaire-Sergeant abonnaireserge...@gmail.com

 Hi,

 I have submitted my honours dissertation for marking, for those
 interested: https://github.com/downloads/frenchy64/papers/paper.pdf

 Corrections welcome!

 Thanks,
 Ambrose

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


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

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

Re: Questions about some-fn and every-pred (possible bug, and improvements)

2012-10-25 Thread Tassilo Horn
Max Penet m...@qbits.cc writes:

Hi Max,

 user ((some-fn) no-matter-what) 
 false 
 user ((every-pred) no-matter-what) 
 true 

 e.g. (some-cn) was equivalent to (constantly false) and (every-pred) was 
 equivalent to (constantly true). 

 Yes I understand that, the proposal was just to avoid exceptions when
 used with apply, but this could end up be bit confusing maybe, and it
 can be tested beforehand anyway.

No, I think it's a valid request and it wouldn't be more confusing than
(and) = true (or) = false.  I'll create a ticket and patch for it.

Bye,
Tassilo

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


Re: Some Friend documentation and regarding documentation in general

2012-10-25 Thread Patrik Sundberg
I've digested openid and using it with google, should have a working 
example to share when I have a time to put it together over weekend.

I've got another common useage pattern I'd like to ask about: How do we 
accomplish automatic redirect to the correct page?

Let's say user accesses /secret, isn't authenticated and gets redirected to 
/login by friend. once authenticated, how do we ensure we get redirected 
back to /secret?


On Wednesday, October 24, 2012 10:12:01 AM UTC+1, Patrik Sundberg wrote:

 On Wednesday, October 24, 2012 3:10:52 AM UTC+1, David Della Costa wrote:

 Patrik, Pierre, have you folks checked out the mock app that Chas 
 created in the test directory?  It's not going to give you everything 
 you're looking for but make it can help.  There is an implementation 
 of the OpenID workflow in there, including a credential-fn example: 


 https://github.com/cemerick/friend/blob/master/test/test_friend/mock_app.clj 


 Been digesting that and reading the OpenID workflow + the openid2java docs 
 to work out what inputs mean what. I'm not quite there yet but starting to 
 have some idea, will experiment today to get auth with Google Account up 
 and running.
  

 This may also help, regarding credential functions: 


 https://github.com/cemerick/friend/blob/master/test/test_friend/credentials.clj
  

 I also highly recommend looking at the bcrypt-credential-fn in the 
 credentials.clj lib, in the src of the project itself: 


 https://github.com/cemerick/friend/blob/master/src/cemerick/friend/credentials.clj
  


 The credentials I grok more easily than the workflow - or more 
 specifically the openid workflow. The form based auth workflow is a lot 
 easier for me to follow, no probs there. That I find the openid workflow 
 more obtuse probably means I don't get OpenID quite yet so will do some 
 standard reading there as well.
  

 This is the default credentials function used in the mock app above, 
 so it should help illustrate some of the concepts.  I've spent a lot 
 of time poring over the code too, so feel free to ping me with 
 questions too, I may be able to help. 

  IMHO the doc is really lacking and I have to say I was expecting more 
  guidance in the code itself. 

 Yes, it's still hard to wrap your head around the docs.  Friend 
 scratches an itch I have, and I think it's going to be rather 
 important if people are trying to web apps quickly in Clojure, so I'm 
 going to keep working on it and see how much I can clean things up and 
 make concepts more clear.  And I know Chas is interested in this as 
 well, from his past comments.  Any help and pull requests are welcome. 
 ;-) 

 I'm working on some updates to everything I've been working on, I'll 
 post updates to the list shortly (later this week probably, maybe even 
 today). 


 Agreed. Happy to contribute a working google acc openid auth once I get 
 there.

 Patrik
  

 DD 

 2012/10/24 Pierre R p.rade...@gmail.com: 
  Thanks David for the extra doc. 
  
  I have had a try with OpenID. Everything works kind of expected. 
  
  I had a question about 302 redirection prior to authentication that I 
  posted on github. 
  
  Another question is how to link the concept of roles with the openid 
  credentials. 
  
  IMHO the doc is really lacking and I have to say I was expecting more 
  guidance in the code itself. 
  
  I guess a lot of stuff obvious to an experienced clojure developers are 
  still dark magic to me. 
  
  In particular it is rather difficult to understand how to write a 
  crendential-fn and this link won't help you ;-) 
  https://github.com/cemerick/friend/blob/master/docs/credentials.md 
  
  For OpenId I have blindly used the identity function without much 
  understanding ... 
  
  I am using Friend to scratch a little auth server. Not sure it is the 
 best 
  fit for that purpose. I will see. 
  
  I hope Friend is going to be reviewed by an extended community of 
 people 
  much more qualified than myself to talk about such matter. 
  
  Still docs could be improved and I believe helps could come from pull 
  requests to suggest the addition of code comments there and there. 
  
  If I dig far enough in the code, I would be pleased to help. 
  
  Thanks for the hard work. 
  
  Cheers, 
  
  Le mardi 23 octobre 2012 17:50:25 UTC+2, Patrik Sundberg a écrit : 
  
  These are great tutorials. Thanks for publishing. 
  
  Right now I'm looking for something similar using the OpenID workflow. 
 I 
  see it's there but how I use to for example create a sign in with 
 google 
  setup is less clear to me. 
  
  Has anyone got a good OpenID example out there somewhere? 
  
  On Saturday, October 6, 2012 4:50:05 PM UTC+1, David Della Costa 
 wrote: 
  
  Hi folks, 
  
  I've been pretty slack in communicating via the mailing list, but I 
  realized today that there is a lot of important dialogue going on 
 here 
  so I have to make more of an effort to take part--I want to be a part 
 of 
  this community! 
 

Re: Rouge: Ruby + Clojure

2012-10-25 Thread Arlen Cuss
Hi all,

As a final (!?) follow-up to this post, you can now play with Rouge online in a 
tryclj-like environment: http://try.rouge.io

Cheers,

Arlen

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


Re: Questions about some-fn and every-pred (possible bug, and improvements)

2012-10-25 Thread Tassilo Horn
Tassilo Horn t...@gnu.org writes:

 user ((some-fn) no-matter-what) 
 false 
 user ((every-pred) no-matter-what) 
 true 

 e.g. (some-cn) was equivalent to (constantly false) and (every-pred) was 
 equivalent to (constantly true). 

 Yes I understand that, the proposal was just to avoid exceptions when
 used with apply, but this could end up be bit confusing maybe, and it
 can be tested beforehand anyway.

 No, I think it's a valid request and it wouldn't be more confusing than
 (and) = true (or) = false.  I'll create a ticket and patch for it.

Done, see http://dev.clojure.org/jira/browse/CLJ-1094

In contrast to what's written above, I decided to make (some-fn) to be
(constantly nil), which matches the behavior of `some` better than
(constantly false).

Bye,
Tassilo

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


Re: Questions about some-fn and every-pred (possible bug, and improvements)

2012-10-25 Thread Max Penet
Thanks, perfect, I had prepared a patch that was identical.

On Thursday, October 25, 2012 2:11:44 PM UTC+2, Tassilo Horn wrote:

 Tassilo Horn ts...@gnu.org javascript: writes: 

  user ((some-fn) no-matter-what) 
  false 
  user ((every-pred) no-matter-what) 
  true 
  
  e.g. (some-cn) was equivalent to (constantly false) and (every-pred) 
 was 
  equivalent to (constantly true). 
  
  Yes I understand that, the proposal was just to avoid exceptions when 
  used with apply, but this could end up be bit confusing maybe, and it 
  can be tested beforehand anyway. 
  
  No, I think it's a valid request and it wouldn't be more confusing than 
  (and) = true (or) = false.  I'll create a ticket and patch for it. 

 Done, see http://dev.clojure.org/jira/browse/CLJ-1094 

 In contrast to what's written above, I decided to make (some-fn) to be 
 (constantly nil), which matches the behavior of `some` better than 
 (constantly false). 

 Bye, 
 Tassilo 


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

Re: future with user specified ExecutorService

2012-10-25 Thread Max Penet
wrong commit: 
https://github.com/mpenet/clojure/commit/9c6e47524dc21c6bdfaa9d0cc2a69377cc69cbf3
 

On Thursday, October 25, 2012 2:35:01 PM UTC+2, Max Penet wrote:

 Another enhancement proposal, would it be possible to have a future-call 
 arity with an additional argument as the ExecutorService used. It seems to 
 be a trivial but useful modification, but I wanted to ask here before 
 creating a ticket for this. 

 Something like this maybe: 
 https://github.com/mpenet/clojure/commit/e5295ac1aa49036c98a3a4e18cba974cd72483d5

 Max


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

ANN: inet.data 0.5.1

2012-10-25 Thread Marshall T. Vandegrift
Hi:

Inet.data is a Clojure library for modeling various Internet-related
conceptual entities as data.  It is intended to support applications
which are *about* the modeled entities versus *interfacing* with them.

It presently contains types and associated APIs for representing IP
addresses, IP networks, and DNS domains.  None of the provided functions
will ever perform any sort of DNS resolution or other network operation
on the entity represented.  Instead, it supports such operations as
network address enumeration, network and DNS zone set membership tests,
and domain suffix list lookups.

Overview documentation and source code available at:

https://github.com/llasram/inet.data

Detailed API documentation at:

http://llasram.github.com/inet.data/

Leiningen dependency coordinates:

[inet.data 0.5.1]

Feedback and contributions welcome!

-Marshall

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


Re: what is the modern equivalent of clojure.contrib.java-utils/file?

2012-10-25 Thread larry google groups

Hmm, how do I include this? I have a strange error. I had an app that was 
working fine, and then I added this one line at the the :require block in 
core.clj:

  (:require clojure.string clojure.java.io who-is-logged-in.memory_display
[clojure.data.json :as json]
[clojure.java.io])

I added that last line, and now, when I compile, I get:

Caused by: java.io.FileNotFoundException: Could not locate 
clojure/data/json__init.class or clojure/data/json.clj on classpath: 

This makes no sense to me, since the JSON was working fine the last time I 
compiled. 




On Wednesday, October 24, 2012 11:11:11 PM UTC-4, yangsx wrote:

 clojure.java.io/file 

 On Thu, Oct 25, 2012 at 11:08 AM, larry google groups 
 lawrenc...@gmail.com javascript: wrote: 
  
  I want to use clojure.contrib.java-utils/file. I am using Clojure 1.3 
 and 
  leinengen. What is the modern equivalent of 
 clojure.contrib.java-utils/file? 
  
  -- 
  You received this message because you are subscribed to the Google 
  Groups Clojure group. 
  To post to this group, send email to clo...@googlegroups.comjavascript: 
  Note that posts from new members are moderated - please be patient with 
 your 
  first post. 
  To unsubscribe from this group, send email to 
  clojure+u...@googlegroups.com javascript: 
  For more options, visit this group at 
  http://groups.google.com/group/clojure?hl=en 


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

Re: Some Friend documentation and regarding documentation in general

2012-10-25 Thread Chas Emerick

On Oct 25, 2012, at 8:04 AM, Patrik Sundberg wrote:

 I've digested openid and using it with google, should have a working example 
 to share when I have a time to put it together over weekend.
 
 I've got another common useage pattern I'd like to ask about: How do we 
 accomplish automatic redirect to the correct page?
 
 Let's say user accesses /secret, isn't authenticated and gets redirected to 
 /login by friend. once authenticated, how do we ensure we get redirected back 
 to /secret?

I think that's a bug in the OpenID workflow.  Friend will do this redirection 
automatically if the workflow enables it:

https://github.com/cemerick/friend/blob/master/src/cemerick/friend/workflows.clj#L79

There are a couple of testcases in the project that verify this; unfortunately, 
the OpenID workflow doesn't yet accept the same configuration option as the 
interactive form workflow.  Please file an issue, and, if you are so bold, a 
patch. :-)

Thanks,

- Chas

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


what is the simplest user auth system possible?

2012-10-25 Thread larry google groups

I have a website written in PHP, using the Symfony framework, which is a 
monolithic framework much like what Ruby On Rails used to be. I have been 
slowly re-writing the website in Clojure, and as I do this I've been 
breaking up the system into several small apps, rather than one huge 
monolithic app. For my next step, I need to come up with a user system. My 
needs are minimal: I only need to know when someone is logged in, and I 
need to associate them with some user id (the id will simply be the id from 
a user table kept in MySql). 

I am curious what is the absolutely easiest way to do this? I think Ring 
has functions for sessions, so I could perhaps compose this app with Ring, 
Jetty, Moustache and Korma? I have almost no experience with Ring, but is 
it able to handle the sessions? Is there any jar that offers a standard way 
of handling username and passwords in Clojure, or should I write that code 
myself? 




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

Re: Some Friend documentation and regarding documentation in general

2012-10-25 Thread Patrik Sundberg
On Thursday, October 25, 2012 1:59:36 PM UTC+1, Chas Emerick wrote:


 On Oct 25, 2012, at 8:04 AM, Patrik Sundberg wrote: 

  I've digested openid and using it with google, should have a working 
 example to share when I have a time to put it together over weekend. 
  
  I've got another common useage pattern I'd like to ask about: How do we 
 accomplish automatic redirect to the correct page? 
  
  Let's say user accesses /secret, isn't authenticated and gets redirected 
 to /login by friend. once authenticated, how do we ensure we get redirected 
 back to /secret? 

 I think that's a bug in the OpenID workflow.  Friend will do this 
 redirection automatically if the workflow enables it: 


 https://github.com/cemerick/friend/blob/master/src/cemerick/friend/workflows.clj#L79
  

 There are a couple of testcases in the project that verify this; 
 unfortunately, the OpenID workflow doesn't yet accept the same 
 configuration option as the interactive form workflow.  Please file an 
 issue, and, if you are so bold, a patch. :-) 


Got it, adding it to my weekend list. Thanks!

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

Re: what is the simplest user auth system possible?

2012-10-25 Thread Stephen Compall
On Oct 25, 2012 9:04 AM, larry google groups lawrencecloj...@gmail.com
wrote:
 For my next step, I need to come up with a user system. My needs are
minimal: I only need to know when someone is logged in, and I need to
associate them with some user id (the id will simply be the id from a user
table kept in MySql).

 I am curious what is the absolutely easiest way to do this?

The easiest auth system to write is the one that's already written.

https://github.com/cemerick/friend

--
Stephen Compall
If anyone in the MSA is online, you should watch this flythrough.

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

Re: ANN: data.json 0.2.0

2012-10-25 Thread Stuart Sierra
I am not opposed to having a shim to support an API compatible with older 
releases. It's not even particularly difficult:

https://gist.github.com/3950124

I certainly did not anticipate this release causing significant problems 
for application or library developers, and if it did then I apologize.

However, I will stand by the decision to update the API. data.json 0.1.x 
suffered from what I consider, in retrospect, to be poor design decisions. 
Those were decisions I made over two years ago in a hasty effort to please 
too many people who had conflicting goals:


  - Converting field names to keywords by default can create invalid 
keywords.

  - Keywordization is controlled by a bare boolean argument with little 
indication of its function.

  - Inconsistent styles of optional arguments: read-json and write-json 
take booleans as bare arguments, json-str and print-json use keyword-value 
pairs.

  - Parsing a string and parsing from a stream -- two very different 
operations -- are conflated in a single function.

  - Functions are not consistently named: json-str, read-json, write-json

  - Function names repeat the name of the library, rather than using 
namespaces.


It was impossible to solve some of these problems without introducing 
breaking changes.

Looking at the Clojure Library Coding Standards[1], data.json 0.2.0 does a 
better job at Use good names and Unroll optional named arguments. It 
fails at Java's commitment to not break existing code. In this instance, 
I believe the tradeoff is worthwhile because the new API can be more easily 
extended with additional arguments. This also opened up a place to add new 
features such as customizable conversion functions, the 
most-commonly-requested feature for this library.

Per Rich's directive[2], I cannot yet make a 1.0.0 release. Therefore, 
0.1.3 to 0.2.0 is the largest version bump I can make and the best 
indication I can give of breaking changes. I hope that these improvements 
to the API bring this library closer to a 1.0.0-ready state.

I'm not trying to make anyone's life more difficult, just trying to provide 
useful tools.

-S


[1]: http://dev.clojure.org/display/design/Library+Coding+Standards
[2]: http://dev.clojure.org/display/design/Contrib+1.0.0+Releases


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

Re: what is the modern equivalent of clojure.contrib.java-utils/file?

2012-10-25 Thread AtKaaZ
it looks like clojure.java.io occurs twice, is that why that happens?

On Thu, Oct 25, 2012 at 2:58 PM, larry google groups 
lawrencecloj...@gmail.com wrote:


 Hmm, how do I include this? I have a strange error. I had an app that was
 working fine, and then I added this one line at the the :require block in
 core.clj:

   (:require clojure.string clojure.java.io who-is-logged-in.memory_display
 [clojure.data.json :as json]
 [clojure.java.io])

 I added that last line, and now, when I compile, I get:

 Caused by: java.io.FileNotFoundException: Could not locate
 clojure/data/json__init.class or clojure/data/json.clj on classpath:

 This makes no sense to me, since the JSON was working fine the last time I
 compiled.




 On Wednesday, October 24, 2012 11:11:11 PM UTC-4, yangsx wrote:

 clojure.java.io/file

 On Thu, Oct 25, 2012 at 11:08 AM, larry google groups
 lawrenc...@gmail.com wrote:
 
  I want to use clojure.contrib.java-utils/**file. I am using Clojure
 1.3 and
  leinengen. What is the modern equivalent of clojure.contrib.java-utils/
 **file?
 
  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clo...@googlegroups.com
  Note that posts from new members are moderated - please be patient with
 your
  first post.
  To unsubscribe from this group, send email to
  clojure+u...@**googlegroups.com
  For more options, visit this group at
  http://groups.google.com/**group/clojure?hl=enhttp://groups.google.com/group/clojure?hl=en

  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To 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




-- 
I may be wrong or incomplete.
Please express any corrections / additions,
they are encouraged and appreciated.
At least one entity is bound to be transformed if you do ;)

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

Re: what is the modern equivalent of clojure.contrib.java-utils/file?

2012-10-25 Thread Jim foo.bar
are you aot compiling? If yes delete all the calss files and 
re-compile...also there is no reason to require it unless you alias it 
to something... a common one would be (:require [clojure.java.io :as 
io])...personally, for clojure.java.io,  I just use the fully qualified 
name most of the times


Jim

On 25/10/12 13:58, larry google groups wrote:


Hmm, how do I include this? I have a strange error. I had an app that 
was working fine, and then I added this one line at the the :require 
block in core.clj:


  (:require clojure.string clojure.java.io who-is-logged-in.memory_display
[clojure.data.json :as json]
[clojure.java.io])

I added that last line, and now, when I compile, I get:

Caused by: java.io.FileNotFoundException: Could not locate 
clojure/data/json__init.class or clojure/data/json.clj on classpath:


This makes no sense to me, since the JSON was working fine the last 
time I compiled.





On Wednesday, October 24, 2012 11:11:11 PM UTC-4, yangsx wrote:

clojure.java.io/file http://clojure.java.io/file

On Thu, Oct 25, 2012 at 11:08 AM, larry google groups
lawrenc...@gmail.com javascript: wrote:

 I want to use clojure.contrib.java-utils/file. I am using
Clojure 1.3 and
 leinengen. What is the modern equivalent of
clojure.contrib.java-utils/file?

 --
 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
http://groups.google.com/group/clojure?hl=en

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

To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en 


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

thinking in data, polymorphism, etc.

2012-10-25 Thread Brian Craft
I'm trying to understand the programming philosophy expressed in some of 
the videos, as it relates to dealing with data with different 
representations. There's a lot of emphasis on working with basic collection 
types,  not using getters and setters, and so-forth.

I have a fairly common scenario where I have a set of operations that need 
to work on two types of data (not data types in the clojure sense) that 
have different internal structure (i.e. maps with different keys). I could 
write a generic function that operates on both types of map. That would 
require implementing getters for each type (not sure where those would 
live). Alternatively, I could use a type-based dispatch, which means 
converting to records. Does that mean I'm in my defrecord phase, as 
Stuart put it in the video? Or perhaps I could stick with maps and use a 
multimethod for dispatch? But dispatch by type and dispatch with 
multimethod both involve implementing all the algorithms twice, unless the 
methods I'm dispatching to are just getters (in which case I can write a 
generic algorithm that uses the getters).

I don't think I understand the alternative to getters or the defrecord 
phase. Have I missed something by arriving at this point in the first 
place (i.e. thinking I need polymorphic functions)?

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

Re: thinking in data, polymorphism, etc.

2012-10-25 Thread Jim foo.bar

On 25/10/12 16:59, Brian Craft wrote:
I have a fairly common scenario where I have a set of operations that 
need to work on two types of data (not data types in the clojure 
sense) that have different internal structure (i.e. maps with 
different keys). I could write a generic function that operates on 
both types of map.


I'm not sure I follow why you need polymorphic behavior of any 
form...the operations that need to operate on 2 internally different 
maps can take the keys to 'touch' as parameters couldn't they? Then it 
is truly generic...if this is not practical you can always make a HOF 
that returns the appropriate handler for the data-type you're examining 
at any given time...meta-data could help you distinguish between the maps...


am I missing something?

Jim

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


Re: ANN: data.json 0.2.0

2012-10-25 Thread Sean Corfield
On Thu, Oct 25, 2012 at 8:08 AM, Stuart Sierra
the.stuart.sie...@gmail.com wrote:
 I certainly did not anticipate this release causing significant problems for
 application or library developers, and if it did then I apologize.

The biggest problem is transitive dependency conflicts (as I had with
congomongo) because this is a very low-level library that is fairly
widely used. I agree with nearly all of your reasons for updating the
API but maintaining the former API as deprecated would have allowed
both application developers and other library maintainers to move at
their own pace instead of forcing lockstep upgrades on whole chains of
libraries. Deprecated in 0.2.0 and removed in 0.3.0 might have been
more appropriate.

 However, I will stand by the decision to update the API. data.json 0.1.x
 suffered from what I consider, in retrospect, to be poor design decisions.

Agreed.

   - Converting field names to keywords by default can create invalid
 keywords.

This was the change that caused me the most work since I needed to
update all call sites in different ways depending on what the code
needed - and then spend a bunch of time carefully testing that I had
restored the correct behavior. Yes, the previous behavior could be
problematic but switching the default behavior of an API is very
disruptive. Since this wasn't mentioned in your highlights, nor in
your Change Log, the first I knew of it was when a huge number of my
unit tests failed in mysterious ways :(

   - Keywordization is controlled by a bare boolean argument with little
 indication of its function.

Agreed this was ugly. Having now restored my code's correct
functionality, I like the flexibility of the :key-fn approach.

   - Inconsistent styles of optional arguments: read-json and write-json take
 booleans as bare arguments, json-str and print-json use keyword-value pairs.

Agreed.

   - Parsing a string and parsing from a stream -- two very different
 operations -- are conflated in a single function.

Agreed.

   - Functions are not consistently named: json-str, read-json, write-json

Agreed.

   - Function names repeat the name of the library, rather than using
 namespaces.

Agreed.
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

Perfection is the enemy of the good.
-- Gustave Flaubert, French realist novelist (1821-1880)

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


[OT] Khan Academy's computer science platform and Bret Victor's response

2012-10-25 Thread Raju Bitter
Bret Victor has been mentioned before on this list, here's another
interesting article he wrote:
http://worrydream.com/LearnableProgramming/

 Here's a trick question: How do we get people to understand programming?
 Khan Academy recently launched an online environment for learning to program.
 It offers a set of tutorials based on the JavaScript and Processing 
 languages, and
 features a live coding environment, where the program's output updates as 
 the
 programmer types.

 Because my work was cited as an inspiration for the Khan system, I felt I 
 should
 respond with two thoughts about learning

Bret responds to John Resig's blog post Redefining the Introduction
to Computer Science
http://ejohn.org/blog/introducing-khan-cs/

Enjoy, Raju

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


Re: A Practical Optional Type System for Clojure

2012-10-25 Thread Raoul Duke
super cool!!!




apparently Racket just had another paper along those lines, won at OOPSLA:
http://www.ccs.neu.edu/racket/pubs/oopsla12-tsdthf.pdf

more about how to promote from dynamic to statically typed stuff.
wadler had some talk about that before, about having a firewall of
sorts, i think.

hope this kind of stuff also some day gets over to erlang/lfe. :-)

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


Re: thinking in data, polymorphism, etc.

2012-10-25 Thread Brandon Bloom
 I have a fairly common scenario where I have a set of operations that 
need to work on two types of data (not data types in the clojure sense) 
that have different internal structure (i.e. maps with different keys).

Could you please be a little more concrete? If you provide a specific 
example, we can provide some specific solutions accompanied by some 
rationale to help you solve similar problems in the future.

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

Re: thinking in data, polymorphism, etc.

2012-10-25 Thread Sean Corfield
On Thu, Oct 25, 2012 at 8:59 AM, Brian Craft craft.br...@gmail.com wrote:
 I have a fairly common scenario where I have a set of operations that need
 to work on two types of data (not data types in the clojure sense) that
 have different internal structure (i.e. maps with different keys). I could
 write a generic function that operates on both types of map. That would
 require implementing getters for each type (not sure where those would
 live).

Jim touched on this - you could have functions that map the two
different input data structures to a common form that the function
needs (assuming the call sites know which structure is which). But as
Brandon said, if you can give a more specific example...?
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

Perfection is the enemy of the good.
-- Gustave Flaubert, French realist novelist (1821-1880)

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


Could not locate clojure/data/json__init.class or clojure/data/json.clj on classpath

2012-10-25 Thread larry google groups
I asked this previously but I thought I would start a new thread to go into 
more detail. This is driving me crazy. I was using json in my app and 
everything was working great. Then I did something, but I don't know what. 
Now it is broken. 

My project.clj is:

(defproject who-is-logged-in 1.1
  :description When users arrive 
  :dependencies [
 [org.clojure/clojure 1.3.0]
 [net.cgrand/moustache 1.1.0]
 [ring 1.1.5]
 [ring/ring-jetty-adapter 1.1.5]
 ]
  :main who-is-logged-in.core
  :jvm-opts [-Xmx1000m])


and the top of core.clj looks like this:

(ns who-is-logged-in.core
  (:gen-class)
  (:import (java.util Date)
   (java.io File))
  (:require clojure.string clojure.java.io who-is-logged-in.memory_display
[clojure.data.json :as json])
  (:use   [net.cgrand.moustache :only [app delegate]]
  [ring.util.response]
  [ring.middleware.params]
  [ring.adapter.jetty :only [run-jetty]]))

I run lein deps and then lein compile. I get this error:

Exception in thread main java.io.FileNotFoundException: Could not locate 
clojure/data/json__init.class or clojure/data/json.clj on classpath: , 
compiling:(core.clj:1)
at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3342)
at clojure.lang.Compiler.compile1(Compiler.java:6985)
at clojure.lang.Compiler.compile1(Compiler.java:6975)
at clojure.lang.Compiler.compile(Compiler.java:7046)
at clojure.lang.RT.compile(RT.java:385)
at clojure.lang.RT.load(RT.java:425)
at clojure.lang.RT.load(RT.java:398)
at clojure.core$load$fn__4610.invoke(core.clj:5386)
at clojure.core$load.doInvoke(core.clj:5385)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5200)
at clojure.core$compile$fn__4615.invoke(core.clj:5397)
at clojure.core$compile.invoke(core.clj:5396)
at user$eval27.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:6465)
at clojure.lang.Compiler.eval(Compiler.java:6455)
at clojure.lang.Compiler.eval(Compiler.java:6431)
at clojure.core$eval.invoke(core.clj:2795)
at clojure.main$eval_opt.invoke(main.clj:296)
at clojure.main$initialize.invoke(main.clj:315)
at clojure.main$null_opt.invoke(main.clj:348)
at clojure.main$main.doInvoke(main.clj:426)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:405)
at clojure.lang.AFn.applyToHelper(AFn.java:163)
at clojure.lang.Var.applyTo(Var.java:518)
at clojure.main.main(main.java:37)
Caused by: java.io.FileNotFoundException: Could not locate 
clojure/data/json__init.class or clojure/data/json.clj on classpath: 


Like I said, this was working, and now it is broken. Can anyone guess why? 









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

Re: [ANN] nrepl.el 0.1.5 released

2012-10-25 Thread Tim King
On Mon, Oct 22, 2012 at 5:35 PM, Erlis Vidal er...@erlisvidal.com wrote:

 Quick question,

 After follow the installation instructions it looks like version 0.1.4 was
 installed instead version 0.1.5 do you know why ?


Hi Erlis,
My guess is you have an old version lying around?
Did you install from marmalade?
What versions of nrepl.el do you have in your ~/.emacs.d/elpa folder?

Cheers,
Tim

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

Re: Could not locate clojure/data/json__init.class or clojure/data/json.clj on classpath

2012-10-25 Thread Jim foo.bar

On 25/10/12 18:01, larry google groups wrote:

(:require clojure.string clojure.java.io who-is-logged-in.memory_display
[clojure.data.json :as json])


I don't like this line...

try:

(:require [clojure.string :as st]
[clojure.java.io :as io]
[clojure.data.json :as json]
[who-is-logged-in.memory_display :as who]) ;;assuming this 
is an ns you can reach


also try deleting all your class files and recompile...keep your eye on 
the mailing list cos I think something changed with data.json...there is 
a discussion currently going on...


Jim

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


Re: Could not locate clojure/data/json__init.class or clojure/data/json.clj on classpath

2012-10-25 Thread Mayank Jain
To clean do
$ lein clean

Sent from phone. Please excuse brevity.
On Oct 25, 2012 10:36 PM, Jim foo.bar jimpil1...@gmail.com wrote:

 On 25/10/12 18:01, larry google groups wrote:

 (:require clojure.string clojure.java.io who-is-logged-in.memory_**
 display
 [clojure.data.json :as json])


 I don't like this line...

 try:

 (:require [clojure.string :as st]
 [clojure.java.io :as io]
 [clojure.data.json :as json]
 [who-is-logged-in.memory_**display :as who]) ;;assuming this
 is an ns you can reach

 also try deleting all your class files and recompile...keep your eye on
 the mailing list cos I think something changed with data.json...there is a
 discussion currently going on...

 Jim

 --
 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+unsubscribe@**googlegroups.comclojure%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=enhttp://groups.google.com/group/clojure?hl=en


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

Re: [ANN] nrepl.el 0.1.5 released

2012-10-25 Thread Tim King
Thanks everyone for all the positive feedback.  Glad to hear the community
is finding this useful.

Cheers,
Tim

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

Re: Could not locate clojure/data/json__init.class or clojure/data/json.clj on classpath

2012-10-25 Thread Dave Ray
Why don't you have clojure.data.json in your dependencies in
project.clj? That seems like a problem to me.

Dave

On Thu, Oct 25, 2012 at 10:01 AM, larry google groups
lawrencecloj...@gmail.com wrote:
 I asked this previously but I thought I would start a new thread to go into
 more detail. This is driving me crazy. I was using json in my app and
 everything was working great. Then I did something, but I don't know what.
 Now it is broken.

 My project.clj is:

 (defproject who-is-logged-in 1.1
   :description When users arrive 
   :dependencies [
  [org.clojure/clojure 1.3.0]
  [net.cgrand/moustache 1.1.0]
  [ring 1.1.5]
  [ring/ring-jetty-adapter 1.1.5]
  ]
   :main who-is-logged-in.core
   :jvm-opts [-Xmx1000m])


 and the top of core.clj looks like this:

 (ns who-is-logged-in.core
   (:gen-class)
   (:import (java.util Date)
(java.io File))
   (:require clojure.string clojure.java.io who-is-logged-in.memory_display
 [clojure.data.json :as json])
   (:use   [net.cgrand.moustache :only [app delegate]]
   [ring.util.response]
   [ring.middleware.params]
   [ring.adapter.jetty :only [run-jetty]]))

 I run lein deps and then lein compile. I get this error:

 Exception in thread main java.io.FileNotFoundException: Could not locate
 clojure/data/json__init.class or clojure/data/json.clj on classpath: ,
 compiling:(core.clj:1)
 at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3342)
 at clojure.lang.Compiler.compile1(Compiler.java:6985)
 at clojure.lang.Compiler.compile1(Compiler.java:6975)
 at clojure.lang.Compiler.compile(Compiler.java:7046)
 at clojure.lang.RT.compile(RT.java:385)
 at clojure.lang.RT.load(RT.java:425)
 at clojure.lang.RT.load(RT.java:398)
 at clojure.core$load$fn__4610.invoke(core.clj:5386)
 at clojure.core$load.doInvoke(core.clj:5385)
 at clojure.lang.RestFn.invoke(RestFn.java:408)
 at clojure.core$load_one.invoke(core.clj:5200)
 at clojure.core$compile$fn__4615.invoke(core.clj:5397)
 at clojure.core$compile.invoke(core.clj:5396)
 at user$eval27.invoke(NO_SOURCE_FILE:1)
 at clojure.lang.Compiler.eval(Compiler.java:6465)
 at clojure.lang.Compiler.eval(Compiler.java:6455)
 at clojure.lang.Compiler.eval(Compiler.java:6431)
 at clojure.core$eval.invoke(core.clj:2795)
 at clojure.main$eval_opt.invoke(main.clj:296)
 at clojure.main$initialize.invoke(main.clj:315)
 at clojure.main$null_opt.invoke(main.clj:348)
 at clojure.main$main.doInvoke(main.clj:426)
 at clojure.lang.RestFn.invoke(RestFn.java:421)
 at clojure.lang.Var.invoke(Var.java:405)
 at clojure.lang.AFn.applyToHelper(AFn.java:163)
 at clojure.lang.Var.applyTo(Var.java:518)
 at clojure.main.main(main.java:37)
 Caused by: java.io.FileNotFoundException: Could not locate
 clojure/data/json__init.class or clojure/data/json.clj on classpath:


 Like I said, this was working, and now it is broken. Can anyone guess why?









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

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


Re: thinking in data, polymorphism, etc.

2012-10-25 Thread Brian Craft


On Thursday, October 25, 2012 9:16:58 AM UTC-7, Jim foo.bar wrote:

 On 25/10/12 16:59, Brian Craft wrote: 
  I have a fairly common scenario where I have a set of operations that 
  need to work on two types of data (not data types in the clojure 
  sense) that have different internal structure (i.e. maps with 
  different keys). I could write a generic function that operates on 
  both types of map. 

 I'm not sure I follow why you need polymorphic behavior of any 
 form...the operations that need to operate on 2 internally different 
 maps can take the keys to 'touch' as parameters couldn't they? Then it 
 is truly generic...if this is not practical you can always make a HOF 
 that returns the appropriate handler for the data-type you're examining 
 at any given time...meta-data could help you distinguish between the 
 maps... 


Is this reimplementing a small bit of what multimethods do? I manually 
write something to keep track of handlers, examine the data type of 
parameters, and then dispatch? How is that different than a multimethod?

Hm... I'm trying to get more specific w/o getting lost in details. Briefly, 
I'm drawing a graphic. The graphic can have different kinds of objects 
which define the x axis. In one form, it's a list of objects each of which 
includes a numeric range of sub-elements. E.g. [{:name 'A :start 1 :end 10} 
{:name 'B :start 1 :end 30} {:name 'C :start 200 :end 400}]. In another 
form it's a list of objects each of which includes a list of objects, e.g. 
[{:name 'A :elements ['a 'b 'c]} {:name 'B :elements ['d 'e 'f]}].

On mouse events, corresponding elements on the x axis have to be found, but 
the way you do this is different for the two types. A drag-zoom handler 
might look something like this:

(def drag-zoom [xaxis x1 x2]
   (set-position (interval xaxis (find-element xaxis x1) (find-element 
xaxis x2

where find-element finds the element at the given coord (e.g. 'A 'b in one 
mode, or 'A 8 in the other), interval returns an sub-interval on the xaxis 
(like [{:name 'A :elements ['b 'c]} {:name 'B :elements ['d 'e]}], or 
[{:name 'A :start 8 :end 10} {:name 'B :start 1 :end 10}], and set-position 
updates the current position with the sub-interval.


But, in general, I think any classic OOP example would do. You have 12 
types of shapes and a method total-area that finds the sum of the areas of 
all the instantiated shapes. If you use maps to represent the shapes, where 
do you implement the area calculations for the 12 types of shapes? A 
multimethod that inspects a :shape key? Or convert to records? I could do 
it javascript functional style and write a function that returns a dispatch 
function representing a particular shape, and which implements an 'area' 
method. But that's getting very OOP, and I doubt it's idiomatic clojure.

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

Re: thinking in data, polymorphism, etc.

2012-10-25 Thread Raoul Duke
On Thu, Oct 25, 2012 at 11:03 AM, Brian Craft craft.br...@gmail.com wrote:
 that's getting very OOP, and I doubt it's idiomatic clojure.

http://www.ibm.com/developerworks/library/j-clojure-protocols/

?

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


Re: thinking in data, polymorphism, etc.

2012-10-25 Thread Brian Craft


On Thursday, October 25, 2012 11:07:23 AM UTC-7, raould wrote:

 On Thu, Oct 25, 2012 at 11:03 AM, Brian Craft 
 craft...@gmail.comjavascript: 
 wrote: 
  that's getting very OOP, and I doubt it's idiomatic clojure. 

 http://www.ibm.com/developerworks/library/j-clojure-protocols/ 

 ? 



Hm, yeah, I don't really get protocols, yet. They seem to be all about java 
classes. If I'm using a map to represent some type of data, would I start 
putting protocols on maps? Seems like that wouldn't be a good approach, 
since different protocols would collide. E.g. two shapes represented by 
maps are going to dispatch to the same area  protocol, I think, since 
they're both maps. I'm not sure.

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

Re: Could not locate clojure/data/json__init.class or clojure/data/json.clj on classpath

2012-10-25 Thread larry google groups
Why don't you have clojure.data.json in your dependencies in 
project.clj? That seems like a problem to me. 

Ah, hell. Looks like I accidentally erased that line. Thanks for pointing 
that out. 

svn diff -r r3166:3250 project.clj 
Index: project.clj
===
--- project.clj(revision 3166)
+++ project.clj(revision 3250)
@@ -1,8 +1,9 @@
-(defproject who-is-logged-in 1.0.1
+(defproject who-is-logged-in 1.1
   :dependencies [[org.clojure/clojure 1.3.0]
  [net.cgrand/moustache 1.1.0]
  [ring 1.1.5]
- [ring/ring-jetty-adapter 1.1.5]]
+ [ring/ring-jetty-adapter 1.1.5]
+ [org.clojure/data.json 0.2.0]]
   :main who-is-logged-in.core
-  :jvm-opts [-Xmx4000m])
\ No newline at end of file
+  :jvm-opts [-Xmx1000m])
\ No newline at end of file


On Thursday, October 25, 2012 1:01:54 PM UTC-4, larry google groups wrote:

 I asked this previously but I thought I would start a new thread to go 
 into more detail. This is driving me crazy. I was using json in my app and 
 everything was working great. Then I did something, but I don't know what. 
 Now it is broken. 

 My project.clj is:

 (defproject who-is-logged-in 1.1
   :description When users arrive 
   :dependencies [
  [org.clojure/clojure 1.3.0]
  [net.cgrand/moustache 1.1.0]
  [ring 1.1.5]
  [ring/ring-jetty-adapter 1.1.5]
  ]
   :main who-is-logged-in.core
   :jvm-opts [-Xmx1000m])


 and the top of core.clj looks like this:

 (ns who-is-logged-in.core
   (:gen-class)
   (:import (java.util Date)
(java.io File))
   (:require clojure.string clojure.java.io who-is-logged-in.memory_display
 [clojure.data.json :as json])
   (:use   [net.cgrand.moustache :only [app delegate]]
   [ring.util.response]
   [ring.middleware.params]
   [ring.adapter.jetty :only [run-jetty]]))

 I run lein deps and then lein compile. I get this error:

 Exception in thread main java.io.FileNotFoundException: Could not locate 
 clojure/data/json__init.class or clojure/data/json.clj on classpath: , 
 compiling:(core.clj:1)
 at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3342)
 at clojure.lang.Compiler.compile1(Compiler.java:6985)
 at clojure.lang.Compiler.compile1(Compiler.java:6975)
 at clojure.lang.Compiler.compile(Compiler.java:7046)
 at clojure.lang.RT.compile(RT.java:385)
 at clojure.lang.RT.load(RT.java:425)
 at clojure.lang.RT.load(RT.java:398)
 at clojure.core$load$fn__4610.invoke(core.clj:5386)
 at clojure.core$load.doInvoke(core.clj:5385)
 at clojure.lang.RestFn.invoke(RestFn.java:408)
 at clojure.core$load_one.invoke(core.clj:5200)
 at clojure.core$compile$fn__4615.invoke(core.clj:5397)
 at clojure.core$compile.invoke(core.clj:5396)
 at user$eval27.invoke(NO_SOURCE_FILE:1)
 at clojure.lang.Compiler.eval(Compiler.java:6465)
 at clojure.lang.Compiler.eval(Compiler.java:6455)
 at clojure.lang.Compiler.eval(Compiler.java:6431)
 at clojure.core$eval.invoke(core.clj:2795)
 at clojure.main$eval_opt.invoke(main.clj:296)
 at clojure.main$initialize.invoke(main.clj:315)
 at clojure.main$null_opt.invoke(main.clj:348)
 at clojure.main$main.doInvoke(main.clj:426)
 at clojure.lang.RestFn.invoke(RestFn.java:421)
 at clojure.lang.Var.invoke(Var.java:405)
 at clojure.lang.AFn.applyToHelper(AFn.java:163)
 at clojure.lang.Var.applyTo(Var.java:518)
 at clojure.main.main(main.java:37)
 Caused by: java.io.FileNotFoundException: Could not locate 
 clojure/data/json__init.class or clojure/data/json.clj on classpath: 


 Like I said, this was working, and now it is broken. Can anyone guess why? 











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

Re: thinking in data, polymorphism, etc.

2012-10-25 Thread Raoul Duke
On Thu, Oct 25, 2012 at 11:17 AM, Brian Craft craft.br...@gmail.com wrote:
 http://www.ibm.com/developerworks/library/j-clojure-protocols/
 since different protocols would collide. E.g. two shapes represented by maps
 are going to dispatch to the same area  protocol, I think, since they're
 both maps.

i suspect it shouldn't be a problem, since i thought protocols are to
support specialization of function per (single dispatchy) type?

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


Re: thinking in data, polymorphism, etc.

2012-10-25 Thread Raoul Duke
On Thu, Oct 25, 2012 at 11:17 AM, Brian Craft craft.br...@gmail.com wrote:
 http://www.ibm.com/developerworks/library/j-clojure-protocols/
 Hm, yeah, I don't really get protocols, yet. They seem to be all about java
 classes. If I'm using a map to represent some type of data, would I start
 putting protocols on maps?

not to be at all snarky, did you read the article? when i read it, it
seemed to explain things such that it answers such questions.

sincerely.

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


Re: what is the modern equivalent of clojure.contrib.java-utils/file?

2012-10-25 Thread larry google groups
clojure.java.io/file http://clojure.java.io/file 

So, in project.clj, I do this: 

[org.clojure/io]

? 

Is there a version number I should put in there? 


On Wednesday, October 24, 2012 11:11:11 PM UTC-4, yangsx wrote:

 clojure.java.io/file 

 On Thu, Oct 25, 2012 at 11:08 AM, larry google groups 
 lawrenc...@gmail.com javascript: wrote: 
  
  I want to use clojure.contrib.java-utils/file. I am using Clojure 1.3 
 and 
  leinengen. What is the modern equivalent of 
 clojure.contrib.java-utils/file? 
  
  -- 
  You received this message because you are subscribed to the Google 
  Groups Clojure group. 
  To post to this group, send email to clo...@googlegroups.comjavascript: 
  Note that posts from new members are moderated - please be patient with 
 your 
  first post. 
  To unsubscribe from this group, send email to 
  clojure+u...@googlegroups.com javascript: 
  For more options, visit this group at 
  http://groups.google.com/group/clojure?hl=en 


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

Re: thinking in data, polymorphism, etc.

2012-10-25 Thread Jim - FooBar();

On 25/10/12 19:20, Raoul Duke wrote:

On Thu, Oct 25, 2012 at 11:17 AM, Brian Craft craft.br...@gmail.com wrote:

http://www.ibm.com/developerworks/library/j-clojure-protocols/

since different protocols would collide. E.g. two shapes represented by maps
are going to dispatch to the same area  protocol, I think, since they're
both maps.

i suspect it shouldn't be a problem, since i thought protocols are to
support specialization of function per (single dispatchy) type?



Protocols go hand-in-hand with records in order to provide the fastest 
polymorphic behaviour possible which is no other that type-based 
dispatch...I still don't understand why you 'd want that from what 
you've described so far...
Going back to your graphics example, I think I've had  similar situation 
in one of my GUIs...I had a canva-react fn that worked for the game of 
chess but not for any other games. So yes, I made it a multi-method and 
now consumers of the lib that are supposed to build board-games with i,t 
can simply add their own canva-react that handles their game...Does this 
sound similar to what you're trying to do?


Jim

ps: if you go down the protocol road most likely you'll have to change 
your maps to records.


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


Re: what is the modern equivalent of clojure.contrib.java-utils/file?

2012-10-25 Thread Jim - FooBar();

On 25/10/12 19:25, larry google groups wrote:

So, in project.clj, I do this:

[org.clojure/io]

? 


No no this namespace is part of Clojure itself. No need to put it in the 
project.clj. Just require it in your namespace where you want to use it...


Jim

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


ANN Langohr 1.0.0-beta10 is released

2012-10-25 Thread Michael Klishin
Langohr is a Clojure RabbitMQ client (http://clojurerabbitmq.info) that
embraces AMQP 0.9.1 Model [1].

`1.0-beta10` is a development release with one fix release. We recommend
all users to upgrade to it.


## Changes in 1.0.0-beta10

### langohr.basic/reject now correctly uses basic.reject

langohr.basic/reject now correctly uses `basic.reject` AMQP method
and not `basic.ack`.

Contributed by @natedev.


## Change Log

Langohr change log [2] is available on GitHub.


## Thank You, Contributors

* natedev [3]


1. http://bitly.com/amqp-model-explained
2. https://github.com/michaelklishin/langohr/blob/master/ChangeLog.md
3. http://github.com/natedev
-- 
MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin

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

compile fails but stack trace does not mention a line of code in my app

2012-10-25 Thread larry google groups

I am finding the following stack trace unusually devoid of information. My 
app is Clojure 1.3. I run lein compile and I get the following stack 
trace. Am I blind, or does this stack trace fail to tell me what line I 
should look at?



lein compile
Compiling who-is-logged-in.core
Exception in thread main java.lang.IllegalArgumentException: Don't know 
how to create ISeq from: clojure.lang.Symbol
at clojure.lang.RT.seqFrom(RT.java:487)
at clojure.lang.RT.seq(RT.java:468)
at clojure.lang.RT.first(RT.java:560)
at clojure.core$first.invoke(core.clj:55)
at clojure.core$map$fn__3811.invoke(core.clj:2432)
at clojure.lang.LazySeq.sval(LazySeq.java:42)
at clojure.lang.LazySeq.seq(LazySeq.java:60)
at clojure.lang.RT.seq(RT.java:466)
at clojure.core$seq.invoke(core.clj:133)
at clojure.core$filter$fn__3830.invoke(core.clj:2468)
at clojure.lang.LazySeq.sval(LazySeq.java:42)
at clojure.lang.LazySeq.seq(LazySeq.java:60)
at clojure.lang.RT.seq(RT.java:466)
at clojure.core$seq.invoke(core.clj:133)
at clojure.core$assert_valid_fdecl.invoke(core.clj:6464)
at clojure.core$sigs.invoke(core.clj:220)
at clojure.core$defn.doInvoke(core.clj:293)
at clojure.lang.RestFn.invoke(RestFn.java:525)
at clojure.lang.Var.invoke(Var.java:421)
at clojure.lang.AFn.applyToHelper(AFn.java:185)
at clojure.lang.Var.applyTo(Var.java:518)
at clojure.lang.Compiler.macroexpand1(Compiler.java:6320)
at clojure.lang.Compiler.macroexpand(Compiler.java:6381)
at clojure.lang.Compiler.compile1(Compiler.java:6970)
at clojure.lang.Compiler.compile(Compiler.java:7046)
at clojure.lang.RT.compile(RT.java:385)
at clojure.lang.RT.load(RT.java:425)
at clojure.lang.RT.load(RT.java:398)
at clojure.core$load$fn__4610.invoke(core.clj:5386)
at clojure.core$load.doInvoke(core.clj:5385)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5200)
at clojure.core$compile$fn__4615.invoke(core.clj:5397)
at clojure.core$compile.invoke(core.clj:5396)
at user$eval27.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:6465)
at clojure.lang.Compiler.eval(Compiler.java:6455)
at clojure.lang.Compiler.eval(Compiler.java:6431)
at clojure.core$eval.invoke(core.clj:2795)
at clojure.main$eval_opt.invoke(main.clj:296)
at clojure.main$initialize.invoke(main.clj:315)
at clojure.main$null_opt.invoke(main.clj:348)
at clojure.main$main.doInvoke(main.clj:426)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:405)
at clojure.lang.AFn.applyToHelper(AFn.java:163)
at clojure.lang.Var.applyTo(Var.java:518)
at clojure.main.main(main.java:37)
Compilation failed.

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

Re: thinking in data, polymorphism, etc.

2012-10-25 Thread Brian Craft


On Thursday, October 25, 2012 11:32:11 AM UTC-7, Jim foo.bar wrote:

 On 25/10/12 19:20, Raoul Duke wrote: 
  On Thu, Oct 25, 2012 at 11:17 AM, Brian Craft 
  craft...@gmail.comjavascript: 
 wrote: 
  http://www.ibm.com/developerworks/library/j-clojure-protocols/ 
  since different protocols would collide. E.g. two shapes represented by 
 maps 
  are going to dispatch to the same area  protocol, I think, since 
 they're 
  both maps. 
  i suspect it shouldn't be a problem, since i thought protocols are to 
  support specialization of function per (single dispatchy) type? 
  

 Protocols go hand-in-hand with records in order to provide the fastest 
 polymorphic behaviour possible which is no other that type-based 
 dispatch...I still don't understand why you 'd want that from what 
 you've described so far... 
 Going back to your graphics example, I think I've had  similar situation 
 in one of my GUIs...I had a canva-react fn that worked for the game of 
 chess but not for any other games. So yes, I made it a multi-method and 
 now consumers of the lib that are supposed to build board-games with i,t 
 can simply add their own canva-react that handles their game...Does this 
 sound similar to what you're trying to do? 


Yes, it does. Ok, so: multimethods. 

Multimethods seem like a convenience layer over duck typing: probe the 
object to see what it is, then dispatch. Is that a fair description?

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

Re: what is the modern equivalent of clojure.contrib.java-utils/file?

2012-10-25 Thread larry google groups
No no this namespace is part of Clojure itself. 

How do you know this? Where is this documented? I find myself baffled as to 
what is a dependency and what is not.




On Thursday, October 25, 2012 2:33:49 PM UTC-4, Jim foo.bar wrote:

 On 25/10/12 19:25, larry google groups wrote: 
  So, in project.clj, I do this: 
  
  [org.clojure/io] 
  
  ? 

 No no this namespace is part of Clojure itself. No need to put it in the 
 project.clj. Just require it in your namespace where you want to use it... 

 Jim 


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

Re: thinking in data, polymorphism, etc.

2012-10-25 Thread Jim - FooBar();

On 25/10/12 19:38, Brian Craft wrote:
Multimethods seem like a convenience layer over duck typing: probe the 
object to see what it is, then dispatch. Is that a fair description?


Not exactly...MUlti-methods have no limitations with regarding dispatch. 
You can dispatch on anything...I mean ANYTHING!!! To give you an idea, 
my canva-react mulit-method dispatches on the type of game being played 
at the moment which is not part of the parameters passed in!!! In other 
words the dispatch function completely ignores the arguments! Nothing to 
do with types/classes etc etc. You dispatch on some function - that is it!!!


similarly:

|(||defmulti||halt|
|(||fn||[||_ _||]| |;dispatch-function checks for OS - ignores args
|
|(||let||[||os||(||System/getProperty||os.name||)||]|
|||(||if||(||.startsWith os||Mac OS||)||:Linux 
||(||keyword||os||)||)||)||)||)|

|;;for Linux and Mac machines |
|(||defmethod||halt :Linux||[||root-pwd minutes-after||]|
|||(||clojure||.java.shell/sh|
|||sudo||-S||shutdown||(||str||+||minutes-after||)||:in||(||str||root-pwd||\n||)||)||)|
|;;for Windows machines|
|(||defmethod||halt :Windows||[||_ minutes-after||]|
|||(||clojure||.java.shell/sh||shutdown||-s||-t| 
|(||str||minutes-after||)||)||)|

|;;for Solaris machines|
|(||defmethod||halt :Solaris||[||root-pwd seconds-after||]|
|||(||clojure||.java.shell/sh|
|||shutdown||-S||-y||(||str||-g||seconds-after||)||-i||S||:in||(||str||root-pwd||\n||)||)||)|
|;;in case nothing fires|
|(||defmethod||halt||:default||[||]||(||throw||(||UnsupportedOperationException.||Unsupported 
operating system!||)||)||)



Jim



|

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

Re: thinking in data, polymorphism, etc.

2012-10-25 Thread Raoul Duke
On Thu, Oct 25, 2012 at 11:38 AM, Brian Craft craft.br...@gmail.com wrote:
 Multimethods seem like a convenience layer over duck typing: probe the
 object to see what it is, then dispatch. Is that a fair description?

maybe if you squint. but i wouldn't have said so, just to my way of thinking.

http://clojure.org/runtime_polymorphism

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


Re: ANN: data.json 0.2.0

2012-10-25 Thread kovas boguta
I agree these changes are for the best.

Not announcing breaking changes is not optimal as it were, but we
should solve the general problem, rather than this specific instance

In a world with codeq, the capability exists to detect breaking
changes. Both by library authors, and by their consumers. The key of
course is to make this easy.

A centralized, pre-imported codeq datomic database, and associated
lein tasks, would be one way to do that.


On Thu, Oct 25, 2012 at 11:08 AM, Stuart Sierra
the.stuart.sie...@gmail.com wrote:
 I am not opposed to having a shim to support an API compatible with older
 releases. It's not even particularly difficult:

 https://gist.github.com/3950124

 I certainly did not anticipate this release causing significant problems for
 application or library developers, and if it did then I apologize.

 However, I will stand by the decision to update the API. data.json 0.1.x
 suffered from what I consider, in retrospect, to be poor design decisions.
 Those were decisions I made over two years ago in a hasty effort to please
 too many people who had conflicting goals:


   - Converting field names to keywords by default can create invalid
 keywords.

   - Keywordization is controlled by a bare boolean argument with little
 indication of its function.

   - Inconsistent styles of optional arguments: read-json and write-json take
 booleans as bare arguments, json-str and print-json use keyword-value pairs.

   - Parsing a string and parsing from a stream -- two very different
 operations -- are conflated in a single function.

   - Functions are not consistently named: json-str, read-json, write-json

   - Function names repeat the name of the library, rather than using
 namespaces.


 It was impossible to solve some of these problems without introducing
 breaking changes.

 Looking at the Clojure Library Coding Standards[1], data.json 0.2.0 does a
 better job at Use good names and Unroll optional named arguments. It
 fails at Java's commitment to not break existing code. In this instance, I
 believe the tradeoff is worthwhile because the new API can be more easily
 extended with additional arguments. This also opened up a place to add new
 features such as customizable conversion functions, the
 most-commonly-requested feature for this library.

 Per Rich's directive[2], I cannot yet make a 1.0.0 release. Therefore, 0.1.3
 to 0.2.0 is the largest version bump I can make and the best indication I
 can give of breaking changes. I hope that these improvements to the API
 bring this library closer to a 1.0.0-ready state.

 I'm not trying to make anyone's life more difficult, just trying to provide
 useful tools.

 -S


 [1]: http://dev.clojure.org/display/design/Library+Coding+Standards
 [2]: http://dev.clojure.org/display/design/Contrib+1.0.0+Releases



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

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


Re: compile fails but stack trace does not mention a line of code in my app

2012-10-25 Thread gaz jones
Look in who-is-logged-in.core for errors

On Thu, Oct 25, 2012 at 1:36 PM, larry google groups
lawrencecloj...@gmail.com wrote:
 who-is-logged-in.core

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


Re: thinking in data, polymorphism, etc.

2012-10-25 Thread Brian Craft


On Thursday, October 25, 2012 11:44:50 AM UTC-7, Jim foo.bar wrote:

  On 25/10/12 19:38, Brian Craft wrote:
  
 Multimethods seem like a convenience layer over duck typing: probe the 
 object to see what it is, then dispatch. Is that a fair description?


 Not exactly...MUlti-methods have no limitations with regarding dispatch. 
 You can dispatch on anything...I mean ANYTHING!!! To give you an idea, my 
 canva-react mulit-method dispatches on the type of game being played at the 
 moment which is not part of the parameters passed in!!! In other words the 
 dispatch function completely ignores the arguments! Nothing to do with 
 types/classes etc etc. You dispatch on some function - that is it!!!

 similarly:

 (defmulti halt
 (fn [_ _]  ;dispatch-function checks for OS - ignores args
  (let [os (System/getProperty os.name)]
   (if (.startsWith os Mac OS) :Linux  (keyword os)
  
 ;;for Linux and Mac machines
 (defmethod halt :Linux [root-pwd minutes-after] 
(clojure.java.shell/sh
sudo -S shutdown (str + minutes-after) :in (str root-pwd \n))
 )
  
 ;;for Windows machines
 (defmethod halt :Windows [_ minutes-after]
(clojure.java.shell/sh shutdown -s -t  (str minutes-after)))
  
 ;;for Solaris machines
 (defmethod halt :Solaris [root-pwd seconds-after]
(clojure.java.shell/sh
shutdown -S -y (str -g seconds-after) -i S :in (str 
 root-pwd \n)))
  
 ;;in case nothing fires
 (defmethod halt :default [] (throw (UnsupportedOperationException. 
 Unsupported 
 operating system!)))


heh. I see. Thanks! 

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

Re: what is the modern equivalent of clojure.contrib.java-utils/file?

2012-10-25 Thread Jim - FooBar();

On 25/10/12 19:39, larry google groups wrote:
How do you know this? Where is this documented? I find myself baffled 
as to what is a dependency and what is not.


OK I'll grant you this...Documentation is not the strong part of 
Clojure. There have been/still are efforts to improve on this but 
generally any newcomer to the language struggles at first...A general 
rule of thumb is that if something starts with clojure.something.. 
chances are it is part of Clojure itself (there are exception though e.g 
clojure.java.jdbc)...


hope that helps :-)

Jim

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


Re: compile fails but stack trace does not mention a line of code in my app

2012-10-25 Thread Sean Corfield
On Thu, Oct 25, 2012 at 11:36 AM, larry google groups
lawrencecloj...@gmail.com wrote:
 I am finding the following stack trace unusually devoid of information. My
 app is Clojure 1.3. I run lein compile and I get the following stack
 trace. Am I blind, or does this stack trace fail to tell me what line I
 should look at?

lein compile is not very helpful in terms of debugging syntax errors.
Working with source code in the REPL is sometimes easier to debug
(sometimes!).

My guess would be a syntax error in your (ns ...) declaration tho'...
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

Perfection is the enemy of the good.
-- Gustave Flaubert, French realist novelist (1821-1880)

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


Re: [ANN] nrepl.el 0.1.5 released

2012-10-25 Thread Manuel Paccagnella
Very useful, thank you very much Tim!

Il giorno giovedì 25 ottobre 2012 19:10:22 UTC+2, Tim King ha scritto:

 Thanks everyone for all the positive feedback.  Glad to hear the community 
 is finding this useful.

 Cheers,
 Tim



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

Re: what is the modern equivalent of clojure.contrib.java-utils/file?

2012-10-25 Thread Sean Corfield
On Thu, Oct 25, 2012 at 11:39 AM, larry google groups
lawrencecloj...@gmail.com wrote:
 How do you know this? Where is this documented? I find myself baffled as to
 what is a dependency and what is not.

http://clojure.github.com

If it's listed separated there, it's a contrib you need to pull in
explicitly. Otherwise it's part of Clojure itself.

Clojure's namespaces are documented here (linked from 'clojure' in the
left column of the above page):

http://clojure.github.com/clojure/
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

Perfection is the enemy of the good.
-- Gustave Flaubert, French realist novelist (1821-1880)

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


Re: what is the modern equivalent of clojure.contrib.java-utils/file?

2012-10-25 Thread Jim - FooBar();

On 25/10/12 19:57, Sean Corfield wrote:

On Thu, Oct 25, 2012 at 11:39 AM, larry google groups
lawrencecloj...@gmail.com wrote:

How do you know this? Where is this documented? I find myself baffled as to
what is a dependency and what is not.

http://clojure.github.com

If it's listed separated there, it's a contrib you need to pull in
explicitly. Otherwise it's part of Clojure itself.

Clojure's namespaces are documented here (linked from 'clojure' in the
left column of the above page):

http://clojure.github.com/clojure/


Nice... :
This definitely more informative than what I suggested! :-[

Jim

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


Re: compile fails but stack trace does not mention a line of code in my app

2012-10-25 Thread Philip Potter
Since we're wild mass guessing, I'd say from that stack trace that there's
invalid syntax in a defn's signature somewhere.

I'm basing this on the references to clojure.core$defn and
clojure.core$sigs shortly above compile and macroexpand.

Phil
On Oct 25, 2012 7:36 PM, larry google groups lawrencecloj...@gmail.com
wrote:


 I am finding the following stack trace unusually devoid of information. My
 app is Clojure 1.3. I run lein compile and I get the following stack
 trace. Am I blind, or does this stack trace fail to tell me what line I
 should look at?



 lein compile
 Compiling who-is-logged-in.core
 Exception in thread main java.lang.IllegalArgumentException: Don't know
 how to create ISeq from: clojure.lang.Symbol
 at clojure.lang.RT.seqFrom(RT.java:487)
 at clojure.lang.RT.seq(RT.java:468)
 at clojure.lang.RT.first(RT.java:560)
 at clojure.core$first.invoke(core.clj:55)
 at clojure.core$map$fn__3811.invoke(core.clj:2432)
 at clojure.lang.LazySeq.sval(LazySeq.java:42)
 at clojure.lang.LazySeq.seq(LazySeq.java:60)
 at clojure.lang.RT.seq(RT.java:466)
 at clojure.core$seq.invoke(core.clj:133)
 at clojure.core$filter$fn__3830.invoke(core.clj:2468)
 at clojure.lang.LazySeq.sval(LazySeq.java:42)
 at clojure.lang.LazySeq.seq(LazySeq.java:60)
 at clojure.lang.RT.seq(RT.java:466)
 at clojure.core$seq.invoke(core.clj:133)
 at clojure.core$assert_valid_fdecl.invoke(core.clj:6464)
 at clojure.core$sigs.invoke(core.clj:220)
 at clojure.core$defn.doInvoke(core.clj:293)
 at clojure.lang.RestFn.invoke(RestFn.java:525)
 at clojure.lang.Var.invoke(Var.java:421)
 at clojure.lang.AFn.applyToHelper(AFn.java:185)
 at clojure.lang.Var.applyTo(Var.java:518)
 at clojure.lang.Compiler.macroexpand1(Compiler.java:6320)
 at clojure.lang.Compiler.macroexpand(Compiler.java:6381)
 at clojure.lang.Compiler.compile1(Compiler.java:6970)
 at clojure.lang.Compiler.compile(Compiler.java:7046)
 at clojure.lang.RT.compile(RT.java:385)
 at clojure.lang.RT.load(RT.java:425)
 at clojure.lang.RT.load(RT.java:398)
 at clojure.core$load$fn__4610.invoke(core.clj:5386)
 at clojure.core$load.doInvoke(core.clj:5385)
 at clojure.lang.RestFn.invoke(RestFn.java:408)
 at clojure.core$load_one.invoke(core.clj:5200)
 at clojure.core$compile$fn__4615.invoke(core.clj:5397)
 at clojure.core$compile.invoke(core.clj:5396)
 at user$eval27.invoke(NO_SOURCE_FILE:1)
 at clojure.lang.Compiler.eval(Compiler.java:6465)
 at clojure.lang.Compiler.eval(Compiler.java:6455)
 at clojure.lang.Compiler.eval(Compiler.java:6431)
 at clojure.core$eval.invoke(core.clj:2795)
 at clojure.main$eval_opt.invoke(main.clj:296)
 at clojure.main$initialize.invoke(main.clj:315)
 at clojure.main$null_opt.invoke(main.clj:348)
 at clojure.main$main.doInvoke(main.clj:426)
 at clojure.lang.RestFn.invoke(RestFn.java:421)
 at clojure.lang.Var.invoke(Var.java:405)
 at clojure.lang.AFn.applyToHelper(AFn.java:163)
 at clojure.lang.Var.applyTo(Var.java:518)
 at clojure.main.main(main.java:37)
 Compilation failed.

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

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

Re: thinking in data, polymorphism, etc.

2012-10-25 Thread Jim - FooBar();

On 25/10/12 19:49, Brian Craft wrote:
heh. I see. Thanks! 


No problem...;-)

Jim

ps: It goes without saying that you shouldn't sprinkle your code with 
multi-methods just because you can! Trust me, I know they are nice and 
very tempting to use but save them for when you truly need 
multiple-dispatch and generally not for performance critical code. All 
the freedom/leverage they provide comes at a cost... For drawing things 
on screen it's fine...


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


Generating permutations in core.logic

2012-10-25 Thread Jordan Lewis
Hi,

I'm new to core.logic and logic programming in general. I tried to write a 
small program to generate all permutations of any size for an input list 
with unique elements. To start, I hardcoded the input list to be (range 3). 
Here's what I came up with:

(defne everyo [g l]
  A relation that guarantees that g holds for all elements of l.
  ([_ ()])
  ([_ [x . r]]
(g x)
(everyo g r)))

(run 16 [q] (everyo #(membero % (range 3)) q) (distincto q))

;; returns (() (0) (1) (2) (0 1) (1 0) (2 0) (0 2) (2 1) (1 2) (2 0 1) (2 1 
0) (0 2 1) (1 2 0) (0 1 2) (1 0 2)), as expected

This program works: it returns all 16 permutations of '(0 1 2). However, if 
I ask for any more than 16 solutions, the program doesn't terminate. Having 
browsed this mailing list a little, I noticed a warning about using 
recursive relations first, so I swapped the two clauses of the run clause:

(run 16 [q] (distincto q) (everyo #(membero % (range 3)) q))
;; returns (() [0] [1] [2] (0 0) (0 1) (1 0) (0 2) (1 1) (2 0) (1 2) (2 1) 
(2 2) (0 0 0) (0 0 1) (0 1 0)), incorrect

This program returns a different result from the first one. The lists it 
returns are no longer distinct, despite declaring that q must be distincto. 
Additionally, the singleton lists are vectors for some reason. Asking for 
more than 16 results now terminates, but returns more incorrect 
(non-distinct) result lists.

Clearly I'm doing something wrong. I suspect that my implementation of 
everyo is flawed somehow. Can someone please offer advice?

Thanks,
Jordan Lewis

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

Re: Generating permutations in core.logic

2012-10-25 Thread Jim - FooBar();

I think you want to have a look at clojure.math.combinatorics

Jim

On 25/10/12 20:10, Jordan Lewis wrote:

Hi,

I'm new to core.logic and logic programming in general. I tried to 
write a small program to generate all permutations of any size for an 
input list with unique elements. To start, I hardcoded the input list 
to be (range 3). Here's what I came up with:


(defne everyo [g l]
  A relation that guarantees that g holds for all elements of l.
  ([_ ()])
  ([_ [x . r]]
(g x)
(everyo g r)))

(run 16 [q] (everyo #(membero % (range 3)) q) (distincto q))

;; returns (() (0) (1) (2) (0 1) (1 0) (2 0) (0 2) (2 1) (1 2) (2 0 1) 
(2 1 0) (0 2 1) (1 2 0) (0 1 2) (1 0 2)), as expected


This program works: it returns all 16 permutations of '(0 1 2). 
However, if I ask for any more than 16 solutions, the program doesn't 
terminate. Having browsed this mailing list a little, I noticed a 
warning about using recursive relations first, so I swapped the two 
clauses of the run clause:


(run 16 [q] (distincto q) (everyo #(membero % (range 3)) q))
;; returns (() [0] [1] [2] (0 0) (0 1) (1 0) (0 2) (1 1) (2 0) (1 2) 
(2 1) (2 2) (0 0 0) (0 0 1) (0 1 0)), incorrect


This program returns a different result from the first one. The lists 
it returns are no longer distinct, despite declaring that q must be 
distincto. Additionally, the singleton lists are vectors for some 
reason. Asking for more than 16 results now terminates, but returns 
more incorrect (non-distinct) result lists.


Clearly I'm doing something wrong. I suspect that my implementation of 
everyo is flawed somehow. Can someone please offer advice?


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

To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en 


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

Re: Generating permutations in core.logic

2012-10-25 Thread David Nolen
On Thu, Oct 25, 2012 at 3:10 PM, Jordan Lewis jordanthele...@gmail.comwrote:

 Hi,

 I'm new to core.logic and logic programming in general. I tried to write a
 small program to generate all permutations of any size for an input list
 with unique elements. To start, I hardcoded the input list to be (range 3).
 Here's what I came up with:


Are you using core.logic 0.8.0-beta1 ? The distincto issue looks like it
might be a bug.

As far as not terminating that's because of the structure of the program.
By asking for the 17th solution you asking to construct lists larger than 3
which satisfy the distincto condition which is of course impossible. The
program fails indefinitely because q has no bound.

David

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

Re: Generating permutations in core.logic

2012-10-25 Thread David Nolen
On Thu, Oct 25, 2012 at 3:27 PM, David Nolen dnolen.li...@gmail.com wrote:

 On Thu, Oct 25, 2012 at 3:10 PM, Jordan Lewis jordanthele...@gmail.comwrote:

 Hi,

 I'm new to core.logic and logic programming in general. I tried to write
 a small program to generate all permutations of any size for an input list
 with unique elements. To start, I hardcoded the input list to be (range 3).
 Here's what I came up with:


You can bound the q w/:

(bounded-listo q n)

n must be ground or you will continue to run into trouble.

David

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

Re: Generating permutations in core.logic

2012-10-25 Thread David Nolen
On Thu, Oct 25, 2012 at 3:10 PM, Jordan Lewis jordanthele...@gmail.comwrote:

 (run 16 [q] (distincto q) (everyo #(membero % (range 3)) q))
 ;; returns (() [0] [1] [2] (0 0) (0 1) (1 0) (0 2) (1 1) (2 0) (1 2) (2 1)
 (2 2) (0 0 0) (0 0 1) (0 1 0)), incorrect


Ticket created for the distincto bug -
http://dev.clojure.org/jira/browse/LOGIC-62

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

Re: thinking in data, polymorphism, etc.

2012-10-25 Thread Laurent PETIT
Sent from a smartphone, please excuse the brevity/typos.

Le 25 oct. 2012 à 20:44, Jim - FooBar(); jimpil1...@gmail.com a écrit :

 On 25/10/12 19:38, Brian Craft wrote:

Multimethods seem like a convenience layer over duck typing: probe the
object to see what it is, then dispatch. Is that a fair description?


Not exactly...MUlti-methods have no limitations with regarding dispatch.
You can dispatch on anything...I mean ANYTHING!!! To give you an idea, my
canva-react mulit-method dispatches on the type of game being played at the
moment which is not part of the parameters passed in!!! In other words the
dispatch function completely ignores the arguments!


Wow, this kind of decision is not for the faint of heart.
Not to be taken lightly, that's for sure! Because then, your code becomes
non pure, harder to test, etc.
not saying that it was not appropriate in your case, but rather than used
as a demonstration of how 'powerful' (as in easy to shoot one selves in the
foot), this should certainly not be a habit to start using this kind of
trick at first...

Nothing to do with types/classes etc etc. You dispatch on some function -
that is it!!!

similarly:

 (defmulti halt
(fn [_ _]  ;dispatch-function checks for OS - ignores args
 (let [os (System/getProperty os.name)]
  (if (.startsWith os Mac OS) :Linux  (keyword os)

;;for Linux and Mac machines
(defmethod halt :Linux [root-pwd minutes-after]
   (clojure.java.shell/sh
   sudo -S shutdown (str + minutes-after) :in (str root-pwd \n)))

;;for Windows machines
(defmethod halt :Windows [_ minutes-after]
   (clojure.java.shell/sh shutdown -s -t  (str minutes-after)))

;;for Solaris machines
(defmethod halt :Solaris [root-pwd seconds-after]
   (clojure.java.shell/sh
   shutdown -S -y (str -g seconds-after) -i S :in (str root-pwd
\n)))

;;in case nothing fires
(defmethod halt :default [] (throw (UnsupportedOperationException. Unsupported
operating system!)))


Jim




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

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

Re: Disconnect a downstream channel in lamina

2012-10-25 Thread Zach Tellman
If the upstream channel is permanent, then it won't close if all downstream 
channels are closed.  You can create a permanent channel using 
(permanent-channel) or (channel* :permanent? true).  Once you have that, 
you can replace all that code with a simple (siphon perm-ch conn-ch)

As an aside, though, you could also accomplish the above without delving 
into functions that are really implementation details.

  (if-let [evs (seq (channel-seq ch))]
evs
(run-pipeline (read-channel* :on-timeout ::timeout, timeout 
POLL-TIMEOUT)
  (fn [msg]
(when-not (= ::timeout msg)
  (conj (channel-seq ch) msg)

This is non-blocking, but will require some outer handler to deal with the 
async-result.

Also, in the future you'll probably get a more reliable reply if you use 
the Aleph mailing list.

Zach
  

On Thursday, October 25, 2012 4:09:40 AM UTC-7, Marko Topolnik wrote:

 I use lamina channels in a library that maintains multiple event streams. 
 The event source is the Asterisk Management Interface, whose raw events are 
 processed, filtered, collated, and finally pushed into appropriate lamina 
 channels.

 On the client side of my library I want to expose the event streams as a 
 web service. My challenge is to implement long polling: a request either 
 finds events already enqueued, returning immediately; or blocks until an 
 event occurs (with a timeout), then accumulates any further events for a 
 short period, then returns the accumulated events. This reduces network 
 overhead for the typical case of events occuring in short bursts (a single 
 user action triggers several events).

 I have implemented this behavior in a piece of code that occupies its 
 thread for the entire duration of the request:

 (require 
   [lamina.core :as m] 
   [lamina.core.graph.node :as node] 
   [lamina.core.channel :as chan])

 (let [evs (node/drain (chan/emitter-node ch))
   evs (if (seq evs)
 evs
 (try (let [ev @(m/with-timeout POLL-TIMEOUT (m/read-channel 
 ch))]
(Thread/sleep EVENT-BURST-PERIOD)
(conj (node/drain (chan/emitter-node ch)) ev))
  (catch TimeoutException _ nil)))]
   (vec evs))

 I would instead like to do this without blocking the thread. Ideally, I'll 
 use aleph to implement the web service and connect a downstream HTTP 
 response channel to my library's lamina channel. What I'm missing is, how 
 do I disconnect the downstream channel without breaking anything in the 
 upstream channel? I want to cleanly disconnect it, let my channel enqueue 
 any further events, then later connect another aleph channel, which will 
 drain those events with no loss.



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

Re: thinking in data, polymorphism, etc.

2012-10-25 Thread Jim - FooBar();

On 25/10/12 20:33, Laurent PETIT wrote:

Wow, this kind of decision is not for the faint of heart.
Not to be taken lightly, that's for sure! Because then, your code 
becomes non pure, harder to test, etc.
not saying that it was not appropriate in your case, but rather than 
used as a demonstration of how 'powerful' (as in easy to shoot one 
selves in the foot), this should certainly not be a habit to start 
using this kind of trick at first...


Yes you're right...suddenly the multi-method depends on some state, 
however the GUI is already pretty stateful and if you want to let the 
user write the logic of a game and suddenly show it up with graphics on 
the screen without writing any code, I don't see how else it can be 
done...It's not critical code, it's extensible, it's powerful...


The point I was trying to make and perhaps I was a bit extreme, is that 
there is no type, there is no class, there is no object  - it's just a 
function! Usually you dispatch on some fn of the arguments or some of 
arguments or if you really want to some other irrelevant var (state). 
Ignoring the arguments clearly makes the point that (perhaps too hard): 
forget anything you knew about single type-based dispatch. 
Multi-methods are on a whole other level  with regards to polymorphism. :-)


Jim

ps: I hope we can agree that there is nothing wrong with the 'halt' 
multi-method I demonstrated as it depends on some state already and 
doesn't need to know about passwords and minutes. Because the arity of 
dispatch-fn has to match the arty of the implementations it is a common 
thing to ignore some arguments in dispatch-fns isn't it? I've seen quite 
a few times...



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


Re: what is the modern equivalent of clojure.contrib.java-utils/file?

2012-10-25 Thread larry google groups
Okay, if I look here:


http://clojure.github.com 


Can I assume that anything that starts with clojure.core is not a 
dependency? And everything else is? 


So this would be listed as a dependency if I use it:


clojure.test.junithttp://clojure.github.com/clojure/clojure.test.junit-api.html



but I would not have to list this as a dependency:

clojure.core.protocolshttp://clojure.github.com/clojure/clojure.core.protocols-api.html




On Thursday, October 25, 2012 2:57:26 PM UTC-4, Sean Corfield wrote:

 On Thu, Oct 25, 2012 at 11:39 AM, larry google groups 
 lawrenc...@gmail.com javascript: wrote: 
  How do you know this? Where is this documented? I find myself baffled as 
 to 
  what is a dependency and what is not. 

 http://clojure.github.com 

 If it's listed separated there, it's a contrib you need to pull in 
 explicitly. Otherwise it's part of Clojure itself. 

 Clojure's namespaces are documented here (linked from 'clojure' in the 
 left column of the above page): 

 http://clojure.github.com/clojure/ 
 -- 
 Sean A Corfield -- (904) 302-SEAN 
 An Architect's View -- http://corfield.org/ 
 World Singles, LLC. -- http://worldsingles.com/ 

 Perfection is the enemy of the good. 
 -- Gustave Flaubert, French realist novelist (1821-1880) 


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

Re: Generating permutations in core.logic

2012-10-25 Thread Jordan Lewis
On Thursday, October 25, 2012 3:17:44 PM UTC-4, Jim foo.bar wrote:

 I think you want to have a look at clojure.math.combinatorics


Jim, thanks for the suggestion. I am trying to get a feel for how 
core.logic works, not reinvent code from the combinatorics library.

On Thursday, October 25, 2012 3:27:40 PM UTC-4, David Nolen wrote:

 Are you using core.logic 0.8.0-beta1 ? The distincto issue looks like it 
 might be a bug. 


Yes.
 


 As far as not terminating that's because of the structure of the program. 
 By asking for the 17th solution you asking to construct lists larger than 3 
 which satisfy the distincto condition which is of course impossible. The 
 program fails indefinitely because q has no bound.


Ah, I see. That's interesting. I had assumed that the two clauses would 
naturally create a bound on the size of the list, but I suppose that it's 
not enough information to go on.


On Thursday, October 25, 2012 3:31:25 PM UTC-4, David Nolen wrote:

 Ticket created for the distincto bug - 
 http://dev.clojure.org/jira/browse/LOGIC-62 


Thanks!

- Jordan 

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

Re: Generating permutations in core.logic

2012-10-25 Thread Jim - FooBar();

On 25/10/12 20:57, Jordan Lewis wrote:
Jim, thanks for the suggestion. I am trying to get a feel for how 
core.logic works, not reinvent code from the combinatorics library.


Fair enough... :-)

Jim

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


Re: thinking in data, polymorphism, etc.

2012-10-25 Thread Brandon Bloom


 (fn [_ _]  ;dispatch-function checks for OS - ignores args
 (let [os (System/getProperty os.name)]
   (if (.startsWith os Mac OS) :Linux  (keyword os)


This seems like a very poor use of multi-methods. Multi-methods exist to 
provide both dynamic and open dispatch. In this case, the dispatch function 
is completely static.

If you don't need dynamism or openness, then you're better off with a 
simple case form at the top level:

(case platform
  :linux (def halt [root-pwd minutes-after] ...)
  :windows ...
  ...
  (def halt [ args] (throw ...)))

If you prefer the appearance of top-level forms, or need the openness, you 
could pretty easily implement a static version of defmulti  defmethod 
which ensure you only pay the dispatch cost once at startup, rather than on 
every invocation.

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

Re: what is the modern equivalent of clojure.contrib.java-utils/file?

2012-10-25 Thread Ben Smith-Mannschott
Anything that starts with clojure. is part of (some version of) clojure.

For Clojure 1.4, that's everything listed in Table of Contents on
the right side of the web page you'll find here:

http://clojure.github.com/clojure/

clojure.core
clojure.data
clojure.inspector
clojure.java.browse
clojure.java.io
clojure.java.javadoc
clojure.java.shell
clojure.main
clojure.pprint
clojure.reflect
clojure.repl
clojure.set
clojure.stacktrace
clojure.string
clojure.template
clojure.test
clojure.walk
clojure.xml
clojure.zip

That'll all be available without needing to add dependencies to your
project.clj. You'll just need to :require it as usual in your ns form.


On Thu, Oct 25, 2012 at 9:52 PM, larry google groups
lawrencecloj...@gmail.com wrote:
 Okay, if I look here:


 http://clojure.github.com


 Can I assume that anything that starts with clojure.core is not a
 dependency? And everything else is?


 So this would be listed as a dependency if I use it:



 clojure.test.junit



 but I would not have to list this as a dependency:


 clojure.core.protocols






 On Thursday, October 25, 2012 2:57:26 PM UTC-4, Sean Corfield wrote:

 On Thu, Oct 25, 2012 at 11:39 AM, larry google groups
 lawrenc...@gmail.com wrote:
  How do you know this? Where is this documented? I find myself baffled as
  to
  what is a dependency and what is not.

 http://clojure.github.com

 If it's listed separated there, it's a contrib you need to pull in
 explicitly. Otherwise it's part of Clojure itself.

 Clojure's namespaces are documented here (linked from 'clojure' in the
 left column of the above page):

 http://clojure.github.com/clojure/
 --
 Sean A Corfield -- (904) 302-SEAN
 An Architect's View -- http://corfield.org/
 World Singles, LLC. -- http://worldsingles.com/

 Perfection is the enemy of the good.
 -- Gustave Flaubert, French realist novelist (1821-1880)

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

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


Re: thinking in data, polymorphism, etc.

2012-10-25 Thread Jim - FooBar();
You say that from the safe standpoint of being able to enumerate all 
OSes in advance...I can imagine a world where anyone can have his own 
OS. :-)

Seriously now, this is not production code obviously! just a demo...

Jim

On 25/10/12 21:04, Brandon Bloom wrote:


|(||fn||[||_ _||]||;dispatch-function checks for OS - ignores args|
|(||let||[||os||(||System/getProperty||os.name
http://os.name||)||]|
|||(||if||(||.startsWith os||Mac OS||)||:Linux
||(||keyword||os||)||)||)||)||)|


This seems like a very poor use of multi-methods. Multi-methods exist 
to provide both dynamic and open dispatch. In this case, the dispatch 
function is completely static.


If you don't need dynamism or openness, then you're better off with a 
simple case form at the top level:


(case platform
  :linux (def halt [root-pwd minutes-after] ...)
  :windows ...
  ...
  (def halt [ args] (throw ...)))

If you prefer the appearance of top-level forms, or need the openness, 
you could pretty easily implement a static version of defmulti  
defmethod which ensure you only pay the dispatch cost once at startup, 
rather than on every invocation.

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

To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en 


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

Re: ANN: data.json 0.2.0

2012-10-25 Thread Stuart Sierra
I'm sorry for causing people extra work. How's this for a solution:

https://github.com/clojure/data.json/commit/6ee71009946731d89ef8f98e7b659fa82443b6a2

This allows the 0.2.x code to pass all the tests for data.json 0.1.3.

I can't retract the 0.2.0 release, but if I push this out as 0.2.1 the 
compatibility issues should be at a minimum.

-S

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

Re: pst shows the cause instead of the last thrown ex thus it doesn't show the chain

2012-10-25 Thread AtKaaZ
I can see why, here's the implementation of pst:
(defn pst
  Prints a stack trace of the exception, to the depth requested. If none
supplied, uses the root cause of the
  most recent repl exception (*e), and a depth of 12.
  {:added 1.3}
  ([] (pst 12))
  ([e-or-depth]
 (if (instance? Throwable e-or-depth)
   (pst e-or-depth 12)
   (when-let [e *e]
 (pst (root-cause e) e-or-depth
  ([^Throwable e depth]
 (binding [*out* *err*]
   (println (str (- e class .getSimpleName)  
 (.getMessage e)
 (when-let [info (ex-data e)] (str   (pr-str info)
   (let [st (.getStackTrace e)
 cause (.getCause e)]
 (doseq [el (take depth
  (remove #(#{clojure.lang.RestFn
clojure.lang.AFn} (.getClassName %))
  st))]
   (println (str \tab (stack-element-str el
 (when cause
   (println Caused by:)
   (pst cause (min depth
   (+ 2 (- (count (.getStackTrace cause))
   (count st))

so this works as expected:
= *(try (throw (Exception. a (Exception. cause))) (catch Exception e
(throw e)))
   (pst *e 123912031)*
Exception cause  cloj2.ka/eval1430 (NO_SOURCE_FILE:1)
Exception a
cloj2.ka/eval1430 (NO_SOURCE_FILE:1)
clojure.lang.Compiler.eval (Compiler.java:6603)
clojure.lang.Compiler.eval (Compiler.java:6566)
clojure.core/eval (core.clj:2836)
clojure.main/repl/read-eval-print--6667 (main.clj:245)
clojure.main/repl/fn--6672/fn--6673 (main.clj:266)
clojure.main/repl/fn--6672 (main.clj:266)
clojure.main/repl (main.clj:264)
clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn--938
(interruptible_eval.clj:58)
clojure.core/apply (core.clj:614)
clojure.core/with-bindings* (core.clj:1785)
clojure.tools.nrepl.middleware.interruptible-eval/evaluate
(interruptible_eval.clj:43)

clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval/fn--979/fn--982
(interruptible_eval.clj:173)
clojure.core/comp/fn--4092 (core.clj:2314)
clojure.tools.nrepl.middleware.interruptible-eval/run-next/fn--972
(interruptible_eval.clj:140)
java.util.concurrent.ThreadPoolExecutor.runWorker
(ThreadPoolExecutor.java:1110)
java.util.concurrent.ThreadPoolExecutor$Worker.run
(ThreadPoolExecutor.java:603)
java.lang.Thread.run (Thread.java:722)
Caused by:
Exception cause
cloj2.ka/eval1430 (NO_SOURCE_FILE:1)
clojure.lang.Compiler.eval (Compiler.java:6603)
nil

but this doesn't:
= *(try (throw (Exception. a (Exception. cause))) (catch Exception e
(throw e)))
   (pst 123912031)*
Exception cause  cloj2.ka/eval1434 (NO_SOURCE_FILE:1)
Exception cause
cloj2.ka/eval1434 (NO_SOURCE_FILE:1)
clojure.lang.Compiler.eval (Compiler.java:6603)
clojure.lang.Compiler.eval (Compiler.java:6566)
clojure.core/eval (core.clj:2836)
clojure.main/repl/read-eval-print--6667 (main.clj:245)
clojure.main/repl/fn--6672/fn--6673 (main.clj:266)
clojure.main/repl/fn--6672 (main.clj:266)
clojure.main/repl (main.clj:264)
clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn--938
(interruptible_eval.clj:58)
clojure.core/apply (core.clj:614)
clojure.core/with-bindings* (core.clj:1785)
clojure.tools.nrepl.middleware.interruptible-eval/evaluate
(interruptible_eval.clj:43)

clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval/fn--979/fn--982
(interruptible_eval.clj:173)
clojure.core/comp/fn--4092 (core.clj:2314)
clojure.tools.nrepl.middleware.interruptible-eval/run-next/fn--972
(interruptible_eval.clj:140)
java.util.concurrent.ThreadPoolExecutor.runWorker
(ThreadPoolExecutor.java:1110)
java.util.concurrent.ThreadPoolExecutor$Worker.run
(ThreadPoolExecutor.java:603)
java.lang.Thread.run (Thread.java:722)
nil


On Wed, Oct 24, 2012 at 3:27 PM, AtKaaZ atk...@gmail.com wrote:

 Here, (pst) doesn't see the thrown exception which is a, it's seeing
 only it's cause:

 = *(try (throw (Exception. a (Exception. cause))) (catch Exception e
 (throw e)))* *(pst 123912031)*
 Exception cause  datest1.core/eval3129 (NO_SOURCE_FILE:1)
 Exception cause
 datest1.core/eval3129 (NO_SOURCE_FILE:1)
 clojure.lang.Compiler.eval (Compiler.java:6603)
 clojure.lang.Compiler.eval (Compiler.java:6566)
 clojure.core/eval (core.clj:2836)
 clojure.main/repl/read-eval-print--6667 (main.clj:245)
 clojure.main/repl/fn--6672/fn--6673 (main.clj:266)
 clojure.main/repl/fn--6672 (main.clj:266)
 clojure.main/repl (main.clj:264)
 clojure.tools.nrepl.middleware.interruptible-eval/evaluate/fn--938
 (interruptible_eval.clj:58)
 clojure.core/apply (core.clj:614)
 clojure.core/with-bindings* (core.clj:1785)
 clojure.tools.nrepl.middleware.interruptible-eval/evaluate
 (interruptible_eval.clj:43)

 clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval/fn--979/fn--982
 

Re: thinking in data, polymorphism, etc.

2012-10-25 Thread Mark Engelberg
On Thu, Oct 25, 2012 at 11:38 AM, Brian Craft craft.br...@gmail.com wrote:

 Multimethods seem like a convenience layer over duck typing: probe the
 object to see what it is, then dispatch. Is that a fair description?



 I think that's pretty accurate.  Others have pointed out that multimethods
can potentially do more than that, but commonly, it's just a way to do
dispatch that leaves things open for extension.

Here's the vanilla way to do dispatch with no special constructs:

(defn circle [radius]
  {:tag :circle, :radius radius})

(defn square [length]
  {:tag :square, :length length})

(defn rectangle [length width]
  {:tag :rectangle, :length length, :width width})

(defn tag-test [tag]
  #(= (:tag %) tag))

(def circle? (tag-test :circle))
(def square? (tag-test :square))
(def rectangle? (tag-test :rectangle))

(defn area-circle [{:keys [radius]}]
  (* 3.14 radius radius))

(defn area-square [{:keys [length]}]
  (* length length))

(defn area-rectangle [{:keys [length width]}]
  (* length width))

(defn area [shape]
  (cond
   (circle? shape) (area-circle shape)
   (square? shape) (area-square shape)
   (rectangle? shape) (area-rectangle shape)))

Here's the way with multimethods:

(defn circle [radius]
  {:tag :circle, :radius radius})

(defn square [length]
  {:tag :square, :length length})

(defn rectangle [length width]
  {:tag :rectangle, :length length, :width width})

(defmulti area :tag)

(defmethod area :circle [{:keys [radius]}]
  (* 3.14 radius radius))

(defmethod area :square [{:keys [length]}]
  (* length length))

(defmethod area :rectangle  [{:keys [length width]}]
  (* length width))

The dispatch function has been eliminated, and we might not need to build
explicit predicates to test for the different types (although in a real
system, you'd probably want those anyway).  Other than that, pretty
similar.  Multimethods become a clearer win if you need inheritance, or if
you need other people to be able to extend the definition of area to new
types without access to your code.

Now let's look at the record version:

(defrecord Circle [radius])
(defrecord Square [length])
(defrecord Rectangle [length width])

(defn area-circle [{:keys [radius]}]
  (* 3.14 radius radius))

(defn area-square [{:keys [length]}]
  (* length length))

(defn area-rectangle [{:keys [length width]}]
  (* length width))

;; Dispatch via protocol

(defprotocol Area
  (area [this]))

(extend Circle
  Area
  {:area area-circle})

(extend Square
  Area
  {:area area-square})

(extend Rectangle
  Area
  {:area area-rectangle})

There are actually several ways to extend protocols to various records.
The most extensible way is to extend records from the outside like above,
and to use maps of functions so the functions aren't locked up inside the
record but can be reused by other related objects.  But as you can see,
this is fairly verbose and it doesn't give you the kind of speed advantage
that people are generally looking for when they convert to
records/protocols.  So most people end up declaring everything inline, like
this:

(defprotocol Area
  (area [this]))

(defrecord Circle [radius]
  Area
  (area [_] (* 3.14 radius radius)))

(defrecord Square [length]
  Area
  (area [_] (* length length)))

(defrecord Rectangle [length width]
  Area
  (area [_] (* length width)))

I personally haven't had a very good experience with records and protocols,
although it is possible that they have improved since I last did much with
them.  First, I found that records were mostly similar to maps, but behaved
subtly different in ways that bit me occasionally.  Second, the
introduction and repetition of protocol names feel clunky to me, especially
in the common case of one function per protocol.  Third, in order to chase
after the supposed performance gains that records/protocols purportedly
bring, I found myself altering my code in ways that looked less and less
Clojurian, using more dot syntax to access constructors, fields, and
methods, and adding type hints.  Even with all those changes, I seemed to
keep running into places that Clojure was forced to use dynamic reflection
on my record-based code (which is never a problem with maps), and the
reflection more than cancels out any performance gains from the dispatch.

So my vote is for multimethods, which is at least as clean and fast as
manual dispatch with more flexibility.  Records/protocols may have some
additional performance benefits in the right use cases, but in my
experience it definitely comes at a cost.

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

Re: what is the modern equivalent of clojure.contrib.java-utils/file?

2012-10-25 Thread John Gabriele
On Thursday, October 25, 2012 2:39:33 PM UTC-4, larry google groups wrote:

 No no this namespace is part of Clojure itself. 

 How do you know this? Where is this documented? I find myself baffled as 
 to what is a dependency and what is not.


Hi Larry,

Note that, concerning libraries, there's three separate but often similar 
names to be aware of:

  * the lib's artifact-id (you'll find it at the top of the lib's very own 
project.clj).
  * the lib's github project name (if it's hosted there)
  * the namespace(s) that the lib provides (specified in the lib's source 
file(s) in the `ns` macro)

Threre's also the lib's group-id, which --- if different from the 
artifact-id --- is also noted at the top of a lib's project.clj file.

You use a lib's group-id and artifact-id in your own project.clj when you 
specify dependencies (group-id is left out when it's the same as the 
artifact-id, which is common for many 3rd-party Clojure libs).

You use a lib's namespace name(s) in your own source's `ns` macro to use 
that lib in your code.

Some notes about contrib libs:

  * all have a group-id of org.clojure, and
  * all have github project names like foo.bar (ex. 
math.combinatorics), under https://github.com/clojure
  * all have namespace names like clojure.foo.bar (ex. 
clojure.math.combinatorics).
  * they're hosted at maven central, not at clojars
  * you can find them all listed at 
http://dev.clojure.org/display/doc/Clojure+Contrib

Some notes about 3rd-party Clojure libs:

  * many have a group-id the same as their artifact-id
  * most are hosted at github, and usually the github project name is the 
same as the artifact-id
  * most are available at Clojars via leiningen
  * many have a namespace like my-proj.core

(Anyone: If there's any errors there, please let me know!)

---John

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

Re: what is the modern equivalent of clojure.contrib.java-utils/file?

2012-10-25 Thread John Gabriele
On Thursday, October 25, 2012 5:04:23 PM UTC-4, John Gabriele wrote:


 Some notes about contrib libs:

   * all have a group-id of org.clojure, and
   * all have github project names like foo.bar (ex. 
 math.combinatorics), under https://github.com/clojure
   * all have namespace names like clojure.foo.bar (ex. 
 clojure.math.combinatorics).
   * they're hosted at maven central, not at clojars
   * you can find them all listed at 
 http://dev.clojure.org/display/doc/Clojure+Contrib


Oooh, one more bullet point for contrib libs:

  * they don't have a project.clj file. They use a  pom.xml file 
instead!

Thought I'd add that, being that it's so close to Halloween and all. ;)

Some notes about 3rd-party Clojure libs:

   * many have a group-id the same as their artifact-id
   * most are hosted at github, and usually the github project name is the 
 same as the artifact-id
   * most are available at Clojars via leiningen
   * many have a namespace like my-proj.core


Most of these are, of course, managed by Leiningen and so *do* have a 
project.clj file.

---John

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

Re: thinking in data, polymorphism, etc.

2012-10-25 Thread Brian Craft


On Thursday, October 25, 2012 1:49:53 PM UTC-7, puzzler wrote:

 On Thu, Oct 25, 2012 at 11:38 AM, Brian Craft craft...@gmail.comjavascript:
  wrote:

 Multimethods seem like a convenience layer over duck typing: probe the 
 object to see what it is, then dispatch. Is that a fair description?



  I think that's pretty accurate.  Others have pointed out that 
 multimethods can potentially do more than that, but commonly, it's just a 
 way to do dispatch that leaves things open for extension.

 Here's the vanilla way to do dispatch with no special constructs:

 (defn circle [radius]
   {:tag :circle, :radius radius})

 (defn square [length]
   {:tag :square, :length length})

 (defn rectangle [length width]
   {:tag :rectangle, :length length, :width width})

 (defn tag-test [tag]
   #(= (:tag %) tag))

 (def circle? (tag-test :circle))
 (def square? (tag-test :square))
 (def rectangle? (tag-test :rectangle))

 (defn area-circle [{:keys [radius]}]
   (* 3.14 radius radius))

 (defn area-square [{:keys [length]}]
   (* length length))

 (defn area-rectangle [{:keys [length width]}]
   (* length width))

 (defn area [shape]
   (cond
(circle? shape) (area-circle shape)
(square? shape) (area-square shape)
(rectangle? shape) (area-rectangle shape)))

 Here's the way with multimethods:

 (defn circle [radius]
   {:tag :circle, :radius radius})

 (defn square [length]
   {:tag :square, :length length})

 (defn rectangle [length width]
   {:tag :rectangle, :length length, :width width})

 (defmulti area :tag)

 (defmethod area :circle [{:keys [radius]}]
   (* 3.14 radius radius))

 (defmethod area :square [{:keys [length]}]
   (* length length))

 (defmethod area :rectangle  [{:keys [length width]}]
   (* length width))

 The dispatch function has been eliminated, and we might not need to build 
 explicit predicates to test for the different types (although in a real 
 system, you'd probably want those anyway).  Other than that, pretty 
 similar.  Multimethods become a clearer win if you need inheritance, or if 
 you need other people to be able to extend the definition of area to new 
 types without access to your code.

 Now let's look at the record version:

 (defrecord Circle [radius])
 (defrecord Square [length])
 (defrecord Rectangle [length width])

 (defn area-circle [{:keys [radius]}]
   (* 3.14 radius radius))

 (defn area-square [{:keys [length]}]
   (* length length))

 (defn area-rectangle [{:keys [length width]}]
   (* length width))

 ;; Dispatch via protocol

 (defprotocol Area
   (area [this]))

 (extend Circle
   Area
   {:area area-circle})

 (extend Square
   Area
   {:area area-square})

 (extend Rectangle
   Area
   {:area area-rectangle})

 There are actually several ways to extend protocols to various records.  
 The most extensible way is to extend records from the outside like above, 
 and to use maps of functions so the functions aren't locked up inside the 
 record but can be reused by other related objects.  But as you can see, 
 this is fairly verbose and it doesn't give you the kind of speed advantage 
 that people are generally looking for when they convert to 
 records/protocols.  So most people end up declaring everything inline, like 
 this:

 (defprotocol Area
   (area [this]))

 (defrecord Circle [radius]
   Area
   (area [_] (* 3.14 radius radius)))

 (defrecord Square [length]
   Area
   (area [_] (* length length)))

 (defrecord Rectangle [length width]
   Area
   (area [_] (* length width)))

 I personally haven't had a very good experience with records and 
 protocols, although it is possible that they have improved since I last did 
 much with them.  First, I found that records were mostly similar to maps, 
 but behaved subtly different in ways that bit me occasionally.  Second, the 
 introduction and repetition of protocol names feel clunky to me, especially 
 in the common case of one function per protocol.  Third, in order to chase 
 after the supposed performance gains that records/protocols purportedly 
 bring, I found myself altering my code in ways that looked less and less 
 Clojurian, using more dot syntax to access constructors, fields, and 
 methods, and adding type hints.  Even with all those changes, I seemed to 
 keep running into places that Clojure was forced to use dynamic reflection 
 on my record-based code (which is never a problem with maps), and the 
 reflection more than cancels out any performance gains from the dispatch.

 So my vote is for multimethods, which is at least as clean and fast as 
 manual dispatch with more flexibility.  Records/protocols may have some 
 additional performance benefits in the right use cases, but in my 
 experience it definitely comes at a cost.



Thanks, this is very helpful! 

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

(if (io/file path-to-session-file) -- returns false though file exists

2012-10-25 Thread larry google groups
So, again, I'm trying to use Clojure to rebuild a PHP site. Right now I 
need the Clojure code to read the PHP session files. In the below function, 
I have a println that shows me that the path points to a file that really 
does exist. And yet this if() clause seems to always return false.  

(defn does-session-exist? [session-id]
  (let [path-to-session-file (str /var/lib/php5/sess_ session-id)]
(println path-to-session-file)
(if (io/file path-to-session-file)
  true
  false)))

io is an alias:

  (:require [clojure.string :as st]
 [clojure.java.io :as io]
 [clojure.data.json :as json]
 [who-is-logged-in.memory_display :as who]) 


I look here and see that the old monolithic Clojure contrib had an exists 
function:

http://clojuredocs.org/clojure_contrib/clojure.contrib.java-utils/file

I see this example:

(. (clojure.contrib.java-utils/file ...) exists)

I'd like to  do that but I don't know how with the modern clojure.java.io. 

I know I can use Java File objects, which has a similar exists method, 
but I wonder if there is any modern Clojure equivalent? 











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

Re: thinking in data, polymorphism, etc.

2012-10-25 Thread Raoul Duke
On Thu, Oct 25, 2012 at 1:49 PM, Mark Engelberg
mark.engelb...@gmail.com wrote:
 So my vote is for multimethods, which is at least as clean and fast as
 manual dispatch with more flexibility.  Records/protocols may have some
 additional performance benefits in the right use cases, but in my experience
 it definitely comes at a cost.

i thought the main problem with multimethods (in most any language
that has them) was that it is hard to make sure the dispatches are all
exactly what you really want e.g. that you've covered all cases, etc.?

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


Clojurescript externs when using a local file (cljsbuild)

2012-10-25 Thread Sean S
Can't seem to get the extern functionality to work, or I'm using it wrong. 
 Basically I have two files:  One live and one test. The test file is built 
with a separate build definition.  I want the test file to be able to see 
the live file using the built in namespace functionality.

This is the live project:

{ :id live
  :source-path src-cljs/live/   
  :compiler 
{ :output-to resources/public/js/*live*/main.js
  :optimizations :simple
  :pretty-print true}} 

I have the test configuration including the file created above:

  { :id test
:source-path src-cljs/test/   
:compiler 
  { :output-to  resources/public/js/*test*/main.js
:optimizations :simple
:externs [resources/public/js/*live*/main.js]  
:pretty-print true}}]}


This is the namespace that I want to include for testing that is in the 
live file resources/public/js/*live*/main.js: 

  (ns helper.webTemplate ...)

This is my attempt to include that namespace in the test file 
resources/public/js/*test*/main.js:

  (ns helper.webTemplate.test
(:require 
  [helper.webTemplate   :as template]...)


With error:

 required helper.webTemplate namespace not provided yet...

Is there a special (Or easier way) to use namespaces in local files?  I 
could just have the test build move down a level since my folder structure 
is:

/src-cljs
  /live
  /test

But would like to know if I can avoid that.

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

Re: (if (io/file path-to-session-file) -- returns false though file exists

2012-10-25 Thread Andy Fingerhut
The only modern Clojure methods I'm aware of for checking for the existence 
of a file are the Java method (.exists (io/file filename-string)), or using 
something like the fs library: https://github.com/Raynes/fs

I'm surprised if the if (io/file path-to-session-fie) always returns false in 
your code example, because (io/file string) returns a Java File object even 
if there is no such file, and Clojure if evaluates that as true, not false.

Andy

On Oct 25, 2012, at 3:21 PM, larry google groups wrote:

 So, again, I'm trying to use Clojure to rebuild a PHP site. Right now I need 
 the Clojure code to read the PHP session files. In the below function, I have 
 a println that shows me that the path points to a file that really does 
 exist. And yet this if() clause seems to always return false.  
 
 (defn does-session-exist? [session-id]
   (let [path-to-session-file (str /var/lib/php5/sess_ session-id)]
 (println path-to-session-file)
 (if (io/file path-to-session-file)
   true
   false)))
 
 io is an alias:
 
   (:require [clojure.string :as st]
  [clojure.java.io :as io]
  [clojure.data.json :as json]
  [who-is-logged-in.memory_display :as who]) 
 
 
 I look here and see that the old monolithic Clojure contrib had an exists 
 function:
 
 http://clojuredocs.org/clojure_contrib/clojure.contrib.java-utils/file
 
 I see this example:
 
 (. (clojure.contrib.java-utils/file ...) exists)
 
 I'd like to  do that but I don't know how with the modern clojure.java.io. 
 
 I know I can use Java File objects, which has a similar exists method, but 
 I wonder if there is any modern Clojure equivalent? 

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

Re: ANN: data.json 0.2.0

2012-10-25 Thread Sean Corfield
Thanx Stuart! That looks great, at a glance.

On Thu, Oct 25, 2012 at 1:25 PM, Stuart Sierra
the.stuart.sie...@gmail.com wrote:
 I'm sorry for causing people extra work. How's this for a solution:

 https://github.com/clojure/data.json/commit/6ee71009946731d89ef8f98e7b659fa82443b6a2

 This allows the 0.2.x code to pass all the tests for data.json 0.1.3.

 I can't retract the 0.2.0 release, but if I push this out as 0.2.1 the
 compatibility issues should be at a minimum.

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


Re: what is the modern equivalent of clojure.contrib.java-utils/file?

2012-10-25 Thread Sean Corfield
On Thu, Oct 25, 2012 at 12:52 PM, larry google groups
lawrencecloj...@gmail.com wrote:
 Okay, if I look here:

 http://clojure.github.com

 Can I assume that anything that starts with clojure.core is not a
 dependency? And everything else is?

No, some clojure.core.* namespaces are contribs (and need a
project.clj dependency), some are built-in. Per my original email:

 On Thursday, October 25, 2012 2:57:26 PM UTC-4, Sean Corfield wrote:
 http://clojure.github.com

 If it's listed separated there, it's a contrib you need to pull in
 explicitly. Otherwise it's part of Clojure itself.

Everything listed in the left hand column is a contrib that you need
to pull in (as a dependency) in your project.clj, including:

core.cache
core.incubator
core.match
core.memoize
core.unify

(and core.logic which is, for some reason, missing from that list)

 Clojure's namespaces are documented here (linked from 'clojure' in the
 left column of the above page):

 http://clojure.github.com/clojure/

Anything listed in the left hand column here is built-in (also listed
under Table of Contents on the right), no dependency needed (other
than Clojure itself), you just need to :require it in your namespace.

Finding clojure.core.protocols is a little harder, since it's a
sub-namespace of clojure.core so you'll find it here:

http://clojure.github.com/clojure/clojure.core-api.html

Specifically:

http://clojure.github.com/clojure/clojure.core-api.html#clojure.core.protocols

You might find the Clojure Atlas helpful for navigating the built-in
Clojure namespaces and functions:

http://www.clojureatlas.com/

It's a bit of a sprawling universe of namespaces and can be a bit
daunting when you first start working in Clojure but you soon get used
to the layout (honest!).

Hope that helps?
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

Perfection is the enemy of the good.
-- Gustave Flaubert, French realist novelist (1821-1880)

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


let in the middle of thread-first

2012-10-25 Thread Jason Bennett

Let's say I have a set of thread-first calls:

(- url
 a
 b
 c
 d
 e)

And let's say that I need to process and save the result of function b as a 
second parameter to function e (function b returns a file, and function e 
needs the extention of that file). How would I drop a let into the middle 
of the thread calls without making a large mess? The only suggestion I've 
gotten so far is to move calls A and B into a let before the thread-first 
so I can process their return values.

jason

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

*default-data-reader-fn* has landed!

2012-10-25 Thread kovas boguta
https://github.com/clojure/clojure/commit/79a1b793f87af417b430450f3c24e7cfe456e3e2

Super exciting!

Thanks guys!

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


Re: let in the middle of thread-first

2012-10-25 Thread Ambrose Bonnaire-Sergeant
I haven't tried them, but you may be in luck for Clojure 1.5.

https://github.com/clojure/clojure/commit/026691e2f6cc8d1bab4feb7e577530a9f06fd85e

Thanks,
Ambrose

On Fri, Oct 26, 2012 at 8:24 AM, Jason Bennett jaso...@gmail.com wrote:


 Let's say I have a set of thread-first calls:

 (- url
  a
  b
  c
  d
  e)

 And let's say that I need to process and save the result of function b as
 a second parameter to function e (function b returns a file, and function e
 needs the extention of that file). How would I drop a let into the middle
 of the thread calls without making a large mess? The only suggestion I've
 gotten so far is to move calls A and B into a let before the thread-first
 so I can process their return values.

 jason

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

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

Re: (if (io/file path-to-session-file) -- returns false though file exists

2012-10-25 Thread Sean Corfield
On Thu, Oct 25, 2012 at 3:21 PM, larry google groups
lawrencecloj...@gmail.com wrote:
 I look here and see that the old monolithic Clojure contrib had an exists
 function:

 http://clojuredocs.org/clojure_contrib/clojure.contrib.java-utils/file

 I see this example:

 (. (clojure.contrib.java-utils/file ...) exists)

 I'd like to  do that but I don't know how with the modern clojure.java.io.

That's a Java method invocation, equivalent to (.exists (io/file
...)) with your io alias.
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

Perfection is the enemy of the good.
-- Gustave Flaubert, French realist novelist (1821-1880)

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


Re: let in the middle of thread-first

2012-10-25 Thread Ben Wolfson
let- seems to rebind the same name repeatedly, so that probably wouldn't help.

You could easily create a macro that bound a new name if it encounters
a literal vector in the arguments and evaluated the remaining forms in
the context of those bindings:

(somevariantof- url
a
[file b]
c
d
(f (extension file)))

Or something like that.

On Thu, Oct 25, 2012 at 5:53 PM, Ambrose Bonnaire-Sergeant
abonnaireserge...@gmail.com wrote:
 I haven't tried them, but you may be in luck for Clojure 1.5.

 https://github.com/clojure/clojure/commit/026691e2f6cc8d1bab4feb7e577530a9f06fd85e

 Thanks,
 Ambrose


 On Fri, Oct 26, 2012 at 8:24 AM, Jason Bennett jaso...@gmail.com wrote:


 Let's say I have a set of thread-first calls:

 (- url
  a
  b
  c
  d
  e)

 And let's say that I need to process and save the result of function b as
 a second parameter to function e (function b returns a file, and function e
 needs the extention of that file). How would I drop a let into the middle of
 the thread calls without making a large mess? The only suggestion I've
 gotten so far is to move calls A and B into a let before the thread-first so
 I can process their return values.

 jason

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


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



-- 
Ben Wolfson
Human kind has used its intelligence to vary the flavour of drinks,
which may be sweet, aromatic, fermented or spirit-based. ... Family
and social life also offer numerous other occasions to consume drinks
for pleasure. [Larousse, Drink entry]

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


ANN: Guzheng 1.2.5

2012-10-25 Thread David Greenberg
Guzheng is a library for doing branch coverage analysis on Clojure
projects at the command line.

Guzheng will warn you which branches were not executed in your
project. It understands all forms
of conditional execution in clojure.core, except for lazy sequence
constructors, macros, protocols,
and when-first. All other forms of conditional execution will be
flagged if there were never executed
while the program ran.

To use guzheng, simply add [lein-guzheng 1.4.3] to your leiningen
plugins or dependencies
(guzheng is compatible with Lein1 and Lein2). Basic usage:

lein guzheng my.ns -- test # What code in my.ns wasn't executed by
the tests?

See https://github.com/dgrnbrg/guzheng/blob/master/lein-guzheng/README.md
for more on usage.

Pull requests welcome!

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


Re: ANN: Guzheng 1.2.5

2012-10-25 Thread Ambrose Bonnaire-Sergeant
How does it work? What kinds of dead-code can it detect?

Thanks,
Ambrose

On Fri, Oct 26, 2012 at 9:17 AM, David Greenberg dsg123456...@gmail.comwrote:

 Guzheng is a library for doing branch coverage analysis on Clojure
 projects at the command line.

 Guzheng will warn you which branches were not executed in your
 project. It understands all forms
 of conditional execution in clojure.core, except for lazy sequence
 constructors, macros, protocols,
 and when-first. All other forms of conditional execution will be
 flagged if there were never executed
 while the program ran.

 To use guzheng, simply add [lein-guzheng 1.4.3] to your leiningen
 plugins or dependencies
 (guzheng is compatible with Lein1 and Lein2). Basic usage:

 lein guzheng my.ns -- test # What code in my.ns wasn't executed by
 the tests?

 See https://github.com/dgrnbrg/guzheng/blob/master/lein-guzheng/README.md
 for more on usage.

 Pull requests welcome!

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


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

Re: let in the middle of thread-first

2012-10-25 Thread Ben Mabey

On 10/25/12 6:24 PM, Jason Bennett wrote:


Let's say I have a set of thread-first calls:

(- url
 a
 b
 c
 d
 e)

And let's say that I need to process and save the result of function b 
as a second parameter to function e (function b returns a file, and 
function e needs the extention of that file). How would I drop a let 
into the middle of the thread calls without making a large mess? The 
only suggestion I've gotten so far is to move calls A and B into a let 
before the thread-first so I can process their return values.


jason


Pallet's thread-exp library has a let- macro that would do the trick:

https://github.com/pallet/thread-expr/blob/develop/src/pallet/thread_expr.clj#L100-106

I love the thread-expr library but when I spoke with Hugo Duncan at 
Clojure West he said that pallet's use of it was largely being replaced 
by monads.


-Ben

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


Re: Clojurescript externs when using a local file (cljsbuild)

2012-10-25 Thread Evan Mezeske
For what you're trying to do, :externs is not the solution.

Ultimately, all you need to do is make sure that both src-cljs/live and 
src-cljs/test are on the classpath at compile time.  The easiest way to do 
this would be to put both builds into the same project:

:builds
{:live {:source-path src-cljs/live :compiler {...}}
 :test {:source-path src-cljs/test :compiler {...}}}

When :builds contains multiple entries, they are all added to the 
classpath, and thus helper.webTemplateTest will be able to load 
helper.webTemplate.

:externs is used for a totally different purpose (JavaScript interop).  If 
you want to learn more about that, I recommend reading this: 
http://lukevanderhart.com/2011/09/30/using-javascript-and-clojurescript.html
 .

-Evan

On Thursday, October 25, 2012 1:25:17 PM UTC-7, Sean S wrote:

 Can't seem to get the extern functionality to work, or I'm using it wrong. 
  Basically I have two files:  One live and one test. The test file is built 
 with a separate build definition.  I want the test file to be able to see 
 the live file using the built in namespace functionality.

 This is the live project:

 { :id live
   :source-path src-cljs/live/   
   :compiler 
 { :output-to resources/public/js/*live*/main.js
   :optimizations :simple
   :pretty-print true}} 

 I have the test configuration including the file created above:

   { :id test
 :source-path src-cljs/test/   
 :compiler 
   { :output-to  resources/public/js/*test*/main.js
 :optimizations :simple
 :externs [resources/public/js/*live*/main.js]  
 :pretty-print true}}]}


 This is the namespace that I want to include for testing that is in the 
 live file resources/public/js/*live*/main.js: 

   (ns helper.webTemplate ...)

 This is my attempt to include that namespace in the test file 
 resources/public/js/*test*/main.js:

   (ns helper.webTemplate.test
 (:require 
   [helper.webTemplate   :as template]...)


 With error:

  required helper.webTemplate namespace not provided yet...

 Is there a special (Or easier way) to use namespaces in local files?  I 
 could just have the test build move down a level since my folder structure 
 is:

 /src-cljs
   /live
   /test

 But would like to know if I can avoid that.


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

Re: Clojurescript externs when using a local file (cljsbuild)

2012-10-25 Thread Evan Mezeske
One other thing I ought to mention is that your *.cljs files need to be 
arranged in an appropriate directory structure (i.e. the directories must 
match the namespaces):

/src-cljs/live/helper/webTemplate.cljs
/src/cljs-test/helper/webTemplate/test.cljs

The ClojureScript compiler (sadly) allows files to shirk this convention if 
they're in the main :source-path (it just grabs ALL *.cljs files 
recursively).  However, if you're loading *.cljs files from a different 
directory, they will be loaded as Java resources, and thus need to use the 
Java directory conventions.

-Evan

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

Re: Generating permutations in core.logic

2012-10-25 Thread David Nolen
On Thu, Oct 25, 2012 at 3:10 PM, Jordan Lewis jordanthele...@gmail.comwrote:

 Hi,

 I'm new to core.logic and logic programming in general. I tried to write a
 small program to generate all permutations of any size for an input list
 with unique elements. To start, I hardcoded the input list to be (range 3).
 Here's what I came up with:


Thanks for this, this actually brought a fairly serious bug to my
attention. core.logic 0.8.0-beta2 is being released and should address the
distincto issue you encountered.

David

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