Is it possible to handle polymorphic effect operations? #706
-
|
Consider, for instance: effect log
fun log(value : a, show : a -> string) : ()
fun log-nine()
log(9, show)
fun main()
with handler
fun log(value : a, show : a -> string)
value.show.println
log-nine()This does not compile, complaining that |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
|
This works with type inference: fun log(value, show)
value.show.printlnor with explicit fun log(value: some<a> a, show: some<a> a -> string)
value.show.printlnHowever, I would expect to be able to do fun log(value: forall<a> a, show: a -> string)
value.show.printlnAnd have the fun log<a>(value: a, show: a -> string)
value.show.printlnThe problem with fun log(value: forall<a> a, show: forall<a> a -> string)
value.show.printlnIs that you would be introducing a "new" unrelated |
Beta Was this translation helpful? Give feedback.
This works with type inference:
or with explicit
someannotations.However, I would expect to be able to do
And have the
forallbe lifted (promoted) to quantify over the full function signature instead of the single parameter (like it does for regular function definitions). This doesn't work currently. It seems like promotion is not happening for these signatures, while it does for all other signatures. I believe this is the problem with the simple annotation in the original post as well. This is…