Make unsafeInterleaveST less unsafe
authorDavid Feuer <david.feuer@gmail.com>
Wed, 22 Mar 2017 21:25:03 +0000 (17:25 -0400)
committerBen Gamari <ben@smart-cactus.org>
Wed, 22 Mar 2017 21:37:37 +0000 (17:37 -0400)
commit167548f4cd087535a6c4c9fc642b60669b4dc019
tree97174f8bf8fc25b01f5c858ce469773a4107d795
parent4a0b1dd8fe165a3f869824ad3e63fb0a5a1eb99f
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

(cherry picked from commit 30d68d630c1685bb81ec4afdaf6d483ba8aafd38)
compiler/prelude/primops.txt.pp
libraries/base/Control/Monad/ST/Imp.hs
libraries/base/Control/Monad/ST/Unsafe.hs
libraries/base/GHC/IO.hs
libraries/base/GHC/IO/Unsafe.hs
libraries/base/GHC/ST.hs