[Haskell-cafe] ST Vector / STRef -- Performances and allocation

Stefan Monnier monnier at iro.umontreal.ca
Mon Jun 20 02:31:09 UTC 2016

> unconditionally. It still could be done if the mutable structure is
> never shared, but it requires a precise non-sharing analysis. I suspect
> that this kind of analysis does not (yet?) exist in ghc, because it
> would not benefit pure code.

Since these mutable boxes seem to mimick plain C variables, it's indeed
better to map them to immutable Haskell variables.  After all, that's
exactly what the C compiler will do via SSA.

GHC could try to do the same with Refs, but it would only be beneficial
on "C-style Haskell code": usually when Refs are used, it's precisely
because SSA doesn't work for that variable, such as when the equivalent
C code would use & on it.


More information about the Haskell-Cafe mailing list