Skip to content

Commit 1b111f4

Browse files
committed
Remove STArray implementation.
1 parent f82c9e6 commit 1b111f4

File tree

4 files changed

+1
-74
lines changed

4 files changed

+1
-74
lines changed

examples/passing/STArray.purs

Lines changed: 0 additions & 25 deletions
This file was deleted.

prelude/prelude.purs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -883,8 +883,6 @@ module Control.Monad.ST where
883883

884884
foreign import data STRef :: * -> * -> *
885885

886-
foreign import data STArray :: * -> * -> *
887-
888886
foreign import newSTRef "function newSTRef(val) {\
889887
\ return function() {\
890888
\ return { value: val };\
@@ -913,40 +911,7 @@ module Control.Monad.ST where
913911
\ };\
914912
\}" :: forall a h r. STRef h a -> a -> Eff (st :: ST h | r) a
915913

916-
foreign import newSTArray "function newSTArray(len) {\
917-
\ return function(a) {\
918-
\ return function() {\
919-
\ var arr = [];\
920-
\ for (var i = 0; i < len; i++) {\
921-
\ arr[i] = a;\
922-
\ };\
923-
\ return arr;\
924-
\ };\
925-
\ };\
926-
\}" :: forall a h r. Number -> a -> Eff (st :: ST h | r) (STArray h a)
927-
928-
foreign import peekSTArray "function peekSTArray(arr) {\
929-
\ return function(i) {\
930-
\ return function() {\
931-
\ return arr[i];\
932-
\ };\
933-
\ };\
934-
\}" :: forall a h r. STArray h a -> Number -> Eff (st :: ST h | r) a
935-
936-
foreign import pokeSTArray "function pokeSTArray(arr) {\
937-
\ return function(i) {\
938-
\ return function(a) {\
939-
\ return function() {\
940-
\ return arr[i] = a;\
941-
\ };\
942-
\ };\
943-
\ };\
944-
\}" :: forall a h r. STArray h a -> Number -> a -> Eff (st :: ST h | r) a
945-
946914
foreign import runST "function runST(f) {\
947915
\ return f;\
948916
\}" :: forall a r. (forall h. Eff (st :: ST h | r) a) -> Eff r a
949917

950-
foreign import runSTArray "function runSTArray(f) {\
951-
\ return f;\
952-
\}" :: forall a r. (forall h. Eff (st :: ST h | r) (STArray h a)) -> Eff r [a]

src/Language/PureScript/Constants.hs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,6 @@ whileE = "whileE"
123123
runST :: String
124124
runST = "runST"
125125

126-
runSTArray :: String
127-
runSTArray = "runSTArray"
128-
129126
stRefValue :: String
130127
stRefValue = "value"
131128

@@ -141,12 +138,6 @@ writeSTRef = "writeSTRef"
141138
modifySTRef :: String
142139
modifySTRef = "modifySTRef"
143140

144-
peekSTArray :: String
145-
peekSTArray = "peekSTArray"
146-
147-
pokeSTArray :: String
148-
pokeSTArray = "pokeSTArray"
149-
150141
mkFn :: String
151142
mkFn = "mkFn"
152143

src/Language/PureScript/Optimizer/MagicDo.hs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ inlineST = everywhereOnJS convertBlock
119119
-- Look for runST blocks and inline the STRefs there.
120120
-- If all STRefs are used in the scope of the same runST, only using { read, write, modify }STRef then
121121
-- we can be more aggressive about inlining, and actually turn STRefs into local variables.
122-
convertBlock (JSApp f [arg]) | isSTFunc C.runST f || isSTFunc C.runSTArray f =
122+
convertBlock (JSApp f [arg]) | isSTFunc C.runST f =
123123
let refs = nub . findSTRefsIn $ arg
124124
usages = findAllSTUsagesIn arg
125125
allUsagesAreLocalVars = all (\u -> let v = toVar u in isJust v && fromJust v `elem` refs) usages
@@ -137,10 +137,6 @@ inlineST = everywhereOnJS convertBlock
137137
if agg then JSAssignment ref arg else JSAssignment (JSAccessor C.stRefValue ref) arg
138138
convert agg (JSApp (JSApp (JSApp f [ref]) [func]) []) | isSTFunc C.modifySTRef f =
139139
if agg then JSAssignment ref (JSApp func [ref]) else JSAssignment (JSAccessor C.stRefValue ref) (JSApp func [JSAccessor C.stRefValue ref])
140-
convert _ (JSApp (JSApp (JSApp f [arr]) [i]) []) | isSTFunc C.peekSTArray f =
141-
JSIndexer i arr
142-
convert _ (JSApp (JSApp (JSApp (JSApp f [arr]) [i]) [val]) []) | isSTFunc C.pokeSTArray f =
143-
JSAssignment (JSIndexer i arr) val
144140
convert _ other = other
145141
-- Check if an expression represents a function in the ST module
146142
isSTFunc name (JSAccessor name' (JSVar st)) = st == C.st && name == name'

0 commit comments

Comments
 (0)