4 ms·
Explain? What would the alternative be? Box the value that is the result of evaluation an expression that calls impure code in IO? This is what I'd expect for
by danieldk 15y ago
Explain? What would the alternative be?
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.
- jrockway 15y agoIf the library developer can prove that a C operation is pure, why shouldn't he tell Haskell about that?
- jrockway 15y agoAnd if you don't trust the developer, it's easy to fix his mistake: unUnsafePerformIO :: a -> IO a unUnsafePerformIO = return
- ezyang 15y agoSorry, 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:~$
- jrockway 15y agoYes, true. Patch the library if the annotation is wrong :)