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.println or with explicit fun log(value: some<a> a, show: some<a> a -> string)
value.show.println However, I would expect to be able to do fun log(value: forall<a> a, show: a -> string)
value.show.println And have the fun log<a>(value: a, show: a -> string)
value.show.println The problem with fun log(value: forall<a> a, show: forall<a> a -> string)
value.show.println Is that you would be introducing a "new" unrelated |
Beta Was this translation helpful? Give feedback.
This works with type inference:
or with explicit
some
annotations.However, I would expect to be able to do
And have the
forall
be 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…