Skip to content

How to pass polymorphic effect type into another effect signature? #377

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

You must be logged in to vote

If one function needs divergence, every function that runs in the same scope essentially has to at least have divergence.
So the solution is to add divergence to both input parameters.

Divergence inference is still pretty immature compared to the rest of the type system. Granted, it is trying to solve a small portion of the halting problem, so it's not going to be perfect.

pub effect iter<a>
  ctl yield(elem : a) : ()

pub fun foreach(it : () -> <iter<a>,div> (), do : a -> <div|e> ()) : <div|e> ()
  with ctl yield(elem)
    do(elem)
    resume(())
  it()

Replies: 1 comment 1 reply

Comment options

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

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