You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Then you can use st :: ST Global as the effect of global mutations. For example:
main :: forall eff. Eff (st :: ST Global | eff) Unit
main = ...
Which would eliminate the need for REF. You could use existing local ST computations (forall r e. Eff (st :: ST r | e)) without runST if you already have an st :: ST Global effect, so I think there would be no issue with duplicate labels.
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.
Activity
hdgarrood commentedon Nov 28, 2016
Most of the time, I think you want to use
runSTthough, in order to have the compiler verify that mutation can't happen outside some particular scope.no-longer-on-githu-b commentedon Nov 28, 2016
Right, as long as you don't do both global and local mutations in a computation, you can still use
runSTto cast away the local ST region, and then use row polymorphism to add the global ST region.hdgarrood commentedon Nov 28, 2016
Ok, good point. Maybe it's useful that
STRefandRefare 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 theSTeffect. Although maybe that's a good thing, because then you could write code that works in both situations.no-longer-on-githu-b commentedon Apr 3, 2017
@hdgarrood Is this still an issue now psc supports duplicate labels? Can you have multiple
steffects that work as expected?no-longer-on-githu-b commentedon Apr 30, 2018
We no longer use effect rows, so I'll close this issue as the situation is now different.