purescript / purescript-st

The ST effect, for safe local mutation
BSD 3-Clause "New" or "Revised" License
25 stars 25 forks source link

Get rid of Eff dependency, add Region kind. #17

Closed paf31 closed 6 years ago

paf31 commented 6 years ago

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.

hdgarrood commented 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?

paf31 commented 6 years ago

I'm in favour, but it would be a non breaking change regardless, one the compiler change comes along, right?

hdgarrood commented 6 years ago

Sorry, I don't quite follow; what would be a non breaking change? Adding that optimization?

paf31 commented 6 years ago

It would be non breaking here to change the representation of ST once the optimization is available.

hdgarrood commented 6 years ago

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?

paf31 commented 6 years ago

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.