Skip to content

Commit 480a65a

Browse files
committed
initial updates for 0.12
1 parent e424494 commit 480a65a

File tree

5 files changed

+28
-35
lines changed

5 files changed

+28
-35
lines changed

bower.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
"package.json"
2222
],
2323
"dependencies": {
24-
"purescript-arrays": "^4.0.0",
25-
"purescript-functions": "^3.0.0",
26-
"purescript-lists": "^4.0.0",
27-
"purescript-st": "^3.0.0",
28-
"purescript-gen": "^1.1.0",
29-
"purescript-foldable-traversable": "^3.6.1"
24+
"purescript-arrays": "#compiler/0.12",
25+
"purescript-functions": "#compiler/0.12",
26+
"purescript-lists": "#compiler/0.12",
27+
"purescript-st": "#compiler/0.12",
28+
"purescript-gen": "#compiler/0.12",
29+
"purescript-foldable-traversable": "#compiler/0.12"
3030
},
3131
"devDependencies": {
3232
"purescript-quickcheck": "^4.0.0",

src/Data/Map.purs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ import Data.FunctorWithIndex (class FunctorWithIndex, mapWithIndex)
4949
import Data.List (List(..), (:), length, nub)
5050
import Data.List.Lazy as LL
5151
import Data.Maybe (Maybe(..), maybe, isJust, fromMaybe)
52-
import Data.Monoid (class Monoid, mempty)
5352
import Data.Ord (class Ord1)
5453
import Data.Traversable (traverse, class Traversable)
5554
import Data.TraversableWithIndex (class TraversableWithIndex, traverseWithIndex)
@@ -109,7 +108,7 @@ instance foldableWithIndexMap :: FoldableWithIndex k (Map k) where
109108
foldMapWithIndex f m = foldMap (uncurry f) $ asList $ toUnfoldable m
110109

111110
asList :: forall k v. List (Tuple k v) -> List (Tuple k v)
112-
asList = id
111+
asList = identity
113112

114113
instance traversableMap :: Traversable (Map k) where
115114
traverse f Leaf = pure Leaf
@@ -126,7 +125,7 @@ instance traversableMap :: Traversable (Map k) where
126125
<*> pure k2
127126
<*> f v2
128127
<*> traverse f right
129-
sequence = traverse id
128+
sequence = traverse identity
130129

131130
instance traversableWithIndexMap :: TraversableWithIndex k (Map k) where
132131
traverseWithIndex f Leaf = pure Leaf

src/Data/StrMap.purs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,14 @@ module Data.StrMap
4444

4545
import Prelude
4646

47-
import Control.Monad.Eff (Eff, runPure, foreachE)
48-
import Control.Monad.ST as ST
49-
47+
import Control.Monad.ST (ST)
5048
import Data.Array as A
5149
import Data.Eq (class Eq1)
5250
import Data.Foldable (class Foldable, foldl, foldr, for_)
5351
import Data.FoldableWithIndex (class FoldableWithIndex)
5452
import Data.Function.Uncurried (Fn2, runFn2, Fn4, runFn4)
5553
import Data.FunctorWithIndex (class FunctorWithIndex)
5654
import Data.Maybe (Maybe(..), maybe, fromMaybe)
57-
import Data.Monoid (class Monoid, mempty)
5855
import Data.StrMap.ST as SM
5956
import Data.Traversable (class Traversable, traverse)
6057
import Data.TraversableWithIndex (class TraversableWithIndex, traverseWithIndex)
@@ -64,26 +61,26 @@ import Data.Unfoldable (class Unfoldable)
6461
-- | `StrMap a` represents a map from `String`s to values of type `a`.
6562
foreign import data StrMap :: Type -> Type
6663

67-
foreign import _copyEff :: forall a b h r. a -> Eff (st :: ST.ST h | r) b
64+
foreign import _copyEff :: forall a b h. a -> ST h b
6865

6966
-- | Convert an immutable map into a mutable map
70-
thawST :: forall a h r. StrMap a -> Eff (st :: ST.ST h | r) (SM.STStrMap h a)
67+
thawST :: forall a h. StrMap a -> ST h (SM.STStrMap h a)
7168
thawST = _copyEff
7269

7370
-- | Convert a mutable map into an immutable map
74-
freezeST :: forall a h r. SM.STStrMap h a -> Eff (st :: ST.ST h | r) (StrMap a)
71+
freezeST :: forall a h. SM.STStrMap h a -> ST h (StrMap a)
7572
freezeST = _copyEff
7673

7774
-- | Freeze a mutable map, creating an immutable map. Use this function as you would use
7875
-- | `Prelude.runST` to freeze a mutable reference.
7976
-- |
8077
-- | The rank-2 type prevents the map from escaping the scope of `runST`.
81-
foreign import runST :: forall a r. (forall h. Eff (st :: ST.ST h | r) (SM.STStrMap h a)) -> Eff r (StrMap a)
78+
foreign import runST :: forall a. (forall h. ST h (SM.STStrMap h a)) -> StrMap a
8279

83-
pureST :: forall a. (forall h e. Eff (st :: ST.ST h | e) (SM.STStrMap h a)) -> StrMap a
84-
pureST f = runPure (runST f)
80+
pureST :: forall a. (forall h e. ST h (SM.STStrMap h a)) -> StrMap a
81+
pureST = runST
8582

86-
mutate :: forall a b. (forall h e. SM.STStrMap h a -> Eff (st :: ST.ST h | e) b) -> StrMap a -> StrMap a
83+
mutate :: forall a b. (forall h. SM.STStrMap h a -> ST h b) -> StrMap a -> StrMap a
8784
mutate f m = pureST do
8885
s <- thawST m
8986
_ <- f s
@@ -125,7 +122,7 @@ instance foldableWithIndexStrMap :: FoldableWithIndex String StrMap where
125122

126123
instance traversableStrMap :: Traversable StrMap where
127124
traverse = traverseWithIndex <<< const
128-
sequence = traverse id
125+
sequence = traverse identity
129126

130127
instance traversableWithIndexStrMap :: TraversableWithIndex String StrMap where
131128
traverseWithIndex f ms =
@@ -222,10 +219,10 @@ update f k m = alter (maybe Nothing f) k m
222219
fromFoldable :: forall f a. Foldable f => f (Tuple String a) -> StrMap a
223220
fromFoldable l = pureST do
224221
s <- SM.new
225-
foreachE (A.fromFoldable l) \(Tuple k v) -> void (SM.poke s k v)
222+
for_ (A.fromFoldable l) \(Tuple k v) -> void (SM.poke s k v)
226223
pure s
227224

228-
foreign import _lookupST :: forall a h r z. Fn4 z (a -> z) String (SM.STStrMap h a) (Eff (st :: ST.ST h | r) z)
225+
foreign import _lookupST :: forall a h z. Fn4 z (a -> z) String (SM.STStrMap h a) (ST h z)
229226

230227
-- | Create a map from a foldable collection of key/value pairs, using the
231228
-- | specified function to combine values for duplicate keys.
@@ -283,7 +280,7 @@ instance monoidStrMap :: (Semigroup a) => Monoid (StrMap a) where
283280
filterWithKey :: forall a. (String -> a -> Boolean) -> StrMap a -> StrMap a
284281
filterWithKey predicate m = pureST go
285282
where
286-
go :: forall h e. Eff (st :: ST.ST h | e) (SM.STStrMap h a)
283+
go :: forall h. ST h (SM.STStrMap h a)
287284
go = do
288285
m' <- SM.new
289286
foldM step m' m

src/Data/StrMap/ST.purs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,27 @@ module Data.StrMap.ST
1010
, delete
1111
) where
1212

