Skip to content

Using mutation effect in handler gives "type is not polymorphic enough" #587

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

You must be logged in to vote

I agree that this error message is pretty hard to read.

It looks like you need to add the type a to the signature for the effect.

pub effect sample
  ctl chance(case : a) : ()

==>

pub effect sample<a>
  ctl chance(case : a) : ()

The problem with the first definition is that the type a could change with every call to chance, which would make cases a list that mixes types, which is not allowed in Koka. I guess it is still allowed in the operation definition because technically you could ignore the parameter.
The error message is misleading because it addresses the consequences of the problem, and not the root problem itself.

We should probably disallow polymorphic variables as parameters …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
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