Skip to content

Instantly share code, notes, and snippets.

// it's good style to mark such objects/classes with sealed to guide complier
// so it will check if match is exhaustive (all possible cases covered)
sealed abstract class Response
sealed abstract class Reason
abstract class TokenType
case class Token(t: TokenType) extends Response
case class Problem(reason: Reason) extends Response
case object InvalidResponse extends Reason
@lazyval
lazyval / gist:4082827
Created November 16, 2012 00:40 — forked from saetia/gist:1623487
Clean Install – Mountain Lion OS X 10.8
implicit val bdStringView = StringView.of[BigDecimal] as { _.toString }
def makeStringValue[T](implicit sv: StringView[T]) = new StringValue {
def getString(value: AnyRef) = sv(value.asInstanceOf[T])
}
bdStringValue = makeStringValue[BigDecimal]
strStringValue = makeStringValue[String]
qtyStringValue = makeStringValue[Long](StringView.of[Long] as { _.toString }
@lazyval
lazyval / dirwatcher.scala
Created August 15, 2012 16:16 — forked from eberle1080/dirwatcher.scala
Recursive directory watcher in Scala
/**
* dirwatcher.scala
*
* Uses the Java 7 WatchEvent filesystem API from within Scala.
* Adapted from:
* http://download.oracle.com/javase/tutorial/essential/io/examples/WatchDir.java
*
* @author Chris Eberle <[email protected]>
* @version 0.1
*/