Replies: 1 comment
-
I finally found a way to write this a bit more clean (also renaming
I still wonder if something like |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I wonder what's the idiomatic way to have a program with an endless loop where it's possible to break out of the loop.
As an exercise to get accustomed to the Koka language, I tried to implement a simple number-guessing game. An easy way seems to do tail recursion:
I noticed that I have to write the function's identifier (
loop
) three times. Is there an easier way?Is the correct way to define an effect and make an abstraction for the effect handler? That could look like this:
Is this idiomatic? Is
while { True }
idiomatic? Does something like thebreak
effect exist instd
? (I didn't find it, at least, but perhaps I was looking in the wrong place. I noticed it's a future reserved word though, according to the docs.)Any comments on where my code is non-idiomatic or could be improved are appreciated. 🙏
I also tried to make the
break
effect generic:And then:
This works fine.
However, without
bottom-workaround
, I get the following error:Also, I haven't been able to add a type annotation here:
As then I would get:
But
forall<k>
isn't the solution:As it leads to:
So two additional questions in regard to the generic
break<r>
effect as defined above:bottom-workaround
?retval
's type in thewith handler
statement?Beta Was this translation helpful? Give feedback.
All reactions