Skip to content

Commit 489634e

Browse files
committed
Remove fromFoldableWithIndexWith
1 parent 56e9241 commit 489634e

File tree

2 files changed

+1
-41
lines changed

2 files changed

+1
-41
lines changed

src/Foreign/Object.purs

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ module Foreign.Object
1616
, fromFoldable
1717
, fromFoldableWith
1818
, fromFoldableWithIndex
19-
, fromFoldableWithIndexWith
2019
, fromHomogeneous
2120
, delete
2221
, pop
@@ -232,24 +231,6 @@ fromFoldableWithIndex l = runST do
232231

233232
foreign import _lookupST :: forall a r z. Fn4 z (a -> z) String (STObject r a) (ST r z)
234233

235-
-- | Create an `Object a` from an indexed foldable collection, using the
236-
-- | specified functions to map key-value pairs to `String`-value pairs and
237-
-- | combine values at duplicate `String` keys
238-
fromFoldableWithIndexWith
239-
:: forall f k a b
240-
. FoldableWithIndex k f
241-
=> (k -> a -> Tuple String b)
242-
-> (b -> b -> b)
243-
-> f a
244-
-> Object b
245-
fromFoldableWithIndexWith f g l = runST do
246-
s <- OST.new
247-
let g' = flip g
248-
forWithIndex_ l \k a -> do
249-
let Tuple k' b = f k a
250-
runFn4 _lookupST b (g' b) k' s >>= \b' -> OST.poke k' b' s
251-
pure s
252-
253234
-- | Create an `Object a` from a foldable collection of key/value pairs, using the
254235
-- | specified function to combine values for duplicate keys.
255236
fromFoldableWith :: forall f a. Foldable f => (a -> a -> a) -> f (Tuple String a) -> Object a
@@ -322,7 +303,7 @@ filterWithKey predicate m = runST go
322303
m' <- OST.new
323304
foldM step m' m
324305
where
325-
step acc k v = if predicate k v then OST.poke k v acc else pure acc
306+
step acc k v = if predicate k v then OST.poke k v acc else pure acc
326307

327308
-- | Filter out those key/value pairs of a map for which a predicate
328309
-- | on the key fails to hold.

test/Test/Foreign/Object.purs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ import Data.List as L
1212
import Data.List.NonEmpty as NEL
1313
import Data.Map as M
1414
import Data.Maybe (Maybe(..), fromMaybe)
15-
import Data.Profunctor.Strong (first)
1615
import Data.Semigroup.First (First(..))
1716
import Data.Semigroup.Last (Last(..))
18-
import Data.String (toUpper)
1917
import Data.Traversable (sequence, traverse)
2018
import Data.TraversableWithIndex (traverseWithIndex)
2119
import Data.Tuple (Tuple(..), fst, snd, uncurry)
@@ -161,14 +159,6 @@ objectTests = do
161159
quickCheck (O.lookup "1" nums == Just "one" <?> "invalid lookup - 1")
162160
quickCheck (O.lookup "2" nums == Just "two" <?> "invalid lookup - 2")
163161

164-
log "fromFoldableWithIndexWith"
165-
do
166-
let numsMap = M.fromFoldable [Tuple 0 "zero", Tuple 1 "one", Tuple 2 "two"]
167-
f n = if n == 0 then "0" else "1"
168-
nums = O.fromFoldableWithIndexWith (\k v -> Tuple (f k) v) (<>) numsMap
169-
quickCheck (O.lookup "0" nums == Just "zero" <?> "invalid lookup - 0")
170-
quickCheck (O.lookup "1" nums == Just "onetwo" <?> "invalid lookup - 1")
171-
172162
log "fromFoldableWith const [] = empty"
173163
quickCheck (O.fromFoldableWith const [] == (O.empty :: O.Object Unit)
174164
<?> "was not empty")
@@ -198,17 +188,6 @@ objectTests = do
198188
let f m1 = O.fromFoldable ((O.toUnfoldable m1) :: L.List (Tuple String Int)) in
199189
O.fromFoldableWithIndex m == f m <?> show m
200190

201-
log "fromFoldableWithIndexWith f const ~ fromFoldable . map (first f) . toUnfoldable"
202-
quickCheck $ \(TestObject m) ->
203-
O.fromFoldableWithIndexWith (\k v -> Tuple (toUpper k) v) const m ==
204-
O.fromFoldable (first toUpper <$> (O.toUnfoldable m :: L.List (Tuple String Int))) <?> show m
205-
206-
log "fromFoldableWithIndexWith Tuple const = fromFoldableWithIndex"
207-
quickCheck $ \arr ->
208-
let m = M.fromFoldable (arr :: L.List (Tuple String Int)) in
209-
O.fromFoldableWithIndexWith Tuple const m ==
210-
O.fromFoldableWithIndex m <?> show m
211-
212191
log "fromFoldableWith const = fromFoldable"
213192
quickCheck $ \arr -> O.fromFoldableWith const arr ==
214193
O.fromFoldable (arr :: L.List (Tuple String Int)) <?> show arr

0 commit comments

Comments
 (0)