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
trait Writes[T] { | |
def writes(o: T): JsValue | |
} | |
trait Reads[T] { | |
def reads(json: JsValue): T | |
} | |
trait Format[T] extends Writes[T] with Reads[T] |
import com.nicta.rng.Rng | |
import org.joda.time.DateTime | |
import scalaz._ | |
import Scalaz._ | |
object Foo extends App { | |
def time[A](f: => A): (Long, Long, Long) = { | |
val t0 = System.currentTimeMillis | |
val a = f |
import scalaz.Id.Id | |
import scalaz.BijectionT._ | |
import scalaz.Lens | |
trait Bijectionz[A, C] { | |
def apply(str: C): A | |
def unapply(a: A): Option[C] |
import scalaz._, Scalaz._ | |
def setS(i: Int): State[List[Int], Unit] = modify(i :: _) | |
val s = (1 to 10000).foldLeft(state[List[Int], Unit](()).lift[Free.Trampoline]) { | |
case (st, i) => st *> setS(i).lift[Free.Trampoline] | |
} | |
s(Nil).run |
Welcome to Scala version 2.10.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_25). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> import play.api.libs.json._; import play.api.libs.functional.Applicative; | |
import play.api.libs.json._ | |
import play.api.libs.functional.Applicative | |
scala> val expected = JsSuccess(10, JsPath(List(KeyPathNode("somekey")))) | |
expected: play.api.libs.json.JsSuccess[Int] = JsSuccess(10,/somekey) |
Welcome to Scala version 2.10.3 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_25). | |
Type in expressions to have them evaluated. | |
Type :help for more information. | |
scala> val map0 = Map.empty[Int, Int] withDefaultValue 0 | |
map0: scala.collection.immutable.Map[Int,Int] = Map() | |
scala> val map1 = map0 mapValues(identity) | |
map1: scala.collection.immutable.Map[Int,Int] = Map() |
//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 { |