Re: is intellij idea a good ide for clojure development?

2013-07-26 Thread Andrew Inggs
On 25 July 2013 21:55, Lee Spector wrote:


 For Sean or anyone who finds Sean's narrative compelling (I do), imagine
 emacs without the learning curve! I say it's possible and I point to the
 long-extinct FRED (Fred Resembles Emacs Deliberately) that was part of
 Macintosh Common Lisp as a proof of principle. I don't have the time or
 chops to develop such a thing, but if anyone here does then this would be a
 way to make the world a better place.


Have you heard of Deuce https://github.com/hraberg/deuce by Håkan Råberg?
 He gave a 
talkhttp://skillsmatter.com/podcast/scala/deuce-is-not-yet-emacs-under-clojureon
it at Skills Matter London.  It not usable yet, but it looks
promising.

From the readme:

*Deuce is a re-implementation of Emacs in Clojure.* It's a port of the C
 core and re-compiles existing Emacs Lisp to Clojure. It uses the Lanterna
 library for text UI. The goal is to reach reasonable compatibility with GNU
 Emacs during 2013. The longer term goal is to phase out Emacs Lisp in
 favour for Clojure, to add a Web UI and re-capture Emacs' spirit on a
 contemporary platform.


Andrew

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




Re: is intellij idea a good ide for clojure development?

2013-07-26 Thread Cedric Greevey
Would that include a contemporary user interface that can show trees
properly, do graphical diffs, and be quickly taken up by any reasonably
adept Windows or Mac user the way Eclipse, clooj, and IntelliJ can?


On Fri, Jul 26, 2013 at 3:02 AM, Andrew Inggs amin...@gmail.com wrote:

 On 25 July 2013 21:55, Lee Spector wrote:


 For Sean or anyone who finds Sean's narrative compelling (I do), imagine
 emacs without the learning curve! I say it's possible and I point to the
 long-extinct FRED (Fred Resembles Emacs Deliberately) that was part of
 Macintosh Common Lisp as a proof of principle. I don't have the time or
 chops to develop such a thing, but if anyone here does then this would be a
 way to make the world a better place.


 Have you heard of Deuce https://github.com/hraberg/deuce by Håkan
 Råberg?  He gave a 
 talkhttp://skillsmatter.com/podcast/scala/deuce-is-not-yet-emacs-under-clojureon
  it at Skills Matter London.  It not usable yet, but it looks promising.

 From the readme:

 *Deuce is a re-implementation of Emacs in Clojure.* It's a port of the C
 core and re-compiles existing Emacs Lisp to Clojure. It uses the Lanterna
 library for text UI. The goal is to reach reasonable compatibility with GNU
 Emacs during 2013. The longer term goal is to phase out Emacs Lisp in
 favour for Clojure, to add a Web UI and re-capture Emacs' spirit on a
 contemporary platform.


 Andrew

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




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




Re: is intellij idea a good ide for clojure development?

2013-07-26 Thread Niels van Klaveren
Live-editing OpenGL under Quill (Processing) worked very well in CCW last 
time I toyed with it.

On Thursday, July 25, 2013 7:27:37 PM UTC+2, Chris Gill wrote:

 I find this interesting. I've been using light table mostly, but recently 
 I tried my hand at socket programming and light table flopped on this type 
 of a project. I ended up using lein repl for most of my work which became a 
 pain and now I'm looking at emacs with a slight kink in my lips. I'll have 
 to try eclipse for clojure out, I've only ever done android in eclipse. Do 
 you think something like an openGL project in clojure in eclipse with 
 live-editing is a possibility? I've mostly seen this kind of stuff in emacs 
 but I feel like it has less to do with emacs and more with nrepl and 
 evaling..

 -c

 On Tuesday, January 29, 2013 1:40:33 PM UTC-5, Timo Mihaljov wrote:

 On 29.01.2013 16:32, Jay Fields wrote: 
  On Tue, Jan 29, 2013 at 9:28 AM, Feng Shen she...@gmail.com wrote: 
  I have programming Clojure for almost 2 years, for a living. 
  
  
  This is probably an important part of what answer the OP is looking 
  for. When I was doing Clojure for about 10% of my job IntelliJ was 
  fine. Now that it's 90% of my job, I wouldn't be able to give up emacs 
  go back to IntelliJ. 
  
  If you're just looking at Clojure as a hobby and you already know 
  IntelliJ, I wouldn't recommend switching. However, if you're going to 
  be programming Clojure almost all of the time, I think emacs is the 
  superior choice. 
  

 For what it's worth, I switched from Emacs to Eclipse and 
 Counterclockwise for Clojure programming. Laurent's done an excellent 
 job with it, and I even prefer his take on paredit over Emacs's 
 original. I still use Emacs for everything else, but for Clojure I find 
 Counterclockwise to be the superior choice. 


 -- 
 Timo 



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




Re: Can we please deprecate the :use directive ?

2013-07-26 Thread Max Gonzih
Totally agree. :use is anti-pattern since :require :refer :all can do the 
same. If you have :use in ns macro and want to make :refer :all visible 
just put it at the end of ns macro, separated b empty line from other 
:require clauses. Having 2 ways of doing so simple thing as requiring code 
is misleading IMHO.

On Tuesday, July 23, 2013 6:50:50 PM UTC+3, Greg Slepak wrote:

 I think I read somewhere that :use is no longer encouraged, but I could be 
 mistaken. 

 From what I've read, it seems like most people agree that Clojure has too 
 many ways of including/importing/referencing/requiring/using things: 


 http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html
  

 The above gives a very nice explanation of all the various difference, but 
 it also acknowledges their complexity. 

 Since :use uses :require, and since :require can do everything that :use 
 can, can we simplify Clojure programming a bit for newcomers by deprecating 
 the use of :use? The situation in ClojureScript is even worse because it 
 adds :require-macros on top of all the other ways of including files. 

 Ideally, it would be awesome if there was just a single directive for 
 everything, but perhaps there's some complicated low-level reason why 
 that's not possible. :-\ 

 Thoughts? 

 Thanks, 
 Greg 

 P.S. If this has already been brought up you have my sincere apologies. 

 -- 
 Please do not email me anything that you are not comfortable also sharing 
 with the NSA. 



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




[ANN] 18th tutorial of modern-cljs series

2013-07-26 Thread Giacomo Cosenza
Hi all,
I just published the 18th episode of the modern-cljs series. 

It talks about two topics:

