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 Fun[A, B](run: A => B) { | |
def map[C](f: B => C): Fun[A, C] = Fun(a => f(run(a))) | |
def flatMap[C](f: B => Fun[A, C]): Fun[A, C] = | |
Fun(a => f(run(a)).run(a)) | |
} | |
case class Config(db: String, logColor: String) | |
object Repo { | |
def get(id: Int): Fun[Config, Int] = Fun(conf => id) | |
} |
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
// simple programm to show how to use ZIO and to show which opportunities it can bring | |
import zio._ | |
// trait to describe Config | |
trait HasConfig { | |
def dbConfig: DBConfig | |
def loggerConfig: LoggerConfig | |
} | |
case class DBConfig(db: String) | |
case class LoggerConfig(logColor: String) |