diff options
author | David Feuer <david.feuer@gmail.com> | 2017-03-22 17:25:03 -0400 |
---|---|---|
committer | David Feuer <David.Feuer@gmail.com> | 2017-03-22 17:29:26 -0400 |
commit | 30d68d630c1685bb81ec4afdaf6d483ba8aafd38 (patch) | |
tree | 0a99cd62c6f131a6e086fede441d6262debaee11 /libraries/base/Control/Monad | |
parent | acd85ce97accb8fac10b1191c30da9bfd507c857 (diff) | |
download | haskell-30d68d630c1685bb81ec4afdaf6d483ba8aafd38.tar.gz |
Make unsafeInterleaveST less unsafe
* Make `unsafeInterleaveST` use `noDuplicate#` like
`unsafeInterleaveIO` does to prevent the suspended action from
being run in two threads.
* In order to accomplish this without `unsafeCoerce#`, generalize
the type of `noDuplicate#`.
* Add `unsafeDupableInterleaveST` to get the old behavior.
* Document unsafe `ST` functions and clean up some related
documentation.
Fixes #13457
Reviewers: austin, hvr, bgamari, ekmett
Reviewed By: bgamari
Subscribers: rwbarton, thomie
Differential Revision: https://phabricator.haskell.org/D3370
Diffstat (limited to 'libraries/base/Control/Monad')
-rw-r--r-- | libraries/base/Control/Monad/ST/Imp.hs | 4 | ||||
-rw-r--r-- | libraries/base/Control/Monad/ST/Unsafe.hs | 1 |
2 files changed, 4 insertions, 1 deletions
diff --git a/libraries/base/Control/Monad/ST/Imp.hs b/libraries/base/Control/Monad/ST/Imp.hs index 984970fc72..c053dcc64d 100644 --- a/libraries/base/Control/Monad/ST/Imp.hs +++ b/libraries/base/Control/Monad/ST/Imp.hs @@ -29,10 +29,12 @@ module Control.Monad.ST.Imp ( -- * Unsafe operations unsafeInterleaveST, + unsafeDupableInterleaveST, unsafeIOToST, unsafeSTToIO ) where -import GHC.ST ( ST, runST, fixST, unsafeInterleaveST ) +import GHC.ST ( ST, runST, fixST, unsafeInterleaveST + , unsafeDupableInterleaveST ) import GHC.Base ( RealWorld ) import GHC.IO ( stToIO, unsafeIOToST, unsafeSTToIO ) diff --git a/libraries/base/Control/Monad/ST/Unsafe.hs b/libraries/base/Control/Monad/ST/Unsafe.hs index 9fa4b739b1..b8560b1cfd 100644 --- a/libraries/base/Control/Monad/ST/Unsafe.hs +++ b/libraries/base/Control/Monad/ST/Unsafe.hs @@ -21,6 +21,7 @@ module Control.Monad.ST.Unsafe ( -- * Unsafe operations unsafeInterleaveST, + unsafeDupableInterleaveST, unsafeIOToST, unsafeSTToIO ) where |