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
// Doesn't compile. Good. | |
def futureInt(): Future[Int] = Future.value(Future.value(1)) | |
// Compiles. Not good. Caller cannot wait on completion of nested future. | |
def futureUnit(): Future[Unit] = Future.value(Future.value(())) | |
// Also compiles. Nice convenience, but not worth the cost of the issues | |
// it might cause (as above), right? | |
def futureUnit(): Future[Unit] = Future.value(1) |
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
-Dconfig.resource=test.conf -Dlogger.file=test/resources/logback-test.xml |
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 scala.collection.immutable | |
import scalaz.std.string._ | |
import scalaz.std.list._ | |
import scalaz.std.anyVal._ | |
import scalaz.std.option._ | |
import scalaz.syntax.show._ | |
import scalaz.concurrent.Task | |
import scalaz.stream.{process1, io, Process} | |
import scalaz.stream.Process._ |
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 scalaz.std.anyVal._ | |
import scalaz.std.tuple._ | |
import scalaz.std.option._ | |
import scalaz.StateT | |
import scalaz.State | |
import scalaz.Free | |
import scalaz.Free._ | |
import scalaz.State._ | |
import scalaz.Trampoline._ | |
import scalaz.syntax.traverse._ |
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.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_15). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> val opt: Option[Int] = Some(10) | |
opt: Option[Int] = Some(10) | |
scala> val typeCheckFail = opt map (_ + "2") getOrElse (3) | |
typeCheckFail: Any = 102 |
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 FuturePimps { | |
/** | |
* Use this instead of new AlreadyCompletedFuture[T] to prevent accidental use of default Akka timeout | |
**/ | |
def alreadyCompletedFuture[T](v: T)(implicit timeout: Timeout): AlreadyCompletedFuture[T] = | |
new AlreadyCompletedFuture[T](Right(v), timeout.duration.toMillis) | |
class FutureFuture[T](f: () => Future[Future[T]]) { | |
def flatten: Future[T] = f().flatMap(identity) |
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
def allDigits: (String) => ValidationNEL[String, String] | |
def maxSizeOfTen: (String) => ValidationNEL[String, String] | |
def toInt: (String) => ValidationNEL[String, Int] | |
val validInt: String => ValidationNEL[String, Int] = s => | |
for { | |
validStr <- (allDigits(s) |@| maxSizeOfTen(s))((_,x) => x) | |
i <- toInt(validStr) |
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
package com.bifflabs | |
import org.scalatest.FunSuite | |
import scalaz._ | |
import scalaz.Scalaz._ | |
class TestHelpersSuiteWithScalazSupport extends FunSuite with IgnoringDefaultEqualizer { | |
import AssertionsWithScalazSupport._ | |
test("1 should equal 1") { |
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
Show hidden characters
/* | |
On OS X, basic text manipulations (left, right, command+left, etc) make use of the system key bindings, | |
and don't need to be repeated here. Anything listed here will take precedence, however. | |
*/ | |
[ | |
{ "keys": ["home"], "command": "move_to", "args": {"to": "bol"} }, | |
{ "keys": ["end"], "command": "move_to", "args": {"to": "eol"} }, | |
{ "keys": ["shift+end"], "command": "move_to", "args": {"to": "eol", "extend": true} }, | |
{ "keys": ["shift+home"], "command": "move_to", "args": {"to": "bol", "extend": true } }, | |
... |
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
package com.mypackage | |
import org.specs.SpecificationWithJUnit | |
import scalaz._ | |
import Scalaz._ | |
class ValidationTests extends SpecificationWithJUnit { | |
"I should be able to convert List[Validation[A, B]] to Validation[List[A], List[B]]" >> { |