- the setup and configuration of a bREPL on top of an nREPL by using the 
piggieback nrepl middleware created by Chas (I always meet its great works on 
my way wherever I go - he's just amazing);
- the setup and configuration of a more comfortable project structure by using 
the lein profiles.

Here is the link

https://github.com/magomimmo/modern-cljs/blob/master/doc/tutorial-18.md

HIH

Mimmo

p.s. the next month I'll be on vacation and I cant' guarantee to be able to add 
new tutorials to the series.  

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




Re: Can we please deprecate the :use directive ?

2013-07-26 Thread Phillip Lord


It's different, because it doesn't necessarily eval with the ns form.
So, for example, nrepl.el has an eval ns form command. This would not
work with a use form.

Gary Trakhman gary.trakh...@gmail.com writes:

 You could also do (use 'clojure.test) below the ns form.  One thing that
 generally annoys me with 'ns' is that people feel it's some magical thing
 that has to be in the head of every file, like java imports, but it's
 really just a macro.

 It just goes to show that conventions are important.

 Curiously, and off-topic, why does core.clj have an 'ns' form and then
 proceeds to define the ns macro?


 On Thu, Jul 25, 2013 at 11:32 AM, Phillip Lord phillip.l...@newcastle.ac.uk
 wrote:

 Laurent PETIT laurent.pe...@gmail.com writes:
  (:use foo :only [a b c]) will become (:require foo :refer [a b c])
  (:use foo) will become (:require foo :refer :all)

 The same logic could suggest we remove or because we can express it
 with and and not.

  This will save lots of time and frustration among people trying to
  remember why (:use :only) somewhere, why (:require :refer :all)
  somewhere else, etc.

 And cause frustration for people who find typing

 (:require clojure.test :refer :all)

 when they used to type

 (:use clojure.test)

 To me, the discussion seems to be confused; I understand why making an
 implementation simpler is important. But removing a simple declaration
 to replace it with a more complex one doesn't seem to make things
 simpler to me.


 Phil

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




 -- 

-- 
Phillip Lord,   Phone: +44 (0) 191 222 7827
Lecturer in Bioinformatics, Email: phillip.l...@newcastle.ac.uk
School of Computing Science,
http://homepages.cs.ncl.ac.uk/phillip.lord
Room 914 Claremont Tower,   skype: russet_apples
Newcastle University,   twitter: phillord
NE1 7RU 

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




Re: Can we please deprecate the :use directive ?

2013-07-26 Thread Phillip Lord
Laurent PETIT laurent.pe...@gmail.com writes:
 The same logic could suggest we remove or because we can express it
 with and and not.

 Except nobody complains about or, and or not ;-)

Actually, they are a right pain when writing my library, because I
wanted to use them to mean something else. some was irritating for the
same reason.


 And cause frustration for people who find typing

 (:require clojure.test :refer :all)

 when they used to type

 (:use clojure.test)

 Code is read more often than written.
 Clojure makes default choices easy, and non default choices harder
 for a reason: to guide people.

And again, I an struggling to see when being able to write

(deftest hello 
  (is true))

is a bad thing. I agree, using many namespaces is problematic, I do
often use one.


 It's like the mantra if you find it hard to write, you may be doing
 it wrong (though it's still possible to do).

 Also, for the REPL, there will still be the (use 'clojure.tests) call
 that you can use in your REPL bootstrapping code.

 To me, the discussion seems to be confused; I understand why making an
 implementation simpler is important. But removing a simple declaration
 to replace it with a more complex one doesn't seem to make things
 simpler to me.

 I don't think I'm confused, AFAIC: I'm not even thinking from the
 implementation perspective, but from the consumer perspective.
 It's also psychological: if you remove :use, even at the cost of
 keeping :refer :all, that's one less top-level 'ns directive to
 remember.


I said the discussion was confused not you!

So far, I have see three main reasons for removing use.

1) It offends my idea of truth and beauty: only clojure.core should be
   unnamespaced. 

Counter argument 1: using deftest makes life a lot easier. And I have
files which have 100s of calls to a one namespace and none to
clojure.core. 

Counter argument 2: the functionality will remain anyway.

Counter argument 3: so, don't use it then.

2) ns is too complex

Counter Argument:

Yes, it is, and it does confuse newcomers. I got confused, not least
because it accepts both vectors and lists (so two syntaxes with no
difference AFAICT). So

(ns a 
 [:use b])

(ns a
 (:use b))

are the same.

It also has short cuts: so

 (:use [a.b.c]) is the same as 
 (:use [a.b c]), (use library a.b.c)

 (:use [a.b c]) is different from 
 (:use [a b c]) (first is use a.b.c second is use a.b and a.c).

It's got :as which means you need nesting. and you can combine this with
aliases. And I think you can drop the brackets so:

(ns a
  (:use [b]))

is the same as 

(ns a
  (:use b))

All of this remains. It's still going to be complex. 

Don't quote me on any of the statements made here; I was trying to do it
from memory to see if I remembered correctly.

3) Removing use will make things simpler

Counter Argument:

Only for people who don't use it, and they don't use it so who cares?
For people who do use it, we now have to do (:require x :refer :all)
instead of the more simple (:use x). And does refer all support exclude?
So can I do

(:require x :refer :all :exclude [a b c])?


 I agree that it is micro-optimization, but this counts too, noticeably
 because it's one of the first things a newcomer is confronted to when
 he starts seriously with the language.

I agree that it's good to simplify things. Confused as to how this
helps.

Phil

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




Re: is intellij idea a good ide for clojure development?

2013-07-26 Thread Charlie Griefer

On Jul 25, 2013, at 12:37 PM, Sean Corfield seancorfi...@gmail.com wrote:

 When I started doing Clojure, I used TextMate so it was an obvious
 choice to try Sublime Text 2. I tried it on Mac, Windows, and Linux
 and it drove me insane with its quirks, bugs, inconsistencies across
 platforms and (at the time) very poor REPL integration. I know it's
 gotten better but I just found it clunky and the workflow felt hacked
 together. That said, three of my team love ST2.


As one of the three on the team, I'd like to clarify something regarding my 
love for ST2. I used it as my primary editor before really delving into 
Clojure, and yes, I thought it was fantastic. Lightweight, but not lacking on 
features. Everything that Eclipse, to me, was not.

Since getting into Clojure, I've been using Emacs. I can't really picture using 
any other editor/IDE for Clojure development. The learning curve was _much_ 
smaller than I had initially anticipated (feared, actually). I simply kept a 
cheat sheet open on my laptop whilst working on the desktop. Still learning, 
and probably will be for a while. But I am able to be productive while 
learning, so that's not too much of an issue.

As far as the original question, if it hasn't already been said in the thread… 
it depends. I know people who swear by IntelliJ and I know people who swear at 
IntelliJ. The same can be said for any IDE/editor. Asking if one is good is 
like asking if a particular flavor of ice cream is good. Which is silly, 
because that's highly subjective. Unless you're asking about butter brickle ice 
cream. I mean c'mon. Who doesn't like butter brickle ice cream?

--
Charlie Griefer
http://charlie.griefer.com

Give light, and the darkness will disappear of itself. 
-- Desiderius Erasmus

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




Re: is intellij idea a good ide for clojure development?

2013-07-26 Thread Charlie Griefer
On Jul 25, 2013, at 8:15 PM, Cedric Greevey cgree...@gmail.com wrote:

 Someone makes free software plugins for nonfree software?!
 
 
 On Thu, Jul 25, 2013 at 11:04 PM, Greg g...@kinostudios.com wrote:
 You submit patches to nonfree software?!
 


I may regret asking this… but don't people deserve to get paid for their work? 
I mean if they choose to charge (I'm not putting down the free model at all)? 

And at $70 for ST 2, well as a developer I use an editor pretty frequently. I'm 
thinking that at $70, if I find the software helps me be productive, then it 
pretty much pays for itself some time during the first day.

--
Charlie Griefer
http://charlie.griefer.com

Give light, and the darkness will disappear of itself. 
-- Desiderius Erasmus

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




Re: is intellij idea a good ide for clojure development?

2013-07-26 Thread Steven Degutis
+1


On Fri, Jul 26, 2013 at 9:56 AM, Timothy Baldridge tbaldri...@gmail.comwrote:

 +1 to Charlie. If I ever went back to Python development I would plop down
 whatever the going rate is for PyCharm (InteliJ Python IDE), that thing is
 an awesome piece of tech. There are very few times I've been utterly blown
 away by an idea all the standard features of Python (testing, debugging,
 code coverage, project structure, etc) are defaults in PyCharm. It even
 detects multiple versions of Python on your system and adds them to the
 intelisense and run menus.

 To be honest, I can't wait until we have something like that for Clojure.
 Give me a fast, light, InteliJ based IDE that just works 100% of the
 time, and I'd pay several hundred dollars for that software.

 Timothy


 On Fri, Jul 26, 2013 at 8:29 AM, Charlie Griefer 
 charlie.grie...@gmail.com wrote:

 On Jul 25, 2013, at 8:15 PM, Cedric Greevey cgree...@gmail.com wrote:

 Someone makes free software plugins for nonfree software?!


 On Thu, Jul 25, 2013 at 11:04 PM, Greg g...@kinostudios.com wrote:

 You submit patches to nonfree software?!



 I may regret asking this… but don't people deserve to get paid for their
 work? I mean if they choose to charge (I'm not putting down the free model
 at all)?

 And at $70 for ST 2, well as a developer I use an editor pretty
 frequently. I'm thinking that at $70, if I find the software helps me be
 productive, then it pretty much pays for itself some time during the first
 day.

  --
 Charlie Griefer
 http://charlie.griefer.comhttp://charlie.griefer.com

 Give light, and the darkness will disappear of itself.
 -- Desiderius Erasmus

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






 --
 “One of the main causes of the fall of the Roman Empire was that–lacking
 zero–they had no way to indicate successful termination of their C
 programs.”
 (Robert Firth)

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




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




Re: What is a state monad binding plan (referring to code in core.async)

2013-07-26 Thread Timothy Baldridge
Well, I wrote the code, so I suppose I should comment on it a bit. The
ioc_macros use a very loosely defined version of the state-monad. I don't
know if the functions/macros follow all the monad laws, and I really don't
care, but here's the problem:

I needed to be able to track some state while parsing the clojure code. I
needed to be able to define blocks while defining other blocks, to have
instructions reference each other, etc. All this could be done with a atom,
but I really don't like mutable state. So I decided to write the entire
thing in a fully immutable way.

Thus, the first step is to start defining functions that return functions
that will take a state:

(defn assoc-plan [k v]
  (fn [state]
[nil (assoc state k v)]))

So each monadic function is a function that takes a state, and returns a
vector of [value new-state]. This allows me to write functions like
add-instruction that both add an instruction to a block and also return a
id to that instruction.

All the other functions in the code are built off this simple concept.
gen-plan then wires them all up together, and is basically monadic bind,
except it's optimized to use lets instead of nested fns.

All this allows the parsing code to remain rather simple, while tracking
state, and remaining fully immutable. The code below looks as if it is
mutating state, but is actually fully immutable.

(defmethod sexpr-to-ssa 'if
  [[_ test then else]]
  (gen-plan
   [test-id (item-to-ssa test)
then-blk (add-block)
else-blk (add-block)
final-blk (add-block)
_ (add-instruction (-CondBr test-id then-blk else-blk))

_ (set-block then-blk)
then-id (item-to-ssa then)
_ (if (not= then-id ::terminated)
(gen-plan
 [_ (add-instruction (-Jmp then-id final-blk))]
 then-id)
(no-op))

_ (set-block else-blk)
else-id (item-to-ssa else)
_ (if (not= else-id ::terminated)
(gen-plan
 [_ (add-instruction (-Jmp else-id final-blk))]
 then-id)
(no-op))

_ (set-block final-blk)
val-id (add-instruction (-Const ::value))]
   val-id))



Most of the time, I recommend people start reading the at functions such as
add-block, get-block, set-block, etc. Ignore the implementation of
gen-plan, and just examine how it's used. After about 30 minutes the light
will go on, and it'll all make sense.

Pretty printing (via the debug function) the output of
parse-to-state-machine will also help you make sense of what's being
constructed.

I hope this helps.

Timothy Baldridge


On Fri, Jul 26, 2013 at 8:51 AM, john john.vie...@gmail.com wrote:

 Hi,
 I am trying to understand the code in  
 ioc_macros.cljhttps://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async/impl/ioc_macros.clj
 .
 I stumbled on the macro gen-plan which doc reads Allows a user to define
 a state monad binding plan
 I am wondering what makes the macro a state monad and how does it
 simplify the building of the state-machine data structure?

 Many Greetings
 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
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.






-- 
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)

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




