I hereby claim:
- I am drstevens on github.
- I am drstevens (https://keybase.io/drstevens) on keybase.
- I have a public key whose fingerprint is FC3A 884C F064 48BC 315E 205C B797 C6B5 C281 822B
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
import monocle.function.Each | |
import monocle.macros.GenLens | |
import monocle.{Lens, Optional} | |
sealed trait Foo | |
object Foo { | |
// This is similar to scalaz.PLens | |
val _foo1Opt: Optional[Foo, Foo1] = Optional[Foo, Foo1] { | |
case f1: Foo1 => Some(f1) |
Copyright © 2017 Fantasyland Institute of Learning. All rights reserved.
A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.
val square : Int => Int = x => x * x
//scala 2.10.2 | |
//"org.scalaz" %% "scalaz-core" % "7.0.3" | |
//"org.specs2" %% "specs2" % "2.1.1" % "test" | |
//"org.mockito" % "mockito-all" % "1.9.0" % "test" | |
import scalaz.State._ | |
import org.specs2.mutable.Specification | |
import org.specs2.mock._ | |
trait Builder { |
// 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) |
-Dconfig.resource=test.conf -Dlogger.file=test/resources/logback-test.xml |
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._ |
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._ |
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 |
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) |