One of the "holes" in real-world Haskell is you never know if a
library/function is calling unsafePerformIO and you have to trust the
library author. I recognize the necessity of the function, but should
it announce itself? unsafePerformIO has this type:<br><br> unsafePerformIO :: IO a -> a<br><br>Would there be any value to making it have a type that can be stripped off, like some other monads? For example, providing a "runUnsafe" or similar:
<br><br> data UnsafePerformIO a = Unsafe a <br><br> runUnsafe :: UnsafePerformIO a -> a<br> runUnsafe (Unsafe o) = o<br><br>and changing unsafePerformIO to have the type:<br><br> unsafePerformIO :: IO a -> UnsafePerformIO a
<br><br>It seems it would be valuable to have functions announce when they use unsafePerformIO, but additionally allow it to be stripped off. So the classic<br><br> launchMissiles :: a -- Uses unsafePerfomIO!<br><br>Would become
<br><br> launchMissiles :: UnsafePerformIO a <br><br>Which could be stripped off it you wanted:<br><br> evilDictatator :: a<br> evilDictator = runUnsafe $ launchMissiles<br><br>But doesn't have to be:<br><br> incompetentDictator :: a
<br> incompetentDictator = launchMissiles -- Doesn't type check!<br><br>I doubt this is original - does it buy anything? <br><br>Justin<br><br>