13-
import Control.Monad.Eff (Eff)
14-
import Control.Monad.ST (ST)
13+
import Control.Monad.ST (ST, kind Region)
1514
import Data.Maybe (Maybe(..))
1615

1716
-- | A reference to a mutable map
1817
-- |
1918
-- | The first type parameter represents the memory region which the map belongs to. The second type parameter defines the type of elements of the mutable array.
2019
-- |
2120
-- | The runtime representation of a value of type `STStrMap h a` is the same as that of `StrMap a`, except that mutation is allowed.
22-
foreign import data STStrMap :: Type -> Type -> Type
21+
foreign import data STStrMap :: Region -> Type -> Type
2322

2423
-- | Create a new, empty mutable map
25-
foreign import new :: forall a h r. Eff (st :: ST h | r) (STStrMap h a)
24+
foreign import new :: forall a h. ST h (STStrMap h a)
2625

2726
-- | Get the value for a key in a mutable map
28-
peek :: forall a h r. STStrMap h a -> String -> Eff (st :: ST h | r) (Maybe a)
27+
peek :: forall a h. STStrMap h a -> String -> ST h (Maybe a)
2928
peek = peekImpl Just Nothing
3029

31-
foreign import peekImpl :: forall a b h r. (a -> b) -> b -> STStrMap h a -> String -> Eff (st :: ST h | r) b
30+
foreign import peekImpl :: forall a b h. (a -> b) -> b -> STStrMap h a -> String -> ST h b
3231

3332
-- | Update the value for a key in a mutable map
34-
foreign import poke :: forall a h r. STStrMap h a -> String -> a -> Eff (st :: ST h | r) (STStrMap h a)
33+
foreign import poke :: forall a h. STStrMap h a -> String -> a -> ST h (STStrMap h a)
3534

3635
-- | Remove a key and the corresponding value from a mutable map
37-
foreign import delete :: forall a h r. STStrMap h a -> String -> Eff (st :: ST h | r) (STStrMap h a)
36+
foreign import delete :: forall a h. STStrMap h a -> String -> ST h (STStrMap h a)

src/Data/StrMap/ST/Unsafe.purs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
module Data.StrMap.ST.Unsafe where
22

3-
import Control.Monad.Eff (Eff)
4-
import Control.Monad.ST (ST)
53
import Data.StrMap (StrMap)
64
import Data.StrMap.ST (STStrMap)
75

86
-- | Unsafely get the map out of ST without copying it
97
-- |
108
-- | If you later change the ST version of the map the pure value will also change.
11-
foreign import unsafeFreeze :: forall a h r. STStrMap h a -> Eff (st :: ST h | r) (StrMap a)
9+
foreign import unsafeFreeze :: forall a h. STStrMap h a -> StrMap a

0 commit comments

Comments
 (0)