@@ -434,6 +434,8 @@ infixl 9 !,!?,\\ --
434
434
-- | \(O(\log n)\). Find the value at a key.
435
435
-- Calls 'error' when the element can not be found.
436
436
--
437
+ -- __Note__: This function is partial. Prefer '!?'.
438
+ --
437
439
-- > fromList [(5,'a'), (3,'b')] ! 1 Error: element not in the map
438
440
-- > fromList [(5,'a'), (3,'b')] ! 5 == 'a'
439
441
@@ -621,8 +623,6 @@ notMember k m = not $ member k m
621
623
{-# INLINE notMember #-}
622
624
#endif
623
625
624
- -- | \(O(\log n)\). Find the value at a key.
625
- -- Calls 'error' when the element can not be found.
626
626
find :: Ord k => k -> Map k a -> a
627
627
find = go
628
628
where
@@ -1454,6 +1454,8 @@ alterFYoneda = go
1454
1454
-- including, the 'size' of the map. Calls 'error' when the key is not
1455
1455
-- a 'member' of the map.
1456
1456
--
1457
+ -- __Note__: This function is partial. Prefer 'lookupIndex'.
1458
+ --
1457
1459
-- > findIndex 2 (fromList [(5,"a"), (3,"b")]) Error: element is not in the map
1458
1460
-- > findIndex 3 (fromList [(5,"a"), (3,"b")]) == 0
1459
1461
-- > findIndex 5 (fromList [(5,"a"), (3,"b")]) == 1
@@ -1500,6 +1502,8 @@ lookupIndex = go 0
1500
1502
-- index in the sequence sorted by keys. If the /index/ is out of range (less
1501
1503
-- than zero, greater or equal to 'size' of the map), 'error' is called.
1502
1504
--
1505
+ -- __Note__: This function is partial.
1506
+ --
1503
1507
-- > elemAt 0 (fromList [(5,"a"), (3,"b")]) == (3,"b")
1504
1508
-- > elemAt 1 (fromList [(5,"a"), (3,"b")]) == (5, "a")
1505
1509
-- > elemAt 2 (fromList [(5,"a"), (3,"b")]) Error: index out of range
@@ -1584,6 +1588,8 @@ splitAt i0 m0
1584
1588
-- the sequence sorted by keys. If the /index/ is out of range (less than zero,
1585
1589
-- greater or equal to 'size' of the map), 'error' is called.
1586
1590
--
1591
+ -- __Note__: This function is partial.
1592
+ --
1587
1593
-- > updateAt (\ _ _ -> Just "x") 0 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "x"), (5, "a")]
1588
1594
-- > updateAt (\ _ _ -> Just "x") 1 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "x")]
1589
1595
-- > updateAt (\ _ _ -> Just "x") 2 (fromList [(5,"a"), (3,"b")]) Error: index out of range
@@ -1610,6 +1616,8 @@ updateAt f !i t =
1610
1616
-- the sequence sorted by keys. If the /index/ is out of range (less than zero,
1611
1617
-- greater or equal to 'size' of the map), 'error' is called.
1612
1618
--
1619
+ -- __Note__: This function is partial.
1620
+ --
1613
1621
-- > deleteAt 0 (fromList [(5,"a"), (3,"b")]) == singleton 5 "a"
1614
1622
-- > deleteAt 1 (fromList [(5,"a"), (3,"b")]) == singleton 3 "b"
1615
1623
-- > deleteAt 2 (fromList [(5,"a"), (3,"b")]) Error: index out of range
@@ -1667,6 +1675,8 @@ lookupMin (Bin _ k x l _) = Just $! kvToTuple (lookupMinSure k x l)
1667
1675
1668
1676
-- | \(O(\log n)\). The minimal key of the map. Calls 'error' if the map is empty.
1669
1677
--
1678
+ -- __Note__: This function is partial. Prefer 'lookupMin'.
1679
+ --
1670
1680
-- > findMin (fromList [(5,"a"), (3,"b")]) == (3,"b")
1671
1681
-- > findMin empty Error: empty map has no minimal element
1672
1682
@@ -1693,6 +1703,8 @@ lookupMax (Bin _ k x _ r) = Just $! kvToTuple (lookupMaxSure k x r)
1693
1703
1694
1704
-- | \(O(\log n)\). The maximal key of the map. Calls 'error' if the map is empty.
1695
1705
--
1706
+ -- __Note__: This function is partial. Prefer 'lookupMax'.
1707
+ --
1696
1708
-- > findMax (fromList [(5,"a"), (3,"b")]) == (5,"a")
1697
1709
-- > findMax empty Error: empty map has no maximal element
1698
1710
@@ -4105,19 +4117,19 @@ maxViewSure !k x !l r = case r of
4105
4117
4106
4118
-- | \(O(\log n)\). Delete and find the minimal element.
4107
4119
--
4108
- -- > deleteFindMin (fromList [(5,"a"), (3,"b"), (10,"c")]) == ((3,"b"), fromList[(5,"a"), (10,"c")])
4109
- -- > deleteFindMin empty Error: can not return the minimal element of an empty map
4110
-
4120
+ -- Calls 'error' if the map is empty.
4121
+ --
4122
+ -- __Note__: This function is partial. Prefer 'minViewWithKey'.
4111
4123
deleteFindMin :: Map k a -> ((k ,a ),Map k a )
4112
4124
deleteFindMin t = case minViewWithKey t of
4113
4125
Nothing -> (error " Map.deleteFindMin: can not return the minimal element of an empty map" , Tip )
4114
4126
Just res -> res
4115
4127
4116
4128
-- | \(O(\log n)\). Delete and find the maximal element.
4117
4129
--
4118
- -- > deleteFindMax (fromList [(5,"a"), (3,"b"), (10,"c")]) == ((10,"c"), fromList [(3,"b"), (5,"a")])
4119
- -- > deleteFindMax empty Error: can not return the maximal element of an empty map
4120
-
4130
+ -- Calls 'error' if the map is empty.
4131
+ --
4132
+ -- __Note__: This function is partial. Prefer 'maxViewWithKey'.
4121
4133
deleteFindMax :: Map k a -> ((k ,a ),Map k a )
4122
4134
deleteFindMax t = case maxViewWithKey t of
4123
4135
Nothing -> (error " Map.deleteFindMax: can not return the maximal element of an empty map" , Tip )
0 commit comments