flix
flix copied to clipboard
Typing of multiple handlers
eff Ask {
pub def ask(): String
}
eff Say {
pub def say(s: String): Unit
}
def greeting(): Unit \ {Ask, Say} =
let name = do Ask.ask();
do Say.say("Hello Mr. ${name}")
def main(): Unit \ IO =
try {
try greeting() with Ask {
def ask(k) = k("Bond, James Bond")
}
} with Say {
def say(s, k) = { println(s); k() }
}
I think its the substitution thing again (#7118), The trick is to squeeze variables out of the continuation
eff Ask {
pub def ask(): String
}
eff Say {
pub def say(s: String): Unit
}
def greeting(): Unit \ {Ask, Say} =
let name = do Ask.ask();
do Say.say("Hello Mr. ${name}")
def main(): Unit \ IO =
try {
try greeting() with Ask {
def ask(k) = {
let kt: String -> Unit \ Say = k;
kt("Bond, James Bond")
}
}
} with Say {
def say(s, k) = { println(s); k() }
}
Thanks- I had a student that was caught on this.
The only thing you have done is to eta expand right?
Not even, I just type annotated the continuation