Replies: 1 comment 7 replies
-
It doesn't answer your question about local, but I would probably use a non-mutable variable for this.
As far as using a mutable variable what you want to do is actually mask the local:
By masking the local you are telling the recursive call that it doesn't need to know about the handler for the local variable, even though you needed it to make a decision in the if expression. Otherwise it thinks that the recursive call needs access to the local above it in the stack and then because of the recursion it would be able to see all local variables recursively above it in the stack, not to mention you would need a local variable just to call the for expression in the first place. That is why you get two locals. You are basically unrolling the handler stack in the type, which turns out to be impossible because of recursion. |
Beta Was this translation helpful? Give feedback.
-
This program is not right (
break
effect is not handled properly), but it type checks.To fix the
break
effect handling I introduce a local variable:Which fails to type check, apparently this uses an effect called
local
now. I can't find any documentation on it, but from the definition of it in the standard library it looks identical to Haskell's ST. So I add it to the type sig:But it fails with:
How can
local<$h>
appear twice in an effect type?Beta Was this translation helpful? Give feedback.
All reactions