Using mutation effect in handler gives "type is not polymorphic enough" #587
-
Consider this simple effect
The line with the mutation statement gives the following compiler error, which I do not understand:
How should I interpret this compiler error, and how can I implement this handler? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I agree that this error message is pretty hard to read. It looks like you need to add the type
==>
The problem with the first definition is that the type We should probably disallow polymorphic variables as parameters to effect operations (or at least give a warning), though we need to allow polymorphic return values (for exceptions). |
Beta Was this translation helpful? Give feedback.
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.==>
The problem with the first definition is that the type
a
could change with every call to chance, which would makecases
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 …