Skip to content

Combining callback effects in the return type? #628

Answered by TimWhiting
osa1 asked this question in Q&A
Discussion options

You must be logged in to vote

These are the changes to get it working.

fun for<item,extra-fx>(iterator: a, next: a -> <div|extra-fx> maybe<item>, cb: (item) -> <ctl-flow,div|extra-fx> ()): <div|extra-fx> ()
  ...
...

// By the way, it looks like your length comparison was inverted. 
fun vector-iterator/next(iterator: vector-iterator<a>): <read<global>, write<global>> maybe<a>
  if iterator.vector.length > !iterator.idx then
  ...
fun for<item,extra-fx>(iterator: a, next: a -> <div|extra-fx> maybe<item>, cb: (item) -> <ctl-flow,div|extra-fx> ()): <div|extra-fx> ()

The effect variable after the vertical bar needs to be the same in all callbacks and the return type. Also <extra-fx> treats it as a label (specific effec…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by osa1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants