Re: Reducers

2012-05-11 Thread nicolas.o...@gmail.com
On Fri, May 11, 2012 at 12:47 AM, Rich Hickey  wrote:
> IMO, Nicolas' material is a distraction in understanding reducers, except as 
> historical background.

I perfectly agree.

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


Re: How to configure a Clojure library at runtime?

2012-05-11 Thread Baishampayan Ghose
Hi,

What about something like this -

* Create a protocol called IGraphDBClient or something similar and
create a spec.
* Provide different client implementations in their own namespaces
using deftype, eg. bulbs.db.neo4j/client, bulbs.db.orientdb/client,
etc.
* Put your core functions in a core ns, eg. bulbs.core. Write all your
functions there. Ideally they should all work on top of the
IGraphDBClient protocol. You could provide client factory functions as
well, eg. (neo4j-client ...), (orientdb-client ...), etc.

Does this work for you?

Regards,
BG

On Fri, May 11, 2012 at 2:23 PM, James Thornton
 wrote:
> As a Clojure learning exercise, I am porting Bulbs (http://bulbflow.com), a
> graph-database library I wrote, from Python to Clojure.
>
> One of the things I'm still somewhat fuzzy on is how to structure the
> library in a Clojure idiomatic way.
>
> To support multiple databases, Bulbs uses dependency injection. The
> different database backends are abstracted away in a custom Client class
> that implements an interface, and the client is configured at runtime.
>
> The Graph object and its various proxy objects hold an instance of the
> low-level Client object:
>
> # bulbs/neo4jserver/graph.py
>
> class Graph(object):
>
>     default_uri = NEO4J_URI
>
>     def __init__(self, config=None):
>         self.config = config or Config(self.default_uri)
>         self.client = Neo4jClient(self.config)
>
>         self.vertices = VertexProxy(Vertex, self.client)
>         self.edges = EdgeProxy(Edge, self.client)
>
> You use Bulbs by creating a Graph object for the respective graph-database
> server:
>
 from bulbs.neo4jserver import Graph
 g = Graph()
>
> And then you can create vertices and edges in the database via the proxy
> objects:
>
 james = g.vertices.create(name="James")
 julie = g.vertices.create(name="Julie")
 g.edges.create(james, "knows", julie)
>
> This design makes it easy to use Bulbs from the REPL because all you have to
> do is import and instantiate the Graph object (or possibly pass in a custom
> Config object if needed).
>
> But I'm not sure how to approach this design in Clojure since the Graph
> object and its proxies need to hold the Client object, which is configured
> at runtime.
>
> What's the Clojure-way of doing this?
>
> Thanks.
>
> - James
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en



-- 
Baishampayan Ghose
b.ghose at gmail.com

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


Re: Reducers

2012-05-11 Thread Softaddicts
Hi Rich,

I may be a bit aggressive here :) but will this be ready for 1.5 ? Or available
as an independent feature ? (I am not sure about this given the name)

I intend to skip 1.4 depending on our delivery cycles and the availability of 
1.5, we are
 about to move 1.3 in prod here and my eyes are
trying to keep focussed on that. I plan releases in a horizon of 6 to 10 months.

Do not feel pressed to answer, take more hammock time if needed after all,
the outside temperatures rose a bit so time spent there is not exposing you 
anymore
to various diseases :)

We run production on clusters of tiny boxes (2 to 4 cores with HT) and we like 
optimizing
our code along the way. This would be a nice improvement, future hardware
upgrades will likely move us to an increased number of cores.

I really like this stuff, it's not alien at all to the language contrary to 
other
attempts made in other languages to implement "transparent" parallelism.

Thank you
Luc


> IMO, Nicolas' material is a distraction in understanding reducers, except as 
> historical background.
> > The reducers library is a rejection/avoidance of the primacy of 
> > recursively/generatively defined data structures and the operations thereon.
> > I recommend, rather than reading about stream fusion, one watches the Guy 
> > Steele presentation linked from the post:
> > Organizing Functional Code for Parallel Execution > or, foldl and foldr 
> > Considered Slightly Harmful:
> > http://vimeo.com/6624203
> > Which boils down to - stop programming with streams, lists, generators etc 
> > if you intend to exploit parallelism, which the reducers library does

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


Re: Getting started

2012-05-11 Thread Enterprise Saas
java -jar clojure-1.4.0.jar
On May 10, 2012 9:36 AM, "Zeno"  wrote:

> Hi,
> I have downloaded and unzipped Clojure 1.4.0 but when trying "java -cp
> clojure-1.4.0.jar clojure.main" as stated on the getting started page
> I get the following.
>
> D:\Profiles\rcarthur\My Documents\Clojure1_4\clojure-1.4.0>java -cp
> clojure-1.4.0.jar clojure.main
>
> Exception in thread "main" java.lang.NoClassDefFoundError: clojure/
> main
> Caused by: java.lang.ClassNotFoundException: clojure.main
>at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>at java.security.AccessController.doPrivileged(Native Method)
>at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
>at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:
> 301)
>at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
>at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:
> 320)
> Could not find the main class: clojure.main.  Program will exit.
>
> Any clues as to what I might be doing wrong?
>
> Regards
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

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

Error while trying to deploy ejb written in clojure to openejb 4.0.0

2012-05-11 Thread Ales
Hi,

I am trying to deploy ejb written in clojure to OpenEjb standalone
server. Clojure library clojure-1.3.0.jar is in /lib directory of
openejb. When ejb is initialising, I get the error pasted below. I'll
be very thankful for any hint or suggestion.

