Hoogle Search

Within LTS Haskell 24.40 (ghc-9.10.3)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. toMap :: SetMap k a -> Map k (Set a)

    multimap Data.SetMap

    O(1). Return the map of sets.

  2. data NEIntMap a

    nonempty-containers Data.IntMap.NonEmpty

    A non-empty (by construction) map from integer keys to values a. At least one key-value pair exists in an NEIntMap v at all times. Functions that take an NEIntMap can safely operate on it with the assumption that it has at least one key-value pair. Functions that return an NEIntMap provide an assurance that the result has at least one key-value pair. Data.IntMap.NonEmpty re-exports the API of Data.IntMap, faithfully reproducing asymptotics, typeclass constraints, and semantics. Functions that ensure that input and output maps are both non-empty (like insert) return NEIntMap, but functions that might potentially return an empty map (like delete) return a IntMap instead. You can directly construct an NEIntMap with the API from Data.IntMap.NonEmpty; it's more or less the same as constructing a normal IntMap, except you don't have access to empty. There are also a few ways to construct an NEIntMap from a IntMap:

    1. The nonEmptyMap smart constructor will convert a IntMap k a into a Maybe (NEIntMap k a), returning Nothing if the original IntMap was empty.
    2. You can use the insertIntMap family of functions to insert a value into a IntMap to create a guaranteed NEIntMap.
    3. You can use the IsNonEmpty and IsEmpty patterns to "pattern match" on a IntMap to reveal it as either containing a NEIntMap or an empty map.
    4. withNonEmpty offers a continuation-based interface for deconstructing a IntMap and treating it as if it were an NEIntMap.
    You can convert an NEIntMap into a IntMap with toMap or IsNonEmpty, essentially "obscuring" the non-empty property from the type.

  3. foldMapWithKey :: Semigroup m => (Key -> a -> m) -> NEIntMap a -> m

    nonempty-containers Data.IntMap.NonEmpty

    O(n). Fold the keys and values in the map using the given semigroup, such that

    foldMapWithKey f = fold1 . mapWithKey f
    
    WARNING: Differs from Data.IntMap.foldMapWithKey, which traverses positive items first, then negative items. This can be an asymptotically faster than foldrWithKey or foldlWithKey for some monoids.

  4. insertMap :: Key -> a -> IntMap a -> NEIntMap a

    nonempty-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. If key is already present, will overwrite the original value. See insertMapMin for a version that is constant-time if the new key is strictly smaller than all keys in the original map.

    insertMap 4 "c" (Data.IntMap.fromList [(5,"a"), (3,"b")]) == fromList ((3,"b") :| [(4,"c"), (5,"a")])
    insertMap 4 "c" Data.IntMap.empty == singleton 4 "c"
    

  5. insertMapMax :: Key -> a -> IntMap a -> NEIntMap a

    nonempty-containers Data.IntMap.NonEmpty

    O(log n) Convert a IntMap into an NEIntMap by adding a key-value pair where the key is strictly greater than all keys in the input map. The keys in the original map must all be strictly less than the new key. The precondition is not checked. At the current moment, this is identical simply insertMap; however, it is left both for consistency and as a placeholder for a future version where optimizations are implemented to allow for a faster implementation.

    insertMap 7 "c" (Data.IntMap.fromList [(5,"a"), (3,"b")]) == fromList ((3,"b") :| [(5,"a"), (7,"c")])
    

  6. insertMapMin :: Key -> a -> IntMap a -> NEIntMap a

    nonempty-containers Data.IntMap.NonEmpty

    O(1) Convert a IntMap into an NEIntMap by adding a key-value pair where the key is strictly less than all keys in the input map. The keys in the original map must all be strictly greater than the new key. The precondition is not checked.

    insertMapMin 2 "c" (Data.IntMap.fromList [(5,"a"), (3,"b")]) == fromList ((2,"c") :| [(3,"b"), (5,"a")])
    valid (insertMapMin 2 "c" (Data.IntMap.fromList [(5,"a"), (3,"b")])) == True
    valid (insertMapMin 7 "c" (Data.IntMap.fromList [(5,"a"), (3,"b")])) == False
    valid (insertMapMin 3 "c" (Data.IntMap.fromList [(5,"a"), (3,"b")])) == False
    

  7. insertMapWith :: (a -> a -> a) -> Key -> a -> IntMap a -> NEIntMap a

    nonempty-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 new value as the first argument if the key is already present.

    insertMapWith (++) 4 "c" (Data.IntMap.fromList [(5,"a"), (3,"b")]) == fromList ((3,"b") :| [(4,"c"), (5,"a")])
    insertMapWith (++) 5 "c" (Data.IntMap.fromList [(5,"a"), (3,"b")]) == fromList ((3,"b") :| [(5,"ca")])
    

  8. insertMapWithKey :: (Key -> a -> a -> a) -> Key -> a -> IntMap a -> NEIntMap a

    nonempty-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"
    

  9. isProperSubmapOf :: Eq a => NEIntMap a -> NEIntMap a -> Bool

    nonempty-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 (==)).

  10. isProperSubmapOfBy :: (a -> b -> Bool) -> NEIntMap a -> NEIntMap b -> Bool

    nonempty-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)]))
    

Page 954 of many | Previous | Next