Skip to content

Commit 1b1b8a3

Browse files
committed
Fix build for new ST
1 parent 0b4d1ce commit 1b1b8a3

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"package.json"
1616
],
1717
"dependencies": {
18-
"purescript-arrays" : "*",
18+
"purescript-arrays" : "~0.2.2",
1919
"purescript-tuples" : "*",
2020
"purescript-maybe" : "*"
2121
}

src/Data/Unfoldable.purs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,23 @@ module Data.Unfoldable where
22

33
import Data.Maybe
44
import Data.Tuple
5+
import Data.Array.ST
56
import Control.Monad.Eff
67
import Control.Monad.ST
78

89
class Unfoldable t where
910
unfoldr :: forall a b. (b -> Maybe (Tuple a b)) -> b -> t a
1011

11-
foreign import newEmptySTArray
12-
"function newEmptySTArray() {\
13-
\ return [];\
14-
\}" :: forall eff h a. Eff (st :: ST h | eff) (STArray h a)
15-
1612
instance unfoldableArray :: Unfoldable [] where
1713
unfoldr f b = runPure (runSTArray (do
18-
arr <- newEmptySTArray
14+
arr <- emptySTArray
1915
seed <- newSTRef b
20-
idx <- newSTRef 0
2116
untilE $ do
2217
b1 <- readSTRef seed
2318
case f b1 of
2419
Nothing -> return true
2520
Just (Tuple a b2) -> do
26-
i <- readSTRef idx
27-
pokeSTArray arr i a
21+
pushSTArray arr a
2822
writeSTRef seed b2
29-
writeSTRef idx (i + 1)
3023
return false
3124
return arr))

0 commit comments

Comments
 (0)