logo       

Unsafe Functions: msg#00156

lang.haskell.libraries

Subject: Unsafe Functions

I would like to start a discussion on the role of unsafe functions in Haskell:

unsafePerformIO :: IO a -> a
unsafeInterleaveIO :: IO a -> IO a
unsafeInterleaveST :: ST s a -> ST s a
unsafeIOToST :: IO a -> ST s a
unsafeIOToSTM :: IO a -> STM a
unsafeFreeze, unsafeThaw,
unsafePreservingMatrix, unsafeRenderPrimitive

perhaps also

unsafeForeignPtrToPtr :: ForeignPtr a -> Ptr a
(which is already under Foreign.*)
hGetContents :: Handle -> IO String
(which is lazy rather than unsafe per se)

* Do you use these, and what for?

* Is there safe functionality that can currently only be obtained with them?

* Do you think they should be standardised, and how?

I'm thinking the unsafe functions should be moved from System.IO.Unsafe and elsewhere to Unsafe, similar to Foreign.*, to better separate them from "real Haskell" conceptually. Also, I would add:

unsafeCoerce :: a -> b

--
Ashley Yakeley, Seattle WA
WWEWDD? http://www.cs.utexas.edu/users/EWD/


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise