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
import scalaz.effect.IO | |
import scalaz.std.function._ | |
import scalaz.{Coyoneda, Free, Monad, State, ~>} | |
object NonFunctor extends App { | |
// my simple algebra | |
sealed trait Console[A] | |
case class PrintLine(msg: String) extends Console[Unit] | |
case object ReadLine extends Console[String] |
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 State[S, A] { | |
val run: S => (S, A) | |
def apply(s: S): (S, A) = | |
run(s) | |
def eval(s: S): A = | |
apply(s)._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
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] |
NewerOlder