The magic of Functional Programming is that you can write the verbs before the nouns.

You have so little commitment to what the data structures are, that it doesn’t get in the way.

Today I find myself mapping across and diff-ing lists of arbitrary ad-hoc dictionaries and tuples.

Had I sat down and had to invent / write methods in terms of classes or Haskell’s parameterized types I’d never have thought of these ad-hoc collections as types to define methods on or even to define functions in terms of.

But as it is, mid-function, I can just decide that what I need is to put them into a collection and process this collection in some way.

Well that was surprisingly painless.

I’m in the process of reorganizing the code for Patterning, my Clojure library that produces (visual) patterns.

Patterning was built using Quil, which is a Clojure wrapper around Processing. But I wanted to be able to call the library directly from Processing itself (Java version).

It seemed silly to create an uberjar file containing the whole of Quil and Processing, to be called from … er … Processing, so I decided to split the project into the core (pure Clojure, no Quil or Processing dependencies) and a Quil based wrapper.

I’m also, compiling the library using ClojureScript to run in the browser. (Called from Javascript). Once again this part doesn’t want any Quil / Processing dependencies.

But I was a bit stumped with how to manage some of this. My previous experience of projects that rely on other projects (git submodules) has been somewhat painful.

But it seems the Clojure (via Java) world has actually sorted this. All I needed to do was create an account over on Clojars and type :

lein deploy clojars

to put the JAR for my Patterning library there.

And so here it is.

Including it in a new project is as simple as referencing it in the project.clj file. There’s a simple test project which combines both Patterning and Quil. And here’s the very simple project.clj file. Note the patterning dependency.


(defproject com.alchemyislands/patterning_quil "0.1.0-SNAPSHOT"
:description "Quil Wrapper for Patterning library"
:url "http://alchemyislands.com"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.5.1"]
[org.clojure/math.numeric-tower "0.0.4"]
[quil "1.7.0"]
[com.alchemyislands/patterning "0.3.0-SNAPSHOT"]]
:aot [patterning_quil.core]
:main patterning_quil.core
)

And that’s more or less it.

If you want to use Patterning in your own projects, just include it like that. If you still want to be using Quil, then use this as your example.

BTW: the new development for the core Patterning library is now at https://github.com/interstar/Patterning-Core