This repository was archived by the owner on Oct 4, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +15
-7
lines changed Expand file tree Collapse file tree 4 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -175,7 +175,7 @@ of duplicate keys
175
175
#### ` unions `
176
176
177
177
``` purescript
178
- unions :: forall k v. (Ord k) => List (Map k v) -> Map k v
178
+ unions :: forall k v f . (Ord k, Foldable f ) => f (Map k v) -> Map k v
179
179
```
180
180
181
181
Compute the union of a collection of maps
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ Create a new, empty mutable map
27
27
#### ` peek `
28
28
29
29
``` purescript
30
- peek :: forall a h r. STStrMap h a -> String -> Eff (st :: ST h | r) a
30
+ peek :: forall a h r. STStrMap h a -> String -> Eff (st :: ST h | r) (Maybe a)
31
31
```
32
32
33
33
Get the value for a key in a mutable map
Original file line number Diff line number Diff line change @@ -7,10 +7,14 @@ exports["new"] = function () {
7
7
return { } ;
8
8
} ;
9
9
10
- exports . peek = function ( m ) {
11
- return function ( k ) {
12
- return function ( ) {
13
- return m [ k ] ;
10
+ exports . peekImpl = function ( just ) {
11
+ return function ( nothing ) {
12
+ return function ( m ) {
13
+ return function ( k ) {
14
+ return function ( ) {
15
+ return { } . hasOwnProperty . call ( m , k ) ? just ( m [ k ] ) : nothing ;
16
+ } ;
17
+ } ;
14
18
} ;
15
19
} ;
16
20
} ;
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import Prelude
14
14
15
15
import Control.Monad.Eff (Eff ())
16
16
import Control.Monad.ST (ST ())
17
+ import Data.Maybe (Maybe (..))
17
18
18
19
-- | A reference to a mutable map
19
20
-- |
@@ -26,7 +27,10 @@ foreign import data STStrMap :: * -> * -> *
26
27
foreign import new :: forall a h r . Eff (st :: ST h | r ) (STStrMap h a )
27
28
28
29
-- | Get the value for a key in a mutable map
29
- foreign import peek :: forall a h r . STStrMap h a -> String -> Eff (st :: ST h | r ) a
30
+ peek :: forall a h r . STStrMap h a -> String -> Eff (st :: ST h | r ) (Maybe a )
31
+ peek = peekImpl Just Nothing
32
+
33
+ foreign import peekImpl :: forall a b h r . (a -> b ) -> b -> STStrMap h a -> String -> Eff (st :: ST h | r ) b
30
34
31
35
-- | Update the value for a key in a mutable map
32
36
foreign import poke :: forall a h r . STStrMap h a -> String -> a -> Eff (st :: ST h | r ) (STStrMap h a )
You can’t perform that action at this time.
0 commit comments