This file contains hidden or 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 pair = for { | |
| _ <- token(char('{')) | |
| id <- token(ident) | |
| _ <- token(char(':')) | |
| v <- integer | |
| _ <- token(char('}')) | |
| } yield id -> v | |
obj: scalaz.parse.huttonmeijer.Parser[(List[Char], Int)] = scalaz.parse.huttonmeijer.Parser$$anon$2@234e7730 | |
scala> pair("{ foo : 17 }".toList) |
This file contains hidden or 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 sbt._ | |
import Keys._ | |
//import com.github.siasia.WebPlugin | |
object BuildSettings { | |
// generic filter settings, need to be applied for Compile and Test | |
def wicketResourceSettings(config: Configuration) = inConfig(config)(Seq[Setting[_]]( | |
excludeFilter in unmanagedResources := ("*.java"), | |
unmanagedResourceDirectories <++= (unmanagedSourceDirectories) apply (identity) |
This file contains hidden or 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
"FingerTree" should { | |
"apply effects in order" in { | |
import std.string._ | |
import Id._ | |
type StringWriter[A] = Writer[String, A] | |
val s: Writer[String, FingerTree[Int, Int]] = streamToTree(intStream.take(5)).traverseTree[StringWriter, Int, Int](x => Writer(x.toString, x)) | |
val (w, a) = s.runT | |
(w, a.toStream) must be_===("12345", streamToTree(intStream.take(5)).toStream) | |
} | |
} |
This file contains hidden or 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 akka.actor.Actor | |
import com.yammer.metrics.Instrumented | |
// Useful for monitoring the mailbox size of actors. | |
// Just fire up your favorite JMX client and watch the pretty graph (which hopefully is a flatline at 0). | |
trait ActorMetrics extends Instrumented { actor: Actor => | |
metrics.gauge("mailbox size", self.id){actor.self.dispatcher.mailboxSize(actor.self)} | |
} |
This file contains hidden or 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
➜ ~/.ivy2/cache/org.scalaz/scalaz-core_2.9.0-1/jars scala -cp scalaz-core_2.9.0-1-6.0.1.jar | |
Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> import scalaz._ | |
import scalaz._ | |
scala> |
This file contains hidden or 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
// see https://github.com/gseitz/Lensed | |
object Lensed { | |
import scalaz._ | |
import Scalaz._ | |
case class Address(street: String, number: Int) | |
case class Person(name: String, address: Address) |
This file contains hidden or 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 sbt._ | |
import Keys._ | |
import ProtobufPlugin._ | |
object build extends Build { | |
// ... the usual project setup stuff thingly | |
settings = Defaults.defaultSettings ++ protobufSettings ++ Seq( | |
scalaSource in protobufConfig <<= (sourceDirectory)(_ / "generated_scala") | |
) | |
} |
This file contains hidden or 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 java.awt.TrayIcon | |
import java.awt.SystemTray.{getSystemTray => tray} | |
import java.awt.Toolkit.{getDefaultToolkit => toolkit} | |
import java.net.URL | |
object Notification { | |
private lazy val scalaIcon = { | |
// of course we use the logo of our favorite language ;) | |
val img = toolkit.getImage(new URL("http://www.scala-lang.org/sites/default/files/favicon.gif")) | |
new TrayIcon(img) |
This file contains hidden or 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
package test2 | |
import test.MyTrait | |
class MyClass extends MyTrait |
This file contains hidden or 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
package example | |
import org.specs2.mutable.Specification | |
import org.specs2.matcher.MatchResult | |
class DummySpec extends Specification { | |
def intSpec: MatchResult[Int] = 1 must be equalTo 1 |