If the library developer can prove that a C operation is pure, why shouldn't he tell Haskell about that?
And if you don't trust the developer, it's easy to fix his mistake:
unUnsafePerformIO :: a -> IO a
unUnsafePerformIO = returnSorry, that doesn't actually work.
ezyang@ezyang:~$ cat Test.hs
import System.IO.Unsafe
unUnsafePerformIO = return
main = do
let a = unUnsafePerformIO (unsafePerformIO (putStrLn "boom"))
a
a
ezyang@ezyang:~$ runghc Test.hs
ezyang@ezyang:~$
Box the value that is the result of evaluation an expression that calls impure code in IO?
This is what I'd expect for calling impure code in third-party libraries.