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
object Algebra { | |
// Build up increasingly complex algebras | |
trait Magma[T] { | |
def add(x : T, y : T) : T | |
} | |
trait Monoid[T] extends Magma[T] { | |
def zero : T | |
} |
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
import rapture.orm._ | |
object TestDb extends App { | |
// Create a database pool | |
val DbPool = new PostgresDbPool("localhost", "conferencedb", "operator", "letmein") | |
// Define the database schema | |
implicit object Conference extends Table(new Conference) { | |
def allActive()(implicit db : Db) = selectFrom("WHERE active").all() |
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
import rapture.io._ | |
// Let's parse some JSON | |
val src: Json = Json.parse(""" | |
{ | |
"foo": "Hello world", | |
"bar": { | |
"baz": 42 | |
} | |
} |
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
import rapture.io._ | |
import scala.async._ | |
import Async._ | |
import scala.concurrent._ | |
import ExecutionContext.Implicits.global | |
import strategy.returnFutures | |
implicit val encoding = Encodings.`UTF-8` | |
val forStyle = for { | |
src <- (Http / "rapture.io" / "example.json").slurp[Char] |
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.10.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_24). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> import rapture.core._ | |
import rapture.core._ | |
scala> import rapture.json._ | |
import rapture.json._ |
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.10.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_51). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> System.getProperty("user.timezone") | |
res0: String = "" | |
scala> new java.util.Date() | |
res1: java.util.Date = Mon May 12 12:49:35 CEST 2014 |
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.10.4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_51). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> import rapture.core._; import rapture.data._; import rapture.json._ | |
import rapture.core._ | |
import rapture.data._ | |
import rapture.json._ | |
scala> import jsonBackends.scalaJson._ |
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> import formatters.humanReadable | |
import formatters.humanReadable | |
scala> Json.format(json"""{ "foo": ["bar", "baz", 42] }""") | |
res0: String = | |
{ | |
"foo": [ | |
"bar", | |
"baz", | |
42 |
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.10.4 (OpenJDK 64-Bit Server VM, Java 1.6.0_27). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> import rapture.json._ | |
import rapture.json._ | |
scala> import jsonBackends.scalaJson._ | |
import jsonBackends.scalaJson._ |
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> case class Bar(file: java.io.File) // We can't extract a File | |
defined class Bar | |
scala> case class Foo(bar: Bar) // therefore we can't extract a Bar | |
defined class Foo | |
scala> json""{ "bar": { "file": "..." } }""".as[Foo] | |
Could not generate a Json extractor for case class Bar because a Json extractor for parameter `file' of type java.io.File could not be found | |
Could not generate a Json extractor for case class Foo because a Json extractor for parameter `bar' of type Bar could not be found | |
<console>:21: error: cannot extract type Foo from rapture.json.Json. |
OlderNewer