unsafeInterleaveST is too unsafe
Several years ago, Edward Kmett wrote a blog post that (among other things) explains that
unsafeInterleaveST is not thread-safe; actions may be performed multiple times.
The fix that would seem to match everything else best would be to rename
unsafeDupableInterleaveST and define
unsafeInterleaveST m = unsafeDupableInterleaveST (noDuplicate >> m) using an
STish version of
As Kmett explains, the dupable version is useful for high performance when the suspended action is known to be idempotent. Actually, the action being idempotent is insufficient, but I believe a sufficient condition is that the action does not both read and write any reference or array element.
While we're at it, we need to document all the functions in