I hereby claim:
- I am patrick-premont on github.
- I am ppremont (https://keybase.io/ppremont) on keybase.
- I have a public key whose fingerprint is 56CE CB40 3F90 A457 B270 F89C E79F 9E8E 931B D152
To claim this, I am signing this object:
def main() = { | |
val lv: Int = 0 | |
def ld : Int = 0 | |
trait A { | |
val v: Int | |
def d : Int | |
def d0() : Int | |
val vf : () => Int | |
def df : () => Int | |
} |
scala> import pprint.Config.Colors._ | |
import pprint.Config.Colors._ | |
scala> case class Test(name: String, value: Int) | |
defined class Test | |
scala> pprint.pprintln(Test("a" * 10, 1)) | |
Test("aaaaaaaaaa", 1) | |
scala> pprint.pprintln(Test("a" * 10, 1))(implicitly, PPrintConfig.copy(showFieldNames = true)) |
// This code attempts to show one way asynchronous requests can be batched in a type safe manner. | |
object BatchableRequests { | |
sealed trait Request[A] { | |
def serialize(): String | |
def deserialize(s: String): Option[(A, String)] | |
def pair[B](b: Request[B]): Request[(A, B)] = RequestPair(this, b) | |
} | |
case class RequestPair[A, B](a: Request[A], b: Request[B]) extends Request[(A, B)] { |
I hereby claim:
To claim this, I am signing this object:
Option
Either
Validated
Future
of Option
with OptionT
# Prerequisite: Install Ammonite-REPL (http://www.lihaoyi.com/Ammonite/#Ammonite-REPL) | |
$ amm | |
Loading... | |
Welcome to the Ammonite Repl 0.8.2 | |
(Scala 2.12.1 Java 1.8.0_66) | |
@ import $ivy.`org.typelevel::cats:0.9.0` | |
@ import scala.concurrent.Future | |
@ import scala.concurrent.ExecutionContext.Implicits.global | |
@ import cats.implicits._ | |
@ import cats.data.OptionT |
# Prerequisite: Install Ammonite-REPL (http://www.lihaoyi.com/Ammonite/#Ammonite-REPL) | |
$ amm | |
Loading... | |
Welcome to the Ammonite Repl 0.8.2 | |
(Scala 2.12.1 Java 1.8.0_66) | |
@ import $ivy.`org.typelevel::cats:0.9.0` | |
@ import cats.implicits._ | |
@ import cats.syntax.either._ | |
@ List(1.asRight, 2.asRight).sequenceU | |
res3: Either[Nothing, List[Int]] = Right(List(1, 2)) |
# Prerequisite: Install Ammonite-REPL (http://www.lihaoyi.com/Ammonite/#Ammonite-REPL) | |
$ amm | |
Loading... | |
Welcome to the Ammonite Repl 0.8.2 | |
(Scala 2.12.1 Java 1.8.0_66) | |
@ import $ivy.`org.typelevel::cats:0.9.0` | |
@ import cats.syntax.option._ | |
@ import cats.implicits._ | |
@ List(1.some, 2.some).sequenceU | |
res3: Option[List[Int]] = Some(List(1, 2)) |
# Prerequisite: Install Ammonite-REPL (http://www.lihaoyi.com/Ammonite/#Ammonite-REPL) | |
$ amm | |
Loading... | |
Welcome to the Ammonite Repl 0.8.2 | |
(Scala 2.12.1 Java 1.8.0_66) | |
@ import $ivy.`org.typelevel::cats:0.9.0` | |
@ import cats.implicits._ | |
@ import cats.data.Validated._ | |
@ List(2, 4).map(a => if (a % 2 == 0) valid(a) else invalidNel(a)).sequenceU | |
res5: cats.data.Validated[cats.data.NonEmptyList[Int], List[Int]] = Valid(List(2, 4)) |
# Illustrates the compile-time dispatch that has to occur with macro overrides. | |
# You can install Ammonite-REPL (http://www.lihaoyi.com/Ammonite/#Ammonite-REPL), or use scala instead of amm | |
$ amm | |
Loading... | |
Welcome to the Ammonite Repl 0.9.3 | |
(Scala 2.12.2 Java 1.8.0_121) | |
@ import scala.reflect.macros.blackbox | |
import scala.reflect.macros.blackbox | |
@ import scala.language.experimental.macros | |
import scala.language.experimental.macros |