File tree Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Expand file tree Collapse file tree 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change 5
5
module Data.Array.ST
6
6
( STArray (..)
7
7
, Assoc
8
- , runSTArray
8
+ , run
9
9
, withArray
10
10
, empty
11
11
, peek
@@ -26,7 +26,8 @@ module Data.Array.ST
26
26
27
27
import Prelude
28
28
29
- import Control.Monad.ST (ST , kind Region , run )
29
+ import Control.Monad.ST as ST
30
+ import Control.Monad.ST (ST , kind Region )
30
31
import Data.Maybe (Maybe (..))
31
32
import Unsafe.Coerce (unsafeCoerce )
32
33
@@ -46,8 +47,8 @@ type Assoc a = { value :: a, index :: Int }
46
47
-- | immutable array for later perusal. This function avoids copying the array
47
48
-- | before returning it - it uses unsafeFreeze internally, but this wrapper is
48
49
-- | a safe interface to that function.
49
- runSTArray :: forall a . (forall h . ST h (STArray h a )) -> Array a
50
- runSTArray st = run (st >>= unsafeFreeze)
50
+ run :: forall a . (forall h . ST h (STArray h a )) -> Array a
51
+ run st = ST . run (st >>= unsafeFreeze)
51
52
52
53
-- | Perform an effect requiring a mutable array on a copy of an immutable array,
53
54
-- | safely returning the result as an immutable array.
Original file line number Diff line number Diff line change @@ -18,9 +18,9 @@ run act = ST.run (act >>= STA.unsafeFreeze)
18
18
testArrayST :: Effect Unit
19
19
testArrayST = do
20
20
21
- log " runSTArray should produce an immutable array by running a constructor operation"
21
+ log " run should produce an immutable array by running a constructor operation"
22
22
23
- assert $ STA .runSTArray (do
23
+ assert $ STA .run (do
24
24
arr <- STA .empty
25
25
void $ STA .push 1 arr
26
26
void $ STA .push 2 arr
You can’t perform that action at this time.
0 commit comments