Re: What is a state monad binding plan (referring to code in core.async)

2013-07-26 Thread john
yes your explanations help me a lot! thank you for replying so quickly! I 
will try to work myself through your code as you suggest.

Many thanks!

Am Freitag, 26. Juli 2013 16:51:54 UTC+2 schrieb john:

 Hi,
 I am trying to understand the code in  
 ioc_macros.cljhttps://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async/impl/ioc_macros.clj
 .
 I stumbled on the macro gen-plan which doc reads Allows a user to define 
 a state monad binding plan
 I am wondering what makes the macro a state monad and how does it 
 simplify the building of the state-machine data structure?

 Many Greetings
 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
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: is intellij idea a good ide for clojure development?

2013-07-26 Thread Lee Spector

On Jul 26, 2013, at 3:02 AM, Andrew Inggs wrote:
 On 25 July 2013 21:55, Lee Spector wrote:
 For Sean or anyone who finds Sean's narrative compelling (I do), imagine 
 emacs without the learning curve! I say it's possible and I point to the 
 long-extinct FRED (Fred Resembles Emacs Deliberately) that was part of 
 Macintosh Common Lisp as a proof of principle. I don't have the time or 
 chops to develop such a thing, but if anyone here does then this would be a 
 way to make the world a better place.
 
 Have you heard of Deuce by Håkan Råberg?  He gave a talk on it at Skills 
 Matter London.  It not usable yet, but it looks promising.

I hadn't and yes it looks interesting to me too, although it's only addressing 
part of what I'm suggesting (and what FRED did, in Common Lisp). It's about 
making emacs work on a Clojure/JVM foundation, and that's great, but the main 
reason I think that FRED was emacs without the learning curve has to do with 
its GUI. 

FRED used totally normal and expected GUI conventions, which users would know 
from any other application on the platform (Mac OS), so that any new user could 
use it and access all of its main functionality without dealing with any exotic 
GUI concepts (e.g. hidden buffers in windows, key chords, etc.).

All of emacs's power was there, and it could be deployed with key chords etc. 
if you wanted to (and extended with Common Lisp). But most of the core 
functionality could also be deployed (and discovered!) through platform-normal 
GUI elements like separate windows and menus and dialogs (which didn't really 
exist when emacs was first developed; some of emacs's GUI conventions are good 
ideas, but many are just historical artifacts).

For example, in FRED standard dialogs were used for standard interactions (e.g. 
opening files) and new information would appear in new windows (could be tabs 
instead these days, I guess) rather than hiding a current buffer in a current 
window. You selected buffers by clicking on windows, just as you would in any 
other application. You could click on a function and use platform-obvious menus 
to get to the function's documentation or definition or a related namespace 
search (apropos in Common Lisp). Errors would produce a scrollable/clickable 
stack backtrace in a new window, which you could browse, click to see stack 
frames with local variable values, etc. You could select an expression in a 
Lisp buffer by double-clicking on one of its delimiters. Etc. 

The key thing here is that all of that powerful emacs-like functionality was 
and could conceivably again be offered in a way that follows reasonably 
standard GUI conventions, so that new users basically know how to use it before 
they use it, and they can figure out more as they go along. They don't need 
cheat sheets or a taste for adventure. And they can install and use the system, 
with most of its most commonly used functions, without knowing anything exotic, 
and learn more as they go, discovering things via platform-standard GUI 
elements.

Several Clojure IDEs seem to be getting much better with respect to 
GUI/usability/learning curve issues, but my point was that there's no reason 
(in principle :-) that one couldn't build a Clojure programming environment 
that really is essentially emacs, with all of its power, but also really has 
essentially no learning curve. I know of some projects that have made it much 
easier to download/install emacs environments for Clojure, and there are also 
some versions of emacs out there with platform-natural menus, but I don't know 
of any projects dedicated to providing a complete emacs-based Clojure 
environment with the usability and lack of learning curve of FRED. And I do 
think this would be a beautiful thing to have in the community!

 -Lee

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




Re: is intellij idea a good ide for clojure development?

2013-07-26 Thread Lee Spector

PS, I wrote:

  but I don't know of any projects dedicated to providing a complete 
 emacs-based Clojure environment with the usability and lack of learning curve 
 of FRED. 

I *do* know about https://mclide.com and 
https://github.com/TerjeNorderhaug/mclide, and it's author Terje Norderhaug 
tells me that that project is alive and well, but it's not clear to me where 
this is headed or with what momentum.

 -Lee

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




Re: Symbol.intern doesnt return already interned symbols?

2013-07-26 Thread Marshall Bockrath-Vandegrift
Jürgen Hötzel juer...@hoetzel.info writes:

 If a symbol X is interned twice, shouldn't the second Symbol.intern(X)
 return the previous interned symbol object?

Symbols in Clojure can have metadata, and so can’t have pure value-based
identity.  Keywords fill that role instead, which is why keywords can’t
hold metadata, and why `Keyword/intern` *does* act as you had expected
`Symbol/intern` to act.  Or at least this is my understanding – I hope
it helps.

-Marshall

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




Does this abstraction have any existing name?

2013-07-26 Thread Yoshinori Kohyama


Hello group.

I wrote a tiny macro to apply a function to values in lowest levels in a map 
with arguments.
Three questions:

   - Does this abstraction have any existing name?
   - Is there any existing function/macro to do similar things?
   - Would anyone improve this implementation?


