半年ぐらい前ですが、Scalaz の解説のプレゼンテーションである、
Scalaz Presentationという プレゼン動画を見ました。
Nick Partridgeさんというオーストラリアの方が、約1年半前に Scalazの説明をされているプレゼンなのですが
半年前に見たときは 何をやっているのかさっぱり理解出来ませんでした。
今 もう一度みると Scalaz に限らず 型パラメータつかって関数を一般化するのに
段階をおって一般化されていくので すごくよくできたプレゼンの内容であるのがやっとわかるようになってきました。
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 CirceMain extends App { | |
import io.circe.Encoder | |
import io.circe.syntax._ | |
case class Person(firstName: String, lastName: String, age: Int) | |
val person = Person("Joe", "Black", 42) | |
{ | |
implicit val personEnc: Encoder[Person] = Encoder.forProduct3( | |
"firstName", "lastName", "age") { |
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 Mappable { | |
implicit class ToMapOps[A](val a: A) extends AnyVal { | |
import shapeless._ | |
import ops.record._ | |
def toMap[L <: HList](implicit | |
gen: LabelledGeneric.Aux[A, L], | |
tmr: ToMap[L] | |
): Map[String, Any] = { | |
val m: Map[tmr.Key, tmr.Value] = tmr(gen.to(a)) |
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
sealed trait Interact[A] | |
case class Ask(prompt: String) | |
extends Interact[String] | |
case class Tell(msg: String) | |
extends Interact[Unit] | |
trait Monad[M[_]] { | |
def pure[A](a: A): M[A] |