Re:Exotic Programming Ideas, Part 3: Effect Systems
by smegma2 on Sunday November 22, 2020 @01:24PM
(#25179627)
I was curious about this function:
Why is it total instead of st<h>? Won't this have a side effect of setting the references?
[ Parent
| on HN ]
Re:Exotic Programming Ideas, Part 3: Effect Systems
by daanx on Sunday November 22, 2020 @01:30PM
(#25179695)
Ah, I think Stephen meant to write the following:
fun add-refs( a : ref<h,int>, b : ref<h,int> ) : st<h> int {
a := 10
b := 20
(!a + !b)
}
where indeed the effect is `st<h>` as the updates are observable. How the function was written before, the two arguments use a "rank-2" polymorphic type and the heaps are fully abstract -- in that case it would be unobservable but you cannot create such values :-)