Kokaの例: Generator
koka(js)effect yield<a>
fun yield(x: a): ()
fun traverse(xs: list<a>): yield<a> ()
match xs
Cons(x,xx) -> { yield(x); traverse(xx) }
Nil -> ()
handle部分
koka(js)fun main(): console ()
with fun yield(i: int)
println("yielded " ++ i.show)
[1,2,3,4,5].traverse
with fun ..
を使うことで自然にresumeしてる
resultyielded 1
yielded 2
yielded 3
yielded 4
yielded 5
参考
恐らく古いverionのKokaで書かれてる
>@yurihaia: kinda cool research language named Koka
>the concepts (especially effects & effect handlers) allows making your own generators, async-await, and stuff like that all
>