Ales


INFO: Configuring enterprise application: /home/ales/openejb/apps/
carina-ejb.jar
java.lang.ExceptionInInitializerError
at clojure.core__init.__init0(Unknown Source)
at clojure.core__init.(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at clojure.lang.RT.loadClassForName(RT.java:2030)
at clojure.lang.RT.load(RT.java:417)
at clojure.lang.RT.load(RT.java:398)
at clojure.lang.RT.doInit(RT.java:434)
at clojure.lang.RT.(RT.java:316)
at carina.CarinaBean.(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at org.apache.openejb.util.Classes.forName(Classes.java:62)
at
org.apache.openejb.config.rules.ValidationBase.loadClass(ValidationBase.java:
139)
at
org.apache.openejb.config.rules.CheckMethods.check_unusedCreateMethods(CheckMethods.java:
305)
at
org.apache.openejb.config.rules.CheckMethods.validate(CheckMethods.java:
52)
at
org.apache.openejb.config.rules.ValidationBase.validate(ValidationBase.java:
45)
at
org.apache.openejb.config.AppValidator.validate(AppValidator.java:96)
at
org.apache.openejb.config.ValidateModules.deploy(ValidateModules.java:
37)
at org.apache.openejb.config.ConfigurationFactory
$Chain.deploy(ConfigurationFactory.java:321)
at
org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:
792)
at
org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:
668)
at
org.apache.openejb.config.ConfigurationFactory.getOpenEjbConfiguration(ConfigurationFactory.java:
437)
at
org.apache.openejb.assembler.classic.Assembler.getOpenEjbConfiguration(Assembler.java:
345)
at
org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:
324)
at org.apache.openejb.OpenEJB$Instance.(OpenEJB.java:
144)
at org.apache.openejb.OpenEJB.init(OpenEJB.java:290)
at org.apache.openejb.server.Server.init(Server.java:64)
at org.apache.openejb.server.Main.initServer(Main.java:154)
at org.apache.openejb.server.Main.main(Main.java:128)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.apache.openejb.cli.MainImpl.main(MainImpl.java:148)
at org.apache.openejb.cli.Bootstrap.main(Bootstrap.java:103)
Caused by: java.lang.IllegalStateException: Attempting to call unbound
fn: #'clojure.core/refer
at clojure.lang.Var$Unbound.throwArity(Var.java:43)
at clojure.lang.AFn.invoke(AFn.java:39)
at clojure.lang.Var.invoke(Var.java:401)
at clojure.lang.RT.doInit(RT.java:447)
at clojure.lang.RT.(RT.java:316)
... 36 more

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


Re: Partitioning a list when the result of a predicate becomes a certain value.

2012-05-11 Thread Stephen Olsen
I think you'd just have to do it manually with a reduce

Something like this should work.

