Unsafe functions
From HaskellWiki
(Difference between revisions)
m (expand) |
|||
| Line 7: | Line 7: | ||
* <hask>unsafeIOToSTM :: IO a -> STM a</hask> | * <hask>unsafeIOToSTM :: IO a -> STM a</hask> | ||
* <hask>unsafeFreeze, unsafeThaw</hask> | * <hask>unsafeFreeze, unsafeThaw</hask> | ||
| + | * <hask>unsafeCoerce# :: a -> b</hask> | ||
| + | * <hask>seq :: a -> b -> b</hask> | ||
| + | |||
| + | Unsafe functions can break type safety (unsafeCoerce#, unsafePerformIO), | ||
| + | interfere with lazy IO (unsafeInterleaveIO), or break paramatericity (seq). | ||
| + | There use (except in the case of <hask>seq</hask>) would require some | ||
| + | kind of assurance on the part of the programmer that what they're doing | ||
| + | is safe. | ||
{{stub}} | {{stub}} | ||
| + | |||
| + | [[Category:Idioms]] | ||
Revision as of 01:20, 8 October 2006
There are a number of unsafe functions in the libraries.
- 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
- unsafeCoerce# :: a -> b
- seq :: a -> b -> b
Unsafe functions can break type safety (unsafeCoerce#, unsafePerformIO), interfere with lazy IO (unsafeInterleaveIO), or break paramatericity (seq).
There use (except in the case ofseq
kind of assurance on the part of the programmer that what they're doing is safe.
This article is a stub. You can help by expanding it.
