Hoogle Search
Within LTS Haskell 24.56 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
mapMaybeWithKey :: (Key -> a -> Maybe b) -> NEIntMap a -> IntMap bnonempty-containers Data.IntMap.NonEmpty O(n). Map keys/values and collect the Just results. Returns a potentially empty map (IntMap), because the function could potentially return Nothing on all items in the NEIntMap.
let f k _ = if k < 5 then Just ("key : " ++ (show k)) else Nothing mapMaybeWithKey f (fromList ((5,"a") :| [(3,"b")])) == Data.IntMap.singleton 3 "key : 3"deleteMaybe :: Key -> NEIntSet -> Maybe NEIntSetnonempty-containers Data.IntSet.NonEmpty O(log n). Delete an element from a set, returning Nothing if the result would be empty. This is more efficient than nonEmptySet . delete x because it avoids converting the known-minimum representation back through IntSet when the deleted element is not the minimum.
deleteMaybe :: Ord k => k -> NEMap k a -> Maybe (NEMap k a)nonempty-containers Data.Map.NonEmpty O(log n). Delete a key and its value from the non-empty map, returning Nothing if the result would be empty. This is more efficient than nonEmptyMap . delete k because it avoids converting the known-minimum representation back through Map when the deleted key is not the minimum.
mapMaybe :: (a -> Maybe b) -> NEMap k a -> Map k bnonempty-containers Data.Map.NonEmpty O(n). Map values and collect the Just results. Returns a potentially empty map (Map), because the function could potentially return Nothing on all items in the NEMap.
let f x = if x == "a" then Just "new a" else Nothing mapMaybe f (fromList ((5,"a") :| [(3,"b")])) == Data.Map.singleton 5 "new a"
mapMaybeWithKey :: (k -> a -> Maybe b) -> NEMap k a -> Map k bnonempty-containers Data.Map.NonEmpty O(n). Map keys/values and collect the Just results. Returns a potentially empty map (Map), because the function could potentially return Nothing on all items in the NEMap.
let f k _ = if k < 5 then Just ("key : " ++ (show k)) else Nothing mapMaybeWithKey f (fromList ((5,"a") :| [(3,"b")])) == Data.Map.singleton 3 "key : 3"traverseMaybeWithKey :: Applicative t => (k -> a -> t (Maybe b)) -> NEMap k a -> t (Map k b)nonempty-containers Data.Map.NonEmpty O(n). Traverse keys/values and collect the Just results. Returns a potentially empty map (Map), our function might return Nothing on every item in the NEMap. Use traverseMaybeWithKey1 whenever possible (if your Applicative also has Apply instance). This version is provided only for types that do not have Apply instance, since Apply is not at the moment (and might not ever be) an official superclass of Applicative.
traverseMaybeWithKey1 :: Apply t => (k -> a -> t (Maybe b)) -> NEMap k a -> t (Map k b)nonempty-containers Data.Map.NonEmpty O(n). Traverse keys/values and collect the Just results. Returns a potentially empty map (Map), our function might return Nothing on every item in the NEMap. Is more general than traverseWithKey, since works with all Apply, and not just Applicative.
deleteMaybe :: Ord a => a -> NESet a -> Maybe (NESet a)nonempty-containers Data.Set.NonEmpty O(log n). Delete an element from a set, returning Nothing if the result would be empty. This is more efficient than nonEmptySet . delete x because it avoids converting the known-minimum representation back through Set when the deleted element is not the minimum.
newtype
ComposeMaybe (f :: k -> Type) (a :: k)patch Data.Functor.Misc We can't use Compose Maybe instead of ComposeMaybe, because that would make the f parameter have a nominal type role. We need f to be representational so that we can use safe coerce.
ComposeMaybe :: Maybe (f a) -> ComposeMaybe (f :: k -> Type) (a :: k)patch Data.Functor.Misc No documentation available.