(require '[clojure.test :refer (with-test is are run-tests)])
 
(with-test
  (defmacro mapf [f m  args]
`((fn f# [n#]
(if (map? n#)
(into {} (map (fn [[k# v#]] [k# (f# v#)]) n#))
(~f n# ~@args)))
  ~m))
 
  (is (= (mapf #(* % %) {:a {:b 3 :c 4} :d 5})
 {:a {:b 9 :c 16} :d 25}))
  (is (= (mapf #(+ (* %1 %1) %2) {:a {:b 3 :c 4} :d 5} 1)
 {:a {:b 10 :c 17} :d 26})))

https://gist.github.com/kohyama/6089899

Thank you in advance.

Y.Kohyama

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




Re: Does this abstraction have any existing name?

2013-07-26 Thread Gary Trakhman
Why does this need to be a macro?  It doesn't actually manipulate code.

Just turn this:  (~f n# ~@args) into (apply f n args) in the function
implementation.


On Fri, Jul 26, 2013 at 11:49 AM, Yoshinori Kohyama yykohy...@gmail.comwrote:

 Hello group.

 I wrote a tiny macro to apply a function to values in lowest levels in a map 
 with arguments.
 Three questions:

- Does this abstraction have any existing name?
- Is there any existing function/macro to do similar things?
- Would anyone improve this implementation?


 (require '[clojure.test :refer (with-test is are run-tests)])

 (with-test
   (defmacro mapf [f m  args]
 `((fn f# [n#]
 (if (map? n#)
 (into {} (map (fn [[k# v#]] [k# (f# v#)]) n#))
 (~f n# ~@args)))
   ~m))

   (is (= (mapf #(* % %) {:a {:b 3 :c 4} :d 5})
  {:a {:b 9 :c 16} :d 25}))
   (is (= (mapf #(+ (* %1 %1) %2) {:a {:b 3 :c 4} :d 5} 1)
  {:a {:b 10 :c 17} :d 26})))

 https://gist.github.com/kohyama/6089899

 Thank you in advance.

 Y.Kohyama

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




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




Re: Can we please deprecate the :use directive ?

2013-07-26 Thread greenh
A couple thoughts, my own 2-cents-worth.

First, I think I’m seeing an entirely legitimate concern being expressed by 
some developers that :use complicates life in their shops. Contrariwise, 
there’s clearly a set of developers who are in environments where :use 
feels very natural, and is of considerable convenience. 

As someone who is generally in the latter situation, I have a hard time 
with notion of getting rid of :use, but I can equally well picture myself 
doing Clojure environments where the restriction was pertinent.  So, how 
about if there was a compiler option that caused :use to be flagged with a 
warning or error? I’d say that was entirely acceptable solution that kept 
everyone happy. 

In general: if you’re talking about expanding the existing functionality to 
help solve people’s problems, I’m all for it. If you’re talking about 
restricting existing functionality to require conformity with your 
particular vision, that’s a problem.

BTW, if you insist on making the :use functionality substantially less 
convenient, well, I know how I respond to such things. I recall a saying 
from long ago in the Lisp community that “if you don’t like the syntax, 
write your own!”---and so I do. I’ve already dealt with several perceived 
nuisances in existing Clojure by writing and using my own macros. Coming up 
with a custom replacement for the ns macro feels a little challenging, but 
I dare say I’d rise to the occasion if need be. If that becomes common 
practice, I’d say you’ve won the conformity battle but lost the war. (Hey, 
maybe we should get rid of macros to prevent such heinous acts, eh? It 
worked for Java…)

Next, there's an I can't tell where identifiers come from thought. Yeah, 
I've felt that pain, and as I've indicated, I'm situationally sympathetic. 
But here's a thought: how is this different from any programming language 
where one file/class/module/whatever can be included by another? Might 
there already be technology for dealing with it---even technology that 
doesn't involve manually qualifying every non-local identifier?

Finally, with respect to the “it’s too hard for newcomers” line of 
argumentation, my reaction is: this is silly.  Do you *really* want to 
optimize Clojure for use by newcomers?  Assuming you managed such a thing, 
would the result still be useful to experienced programmers---who are, 
after all, are the main constituency for Clojure? Newcomers don’t tend to 
stay newcomers for very long, right?

Similarly, with respect to the “ns is too complex” meme, my response is: 
gimme a break. It really isn’t all *that* complicated, and reducing its set 
of options by one isn’t going to change that very much. In the overall 
scheme of things involving functional programming in general and Clojure in 
particular, this tiny spec of complexity hardly signifies. 

Now, what *is *a problem is one of explanation---like, how to make 
newcomers aware of a good-enough set of recipes to get them going, or a 
lucid description of what the options actually are, and where they should 
be applied. 

So, here's a suggestion: improve the documentation!! Have you looked at the 
docstring associated with ns? Yeeesh!  It’s all proper and correct, and 
about as profoundly uninformative as can be. (I’ve been doing Clojure 
intensively for about three years now, and just now I had a hard time even 
parsing it.) 

In fact, I think I’d generalize on this, as a lot of the docstrings in core 
Clojure are, um, terse… so I’d suggest that if Clojure 2.0 is afoot, 
improving the documentation would be an excellent goal. 

FWIW...


Howard


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




Re: Does this abstraction have any existing name?

2013-07-26 Thread Yoshinori Kohyama


Thank you Gary.
There's no reason why this need to be a macro.
It has rewritten as a function.

And I'd still like to hear any response about the same three questions.

(require '[clojure.test :refer (with-test is run-tests)])
 
(with-test
  (defn mapf [f m  args]
((fn g [n]
   (if (map? n)
   (into {} (map (fn [[k v]] [k (g v)]) n))
   (apply f n args)))
 m))
 
  (is (= (mapf #(* % %) {:a {:b 3 :c 4} :d 5})
 {:a {:b 9 :c 16} :d 25}))
  (is (= (mapf #(+ (* %1 %1) %2) {:a {:b 3 :c 4} :d 5} 1)
 {:a {:b 10 :c 17} :d 26})))

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




Re: Ring: How to auto-redirect URI's missing trailing slash

2013-07-26 Thread Reginald Choudari
Thanks for all the replies.

Looks like the ring library has a redirect function in ring.util.response 
namespace.

It redirects using the 302 message.

Works for me. Although it is a pain to have to declare a redirect for every 
handler.

On Thursday, July 25, 2013 9:08:50 PM UTC-4, Reginald Choudari wrote:

 Hello, I'm trying to figure out what is the best way in handling this 
 problem.

 Using Ring I have a handlers set to direct routes with relative URI paths 
 (e.g. /, ./posts, /about). But I would like the URI to be 
 automatically redirected to /posts/ and /about/ with the trailing 
 slash, so that all my links and references work correctly. If the URI is 
 without the trailing slash, I'm sure you know what happens to all your 
 relative paths.

 Any efficient way of dealing with this?

 Thanks,
 Reginald




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




Re: Ring: How to auto-redirect URI's missing trailing slash

2013-07-26 Thread Reginald Choudari
Thanks for all the replies.

Looks like the ring library has a redirect function in ring.util.response 
namespace.

It redirects using the 302 status code.

Works for me. Although it is a pain to have to declare a redirect for every 
route.


On Thursday, July 25, 2013 9:08:50 PM UTC-4, Reginald Choudari wrote:

 Hello, I'm trying to figure out what is the best way in handling this 
 problem.

 Using Ring I have a handlers set to direct routes with relative URI paths 
 (e.g. /, ./posts, /about). But I would like the URI to be 
 automatically redirected to /posts/ and /about/ with the trailing 
 slash, so that all my links and references work correctly. If the URI is 
 without the trailing slash, I'm sure you know what happens to all your 
 relative paths.

 Any efficient way of dealing with this?

 Thanks,
 Reginald




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




Re: Does this abstraction have any existing name?

2013-07-26 Thread Jay Fields
I defined update-vals in jry:
https://github.com/jaycfields/jry/blob/master/src/clojure/jry.clj#L74-L75

It doesn't traverse nested maps, but I haven't ever needed that ability
either.

1) I've never seen a name for that.
2) not in core. I'm sure it's been written 50 times in various helper libs.
3) I'd probably write it like below, but I'm not convinced it's any better.

(defn deep-update-vals
  [m f  args]
  (if (map? m)
(reduce-kv #(assoc %1 %2 (apply deep-update-vals %3 f args)) {} m)
(apply f m args)))


On Fri, Jul 26, 2013 at 1:31 PM, Yoshinori Kohyama yykohy...@gmail.comwrote:

 Thank you Gary.
 There's no reason why this need to be a macro.
 It has rewritten as a function.

 And I'd still like to hear any response about the same three questions.

 (require '[clojure.test :refer (with-test is run-tests)])

 (with-test
   (defn mapf [f m  args]
 ((fn g [n]
(if (map? n)
(into {} (map (fn [[k v]] [k (g v)]) n))
(apply f n args)))

  m))

   (is (= (mapf #(* % %) {:a {:b 3 :c 4} :d 5})
  {:a {:b 9 :c 16} :d 25}))
   (is (= (mapf #(+ (* %1 %1) %2) {:a {:b 3 :c 4} :d 5} 1)
  {:a {:b 10 :c 17} :d 26})))

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




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




Re: Symbol.intern doesnt return already interned symbols?

2013-07-26 Thread Jürgen Hötzel
Hi Marshall,


On Fri, Jul 26, 2013 at 5:39 PM, Marshall Bockrath-Vandegrift 
llas...@gmail.com wrote:

 Jürgen Hötzel juer...@hoetzel.info writes:

  If a symbol X is interned twice, shouldn't the second Symbol.intern(X)
  return the previous interned symbol object?

 Symbols in Clojure can have metadata, and so can’t have pure value-based
 identity.  Keywords fill that role instead, which is why keywords can’t
 hold metadata, and why `Keyword/intern` *does* act as you had expected
 `Symbol/intern` to act.  Or at least this is my understanding – I hope
 it helps.


All Symbols are immutable. with-meta returns a new Symbol:

public IObj withMeta(IPersistentMap meta){


return new Symbol(meta, ns, name);


}



My Question was about the interning. AFAIK interning shoult only return a
new Symbol, when the Symbol wasn't interned already.

Jürgen

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




Re: Does this abstraction have any existing name?

2013-07-26 Thread Jay Fields
I'm not sure I'd call this more readable, but it's another option - using
clojure.walk

(defn deep-update-vals
  [m f  args]
  (let [f (fn [[k v]] (if (map? v) [k v] [k (apply f v args)]))]
(clojure.walk/postwalk (fn [x] (if (map? x) (into {} (map f x)) x)) m)))


On Fri, Jul 26, 2013 at 2:06 PM, Jay Fields j...@jayfields.com wrote:

 I defined update-vals in jry:
 https://github.com/jaycfields/jry/blob/master/src/clojure/jry.clj#L74-L75

 It doesn't traverse nested maps, but I haven't ever needed that ability
 either.

 1) I've never seen a name for that.
 2) not in core. I'm sure it's been written 50 times in various helper libs.
 3) I'd probably write it like below, but I'm not convinced it's any better.

 (defn deep-update-vals
   [m f  args]
   (if (map? m)
 (reduce-kv #(assoc %1 %2 (apply deep-update-vals %3 f args)) {} m)
 (apply f m args)))


 On Fri, Jul 26, 2013 at 1:31 PM, Yoshinori Kohyama yykohy...@gmail.comwrote:

 Thank you Gary.
 There's no reason why this need to be a macro.
 It has rewritten as a function.

 And I'd still like to hear any response about the same three questions.


 (require '[clojure.test :refer (with-test is run-tests)])


 (with-test
   (defn mapf [f m  args]

 ((fn g [n]
(if (map? n)

(into {} (map (fn [[k v]] [k (g v)]) n))

(apply f n args)))

  m))

   (is (= (mapf #(* % %) {:a {:b 3 :c 4} :d 5})

  {:a {:b 9 :c 16} :d 25}))

   (is (= (mapf #(+ (* %1 %1) %2) {:a {:b 3 :c 4} :d 5} 1)

  {:a {:b 10 :c 17} :d 26})))


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






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




Re: Can we please deprecate the :use directive ?

2013-07-26 Thread Gary Trakhman
This post takes quite a lot of things to extremes, but I think the main
argument still stands.

We need good defaults, not to totally change clojure into a newbie-friendly
thing at the expense of what makes clojure special.  This proposed change
fixes a pervasive pain point in many codebases because :use is easy in the
small and complex in the large, and it does it by simply raising the
perceived cost of 'use' slightly.

We spent time at my company on our own internal style debate over this, and
I'm sure other companies do the same.  Any time I spend significant time in
a namespace, I move the code over to :require, so that's already
not-inconsequential effort that doesn't need to exist.

Advanced users are willing/able to do whatever it takes to make things
easier for themselves, adjust to change quickly, and are likely more vocal
and critical about change in the first place.  I think that the negative
impact of a change will always be a bit overblown.

I guess it comes down to whether the negative impact is outweighed by the
increase in clarity.  Negative impact is obvious and instant, clarity is
mostly invisible and its benefits are realized over time.

People need some kind of feedback, a change in core is far-reaching with
some downsides.


On Fri, Jul 26, 2013 at 1:30 PM, greenh greenh.greenh...@gmail.com wrote:

 A couple thoughts, my own 2-cents-worth.

 First, I think I’m seeing an entirely legitimate concern being expressed
 by some developers that :use complicates life in their shops. Contrariwise,
 there’s clearly a set of developers who are in environments where :use
 feels very natural, and is of considerable convenience.

 As someone who is generally in the latter situation, I have a hard time
 with notion of getting rid of :use, but I can equally well picture myself
 doing Clojure environments where the restriction was pertinent.  So, how
 about if there was a compiler option that caused :use to be flagged with a
 warning or error? I’d say that was entirely acceptable solution that kept
 everyone happy.

 In general: if you’re talking about expanding the existing functionality
 to help solve people’s problems, I’m all for it. If you’re talking about
 restricting existing functionality to require conformity with your
 particular vision, that’s a problem.

 BTW, if you insist on making the :use functionality substantially less
 convenient, well, I know how I respond to such things. I recall a saying
 from long ago in the Lisp community that “if you don’t like the syntax,
 write your own!”---and so I do. I’ve already dealt with several perceived
 nuisances in existing Clojure by writing and using my own macros. Coming up
 with a custom replacement for the ns macro feels a little challenging, but
 I dare say I’d rise to the occasion if need be. If that becomes common
 practice, I’d say you’ve won the conformity battle but lost the war. (Hey,
 maybe we should get rid of macros to prevent such heinous acts, eh? It
 worked for Java…)

 Next, there's an I can't tell where identifiers come from thought. Yeah,
 I've felt that pain, and as I've indicated, I'm situationally sympathetic.
 But here's a thought: how is this different from any programming language
 where one file/class/module/whatever can be included by another? Might
 there already be technology for dealing with it---even technology that
 doesn't involve manually qualifying every non-local identifier?

 Finally, with respect to the “it’s too hard for newcomers” line of
 argumentation, my reaction is: this is silly.  Do you *really* want to
 optimize Clojure for use by newcomers?  Assuming you managed such a
 thing, would the result still be useful to experienced programmers---who
 are, after all, are the main constituency for Clojure? Newcomers don’t tend
 to stay newcomers for very long, right?

 Similarly, with respect to the “ns is too complex” meme, my response is:
 gimme a break. It really isn’t all *that* complicated, and reducing its
 set of options by one isn’t going to change that very much. In the overall
 scheme of things involving functional programming in general and Clojure in
 particular, this tiny spec of complexity hardly signifies.

 Now, what *is *a problem is one of explanation---like, how to make
 newcomers aware of a good-enough set of recipes to get them going, or a
 lucid description of what the options actually are, and where they should
 be applied.

 So, here's a suggestion: improve the documentation!! Have you looked at
 the docstring associated with ns? Yeeesh!  It’s all proper and correct,
 and about as profoundly uninformative as can be. (I’ve been doing Clojure
 intensively for about three years now, and just now I had a hard time even
 parsing it.)

 In fact, I think I’d generalize on this, as a lot of the docstrings in
 core Clojure are, um, terse… so I’d suggest that if Clojure 2.0 is afoot,
 improving the documentation would be an excellent goal.

 FWIW...


 Howard


  --
 --
 You received this 

Re: Symbol.intern doesnt return already interned symbols?

2013-07-26 Thread Marshall Bockrath-Vandegrift
Jürgen Hötzel juer...@hoetzel.info writes:

 My Question was about the interning. AFAIK interning shoult only
 return a new Symbol, when the Symbol wasn't interned already.

We may already be on the same page.  I was just pointing out that there
aren’t any semantic benefits to that form of iterning for Symbols.  The
way keywords are interned guarantees that any Keywords which are `=` are
the same object and thus `identical?`.  Symbols with different metadata
being separate objects precludes that.  You could have `Symbol/intern`
maintain a (weak-reference) cache to the nil-metadata versions of
Symbols, but it would *just* a cache.  If you had profiling results
which showed that maintaining such a cache made compilation x% faster,
that might be interesting, but otherwise I’m not clear on what the
benefit would be.

-Marshall

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




Re: Ring: How to auto-redirect URI's missing trailing slash

2013-07-26 Thread Brian Craft
Other (not clojure) frameworks do this with middleware that redirects to 
the url + slash when a route lookup fails, and the url has no trailing 
slash.

Is that possible with ring?

On Friday, July 26, 2013 10:45:33 AM UTC-7, Reginald Choudari wrote:

 Thanks for all the replies.

 Looks like the ring library has a redirect function in ring.util.response 
 namespace.

 It redirects using the 302 status code.

 Works for me. Although it is a pain to have to declare a redirect for 
 every route.


 On Thursday, July 25, 2013 9:08:50 PM UTC-4, Reginald Choudari wrote:

 Hello, I'm trying to figure out what is the best way in handling this 
 problem.

 Using Ring I have a handlers set to direct routes with relative URI paths 
 (e.g. /, ./posts, /about). But I would like the URI to be 
 automatically redirected to /posts/ and /about/ with the trailing 
 slash, so that all my links and references work correctly. If the URI is 
 without the trailing slash, I'm sure you know what happens to all your 
 relative paths.

 Any efficient way of dealing with this?

 Thanks,
 Reginald




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




Re: Ring: How to auto-redirect URI's missing trailing slash

2013-07-26 Thread Steven Degutis
Yeah, that sounds possible. I'll take a shot at it.

-Steven


On Fri, Jul 26, 2013 at 1:55 PM, Brian Craft craft.br...@gmail.com wrote:

 Other (not clojure) frameworks do this with middleware that redirects to
 the url + slash when a route lookup fails, and the url has no trailing
 slash.

 Is that possible with ring?


 On Friday, July 26, 2013 10:45:33 AM UTC-7, Reginald Choudari wrote:

 Thanks for all the replies.

 Looks like the ring library has a redirect function in ring.util.response
 namespace.

 It redirects using the 302 status code.

 Works for me. Although it is a pain to have to declare a redirect for
 every route.


 On Thursday, July 25, 2013 9:08:50 PM UTC-4, Reginald Choudari wrote:

 Hello, I'm trying to figure out what is the best way in handling this
 problem.

 Using Ring I have a handlers set to direct routes with relative URI
 paths (e.g. /, ./posts, /about). But I would like the URI to be
 automatically redirected to /posts/ and /about/ with the trailing
 slash, so that all my links and references work correctly. If the URI is
 without the trailing slash, I'm sure you know what happens to all your
 relative paths.

 Any efficient way of dealing with this?

 Thanks,
 Reginald


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




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




Re: is intellij idea a good ide for clojure development?

2013-07-26 Thread Cedric Greevey
On Fri, Jul 26, 2013 at 10:29 AM, Charlie Griefer charlie.grie...@gmail.com
 wrote:

 On Jul 25, 2013, at 8:15 PM, Cedric Greevey cgree...@gmail.com wrote:

 Someone makes free software plugins for nonfree software?!


 On Thu, Jul 25, 2013 at 11:04 PM, Greg g...@kinostudios.com wrote:

 You submit patches to nonfree software?!



 I may regret asking this… but don't people deserve to get paid for their
 work?


There's a difference between getting paid for your work and getting paid
over and over again for work you did once, years ago. There's also a
difference between getting paid for your work and getting free
improvements contributed to your code but not making your code, in turn,
freely available to the community. And that's leaving aside the matter of
the free in (non)free software being free as in speech, not as in
beer.

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




Re: is intellij idea a good ide for clojure development?

2013-07-26 Thread Gary Trakhman
Open-source developers are paid for their work in lots of ways that
may/may-not involve cash.

Commercial devs and products are not necessarily evil, and can be good for
the community.

Who cares if software gets bought over and over again? That's the beauty of
software!  Competition actually still drives improvement in this space
(Jetbrains is not Microsoft).

This is kind of like an open source version of the the software-piracy
'lost sale' argument, a 'lost contribution' argument.  Not every
open-source plugin developer for a commercial product would have
contributed to an open-source project instead.


On Fri, Jul 26, 2013 at 3:07 PM, Cedric Greevey cgree...@gmail.com wrote:

 On Fri, Jul 26, 2013 at 10:29 AM, Charlie Griefer 
 charlie.grie...@gmail.com wrote:

 On Jul 25, 2013, at 8:15 PM, Cedric Greevey cgree...@gmail.com wrote:

 Someone makes free software plugins for nonfree software?!


 On Thu, Jul 25, 2013 at 11:04 PM, Greg g...@kinostudios.com wrote:

 You submit patches to nonfree software?!



 I may regret asking this… but don't people deserve to get paid for their
 work?


 There's a difference between getting paid for your work and getting
 paid over and over again for work you did once, years ago. There's also a
 difference between getting paid for your work and getting free
 improvements contributed to your code but not making your code, in turn,
 freely available to the community. And that's leaving aside the matter of
 the free in (non)free software being free as in speech, not as in
 beer.

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




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




Re: is intellij idea a good ide for clojure development?

2013-07-26 Thread Andy Fingerhut
There are many who agree with Richard Stallman that it is unethical to 
distribute software without the source code.

There are many who disagree with him, myself included.  I think it is 100% 
ethical to sell proprietary software, sans source code.

I only mention this in hopes that people interested in discussing the topic at 
length will find an appropriate forum to do so, which I hope the Clojure Google 
group is not.

Andy

On Jul 26, 2013, at 12:07 PM, Cedric Greevey cgree...@gmail.com wrote:

 On Fri, Jul 26, 2013 at 10:29 AM, Charlie Griefer charlie.grie...@gmail.com 
 wrote:
 On Jul 25, 2013, at 8:15 PM, Cedric Greevey cgree...@gmail.com wrote:
 
 Someone makes free software plugins for nonfree software?!
 
 
 On Thu, Jul 25, 2013 at 11:04 PM, Greg g...@kinostudios.com wrote:
 You submit patches to nonfree software?!
 
 
 I may regret asking this… but don't people deserve to get paid for their 
 work?
 
 There's a difference between getting paid for your work and getting paid 
 over and over again for work you did once, years ago. There's also a 
 difference between getting paid for your work and getting free 
 improvements contributed to your code but not making your code, in turn, 
 freely available to the community. And that's leaving aside the matter of 
 the free in (non)free software being free as in speech, not as in beer.
 
 -- 
 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with your 
 first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 --- 
 You received this message because you are subscribed to the Google Groups 
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.
  
  

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




Re: is intellij idea a good ide for clojure development?

2013-07-26 Thread Cedric Greevey
On Fri, Jul 26, 2013 at 3:19 PM, Gary Trakhman gary.trakh...@gmail.comwrote:

 Open-source developers are paid for their work in lots of ways that
 may/may-not involve cash.


But generally they're paid as they work, and if they stop working, they
stop getting paid, like in most jobs.

Of course, the actual coders of closed-source software like Windows also
stop getting paid if they stop working; it's the big company that hired
them that gets to keep raking it in without necessarily having to do any
more work.


 Commercial devs and products are not necessarily evil, and can be good for
 the community.


Did I claim otherwise? I just thought it odd that people would make unpaid
contributions to nonfree software. Seems kind of like donating money to
Apple instead of to a local soup kitchen.

Who cares if software gets bought over and over again? That's the beauty of
 software!  Competition actually still drives improvement in this space
 (Jetbrains is not Microsoft).

 This is kind of like an open source version of the the software-piracy
 'lost sale' argument, a 'lost contribution' argument.  Not every
 open-source plugin developer for a commercial product would have
 contributed to an open-source project instead.


I don't think I claimed that either. On the other hand, one can make an
argument that the plugin developer may be being taken advantage of, if they
are essentially improving a *commercial* product (and only a commercial
product, rather than a wide, interoperable array of both commercial and
free products) gratis.

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




Re: Does this abstraction have any existing name?

2013-07-26 Thread Takahiro Hozumi
I think clojure.walk is suited to this purpose.
https://github.com/clojure/clojure/blob/master/src/clj/clojure/walk.clj
See keywordize-keys as an example.

On Saturday, July 27, 2013 2:31:21 AM UTC+9, Yoshinori Kohyama wrote:

 Thank you Gary.
 There's no reason why this need to be a macro.
 It has rewritten as a function.

 And I'd still like to hear any response about the same three questions.

 (require '[clojure.test :refer (with-test is run-tests)])
  
 (with-test
   (defn mapf [f m  args]
 ((fn g [n]
(if (map? n)
(into {} (map (fn [[k v]] [k (g v)]) n))
(apply f n args)))
  m))
  
   (is (= (mapf #(* % %) {:a {:b 3 :c 4} :d 5})
  {:a {:b 9 :c 16} :d 25}))
   (is (= (mapf #(+ (* %1 %1) %2) {:a {:b 3 :c 4} :d 5} 1)
  {:a {:b 10 :c 17} :d 26})))



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




Re: Does this abstraction have any existing name?

2013-07-26 Thread Dave Sann
if you are thinking of the nested map as a sort of tree - which you seem to 
be doing - then map-leaves or something similar might convey the intent.

On Saturday, 27 July 2013 04:30:30 UTC+10, Jay Fields wrote:

 I'm not sure I'd call this more readable, but it's another option - using 
 clojure.walk

 (defn deep-update-vals
   [m f  args]
   (let [f (fn [[k v]] (if (map? v) [k v] [k (apply f v args)]))]
 (clojure.walk/postwalk (fn [x] (if (map? x) (into {} (map f x)) x)) 
 m)))


 On Fri, Jul 26, 2013 at 2:06 PM, Jay Fields j...@jayfields.comjavascript:
  wrote:

 I defined update-vals in jry: 
 https://github.com/jaycfields/jry/blob/master/src/clojure/jry.clj#L74-L75

 It doesn't traverse nested maps, but I haven't ever needed that ability 
 either.

 1) I've never seen a name for that.
 2) not in core. I'm sure it's been written 50 times in various helper 
 libs.
 3) I'd probably write it like below, but I'm not convinced it's any 
 better.

 (defn deep-update-vals
   [m f  args]
   (if (map? m)
 (reduce-kv #(assoc %1 %2 (apply deep-update-vals %3 f args)) {} m)
 (apply f m args)))


 On Fri, Jul 26, 2013 at 1:31 PM, Yoshinori Kohyama 
 yyko...@gmail.comjavascript:
  wrote:

 Thank you Gary.
 There's no reason why this need to be a macro.
 It has rewritten as a function.

 And I'd still like to hear any response about the same three questions.



 (require '[clojure.test :refer (with-test is run-tests)])


  
 (with-test
   (defn mapf [f m  args]


 ((fn g [n]
(if (map? n)


(into {} (map (fn [[k v]] [k (g v)]) n))


(apply f n args)))

  m))
  
   (is (= (mapf #(* % %) {:a {:b 3 :c 4} :d 5})


  {:a {:b 9 :c 16} :d 25}))


   (is (= (mapf #(+ (* %1 %1) %2) {:a {:b 3 :c 4} :d 5} 1)


  {:a {:b 10 :c 17} :d 26})))



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





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




core.async: How to signal worker completion

2013-07-26 Thread Jeff Sigmon
I would like to signal after a channel is drained AND subsequently 
processed by workers inside go blocks. My understanding is that I could 
return a channel in my worker function and then close the channel when all 
of the workers have finished to signal completion. Since the channel can 
only be closed once, I must ensure that the last worker completed is the 
only one to call close. To maintain this state I am counting the number of 
workers completed using an atom. When a worker reads a Nil from the input 
channel, it increments the workers finished count and closes the channel if 
all other workers have finished. The code below is working but is there a 
better way to do this without relying on the atom?

https://gist.github.com/LAMF/6093294

(def work 10)
(def workers 2)

(defn make-work []
  (let [c (chan work)]
(dotimes [i work]
  (!! c i))
(close! c)
c))

(defn do-work [c]
  (let [out (chan)
completed (atom 0)
finish (fn []
 (swap! completed inc)
 (if (= @completed workers)
 (close! out)))]
(dotimes [i workers]
  (go
   (loop []
 (when-let [i (! c)]
   (! (timeout (rand-int 500)))
   (println i)
   (recur)))
   (finish)))
out))


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




Re: Symbol.intern doesnt return already interned symbols?

2013-07-26 Thread Jeremy Heiler
On July 26, 2013 at 10:39:47 AM, Jürgen Hötzel (juer...@hoetzel.info) wrote:
I did some memory profiling on a Clojure Application.

I wondered why 361000 clojure.lang.Symbols exist.

So I did some object browsing on the memory dump  and found duplicate symbols. 
After checking the source:

static public Symbol intern(String nsname){
        int i = nsname.indexOf('/');
        if(i == -1 || nsname.equals(/))
                return new Symbol(null, nsname.intern());
        else
                return new Symbol(nsname.substring(0, i).intern(), 
nsname.substring(i + 1).intern());
}


I realized that interning of a symbol always returns a new Symbol object.

If a symbol X is interned twice, shouldn't the second Symbol.intern(X)  return 
the  previous interned symbol object?
It's not the symbol that's being interned, it's the string that represents the 
symbol. If you look at the equals() method for Symbol, you'll notice that it is 
using object equality (the double equals operator, ==) to compare the name of 
the symbol. So, if you have two symbols with the same name, they will be 
equivalent because they have the same string object internally. However, since 
each symbol can have its own metadata, the symbol objects cannot be interned as 
your are describing. Keywords fill that role, as Marshall mentioned.

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




ANN: substantiation, An opinionated nested maps validations library

2013-07-26 Thread ronen


Substantiation is an opinionated simple nested map validation library:

   - Predicates and description kept separate.
   - Validation description map follows validated input structure. 
   - Pure data structures to describe validations.
   - Composability of validations is trivial.
   - Validation predicates scope is limited (can only access the checked 
   value).
   - High level decisions such as when to activate a group of validations 
   should happen on upper layer.
   - Non strict, only described items checked.

Github: https://github.com/narkisr/substantiation

Feedback is welcome
Ronen

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




Re: Does this abstraction have any existing name?

2013-07-26 Thread Yoshinori Kohyama
Thanks, Jay.
Your reply helps me much.

I often think which is better,
  (into {} (map (fn [[k v]] [k (f v)]) m))
and
  (reduce (fn [a [k v]] (assoc a k (f v))) m m)
or
  (reduce-kv (fn [a k v] (assoc a k (f v))) m m)
, where f is a function, m is a map.

Any body have any opinion?

Thanks.
Y. Kohyama

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




Re: Does this abstraction have any existing name?

2013-07-26 Thread Ben Wolfson
If the map is a tree with values at the leaves, then it's a functor and
applying a function to the values is fmap.


On Fri, Jul 26, 2013 at 6:02 PM, Dave Sann daves...@gmail.com wrote:

 if you are thinking of the nested map as a sort of tree - which you seem
 to be doing - then map-leaves or something similar might convey the intent.

 On Saturday, 27 July 2013 04:30:30 UTC+10, Jay Fields wrote:

 I'm not sure I'd call this more readable, but it's another option - using
 clojure.walk

 (defn deep-update-vals
   [m f  args]
   (let [f (fn [[k v]] (if (map? v) [k v] [k (apply f v args)]))]
 (clojure.walk/postwalk (fn [x] (if (map? x) (into {} (map f x)) x))
 m)))


 On Fri, Jul 26, 2013 at 2:06 PM, Jay Fields j...@jayfields.com wrote:

 I defined update-vals in jry: https://github.com/**
 jaycfields/jry/blob/master/**src/clojure/jry.clj#L74-L75https://github.com/jaycfields/jry/blob/master/src/clojure/jry.clj#L74-L75

 It doesn't traverse nested maps, but I haven't ever needed that ability
 either.

 1) I've never seen a name for that.
 2) not in core. I'm sure it's been written 50 times in various helper
 libs.
 3) I'd probably write it like below, but I'm not convinced it's any
 better.

 (defn deep-update-vals
   [m f  args]
   (if (map? m)
 (reduce-kv #(assoc %1 %2 (apply deep-update-vals %3 f args)) {} m)
 (apply f m args)))


 On Fri, Jul 26, 2013 at 1:31 PM, Yoshinori Kohyama yyko...@gmail.comwrote:

 Thank you Gary.
 There's no reason why this need to be a macro.
 It has rewritten as a function.

 And I'd still like to hear any response about the same three questions.



 (require '[clojure.test :refer (with-test is run-tests)])



 (with-test
   (defn mapf [f m  args]


 ((fn g [n]
(if (map? n)


(into {} (map (fn [[k v]] [k (g v)]) n))


(apply f n args)))

  m))

   (is (= (mapf #(* % %) {:a {:b 3 :c 4} :d 5})


  {:a {:b 9 :c 16} :d 25}))


   (is (= (mapf #(+ (* %1 %1) %2) {:a {:b 3 :c 4} :d 5} 1)


  {:a {:b 10 :c 17} :d 26})))



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

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

 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=enhttp://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to clojure+u...@**googlegroups.com.

 For more options, visit 
 https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
 .





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






-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Does this abstraction have any existing name?

2013-07-26 Thread Yoshinori Kohyama
Thank you, Dave.

Yes, I'm thinking of a nested map as a sort of tree.
Then, what I do may be called 'map-leaves', as you say.

Is there an existing function named like that?
Or did you say that just as 'an abstraction name'?

Y.Kohyama

2013年7月27日土曜日 10時02分17秒 UTC+9 Dave Sann:

 if you are thinking of the nested map as a sort of tree - which you seem 
 to be doing - then map-leaves or something similar might convey the intent.


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




Re: Does this abstraction have any existing name?

2013-07-26 Thread Yoshinori Kohyama
Thank you, Ben.

If I think the map as a tree, then as a functor, what I do is 'fmap' (in 
Haskell or some languages),
,as you say.
Thanks for saying that.

Does Algo supply things around Functor, Applicative and Monad?
I'm going to look at Algo.

Or anybody knows any other libraries or implementations around these things 
in Clojure?

Regards,
Y.Kohyama


2013年7月27日土曜日 13時06分23秒 UTC+9 Ben:

 If the map is a tree with values at the leaves, then it's a functor and 
 applying a function to the values is fmap.


 On Fri, Jul 26, 2013 at 6:02 PM, Dave Sann dave...@gmail.comjavascript:
  wrote:

 if you are thinking of the nested map as a sort of tree - which you seem 
 to be doing - then map-leaves or something similar might convey the intent.

 On Saturday, 27 July 2013 04:30:30 UTC+10, Jay Fields wrote:

 I'm not sure I'd call this more readable, but it's another option - 
 using clojure.walk

 (defn deep-update-vals
   [m f  args]
   (let [f (fn [[k v]] (if (map? v) [k v] [k (apply f v args)]))]
 (clojure.walk/postwalk (fn [x] (if (map? x) (into {} (map f x)) x)) 
 m)))


 On Fri, Jul 26, 2013 at 2:06 PM, Jay Fields j...@jayfields.com wrote:

 I defined update-vals in jry: https://github.com/**
 jaycfields/jry/blob/master/**src/clojure/jry.clj#L74-L75https://github.com/jaycfields/jry/blob/master/src/clojure/jry.clj#L74-L75

 It doesn't traverse nested maps, but I haven't ever needed that ability 
 either.

 1) I've never seen a name for that.
 2) not in core. I'm sure it's been written 50 times in various helper 
 libs.
 3) I'd probably write it like below, but I'm not convinced it's any 
 better.

 (defn deep-update-vals
   [m f  args]
   (if (map? m)
 (reduce-kv #(assoc %1 %2 (apply deep-update-vals %3 f args)) {} m)
 (apply f m args)))


 On Fri, Jul 26, 2013 at 1:31 PM, Yoshinori Kohyama 
 yyko...@gmail.comwrote:

 Thank you Gary.
 There's no reason why this need to be a macro.
 It has rewritten as a function.

 And I'd still like to hear any response about the same three questions.




 (require '[clojure.test :refer (with-test is run-tests)])



  
 (with-test
   (defn mapf [f m  args]



 ((fn g [n]
(if (map? n)



(into {} (map (fn [[k v]] [k (g v)]) n))



(apply f n args)))

  m))
  
   (is (= (mapf #(* % %) {:a {:b 3 :c 4} :d 5})



  {:a {:b 9 :c 16} :d 25}))



   (is (= (mapf #(+ (* %1 %1) %2) {:a {:b 3 :c 4} :d 5} 1)



  {:a {:b 10 :c 17} :d 26})))




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

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

 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=enhttp://groups.google.com/group/clojure?hl=en
 --- 
 You received this message because you are subscribed to the Google 
 Groups Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send 
 an email to clojure+u...@**googlegroups.com.

 For more options, visit 
 https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
 .
  
  



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




 -- 
 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
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit 

Re: Does this abstraction have any existing name?

2013-07-26 Thread Jason Wolfe
This is 'map-leaves' in our open-source lib plumbing.map (besides the 
option for additional args):

https://github.com/Prismatic/plumbing/blob/master/src/plumbing/map.clj

Cheers, Jason

On Friday, July 26, 2013 8:49:14 AM UTC-7, Yoshinori Kohyama wrote:

 Hello group.

 I wrote a tiny macro to apply a function to values in lowest levels in a map 
 with arguments.
 Three questions:

- Does this abstraction have any existing name?
- Is there any existing function/macro to do similar things?
- Would anyone improve this implementation?


 (require '[clojure.test :refer (with-test is are run-tests)])
  
 (with-test
   (defmacro mapf [f m  args]
 `((fn f# [n#]
 (if (map? n#)
 (into {} (map (fn [[k# v#]] [k# (f# v#)]) n#))
 (~f n# ~@args)))
   ~m))
  
   (is (= (mapf #(* % %) {:a {:b 3 :c 4} :d 5})
  {:a {:b 9 :c 16} :d 25}))
   (is (= (mapf #(+ (* %1 %1) %2) {:a {:b 3 :c 4} :d 5} 1)
  {:a {:b 10 :c 17} :d 26})))

 https://gist.github.com/kohyama/6089899

 Thank you in advance.

 Y.Kohyama



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




Re: Does this abstraction have any existing name?

2013-07-26 Thread Ben Wolfson
On Fri, Jul 26, 2013 at 9:27 PM, Yoshinori Kohyama yykohy...@gmail.comwrote:

 Thank you, Ben.

 If I think the map as a tree, then as a functor, what I do is 'fmap' (in
 Haskell or some languages),
 ,as you say.
 Thanks for saying that.

 Does Algo supply things around Functor, Applicative and Monad?
 I'm going to look at Algo.

 Or anybody knows any other libraries or implementations around these
 things in Clojure?


algo.generic has a functor implementation for regular maps which you could
already use, if your maps have uniform depth:

(fmap (partial fmap inc) {:a {:x 1} :b {:y 2}}) --- {:a {:x 2} :b {:y 3}}

if you want to use that fmap (or, I'd think, the fmaps provided by either
morph or fluokitten) with uneven depths, you'd have to wrap them in a
defrecord or deftype, I'd expect.

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Does this abstraction have any existing name?

2013-07-26 Thread Ben Wolfson
On Fri, Jul 26, 2013 at 9:31 PM, Ben Wolfson wolf...@gmail.com wrote:

 On Fri, Jul 26, 2013 at 9:27 PM, Yoshinori Kohyama yykohy...@gmail.comwrote:

 Thank you, Ben.

 If I think the map as a tree, then as a functor, what I do is 'fmap' (in
 Haskell or some languages),
 ,as you say.
 Thanks for saying that.

 Does Algo supply things around Functor, Applicative and Monad?
 I'm going to look at Algo.

 Or anybody knows any other libraries or implementations around these
 things in Clojure?


 algo.generic has a functor implementation for regular maps which you could
 already use, if your maps have uniform depth:

 (fmap (partial fmap inc) {:a {:x 1} :b {:y 2}}) --- {:a {:x 2} :b {:y 3}}

 if you want to use that fmap (or, I'd think, the fmaps provided by either
 morph or fluokitten) with uneven depths, you'd have to wrap them in a
 defrecord or deftype, I'd expect.


You could also engage in this underhanded trick:

user= (defmethod f/fmap Object [f v] (f v)) ;;; Identity functor
#MultiFn clojure.lang.MultiFn@5de33e
user= (defmethod f/fmap clojure.lang.IPersistentMap [f v] (into {} (map
(fn [[k v]] [k (f/fmap f v)]) v)))
#MultiFn clojure.lang.MultiFn@5de33e
user= (f/fmap inc {:a {:y 1} :b {:x 2 :z {:c [1 2 3]}}})
{:a {:y 2}, :b {:z {:c [2 3 4]}, :x 3}}

But I wouldn't recommend it.

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




Re: Does this abstraction have any existing name?

2013-07-26 Thread Yoshinori Kohyama
Thank you, Jason.

The 'map-leaves' does the same as my 'mapf' and simpler.
Its name and implementation is very sophisticated with other functions doing
similar but different things.
Thanks the information.

Regards,
Y.Kohyama

2013年7月27日土曜日 13時31分28秒 UTC+9 Jason Wolfe:

 This is 'map-leaves' in our open-source lib plumbing.map (besides the 
 option for additional args):

 https://github.com/Prismatic/plumbing/blob/master/src/plumbing/map.clj

 Cheers, 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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Does this abstraction have any existing name?

2013-07-26 Thread Yoshinori Kohyama
Thanks Ben, for very useful informations!

2013年7月27日土曜日 13時31分41秒 UTC+9 Ben:

 if you want to use that fmap (or, I'd think, the fmaps provided by either 
 morph or fluokitten) with uneven depths, you'd have to wrap them in a 
 defrecord or deftype, I'd expect.


I see.

2013年7月27日土曜日 13時37分28秒 UTC+9 Ben:

 user= (defmethod f/fmap Object [f v] (f v)) ;;; Identity functor
 #MultiFn clojure.lang.MultiFn@5de33e
 user= (defmethod f/fmap clojure.lang.IPersistentMap [f v] (into {} (map 
 (fn [[k v]] [k (f/fmap f v)]) v)))
 #MultiFn clojure.lang.MultiFn@5de33e
 user= (f/fmap inc {:a {:y 1} :b {:x 2 :z {:c [1 2 3]}}})
 {:a {:y 2}, :b {:z {:c [2 3 4]}, :x 3}}

 But I wouldn't recommend it.


One way.  It can be used, I think.

Thanks again.

Regards,
Y.Kohyama

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