[Haskell-cafe] what are the safety conditions for unsafeIOToST
rl at cse.unsw.edu.au
Wed Apr 7 22:46:48 EDT 2010
On 08/04/2010, at 01:38, Henning Thielemann wrote:
>> On Apr 6, 2010, at 5:30 PM, Roman Leshchinskiy wrote:
>>> In fact, the only safe-ish use for it I have found is to use Storable-related functions in ST, hoping that the instances don't actually use any real IO functionality. Arguably, this shouldn't be necessary as Storable should live in ST anyway.
> But Storable in ST monad would be still dangerous, because pointers may point to non-allocated memory or point outside of an array.
I don't think that's the kind of safety the original poster had in mind. You can have invalid memory accesses even in pure code but that's ok since we know what the semantics is: bottom. I understood the question to be about the conditions under which unsafeIOToST can violate referential transparency.
More information about the Haskell-Cafe