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
175175#### ` unions `
176176
177177``` 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
179179```
180180
181181Compute 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
2727#### ` peek `
2828
2929``` 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)
3131```
3232
3333Get 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 () {
77 return { } ;
88} ;
99
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+ } ;
1418 } ;
1519 } ;
1620} ;
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import Prelude
1414
1515import Control.Monad.Eff (Eff ())
1616import Control.Monad.ST (ST ())
17+ import Data.Maybe (Maybe (..))
1718
1819-- | A reference to a mutable map
1920-- |
@@ -26,7 +27,10 @@ foreign import data STStrMap :: * -> * -> *
2627foreign import new :: forall a h r . Eff (st :: ST h | r ) (STStrMap h a )
2728
2829-- | 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
3034
3135-- | Update the value for a key in a mutable map
3236foreign 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