Skip to content
This repository was archived by the owner on Oct 4, 2020. It is now read-only.

Commit 409e4d8

Browse files
authored
Merge pull request #87 from mlang/Discard
Avoid Discard constraint
2 parents e13b408 + 771c5dc commit 409e4d8

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Diff for: src/Data/StrMap.purs

+10-10
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ pureST :: forall a. (forall h e. Eff (st :: ST.ST h | e) (SM.STStrMap h a)) -> S
7676
pureST f = runPure (runST f)
7777

7878
mutate :: forall a b. (forall h e. SM.STStrMap h a -> Eff (st :: ST.ST h | e) b) -> StrMap a -> StrMap a
79-
mutate f m = pureST (do
79+
mutate f m = pureST do
8080
s <- thawST m
81-
f s
82-
pure s)
81+
_ <- f s
82+
pure s
8383

8484
foreign import _fmapStrMap :: forall a b. Fn2 (StrMap a) (a -> b) (StrMap b)
8585

@@ -149,10 +149,10 @@ foreign import size :: forall a. StrMap a -> Number
149149

150150
-- | Create a map with one key/value pair
151151
singleton :: forall a. String -> a -> StrMap a
152-
singleton k v = pureST (do
152+
singleton k v = pureST do
153153
s <- SM.new
154-
SM.poke s k v
155-
pure s)
154+
_ <- SM.poke s k v
155+
pure s
156156

157157
foreign import _lookup :: forall a z. Fn4 z (a -> z) String (StrMap a) z
158158

@@ -166,13 +166,13 @@ member = runFn4 _lookup false (const true)
166166

167167
-- | Insert a key and value into a map
168168
insert :: forall a. String -> a -> StrMap a -> StrMap a
169-
insert k v = mutate (\s -> SM.poke s k v)
169+
insert k v = mutate (\s -> void $ SM.poke s k v)
170170

171171
foreign import _unsafeDeleteStrMap :: forall a. Fn2 (StrMap a) String (StrMap a)
172172

173173
-- | Delete a key and value from a map
174174
delete :: forall a. String -> StrMap a -> StrMap a
175-
delete k = mutate (\s -> SM.delete s k)
175+
delete k = mutate (\s -> void $ SM.delete s k)
176176

177177
-- | Delete a key and value from a map, returning the value
178178
-- | as well as the subsequent map
@@ -225,7 +225,7 @@ values = L.fromFoldable <<< _collect (\_ v -> v)
225225
-- | Compute the union of two maps, preferring the first map in the case of
226226
-- | duplicate keys.
227227
union :: forall a. StrMap a -> StrMap a -> StrMap a
228-
union m = mutate (\s -> foldM SM.poke s m)
228+
union m = mutate (\s -> void $ foldM SM.poke s m)
229229

230230
-- | Compute the union of a collection of maps
231231
unions :: forall a. L.List (StrMap a) -> StrMap a
@@ -238,7 +238,7 @@ mapWithKey :: forall a b. (String -> a -> b) -> StrMap a -> StrMap b
238238
mapWithKey f m = runFn2 _mapWithKey m f
239239

240240
instance semigroupStrMap :: (Semigroup a) => Semigroup (StrMap a) where
241-
append m1 m2 = mutate (\s1 -> foldM (\s2 k v2 -> SM.poke s2 k (runFn4 _lookup v2 (\v1 -> v1 <> v2) k m2)) s1 m1) m2
241+
append m1 m2 = mutate (\s1 -> void $ foldM (\s2 k v2 -> SM.poke s2 k (runFn4 _lookup v2 (\v1 -> v1 <> v2) k m2)) s1 m1) m2
242242

243243
instance monoidStrMap :: (Semigroup a) => Monoid (StrMap a) where
244244
mempty = empty

0 commit comments

Comments
 (0)