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.
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")]
unsafeFromMap :: IntMap a -> NEIntMap anonempty-containers Data.IntMap.NonEmpty O(log n). Unsafe version of nonEmptyMap. Coerces a IntMap into an NEIntMap, but is undefined (throws a runtime exception when evaluation is attempted) for an empty IntMap.
-
nonempty-containers Data.IntMap.NonEmpty.Internal 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:
- The nonEmptyMap smart constructor will convert a IntMap k a into a Maybe (NEIntMap k a), returning Nothing if the original IntMap was empty.
- You can use the insertIntMap family of functions to insert a value into a IntMap to create a guaranteed NEIntMap.
- 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.
- withNonEmpty offers a continuation-based interface for deconstructing a IntMap and treating it as if it were an NEIntMap.
NEIntMap :: Key -> a -> !IntMap a -> NEIntMap anonempty-containers Data.IntMap.NonEmpty.Internal No documentation available.
foldMapWithKey :: Semigroup m => (Key -> a -> m) -> NEIntMap a -> mnonempty-containers Data.IntMap.NonEmpty.Internal 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.insertMaxMap :: Key -> a -> IntMap a -> IntMap anonempty-containers Data.IntMap.NonEmpty.Internal O(log n). Insert new key and value into a map where keys are strictly less than the new key. That is, the new key must be strictly greater than all keys present in the IntMap. /The precondition is not checked./ At the moment this is simply an alias for Data.IntSet.insert, but it's left here as a placeholder in case this eventually gets implemented in a more efficient way.
insertMinMap :: Key -> a -> IntMap a -> IntMap anonempty-containers Data.IntMap.NonEmpty.Internal O(log n). Insert new key and value into a map where keys are strictly greater than the new key. That is, the new key must be strictly less than all keys present in the IntMap. /The precondition is not checked./ At the moment this is simply an alias for Data.IntSet.insert, but it's left here as a placeholder in case this eventually gets implemented in a more efficient way.