
19 Jun
2016
19 Jun
'16
10:31 p.m.
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. Stefan