
On 27-Nov-2000, Adrian Hey
On Mon 27 Nov, Fergus Henderson wrote:
Do you think that Haskell would be better without `unsafePerformIO'?
Well, a sceptic like me is bound to wonder why such a non-function is provided in a purely functional language. What really worries me is that the damage isn't localised. If you allow such things you can never be sure that any function really is a function, without careful scrutiny of all the code it's dependent on.
This is an issue, but it arises in any "pure" language with a foreign language interface. I think what would be nice to have is a notion of "trust". Only "trusted" people can use unsafePerformIO -- of course as the application developer you can decide who you trust and who you don't trust. It would be possible to use public key crypto to handle trust (if you were worried enough to bother). Then you only have to scrutinze uses of unsafePerformIO that you don't trust. We have been thinking of adding some support for "safety", "purity" and "trust" to Mercury for a while, but haven't quite hammered out exactly what these concepts mean and how they interact (or even whether it is all worthwhile). The general idea is that you could trust :- promise pure declarations (which are similar to unsafePerformIO). There are other :- promise declarations too. To use a :- promise declaration you would have to trust the author. -- Tyson Dowd # # Surreal humour isn't everyone's cup of fur. trd@cs.mu.oz.au # http://www.cs.mu.oz.au/~trd #