Skip to content

Zipping multiple yields into a single yield #314

Answered by anfelor
robertkleffner asked this question in Q&A
Discussion options

You must be logged in to vote

Hi, great question! I assume you mean the yield effect from the homepage?

I believe that it is not possible to define a zip function on a fun yield effect, since a computation with this effect can not be stopped and resumed later. In this sense it is similar to a push stream: the computation will push values to you and you have to deal with them immediately.

You can however implement zip on a ctl yield effect, since the ctl allows you to capture the remaining computation. This is more similar to pull streams: you can request the computation to run until it first yields. It looks like this:

effect yield<a>
  ctl yield( x : a ) : ()

// Traverse a list and yield the elements
fun traverse( x…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@robertkleffner
Comment options

Answer selected by robertkleffner
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