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
case class Reader[E, A](run: E => A) | |
object Reader { | |
def >==>[E, A, B, C](fa: A => Reader[E, B], | |
fb: B => Reader[E, C]): A => Reader[E, C] = { input: A => | |
val readerB: Reader[E, B] = fa(input) | |
flatMap(readerB)(fb) | |
} | |
def run[E, A]: Reader[E, A] => E => 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
case class Writer[W, A](run: (W, A)) | |
trait Monoid[A] { | |
def combine(a: A, b: A): A | |
def empty: A | |
} | |
object Writer { | |
def >==>[W: Monoid[W], A, B, C](a: A => Writer[W, B], |
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 Option[+A] | |
case class Some[+A](get: A) extends Option[A] | |
case object None extends Option[Nothing] | |
sealed trait EitherError[Exception, +A] | |
case class RecoverableError(e: Exception) | |
extends EitherError[Exception, Nothing] | |
case class Result[+A](value: A) extends EitherError[Exception, A] | |
object Option { |
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 scala.concurrent.ExecutionContext | |
case class Async[A, E](cb: (A => E) => E) | |
object Async { | |
def run[A, E](async: Async[A, E])( | |
implicit ec: ExecutionContext): (A => E) => E = { | |
case Async(callback) => | |
f => |
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 IO[A] { | |
def run: A // case class parameters may not be call-by-name | |
// so we put unit in a singleton | |
} | |
object IO { | |
def pure[A](input: => A): IO[A] = new IO[A] { def run: A = input } | |
def >==>[A, B, C](a: A => IO[B], b: B => IO[C]): A => IO[C] = { input => | |
val pureIntput: IO[A] = pure(input) |
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 Undecidable[Nothing, +A] | |
case object Forever extends Undecidable[Nothing, Nothing] | |
case class Halt[+A](value: A) extends Undecidable[Nothing, A] | |
object Undecidable { | |
def >==>[A, B, C]( | |
a: A => Undecidable[Nothing, B], | |
b: B => Undecidable[Nothing, C]): A => Undecidable[Nothing, C] = { | |
input: 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
def f1[A, B]: A => B | |
def f2[B, C]: B => C | |
def f3[C, D]: C => D | |
f1 compose(f2 compose f3) === (f1 compose f2) compose f3 === f1 compose f2 compose f3 |
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 f[A, B]: A => B | |
def aIdentity[A]: A => A | |
def bIdentity[B]: B => B | |
aIdentity compose f === f compose bIdentity |
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.zio.{App, IO, KleisliIO} | |
case class AppConfig(service1QueueSize: Int, | |
service1SecretPath: String, | |
service2SecretPath: String, | |
service1DBToUse: String, | |
service2DBToUse: String, | |
service2MonitoringEndpoint: String) | |
case class SecretDependencyService(secretPath: 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
case class Reader[E, A](run: E => A) | |
object Reader { | |
def run[E, A]: Reader[E, A] => E => A = { | |
case Reader(runnable) => | |
e => | |
runnable(e) | |
} | |
} |
OlderNewer