Make unsafeInterleaveST less unsafe
authorDavid Feuer <david.feuer@gmail.com>
Wed, 22 Mar 2017 21:25:03 +0000 (17:25 -0400)
committerDavid Feuer <David.Feuer@gmail.com>
Wed, 22 Mar 2017 21:29:26 +0000 (17:29 -0400)
commit30d68d630c1685bb81ec4afdaf6d483ba8aafd38
tree0a99cd62c6f131a6e086fede441d6262debaee11
parentacd85ce97accb8fac10b1191c30da9bfd507c857
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
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