Skip to content

Instantly share code, notes, and snippets.

@AlexeySoshin
Last active July 7, 2020 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexeySoshin/1bfe5fd3b864139f2107e00b019e5664 to your computer and use it in GitHub Desktop.
Save AlexeySoshin/1bfe5fd3b864139f2107e00b019e5664 to your computer and use it in GitHub Desktop.
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