Closed rightfold closed 4 years ago
Moving everything to use MonadST
constraints would destroy the ability to optimize ST
I think (not that it is optimized in the 0.12 RC just now).
Honest question: why/when would you want to do this? I can't think of any situations where I've wanted a non-closed ST.
When you have a library that already uses ST, but you want to use it from Effect (for example STArray; I've been using MVector lately in Haskell in both IO and ST, for production and testing respectively).
Granted, explicit liftST is enough for that, you don't need the constraint for all the operations (it would just be more convenient).
Am wanting to use STObject in Effect. Got my upvote.
Previous issue was #7, but that was still about effect rows.
Now that we no longer use effect rows, it is no longer possible to use ST globally by adding
st :: ST a
to the effect row ofmain
.I think that we can abstract over Effect and ST so that code that uses mutation can be used on both global and local state, as follows.
Now we can abstract over it.
Now,
STRef
andRef
can be unified, allowing for code reuse. Similar forSTArray
and something I don't think exists yet (useful for fixing https://github.com/purescript-node/purescript-node-process/issues/8).Additionally, ST can be used without explicit lifting with monad transformers.