(defn foldfn [i n]
  (let [result (first i)
current (second i)]
(if (re-matches #"^(\w)\1.*" n)
  (if (= [] current)
[result [n]]
[(conj result current) [n]])
  [result (conj current n)])))

(defn partition-lst
  [lst]
  (let [reduced (reduce foldfn [[][]] lst)
result (first reduced)
current (second reduced)]
(if (= current [])
  result
  (conj result current



-- 
Stephen Olsen
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)


On Thursday, May 10, 2012 at 4:11 PM, Ant wrote:

> Hi all,
> 
> I am battering my head against the following problem which I'm sure is
> straightforward if only I knew how. I want to partition the following
> list:
> 
> '("aa123" "x" "y" "z" "bb123" "ccq23" "3" "yg")
> 
> into the following:
> 
> (("aa123" "x" "y" "z") ("bb123") ("ccq23" "3" "yg"))
> 
> The predicate is:
> 
> #(re-matches #"^(\w)\1.*" %)
> 
> partition-by doesn't work, since it splits the sequence when the
> result of applying the predicate changes. I want to partition when the
> predicate becomes a particular value.
> 
> Any clues on how to accomplish this would be gratefully received!
> 
> Thanks,
> 
> Anthony.
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com 
> (mailto:clojure@googlegroups.com)
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com 
> (mailto:clojure+unsubscr...@googlegroups.com)
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> 
> 


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

Getting a Custom JFrame up and Running

2012-05-11 Thread JvJ
Hi,

I'm new to Clojure, but a longtime Java programmer.  I'm trying to get
the hang of gen-class, and I'd like to write a custom JFrame that
extends the paint method so I can get some ***aw3xX0m3 gr4f-X***.

Anyways, I'm having some trouble understanding gen-class, inheritance,
etc.

Here's what I have so far:

(import '(javax.swing JFrame)
'(java.awt Graphics)
'(java.awt.event WindowAdapter))

(ns LifeFrame)

(gen-class
  :name LFrame
  :extends javax.swing.JFrame
  :constructors {[String] [String]}
  :state state
  :prefix lFrame-)

;;; Draw a black rectangle
(defn lFrame-paint [this gfx]
  (.fillRect gfx 0 0 100 100))

(defn mainRun []
  (let [f (LifeFrame/LFrame.)]
(.setVisible f true)));; Run the constructor

When I call mainRun from the REPL, I get the following error:

CompilerException java.lang.IllegalArgumentException: Unable to
resolve classname: LFrame, compiling:(LifeFrame.clj:24)


Any knowledge about this would be greatly appreciated.

Thanks.

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


Re: Getting a Custom JFrame up and Running

2012-05-11 Thread Frank Siebenlist
You may want to check-out Dave Ray's seesaw .

"Seesaw turns the Horror of Swing into a friendly, well-documented, Clojure 
library"

https://github.com/daveray/seesaw

-FS.

On May 10, 2012, at 3:03 PM, JvJ wrote:

> Hi,
> 
> I'm new to Clojure, but a longtime Java programmer.  I'm trying to get
> the hang of gen-class, and I'd like to write a custom JFrame that
> extends the paint method so I can get some ***aw3xX0m3 gr4f-X***.
> 
> Anyways, I'm having some trouble understanding gen-class, inheritance,
> etc.
> 
> Here's what I have so far:
> 
> (import '(javax.swing JFrame)
>'(java.awt Graphics)
>'(java.awt.event WindowAdapter))
> 
> (ns LifeFrame)
> 
> (gen-class
>  :name LFrame
>  :extends javax.swing.JFrame
>  :constructors {[String] [String]}
>  :state state
>  :prefix lFrame-)
> 
> ;;; Draw a black rectangle
> (defn lFrame-paint [this gfx]
>  (.fillRect gfx 0 0 100 100))
> 
> (defn mainRun []
>  (let [f (LifeFrame/LFrame.)]
>(.setVisible f true)));; Run the constructor
> 
> When I call mainRun from the REPL, I get the following error:
> 
> CompilerException java.lang.IllegalArgumentException: Unable to
> resolve classname: LFrame, compiling:(LifeFrame.clj:24)
> 
> 
> Any knowledge about this would be greatly appreciated.
> 
> Thanks.
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

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


Re: How to configure a Clojure library at runtime?

2012-05-11 Thread James Thornton


On Friday, May 11, 2012 4:03:52 AM UTC-5, Baishampayan Ghose wrote:
>
>
> * Create a protocol called IGraphDBClient or something similar and 
> create a spec. 
> * Provide different client implementations in their own namespaces 
> using deftype, eg. bulbs.db.neo4j/client, bulbs.db.orientdb/client, 
> etc. 
> * Put your core functions in a core ns, eg. bulbs.core. Write all your 
> functions there. Ideally they should all work on top of the 
> IGraphDBClient protocol. You could provide client factory functions as 
> well, eg. (neo4j-client ...), (orientdb-client ...), etc. 
>


Thanks BG. 

Is setting a dynamic binding at runtime the recommended way of storing the 
 config map?

- James

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

ANN: Mori, use ClojureScript from the comfort of vanilla JavaScript

2012-05-11 Thread David Nolen
A work in progress:

http://github.com/swannodette/mori

Pull requests welcome :)

David

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

Re: Reducers

2012-05-11 Thread Sean Corfield
On Fri, May 11, 2012 at 6:28 AM, Softaddicts
 wrote:
> I may be a bit aggressive here :) but will this be ready for 1.5 ? Or 
> available
> as an independent feature ? (I am not sure about this given the name)

Reducers are part of the 1.5.0 master branch. The only reason they're
not already available in a master-SNAPSHOT build is because Clojure
isn't building at the moment due to the jsr166y change and Java 6
dependency. So, not to speak for Rich or Clojure/core but, I can't
imagine reducers being removed from 1.5.0 at this point...
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

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

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


Re: Reducers

2012-05-11 Thread Sean Corfield
On Fri, May 11, 2012 at 9:17 AM, Sean Corfield  wrote:
> Reducers are part of the 1.5.0 master branch. The only reason they're
> not already available in a master-SNAPSHOT build is because Clojure
> isn't building at the moment due to the jsr166y change and Java 6
> dependency.

Just to clarify: Clojure isn't building at the moment _on
build.clojure.org_ but you can build it yourself easily enough:
* git clone git://github.com/clojure/clojure.git
* mvn install
Then you'll have a local clojure-1.5.0-master-SNAPSHOT.jar you can
depend on and try the reducers out for yourself.
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

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

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


Re: [ANN] The Kiln, an Evaulation Strategy for Insanely Complex Functions

2012-05-11 Thread Jeffrey Straszheim
Looks awesome.

I think we're going the same direction. Myself, I wanted clays to be 
first-class items that can live in Clojure namespaces, and give you all of 
that. The downside is this: if I particular clay is wrong for some 
particular evaluation, you're stuck. The clay is the clay is the clay.

There are a couple ways around this. For testing, with-redefs has its 
normal purpose. You can also use a function unsafe-set-clay!! to force a 
clay's value. But that's heavy handed. More usefully, clays can be built 
lexically, as in

 (let [a-clay (clay :value (... stuff ...) :name something)]
  ... stuff ...)

And passed around

(fire kiln clay-with-args a-lexical-clay)

(defclay clay-with-args
   :args [some-clay]
   :value (blah (?? some-clay)))

This would let you build a computational graph on an as-needed basis.

But still, those are clumsy tools: fine for a few edge cases, but if needed 
often you'd want something built for the task. For your use case, it sounds 
like your approach is better. For the specific applications that led to my 
thinking, the entities were pretty well-defined and their computation 
well-known. Making them top-level named objects seems the right way to go.





On Thursday, May 10, 2012 11:11:15 AM UTC-4, mlimotte wrote:
>
> Hi Jeff,
>
> What do you think about a Map interface for this?
>
> I recently implemented something similar in a project of mine, which I 
> called an 'evaluating-map'.  It's not a Web project, but the pattern is a 
> general one.  In my case, a DSL for specifying a job to run.  I want the 
> DSL writer to have access to a lot of data/logic which can come from a lot 
> of different sources (a "big ball of mud" to use your term).
>
> Like you, the mud-ball could contain values or functions.  These functions 
> can have references to other values in the "ball of mud".  I expanded this 
> to include interpolated strings (e.g. "foo is ${foo}") and collections of 
> values/Strings/functions which are handled recursively.  My code doesn't do 
> anything to manage state, although users are encouraged to provide memoized 
> functions and a helper is provided to assist with this.
>
> Here's an example comparable to your example from the Kiln project.
>
> (def m 
>   {:request "foo"
>:uri #(build-uri (:request %))   ; an anonymous function works, or
>:path (lfn [uri] (.getPath uri)) ; use lfn, a helper that returns a fn
>:dispatch 
>  (lfn [path] (condp = path 
>"/remove-user" :remove-user
>"/add-user" :add-user
>"/view-user" :view-user))
>:action! action  ; assuming action is defn'ed elsewhere
>... and so on ... })
>
> lfn is the helper that I mentioned-- it pulls it's args as keys from the 
> "ball-of-mud" and returns a memoized fn of those args.
>
> Eventually, you fire it.  Like Kiln, the concept is that you have a bunch 
> of code that sets it up and then at some point you mix in a few seed values 
> and kick it off.  My fire function does a bunch of other stuff, but the 
> relevant part boils down to (-> m (assoc :request req) evaluating-map), 
> which is used like this:
>
> (let [k (-> m (assoc :request req) evaluating-map)
>   result (try 
>(:action! k)
>(render-template (:template k) ...other kiln data...)
>... catch)]
>   ; because it's a Map, you can do things like
>   (log/debug (select-keys k [:uri :path]))
>   result)
>
> I didn't write support for glazes and cleanup.  I think glazes could be 
> done ring-style.  Cleanup requires some extra thought.  Those are nice 
> features of Kiln.
>
> I think Kiln gives you more control over the execution and state, making 
> things like cleanup easy.  What I like about the Map interface, aside from 
> the convenience of being able to use standard collection functions (merge, 
> select-keys, dissoc, etc) is that you can construct the map from many 
> different sources.  I.e. you can merge maps which are constructed 
> dynamically at different points in your flow.  This was important for my 
> use-case, since DSL users are writing code that my core code knows nothing 
> about.  Using the example above, a subsequent user could replace the :uri 
> fn:
>
> (merge m {:uri (lfn [request] (some-other-build-fn request))}) 
>
> This new function would then be the input for the :path function.
>
> My code for this abstraction isn't isolated, but you can see it in context 
> of another project 
> here
> .
>
> Anyway, I like the project and thanks for sharing it.
>
> Marc 
>
>
>

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

Re: how to get good at clojure?

2012-05-11 Thread Daniel Gagnon
On Mon, May 7, 2012 at 8:48 PM, toan  wrote:

> Hi folks,
>
> I've been trying to learn clojure for a while. I've read the clojure
> section of "seven languages..." and currently trying to get through
> "joy of clojure." I've been practicing with the prompt a bit and
> trying to learn emacs that came with "clojurebox."
>
>
The clojure part of "seven languages" isn't very idiomatic.

Try Programming Clojure 2n Edition by Stuart Halloway, I think it's the
best learning book.

And clojurebox is quite outdated give a try to lein and the clooj editor.

I have 2 questions, 1. does anyone have advice on getting somewhat
> competent for a newb? (alternatively, how did you get good?)


Code until it "clicks", then progress gets much faster.


> 2. if i
> have no interest in java, should a learn at least some fundamentals?
> would that be helpful?
>
>
Try reading some javadoc and see if it makes sense to you. Learning Java
isn't critical to start but eventually, you'll want to use Java libraries
and then it's best to have some basics.


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

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

[ANN] C2: Clojure/ClojureScript data visualization

2012-05-11 Thread Kevin Lynagh
Announcing C2, a data visualization library inspired by D3.js
C2 is not a charting library; there are no plotting functions like
"scatterplot" or "piechart" .
Instead, C2 is a collection of scales, map projections, and component
templates (e.g., axes) that you can compose to build custom data
graphics on a DOM (e.g., HTML or SVG).

C2 is written in Clojure and can be used on the JVM in conjunction
with the Hiccup HTML rendering library to generate markup.
C2 can also be used within ClojureScript, where it includes

+ its own Hiccup compiler that acts directly on live DOM nodes
+ event wrappers for use with large datasets (via delegation)
+ DOM manipulation helpers (the usual suspects for manipulating
styles/attributes, selecting, appending, and removing DOM nodes)

To get started, just add it to your project.clj:

[com.keminglabs/c2 "0.1.0"]

There is also a standalone uberjar with built-in web server if you
don't have Leiningen around; see this 2-minute screencast:

http://www.youtube.com/watch?v=Urg79FmQnYs

For more information, see

Homepage: http://keminglabs.com/c2/
Marginalia docs: http://keminglabs.com/c2/docs/
Github: https://github.com/lynaghk/c2/

Some projects that pair well with C2:

cljx, a Leiningen plugin that statically rewrites metadata-annotated
Clojure code into platform specific code:

https://github.com/lynaghk/cljx

Cassowary, a linear constraint solver accessible from ClojureScript:

https://github.com/lynaghk/cassowary-coffee

Vomnibus, a collection of geographic data and color schemes:

https://github.com/lynaghk/vomnibus

Further reading:

D3 paper: http://vis.stanford.edu/files/2011-D3-InfoVis.pdf
D3 examples: https://github.com/mbostock/d3/wiki/Gallery
Tick selection algorithm: 
http://graphics.stanford.edu/vis/publications/2010/labeling-preprint.pdf
Stephen Few: http://www.perceptualedge.com/library.php
Bret Victor on information software: http://worrydream.com/MagicInk/

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


Re: How to configure a Clojure library at runtime?

2012-05-11 Thread Stuart Sierra
 
>
> Is setting a dynamic binding at runtime the recommended way of storing the 
>  config map?
>

I prefer passing it in explicitly. Slightly more verbose, but easier to 
understand.

-S

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

Re: require without :as in clojurescript?

2012-05-11 Thread Stuart Sierra
Just hasn't been implemented yet, I think.
-S

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

Re: how to get good at clojure?

2012-05-11 Thread Sam Aaron
In addition to following up on all the great suggestions above, I'd hack about 
with Quil; it's a lot of fun and you'll get instant feedback. You'll also very 
quickly run into the fun that is juggling pure fns, lazy sequences and 
orchestrating side effects (to sketch stuff). 

http://github.com/quil/quil 

-- 
http://sam.aaron.name


On Friday, 11 May 2012 at 18:26, Daniel Gagnon wrote:

> 
> 
> On Mon, May 7, 2012 at 8:48 PM, toan  (mailto:kidn...@gmail.com)> wrote:
> > Hi folks,
> > 
> > I've been trying to learn clojure for a while. I've read the clojure
> > section of "seven languages..." and currently trying to get through
> > "joy of clojure." I've been practicing with the prompt a bit and
> > trying to learn emacs that came with "clojurebox."
> 
> 
> The clojure part of "seven languages" isn't very idiomatic.
> 
> Try Programming Clojure 2n Edition by Stuart Halloway, I think it's the best 
> learning book. 
> 
> And clojurebox is quite outdated give a try to lein and the clooj editor.
> 
> > I have 2 questions, 1. does anyone have advice on getting somewhat
> > competent for a newb? (alternatively, how did you get good?)
> 
> 
> Code until it "clicks", then progress gets much faster.
> 
> > 2. if i
> > have no interest in java, should a learn at least some fundamentals?
> > would that be helpful?
> 
> 
> Try reading some javadoc and see if it makes sense to you. Learning Java 
> isn't critical to start but eventually, you'll want to use Java libraries and 
> then it's best to have some basics. 
> 
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com 
> > (mailto:clojure@googlegroups.com)
> > Note that posts from new members are moderated - please be patient with 
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com 
> > (mailto:clojure%2bunsubscr...@googlegroups.com)
> > For more options, visit this group at
> > http://groups.google.com/group/clojure?hl=en
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com 
> (mailto:clojure@googlegroups.com)
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com 
> (mailto:clojure+unsubscr...@googlegroups.com)
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en



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


Faster application startup for rapid development

2012-05-11 Thread Stuart Sierra
I have a large-ish Clojure project that involves a lot of network servers 
and background threads. It's difficult to work on a program like this by 
reloading code at the REPL, because old background threads may still be 
running with old code. So I end up restarting the process many times per 
day.

I'm using Leiningen 2.0.0-preview3 and Apple's JDK 1.6.0_29 on Mac OS X 
10.6.8.

My Leiningen project is configured to load my app in the REPL:

:repl-options {:init-ns my-project.main}

>From a clean start, `lein repl` takes 25 seconds to get to the first 
prompt. That's a long time during development.

I tried pre-compiling everything by adding AOT-compilation:

:aot [my-project.main]

This is reasonable, because I'm usually only working on one source file, 
trying to fix a bug, and the Clojure loader will prefer .clj files that are 
more recent than their corresponding .class files.

After `lein compile`, I'm down to 14 seconds to start a REPL. Better, but 
still not fast enough.

What if I omit Leiningen altogether? First, generate the classpath:

lein classpath > target/classpath

Then call Java directly:

java -cp `cat target/classpath` clojure.main -i src/my_project/main.clj 
-r

This cuts startup time down to 6 seconds, but I lose all the niceties of 
the Leiningen REPL.

Running Java with '-XX:+TieredCompilation' took off another half second. 
Adding '-client' had no visible effect. 

What other tricks do you have for speeding up your development cycle with 
Clojure?

-S

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

Re: Faster application startup for rapid development

2012-05-11 Thread Phil Hagelberg
On Fri, May 11, 2012 at 2:33 PM, Stuart Sierra
 wrote:
> I have a large-ish Clojure project that involves a lot of network servers
> and background threads. It's difficult to work on a program like this by
> reloading code at the REPL, because old background threads may still be
> running with old code.

Don't the ^:dynamic changes in 1.3 also include code to
forward-propagate recompiled defns to call sites that use them? So I
think restarting should only be necessary if AOT'd code has changed or
if you want to ensure you don't have any stray defns that don't exist
on disk any more. Though I suppose this is not true of HOFs. I wonder
if a macro would be helpful here to check the value of a system
property like "clojure.interactive" and go through a var if it's true
but use a direct function reference if not. (Dynamicity knobs in
action again?)

> From a clean start, `lein repl` takes 25 seconds to get to the first prompt.
> That's a long time during development.

Do you know if it takes about the same amount of time on Linux? I've
heard Mac users complain about slowdowns that I have been unable to
reproduce myself before, though that was a long time ago.

> What if I omit Leiningen altogether? First, generate the classpath:
>
>     lein classpath > target/classpath
>
> Then call Java directly:
>
>     java -cp `cat target/classpath` clojure.main -i src/my_project/main.clj -r

Leiningen 2 is using nrepl, so some of the overhead could come from
there. How long does `lein trampoline run -m clojure.main/main` take?
Have you tried swank-clojure?

> Running Java with '-XX:+TieredCompilation' took off another half second.
> Adding '-client' had no visible effect.

For what it's worth, tiered compilation should have the same effect as
-client; the latter is still there only for JVMs that are too old to
support tiered compilation. I did just realize that we currently only
apply tiered compilation to Leiningen's own JVM and not the project's,
so thanks for bringing that up; this will be rectified in preview4.

Thinking this over, I had another idea for a way in which launch could
be sped up using the trampoline task. Not sure if it's feasible, but I
will investigate it for the preview5 release:
https://github.com/technomancy/leiningen/issues/573

-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


Re: Faster application startup for rapid development

2012-05-11 Thread Softaddicts
You are using an SSD drive I assume ? When you say large, how many
servers/threads ?

Luc


> I have a large-ish Clojure project that involves a lot of network servers 
> and background threads. It's difficult to work on a program like this by 
> reloading code at the REPL, because old background threads may still be 
> running with old code. So I end up restarting the process many times per 
> day.
> 
> I'm using Leiningen 2.0.0-preview3 and Apple's JDK 1.6.0_29 on Mac OS X 
> 10.6.8.
> 
> My Leiningen project is configured to load my app in the REPL:
> 
> :repl-options {:init-ns my-project.main}
> 
> From a clean start, `lein repl` takes 25 seconds to get to the first 
> prompt. That's a long time during development.
> 
> I tried pre-compiling everything by adding AOT-compilation:
> 
> :aot [my-project.main]
> 
> This is reasonable, because I'm usually only working on one source file, 
> trying to fix a bug, and the Clojure loader will prefer .clj files that are 
> more recent than their corresponding .class files.
> 
> After `lein compile`, I'm down to 14 seconds to start a REPL. Better, but 
> still not fast enough.
> 
> What if I omit Leiningen altogether? First, generate the classpath:
> 
> lein classpath > target/classpath
> 
> Then call Java directly:
> 
> java -cp `cat target/classpath` clojure.main -i src/my_project/main.clj 
> -r
> 
> This cuts startup time down to 6 seconds, but I lose all the niceties of 
> the Leiningen REPL.
> 
> Running Java with '-XX:+TieredCompilation' took off another half second. 
> Adding '-client' had no visible effect. 
> 
> What other tricks do you have for speeding up your development cycle with 
> Clojure?
> 
> -S
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
--
Softaddicts sent by ibisMail from my ipad!

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


Re: Faster application startup for rapid development

2012-05-11 Thread Moritz Ulrich
Are you on 32 or 64 bit Java? Startup is much faster on my machine
(2008 Macbook, Core2Duo) when I use a 32bit vm.

On Fri, May 11, 2012 at 11:33 PM, Stuart Sierra
 wrote:
> I have a large-ish Clojure project that involves a lot of network servers
> and background threads. It's difficult to work on a program like this by
> reloading code at the REPL, because old background threads may still be
> running with old code. So I end up restarting the process many times per
> day.
>
> I'm using Leiningen 2.0.0-preview3 and Apple's JDK 1.6.0_29 on Mac OS X
> 10.6.8.
>
> My Leiningen project is configured to load my app in the REPL:
>
>     :repl-options {:init-ns my-project.main}
>
> From a clean start, `lein repl` takes 25 seconds to get to the first prompt.
> That's a long time during development.
>
> I tried pre-compiling everything by adding AOT-compilation:
>
>     :aot [my-project.main]
>
> This is reasonable, because I'm usually only working on one source file,
> trying to fix a bug, and the Clojure loader will prefer .clj files that are
> more recent than their corresponding .class files.
>
> After `lein compile`, I'm down to 14 seconds to start a REPL. Better, but
> still not fast enough.
>
> What if I omit Leiningen altogether? First, generate the classpath:
>
>     lein classpath > target/classpath
>
> Then call Java directly:
>
>     java -cp `cat target/classpath` clojure.main -i src/my_project/main.clj
> -r
>
> This cuts startup time down to 6 seconds, but I lose all the niceties of the
> Leiningen REPL.
>
> Running Java with '-XX:+TieredCompilation' took off another half second.
> Adding '-client' had no visible effect.
>
> What other tricks do you have for speeding up your development cycle with
> Clojure?
>
> -S
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en



-- 
Moritz Ulrich

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


Re: Faster application startup for rapid development

2012-05-11 Thread Softaddicts
I use ubuntu with an SSD and I hardly notice the lein repl  startup time.
Even in Eclipse the repl starts within a couple of seconds.

I am in the same situation, multiple processes, oracle,  About 80 
dependencies total.
I7 HT, 8 gig of ram

Before using an SSD, I used to copy the most used tools (jdk, tomcat, ...) to a
Ram drive at boot time (asynchronously obviously) and this cut the
start->crash->edit fix->restart by a significant factor.

Presently, I am on the verge of switching to ubuntu 64-bits. Just waiting for a
window to work on it.

Luc

> I have a large-ish Clojure project that involves a lot of network servers 
> and background threads. It's difficult to work on a program like this by 
> reloading code at the REPL, because old background threads may still be 
> running with old code. So I end up restarting the process many times per 
> day.
> 
> I'm using Leiningen 2.0.0-preview3 and Apple's JDK 1.6.0_29 on Mac OS X 
> 10.6.8.
> 
> My Leiningen project is configured to load my app in the REPL:
> 
> :repl-options {:init-ns my-project.main}
> 
> From a clean start, `lein repl` takes 25 seconds to get to the first 
> prompt. That's a long time during development.
> 
> I tried pre-compiling everything by adding AOT-compilation:
> 
> :aot [my-project.main]
> 
> This is reasonable, because I'm usually only working on one source file, 
> trying to fix a bug, and the Clojure loader will prefer .clj files that are 
> more recent than their corresponding .class files.
> 
> After `lein compile`, I'm down to 14 seconds to start a REPL. Better, but 
> still not fast enough.
> 
> What if I omit Leiningen altogether? First, generate the classpath:
> 
> lein classpath > target/classpath
> 
> Then call Java directly:
> 
> java -cp `cat target/classpath` clojure.main -i src/my_project/main.clj 
> -r
> 
> This cuts startup time down to 6 seconds, but I lose all the niceties of 
> the Leiningen REPL.
> 
> Running Java with '-XX:+TieredCompilation' took off another half second. 
> Adding '-client' had no visible effect. 
> 
> What other tricks do you have for speeding up your development cycle with 
> Clojure?
> 
> -S
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
--
Softaddicts sent by ibisMail from my ipad!

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


Re: Faster application startup for rapid development

2012-05-11 Thread Phil Hagelberg
On Fri, May 11, 2012 at 3:58 PM, Moritz Ulrich
 wrote:
> Are you on 32 or 64 bit Java? Startup is much faster on my machine
> (2008 Macbook, Core2Duo) when I use a 32bit vm.

If you have a newish JVM (hotspot 20+ IIRC) then TieredCompilation
will allow the 64-bit JVM to boot as fast as the 32-bit one.

-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


[ANN] Leiningen 2.0.0-preview4

2012-05-11 Thread Phil Hagelberg
Hello folks.

I'm happy to announce the release of the fourth preview of Leiningen 2.0.0.

The most important thing in this release is that it fixes a bug where
the dev profile would be applied when generating a pom to push to
clojars. So if you are developing libraries with preview3, it's
important to get this update. Other highlights include dynamic jar
manifests, repl bugfixes, and the ability to force offline or
update-snapshots mode with the -o and -U commands.

## 2.0.0-preview4 / 2012-05-11

* Checkout dependencies are not applied with production profile.
* Move pom.xml back to the project root.
* Add -U alias for forcing updates of snapshots.
* Support setting :update and :checksum profiles at top level of project.
* Blink matching parens in repl. (Colin Jones)
* Fix a bug where repl would interfere with project agents. (Chas Emerick)
* Show repl output that is emitted after return value. (Colin Jones)
* Make it easier for plugins to undo profile merging. (David Santiago)
* Add -o alias for activating offline profile.
* Ignore $CLASSPATH environment variable.
* Fix bug where repl task couldn't be trampolined. (Colin Jones)
* Allow jar manifest entries to be dynamically calculated.
* Support map-style :javac-opts like Leiningen 1.x used. (Michael Klishin)
* Allow group-id to be specified when creating new projects. (Michael Klishin)
* Fix a bug where :dev dependencies would be exposed in pom.
* Use Clojure 1.4.0 internally; plugins have access to new Clojure features.

If you have an earlier preview version, you can pull this in via "lein
upgrade". If you only have Leiningen 1.x installed, you will have to
download preview4 by hand:

https://raw.github.com/technomancy/leiningen/preview/bin/lein

Note that this does not conflict in any way with Leiningen 1.x; you can
keep the two of them installed side-by-side. It's common to save the
above script as "lein2" to differentiate between the two of them if you
have projects that don't yet work with Leiningen 2.

So far we've found the preview releases to be quite stable, so now would
be a great time to try upgrading if you've been holding off:

https://github.com/technomancy/leiningen/wiki/Upgrading

As always, please let us know if you run into any issues.

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


Re: [ANN] Exploding Fish: A URI Library for Clojure

2012-05-11 Thread Anthony Grimes
Hey there! I was taking a look at the libraries implementation and have a 
few suggestions/questions.

Most importantly, what is going on 
here: 
https://github.com/wtetzner/exploding-fish/blob/master/src/org/bovinegenius/exploding_fish/query_string.clj

It looks like you have written a little mini-library for creating and 
working with association lists. Why on earth would you use association 
lists instead of mas? The seq representation of a map is basically the same.

user=> (seq {"foo" "bar"})
(["foo" "bar"])
user=> (into {} (seq {"foo" "bar"}))
{"foo" "bar"}

As you can see, you can go to and from easily. I bet that entire file could 
be written in a few lines if you just used maps.

Second thing is your (ns ..) declarations.

(ns org.bovinegenius.exploding-fish
  (:use (org.bovinegenius.exploding-fish query-string parser constructor))
  (:require (org.bovinegenius.exploding-fish [path :as path]))
  (:import (java.net URI URL URLDecoder URLEncoder)))

A couple of things here:

- People usually use vectors instead of prefix lists: (:use 
[org.bovinegenius...]

- Don't import a bunch of things on the same line. Instead of (:use 
[org.bovinegenius.exploding-fish query-string parser]), do
  (:use [org.bovinegenius.exploding-fish.query-string :only [..]]
  [org.bovinegenius.exploding-fish.parser :only [..]])

- Based off of the last suggestion, never use :use without using :only. 
Only pull in the vars you need. Pulling in everything makes it 
  impossible to easily track where things come from and impossible to read 
your code. Use either :require or :use with :only.

- This one is entirely personal and totally subjective, but man, I hate 
copyright headers in files. Putting it in the README should
   suffice, right? I don't like having to scroll down to get to code. I 
imagine this entirely personal opinion, but I wanted to complain
   about it regardless. :)

-Anthony

On Sunday, May 6, 2012 3:10:52 PM UTC-5, Walter Tetzner wrote:
>
> I've written a URI library for Clojure, whose functions work on a 
> custom Uri type, java.net.URI, java.net.URL, and java.lang.String. 
> It's intended to make working with URIs less painful. It makes it easy 
> to get at the pieces of a URI, as well as doing functional updates. In 
> particular, it makes it easy to deal with query string parameters. 
>
> The source and some documentation (in the README) can be found at 
> https://github.com/wtetzner/exploding-fish. 
>
> Example usage: 
>
> Access URI pieces: 
> user> (scheme "http://www.example.com/";) 
> "http" 
> user> (scheme (URI. "http://www.example.com/";)) 
> "http" 
> user> (fragment (URL. "http://www.example.com/#fragment";)) 
> "fragment" 
> user> (fragment (uri "http://www.example.com/#fragment";)) 
> "fragment" 
>
> Uri objects behave like maps, but ensure that the values remain 
> consistent: 
> user> (:host (uri "http://www.example.com/";)) 
> "www.example.com" 
> user> (assoc (uri "http://www.example.com/";) :port 8080) 
> #http://www.example.com:8080/> 
>
> Make functional updates: 
> user> (fragment (uri "http://www.example.com/#fragment";) nil) 
> #http://www.example.com/> 
> user> (host "http://www.example.com/#fragment"; "www.bovinegenius.org") 
> "http://www.bovinegenius.org/#fragment"; 
> user> (fragment (URI. "http://www.example.com/#fragment";) "it-works- 
> on- 
> java-uris") 
> #http://www.example.com/#it-works-on-java-uris> 
>
> Working with query string parameters: 
> user> (params "http://www.test.net/some/path?x=y&a=w&d%20x=m 
> %3df&a=x&m=2 " 
> "a") 
> ["w" "x"] 
> user> (param "http://www.test.net/some/path?x=y&a=w&d%20x=m 
> %3df&a=x&m=2 " 
> "d x") 
> "m=f" 
> user> (param "http://www.test.net/some/path?x=y&a=w&d%20x=m 
> %3df&a=x&m=2 " 
> "d x" "new-value") 
> "http://www.test.net/some/path?x=y&a=w&d+x=new-value&a=x&m=2"; 
> user> (query-map "http://www.test.net/some/path?x=y&a=w&d%20x=m 
> %3df&a=x&m=2 ") 
>
> {"x" "y", "a" "x", "d x" "m=f", "m" "2"}

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

Re: [ANN] Leiningen 2.0.0-preview4

2012-05-11 Thread Michael Klishin
Phil Hagelberg:

> I'm happy to announce the release of the fourth preview of Leiningen 2.0.0.
> 
> The most important thing in this release is that it fixes a bug where
> the dev profile would be applied when generating a pom to push to
> clojars. So if you are developing libraries with preview3, it's
> important to get this update. Other highlights include dynamic jar
> manifests, repl bugfixes, and the ability to force offline or
> update-snapshots mode with the -o and -U commands.

I am happy to report that travis-ci.org has been upgraded to lein2-preview4. If 
you are just migrating to Lein 2,
this guide explains how to instruct Travis CI to use it:

http://about.travis-ci.org/docs/user/languages/clojure/

MK

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

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


Re: [ANN] Exploding Fish: A URI Library for Clojure

2012-05-11 Thread Walter Tetzner


> It looks like you have written a little mini-library for creating and
> working with association lists. Why on earth would you use association
> lists instead of mas? The seq representation of a map is basically the
> same.
>
> user=> (seq {"foo" "bar"})
> (["foo" "bar"])
> user=> (into {} (seq {"foo" "bar"}))
> {"foo" "bar"}
>

The reason for using association lists is that query strings are not
maps. You can have duplicate keys, and order can matter.

Second thing is your (ns ..) declarations.
>

I'll take these suggestions into consideration.

- This one is entirely personal and totally subjective, but man, I
>   hate copyright headers in files. Putting it in the README should
>   suffice, right? I don't like having to scroll down to get to
>   code. I imagine this entirely personal opinion, but I wanted to
>   complain about it regardless. :)
>

I'm not entirely sure how I feel about this yet. I probably won't
change it any time soon.

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

Re: How to configure a Clojure library at runtime?

2012-05-11 Thread Baishampayan Ghose
On Fri, May 11, 2012 at 8:53 PM, James Thornton
 wrote:
> Is setting a dynamic binding at runtime the recommended way of storing the
>  config map?

There are many ways of doing this. One approach that I have seen a lot
is something like this -

;; core.clj

(def ^:dynamic *settings* {:default :stuff}) ;; the default settings can be nil

(defmacro with-settings [settings & body]
  `(binding [*settings* ~settings]
~@body)) ;; or something similar

;; so that the default can be set once and for all
(defn init! [settings]
  (alter-var-root #'*settings* settings))

;; just use *settings*
(defn foo [x]
  ...)

(defn bar [x]
  ...)

;; user.clj

(foo 42) ;; will use the library provided defaults

(core/init! {:custom :settings})

(foo 42) ;; uses the custom settings
(bar "Sophie") ;; uses the custom settings

(with-settings {:my :settings}
  (foo 42)
  (bar "Sophie")) ;; will use the temporary settings

The code above is obviously for explanation only.

I hope that helps.

Regards,
BG

-- 
Baishampayan Ghose
b.ghose at gmail.com

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