@@ -32,7 +32,8 @@ import Control.Monad.Rec.Class (Step(..), tailRecM2)
32
32
import Control.Monad.ST (ST )
33
33
import Control.Monad.ST as ST
34
34
import Data.Array as Array
35
- import Data.Array.ST (STArray , emptySTArray , pushSTArray , unsafeFreeze )
35
+ import Data.Array.ST (STArray )
36
+ import Data.Array.ST as STArray
36
37
import Data.Eq (class Eq1 )
37
38
import Data.Foldable (class Foldable , foldMap , foldl , foldr )
38
39
import Data.List (List )
@@ -158,7 +159,7 @@ properSubset s1 s2 = subset s1 s2 && (s1 /= s2)
158
159
159
160
-- | The set of elements which are in both the first and second set
160
161
intersection :: forall a . Ord a => Set a -> Set a -> Set a
161
- intersection s1 s2 = fromFoldable (ST .run (emptySTArray >>= intersect >>= unsafeFreeze))
162
+ intersection s1 s2 = fromFoldable (ST .run (STArray .empty >>= intersect >>= STArray . unsafeFreeze))
162
163
where
163
164
toArray = Array .fromFoldable <<< toList
164
165
ls = toArray s1
@@ -172,7 +173,7 @@ intersection s1 s2 = fromFoldable (ST.run (emptySTArray >>= intersect >>= unsafe
172
173
if l < ll && r < rl
173
174
then case compare (ls `Array.unsafeIndex` l) (rs `Array.unsafeIndex` r) of
174
175
EQ -> do
175
- _ <- pushSTArray acc (ls `Array.unsafeIndex` l)
176
+ _ <- STArray .push (ls `Array.unsafeIndex` l) acc
176
177
pure $ Loop {a: l + 1 , b: r + 1 }
177
178
LT -> pure $ Loop {a: l + 1 , b: r}
178
179
GT -> pure $ Loop {a: l, b: r + 1 }
0 commit comments