This file contains hidden or 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
| case class M[+A](in: (A => Any) => Any); | |
| def unit[A](x: A) = M { k: (A => Any) => k(x) } | |
| def bind[A, B](m: M[A], f: A => M[B]): M[B] = | |
| M { k: (B => Any) => | |
| m.in { x: A => | |
| f(x).in(k) | |
| } | |
| } |
This file contains hidden or 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 Main extends App { | |
| trait Functor[F[_]] { | |
| def map[A, B](fa: F[A])(f: A => B): F[B] | |
| } | |
| sealed trait Nat[A] | |
| final case class Z[A]() extends Nat[A] | |
| final case class S[A](a: A) extends Nat[A] |
This file contains hidden or 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
| import cats.Functor | |
| import cats.implicits._ | |
| import scala.language.higherKinds | |
| sealed trait StackR | |
| final case class DoneR(result: Int = 1) extends StackR | |
| final case class MoreR(acc: StackR, next: Int) extends StackR | |
| sealed trait Stack[A] |
This file contains hidden or 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
| package fpmax | |
| import scala.util.Try | |
| import scala.io.StdIn.readLine | |
| object App0 { | |
| def main: Unit = { | |
| println("What is your name?") | |
| val name = readLine() |
This file contains hidden or 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 MyIteratee{ | |
| sealed trait Input[+E] { | |
| } | |
| object Input { | |
| case class El[+E](e: E) extends Input[E] | |
| case object EOF extends Input[Nothing] | |
| } | |
| trait Iteratee[E, A] { |
OlderNewer