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
!SLIDE | |
sclaz7 の scalaz.Iteratee の紹介 | |
================================ | |
!SLIDE | |
発端 | |
---- | |
> @halcat0x15a: @lyrical_logical 7のiterateeが別物になってて読めないです・・・・ 11:38 PM - 14 Feb 12 |
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
parseOpt(request.body) map { json => | |
(json \\ "events" \\ "message").values | |
} collect { case msg : Map[String, String] => | |
hoge | |
} getOrElse { | |
huga | |
} |
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
Inductive even : nat -> Prop := | |
| even_O : even 0 | |
| even_S : forall n, odd n -> even (S n) | |
with odd : nat -> Prop := | |
| odd_S : forall n, even n -> odd (S n). | |
Scheme even_mut := Induction for even Sort Prop | |
with odd_mut := Induction for odd Sort Prop. | |
Theorem daigakuseinosuugakuryoku : forall n m, |
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
trait Abs { def f(): Int } | |
trait ConA extends Abs { def f() = 1 } | |
trait ConB extends Abs { abstract override def f() = super.f + 1 } | |
trait Delegate extends Abs { | |
val abs: Abs | |
def f() = abs.f | |
} | |
class A { this: Abs => |
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 withRight[A, B] = new { def apply[R](f: (Either[A, B] => Either.RightProjection[A, B]) => R) = f(_.right) } | |
def withLeft[A, B] = new { def apply[R](f: (Either[A, B] => Either.LeftProjection[A, B]) => R) = f(_.left) } | |
withRight[Int, Int] { implicit ev => | |
for { | |
x <- Right(1) | |
y <- Right(2) | |
} yield x + y // => Right(3) | |
for { | |
x <- Right(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
trait Zero[A] { val zero: A } | |
implicit val IntZero = new Zero[Int] { val zero = 0 } | |
implicit def RightProjectionWithFilter[A, B](r: Either.RightProjection[A, B])(implicit azero: Zero[A]) = new { | |
class WithFilter(p: B => Boolean) { | |
def map[C](f: B => C): Either[A, C] = r.filter(p).getOrElse(Left(azero.zero)).right.map(f) | |
def flatMap[AA >: A, C](f: B => Either[AA, C]): Either[AA, C] = r.filter(p).getOrElse(Left(azero.zero)).right.flatMap(f) | |
def withFilter(p0: B => Boolean): WithFilter = new WithFilter(b => p(b) && p0(b)) | |
} | |
def withFilter(p: B => Boolean): WithFilter = new WithFilter(p) |
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
type 'a node = | |
| A: int -> int node | |
| B: string -> string node | |
module type Exists = sig | |
type t | |
val ret: t node | |
end | |
module type PolyFun = sig |
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
lazy val fab: PartialFunction[Base, Int] = { | |
case A(base) => 1 + fabc(base) // PartialFunction#apply の呼び出し。危ない! | |
case B(left, right) => 1 + fabcd(left) + fabcd(right) // 同様 | |
} | |
// 全域関数だと scala コンパイラにはわからない! | |
lazy val fabcd: PartialFunction[Base, Int] = fab orElse { | |
case C => 1 | |
case D => 2 | |
} |
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
!SLIDE | |
Play 2.0 の Action と BodyParser について学ぼう | |
---------------- | |
!SLIDE | |
自己紹介 | |
---------------- | |
* 望月 慎也 | |
* @lyrical_logical | |
* 株式会社レピダム |
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
imoprt Iteratee._ | |
lazy val takeOdds = { | |
val aux = for { | |
one <- headOption[Byte[Array]] // ダサい | |
_ <- headOption[Byte[Array]] // ダサい | |
} yield one | |
for { | |
odds <- aux |