I modestly suggest - as the Runnable is very close to the first IO implementation -


you than can observe a stack trace

at scala.Function1$$anonfun$andThen$1.apply(Function1.scala:55)
at scala.Function1$$anonfun$andThen$1.apply(Function1.scala:55)
at scala.Function1$$anonfun$andThen$1.apply(Function1.scala:55)
at scala.Function1$$anonfun$andThen$1.apply(Function1.scala:55)
at scala.Function1$$anonfun$andThen$1.apply(Function1.scala:55)
Hi, and thanks for writing such a book.
As an IntelliJ/Maven advocate I found useful to create these dependencies for the purpose of chapter 3:


You may find it useful as the unzip and classpath setting is not always easy starting a small project.

Regards, thanks again
Section 3.3.3

public class AgentFinderProvider extends Provider<AgentFinder>

it seems to me that it is

public class AgentFinderProvider implements Provider<AgentFinder>

But maybe I missed something


Message was edited by:

I am preparing a little blog entry about Method handle and I came naturally to read chapter 5. Fabulous, a lot of answers to my questions =D
I found in section 5.2:

MethodHandle mh = manager.makeMh();
try {
System.out.println("With Method Handle");
mh.invokeExact(hndl); #B
} catch (Throwable e) { #C

In b142 of JDK7 I have to specify as first argument the receiver with invokeExact using my sample.
It seems to be

mh.invokeExact(manager, hndl)

1. web.xml

Just at the end of 5.4.2 I suggest that the location of the web.xml file may not be src/webapp/WEB-INF but src/main/webapp/WEB-INF

2.Code compile

With Scalaz-http 6.0.1 you have a code compile error if you do not put

HttpServlet.resource(found, NotFound.xhtml)

There is a conflict on the resource name importing Scalaz._ and HttpServlet._

3. sbt I finally succeeded in setting something with sb 0.10.x:

If it can help:

import sbt._
import Keys._
import com.github.siasia.WebPlugin._

object BuildSettings {
val buildSettings = Defaults.defaultSettings ++ Seq (
organization := "com.promindis",
version := "0.1-SNAPSHOT",
scalaVersion := "2.9.0-1",
scalacOptions := Seq("-unchecked", "-deprecation"),
crossScalaVersions := Seq("2.9.0-1", "2.9.1.RC4")

object Resolvers {
val scalaToolsReleases = "Scala-Tools Maven2 Releases Repository" at "http://scala-tools.org/repo-releases"
val scalaToolsSnapshots = "Scala-Tools Maven2 Snapshots Repository" at "http://scala-tools.org/repo-snapshots"


object ScalazDependencies {
lazy val scalazVersion = "6.0.1"
lazy val scalazCore = "org.scalaz" %% "scalaz-core" % scalazVersion
lazy val scalazHttp = "org.scalaz" %% "scalaz-http" % scalazVersion

object JettyDependencies {
lazy val jettyVersion = "7.3.0.v20110203"
lazy val jettyServlet = "org.eclipse.jetty" % "jetty-servlet" % jettyVersion
lazy val jetty7 = "org.eclipse.jetty" % "jetty-webapp" % jettyVersion % "test, jetty"
lazy val jettyServer = "org.eclipse.jetty" % "jetty-server" % jettyVersion

object Dependencies {
val testDependencies = Seq(libraryDependencies <<= (scalaVersion, libraryDependencies) { (version, dependencies) =>
val specs2Version = version match {
case "2.9.1.RC4" => "1.6-SNAPSHOT"
case _ => "1.5"
dependencies :+ ("org.specs2" %% "specs2" % specs2Version % "test")

object MainBuild extends Build {
import Resolvers._
import Dependencies._
import BuildSettings._
import JettyDependencies._
import ScalazDependencies._

lazy val wekanban = Project(
settings = buildSettings ++ testDependencies ++ webSettings ++ Seq (
libraryDependencies ++= Seq(jettyServlet, jetty7, jettyServer, scalazCore, scalazHttp)

You migh notice the import of siasia web plugin.

So to plug it I used the build.sbt file under the plugins directory:

resolvers ++= Seq(
"Web plugin repo" at "http://siasia.github.com/maven2",
Resolver.url("Typesafe repository", new java.net.URL("http://typesafe.artifactoryonline.com/typesafe/ivy-releases/"))(Resolver.defaultIvyPatterns)

//Following means libraryDependencies += "com.github.siasia" %% "xsbt-web-plugin" % "0.1.0-<sbt version>""
libraryDependencies <+= sbtVersion(v => "com.github.siasia" %% "xsbt-web-plugin" % ("0.1.0-"+v))
Thanks to some help of the guys on the SBT Google group I added the following to the previous settings in order to start/stop H2

object H2TaskManager {
var process: Option[Process] = None

val runH2 = TaskKey[Unit]("h2-run", "Runs h2")
val runH2Task = runH2 :={}

val stopH2 = TaskKey[Unit]("h2-stop", "Stops h2")
val stopH2Task = stopH2 :={
process match {
case None => println("Database already stopped"smilie
case Some(_) =>
println("Stopping database...")
process = None
println("Database stopped...")

def startDatabase(paths: Seq[String]) = {
process match {
case None =>
val cp = paths.mkString(System.getProperty("path.seperator"))
val command = "java -cp " + cp + " org.h2.tools.Server"
println("Starting Database with command: " + command)
process = Some(Process(command).run())
println("Database started ! ")
case Some(_) =>
println("H2 Database already started")

object MainBuild extends Build {
import Resolvers._
import Dependencies._
import BuildSettings._
import JettyDependencies._
import ScalazDependencies._
import DatabaseDependencies._
import H2TaskManager._

lazy val wekanban = Project(
settings = buildSettings ++ testDependencies ++ webSettings ++ Seq(stopH2Task) ++ Seq (
libraryDependencies ++= Seq(jettyServlet, jetty7, jettyServer, scalazCore, scalazHttp, h2, squeryl),
runH2 <<= (fullClasspath in Compile) map { cp =>


Seems to work fine smilie
Hello and thank you for this nice work .
The chapter fits nicely after my reading of learn you a Haskell. It allows to nicely transpose the concepts learnt from Haskell to Scala
The only impediment I see is that I will have to be a little imaginative in order to blog something smilie
This chapter is a jewel.
Could I modestly suggest adding the name of Carl Hewitt because of his historical work on actors which also influenced the work of Abelson and Sussman on Scheme ?

Thanks again for your job

I was learning from chapter 4 when I read the compiler generates static method for obtaining the default value.
I ran with a test:

final class WithDefaultArgument {

def doSomething(withObject: String= "default"): Unit = {

def run() {


and javap produced:

public final class WithDefaultArgument implements scala.ScalaObject {
public void doSomething(java.lang.String);
0: getstatic #11 // Field scala/Predef$.MODULE$:Lscala/Predef$;
3: aload_1
4: invokevirtual #16 // Method scala/Predef$.printlnsmilieLjava/lang/ObjectsmilieV
7: return

public java.lang.String doSomething$default$1();
0: ldc #25 // String default
2: areturn

public void run();
0: aload_0
1: aload_0
2: invokevirtual #31 // Method doSomething$default$1smilie)Ljava/lang/String;
5: invokevirtual #33 // Method doSomethingsmilieLjava/lang/StringsmilieV
8: return

public WithDefaultArgument();
0: aload_0
1: invokespecial #38 // Method java/lang/Object."<init>"smilie)V
4: return


public java.lang.String doSomething$default$1()

seems not to be static. Am I missing something ?
Hi made a fool of myself, you talk about that in the following, sorry for the inconvenience
Hello, progressing in the reading of this nice MEAP I found that Application trait was deprecated in favor of the App as of the 2.9.+ versions:

@deprecated("use App instead", "2.9.0")
trait Application {...}
Chapter 6 p 157 the definition of callbacks is missing in the IntStore class definition:

var callbacks = Map[(this.type => Unit), (this.type => Unit)]()
Chapter 6 (p155) the Observable trait template is missing a map definition:

trait Observable {
type Handle
var callbacks: Map[Handle, this.type => Unit]

def observe(callback: this.type => Unit): Handle ={
I think there may be a typo error p13: The compiler may attempt to apply..

Nice book by the way =D
In order to obtain a list of king moves defined as a list of vectors of vectors, I think the neighbors function body should use the lambda

(map #(vec (map + cell %)) deltas)

when mapping the delta to the cells. If not, we obtain:

[:K (1 2)] [:K (1 1)] [:K (2 2)] [:K (2 2)] [:K (1 0)]
Change your neighbors function (the provided one in listing 5.1) with

(defn neighbors
  ([within-limit at] (neighbors [[-1 0] [1 0] [0 -1] [0 1]] within-limit at))
  ([deltas within-limit at]
  (every? #(< -1 % within-limit) neighbour))
  (map #(vec (map + at %)) deltas))))

now your return neighbors for [0 0] will be ([1 0] [0 1]) and not ((1 0) (0 1))

I enjoy Chapter 8 as a TDD advocate but I came to an issue concerning the var dynamic binding with Clojure 1.3:

Referencing the article at https://groups.google.com/forum/#!topic/clojure/vOL8MSOhp1M

I came to the following:

(defn ^:dynamic calc-x [x1 x2] (+ x1 x2))
(defn ^:dynamic calc-y [y1 y2] (/ y1 y2))
(defn some-client [] (println (calc-x 2 3) (calc-y 3 4)))
(stubbing [calc-x 1 calc-y 2] (some-client))

which works perfectly.

I am just annoyed because the code is a little more cluttered and expresses that the function may be stubbed. Does someone have an advice on the question ?