Last active
July 7, 2020 12:31
-
-
Save AlexeySoshin/1bfe5fd3b864139f2107e00b019e5664 to your computer and use it in GitHub Desktop.
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
object Runtime { | |
fun <A> unsafeRunSync(kio: KIO<A>): A = eval(kio) | |
fun <A> eval(kio: KIO<A>): A { | |
return when (kio) { | |
is Effect<A> -> kio.f() | |
is FlatMap<*, A> -> { | |
val res: Any? = eval(kio.input) | |
val f = kio.f as (Any?) -> KIO<A> | |
eval(f(res)) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment