Closed rightfold closed 6 years ago
Most of the time, I think you want to use runST
though, in order to have the compiler verify that mutation can't happen outside some particular scope.
Right, as long as you don't do both global and local mutations in a computation, you can still use runST
to cast away the local ST region, and then use row polymorphism to add the global ST region.
Ok, good point. Maybe it's useful that STRef
and Ref
are different types, though, because then you can signal whether you expect to restrict the mutation to some local scope or not? That might not be clear from the rows, since you could universally quantify over the parameter to the ST
effect. Although maybe that's a good thing, because then you could write code that works in both situations.
@hdgarrood Is this still an issue now psc supports duplicate labels? Can you have multiple st
effects that work as expected?
We no longer use effect rows, so I'll close this issue as the situation is now different.
If this library adds a named region:
Then you can use
st :: ST Global
as the effect of global mutations. For example:Which would eliminate the need for
REF
. You could use existing local ST computations (forall r e. Eff (st :: ST r | e)
) withoutrunST
if you already have anst :: ST Global
effect, so I think there would be no issue with duplicate labels.