3 ms·
> what you really want is a system that lets you mutate something as long as you are the only one with a reference to it You mean like STRef[1]? Because that i
by Tarean 9y ago
> what you really want is a system that lets you mutate something as long as you are the only one with a reference to it
You mean like STRef[1]? Because that is exactly what STRef does. It is worth noting that STRef is significantly safer than similar rust constructs because they deal with reference cycles. On the other hand implicit resource freeing is more awkward and you still need a gc.
This allows you to write programs that are asymptotically more efficient through mutability. Though there is a class of algorithms where lazy pure implementations gain the same benefits as impure ones using the sharing/implicit mutation that call-by-need provides.
There is an experimental linear haskell branch which might be merged into ghc proper eventually. It is stricter then rust, though, and prevents things like reference cycles which is more awkward but safer in places.
[1]https://hackage.haskell.org/package/base-4.10.0.0/docs/Data-STRef.html https://hackage.haskell.org/package/base-4.10.0.0/docs/Data-...