Hoogle Search
Within LTS Haskell 24.68 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
insertMapWithKey :: (Key -> a -> a -> a) -> Key -> a -> IntMap a -> NEIntMap anonempty-containers Data.IntMap.NonEmpty O(log n). Convert a IntMap into an NEIntMap by adding a key-value pair. Because of this, we know that the map must have at least one element, and so therefore cannot be empty. Uses a combining function with the key and new value as the first and second arguments if the key is already present.
let f key new_value old_value = (show key) ++ ":" ++ new_value ++ "|" ++ old_value insertWithKey f 5 "xxx" (Data.IntMap.fromList [(5,"a"), (3,"b")]) == fromList ((3, "b") :| [(5, "5:xxx|a")]) insertWithKey f 7 "xxx" (Data.IntMap.fromList [(5,"a"), (3,"b")]) == fromList ((3, "b") :| [(5, "a"), (7, "xxx")]) insertWithKey f 5 "xxx" Data.IntMap.empty == singleton 5 "xxx"
isProperSubmapOf :: Eq a => NEIntMap a -> NEIntMap a -> Boolnonempty-containers Data.IntMap.NonEmpty O(m*log(n/m + 1)), m <= n. Is this a proper submap? (ie. a submap but not equal). Defined as (isProperSubmapOf = isProperSubmapOfBy (==)).
isProperSubmapOfBy :: (a -> b -> Bool) -> NEIntMap a -> NEIntMap b -> Boolnonempty-containers Data.IntMap.NonEmpty O(m*log(n/m + 1)), m <= n. Is this a proper submap? (ie. a submap but not equal). The expression (isProperSubmapOfBy f m1 m2) returns True when m1 and m2 are not equal, all keys in m1 are in m2, and when f returns True when applied to their respective values. For example, the following expressions are all True:
isProperSubmapOfBy (==) (singleton 1 1) (fromList ((1,1) :| [(2,2)])) isProperSubmapOfBy (<=) (singleton 1 1) (fromList ((1,1) :| [(2,2)]))
But the following are all False:isProperSubmapOfBy (==) (fromList ((1,1) :| [(2,2)])) (fromList ((1,1) :| [(2,2)])) isProperSubmapOfBy (==) (fromList ((1,1) :| [(2,2)])) (singleton 1 1)) isProperSubmapOfBy (<) (singleton 1 1) (fromList ((1,1) :| [(2,2)]))
isSubmapOf :: Eq a => NEIntMap a -> NEIntMap a -> Boolnonempty-containers Data.IntMap.NonEmpty O(m*log(n/m + 1)), m <= n. This function is defined as (isSubmapOf = isSubmapOfBy (==)).
isSubmapOfBy :: (a -> b -> Bool) -> NEIntMap a -> NEIntMap b -> Boolnonempty-containers Data.IntMap.NonEmpty O(m*log(n/m + 1)), m <= n. The expression (isSubmapOfBy f t1 t2) returns True if all keys in t1 are in tree t2, and when f returns True when applied to their respective values. For example, the following expressions are all True:
isSubmapOfBy (==) (singleton 'a' 1) (fromList (('a',1) :| [('b',2)])) isSubmapOfBy (<=) (singleton 'a' 1) (fromList (('a',1) :| [('b',2)])) isSubmapOfBy (==) (fromList (('a',1) :| [('b',2)])) (fromList (('a',1) :| [('b',2)]))But the following are all False:isSubmapOfBy (==) (singleton 'a' 2) (fromList (('a',1) :| [('b',2)])) isSubmapOfBy (<) (singleton 'a' 1) (fromList (('a',1) :| [('b',2)])) isSubmapOfBy (==) (fromList (('a',1) :| [('b',2)])) (singleton 'a' 1)nonEmptyMap :: IntMap a -> Maybe (NEIntMap a)nonempty-containers Data.IntMap.NonEmpty O(log n). Smart constructor for an NEIntMap from a IntMap. Returns Nothing if the IntMap was originally actually empty, and Just n with an NEIntMap, if the IntMap was not empty. nonEmptyMap and maybe empty toMap form an isomorphism: they are perfect structure-preserving inverses of eachother. See IsNonEmpty for a pattern synonym that lets you "match on" the possiblity of a IntMap being an NEIntMap.
nonEmptyMap (Data.IntMap.fromList [(3,"a"), (5,"b")]) == Just (fromList ((3,"a") :| [(5,"b")]))
toMap :: NEIntMap a -> IntMap anonempty-containers Data.IntMap.NonEmpty O(log n). Convert a non-empty map back into a normal possibly-empty map, for usage with functions that expect IntMap. Can be thought of as "obscuring" the non-emptiness of the map in its type. See the IsNotEmpty pattern. nonEmptyMap and maybe empty toMap form an isomorphism: they are perfect structure-preserving inverses of eachother.
toMap (fromList ((3,"a") :| [(5,"b")])) == Data.IntMap.fromList [(3,"a"), (5,"b")]
unionMapLeft :: IntMap a -> NEIntMap a -> NEIntMap anonempty-containers Data.IntMap.NonEmpty O(m*log(n/m + 1)), m <= n. Left-biased union of a possibly-empty IntMap and a non-empty map.
unionMapRight :: NEIntMap a -> IntMap a -> NEIntMap anonempty-containers Data.IntMap.NonEmpty O(m*log(n/m + 1)), m <= n. Left-biased union of a non-empty map and a possibly-empty IntMap.
unionMapWithKeyLeft :: (Key -> a -> a -> a) -> IntMap a -> NEIntMap a -> NEIntMap anonempty-containers Data.IntMap.NonEmpty O(m*log(n/m + 1)), m <= n. Union of a possibly-empty IntMap and a non-empty map with a combining function, given the matching key.