Closed paf31 closed 6 years ago
I was wondering if, rather than adding more ffi code, it might be worth considering an approach where whenever we have a newtype over Effect
which uses the derived newtype instances for the Monad hierarchy, we get the compiler to apply the magic do optimization, and then define ST
in that way. Does that sound doable?
I'm in favour, but it would be a non breaking change regardless, one the compiler change comes along, right?
Sorry, I don't quite follow; what would be a non breaking change? Adding that optimization?
It would be non breaking here to change the representation of ST once the optimization is available.
I think the optimisation is quite important to the correct operation of code that uses ST; therefore I think it’s arguable that changing the representation in such a way that the optimisation no longer fires on a given compiler version should really be considered a breaking change?
Makes sense. I don't have time to work on the optimization unfortunately, so I'll leave this up to you to close or leave open for now until that stuff is decided.
I wasn't sure if anyone was working on this, but it seemed simple enough.
Obviously there are optimizer changes needed to support something like this.
I wasn't able to use the name
runST
because of the way that function currently gets inlined, so that will need some thought if we would like users to be able to use the old library version with the new compiler, and vice versa.