Skip to content

Commit 6261871

Browse files
committed
Add docs for newly added (since 0.2.11) HashMap.!?.
1 parent 3269b19 commit 6261871

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

docs/hash-map.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,13 @@ Lookup an entry in the map (lookup)
229229
HashMap.lookup :: k -> HashMap k v -> Maybe v
230230
HashMap.lookup key m = ...
231231

232+
HashMap.!? :: HashMap k v -> k -> Maybe v
233+
HashMap.!? m key = ...
234+
232235
:haddock_short:`/Data.HashMap.Strict#lookup` the value corresponding to the given
233-
``key``, returns ``Nothing`` if the key is not present.
236+
``key``, returns ``Nothing`` if the key is not present. The ``!?`` operator
237+
(*since 0.2.11*) is a flipped version of ``lookup`` and can often be imported
238+
unqualified.
234239

235240
If you want to provide a default value if the key doesn't exist you can use:
236241

@@ -247,6 +252,9 @@ For example::
247252
HashMap.lookup 1 (HashMap.fromList [(1,"one"),(2,"two"),(3,"three")])
248253
> Just "one"
249254

255+
(HashMap.fromList [(1,"one"),(2,"two"),(3,"three")]) !? 1
256+
> Just "one"
257+
250258
HashMap.lookupDefault "?" k HashMap.empty
251259
> "?"
252260

0 commit comments

Comments
 (0)