This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Welcome to Scala version 2.9.0.final (OpenJDK Server VM, Java 1.6.0_20). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> import tools.scalap.scalax.rules.scalasig._ | |
import tools.scalap.scalax.rules.scalasig._ | |
scala> import scala.runtime._ | |
import scala.runtime._ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe("decorators") { | |
trait Window { | |
var ds = Map.empty[String, Decorator] | |
def register(d: Decorator) = ds += ((d.id, d)) | |
def deregister(d: Decorator) = ds -= d.id | |
} | |
case class MWindow(x: Int, y: Int) extends Window { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
java.lang.IllegalStateException: Invalid use of SingleClientConnManager: connection still allocated. | |
Make sure to release the connection before allocating another one. | |
at org.apache.http.impl.conn.SingleClientConnManager.getConnection(SingleClientConnManager.java:218) | |
at org.apache.http.impl.conn.SingleClientConnManager$1.getConnection(SingleClientConnManager.java:192) | |
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:391) | |
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820) | |
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:776) | |
at dispatch.BlockingHttp$class.dispatch$BlockingHttp$$execute(Http.scala:45) | |
at dispatch.BlockingHttp$$anonfun$execute$1$$anonfun$apply$3.apply(Http.scala:58) | |
at dispatch.BlockingHttp$$anonfun$execute$1$$anonfun$apply$3.apply(Http.scala:58) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## couchdb.stdout | |
[error] [<0.1313.0>] OS Process Error <0.279.1> :: {os_process_error, {exit_status,1}} | |
[error] [<0.1313.0>] OS Process Error <0.282.1> :: {os_process_error, | |
{exit_status,1}} | |
<<lots of same message>> | |
## couchdb.stderr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Welcome to Scala version 2.9.0.final (Java HotSpot(TM) Server VM, Java 1.6.0_24). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> import scala.tools.nsc.interpreter.IMain | |
import scala.tools.nsc.interpreter.IMain | |
scala> val i = new IMain | |
i: scala.tools.nsc.interpreter.IMain = scala.tools.nsc.interpreter.IMain@d5b561 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait MyOption[+A] { | |
// single abstract method | |
def cata[X](some: A => X, none: => X): X | |
import MyOption._ | |
def map[B](f: A => B): MyOption[B] = cata(f andThen some, none) | |
// Also | |
// def map[B](f: A => B): MyOption[B] = flatMap(f andThen some) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Church-encoded cons list | |
trait MyList[A] { | |
def foldRight[B]: (A => B => B) => B => B | |
} | |
object MyList { | |
def nil[A]: MyList[A] = new MyList[A] { | |
def foldRight[B] = | |
_ => z => z | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> List(10, 12).transLift[OptionT].runT | |
res12: List[Option[Int]] = List(Some(10), Some(12)) | |
scala> optionT(List(some(12), some(50))).runT | |
res13: List[Option[Int]] = List(Some(12), Some(50)) | |
scala> List(some(12), some(50)) | |
res14: List[Option[Int]] = List(Some(12), Some(50)) | |
scala> optionT(List(some(12), some(50))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> val l = List(10, 100, 1000, 10000) | |
l: List[Int] = List(10, 100, 1000, 10000) | |
scala> l.orElse[Int, Int]{ case i: Int => 34 } | |
res14: PartialFunction[Int,Int] = <function1> | |
scala> res14(0) | |
res15: Int = 10 | |
scala> res14(10) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Foo.scala as .. | |
package net.debasishg.domain.trade.service | |
trait Foo { | |
final val foo: Int => Int = {i => i * 2} | |
} | |
object Foo extends Foo | |
and a test spec TSpec.scala as .. |