Hoogle Search
Within LTS Haskell 24.20 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
-
mono-traversable Data.Containers Equivalent to adjustMap, but the function accepts the key, as well as the previous value.
-
strict Data.Strict.Maybe Extracts the element out of a Just and throws an error if the argument is Nothing.
-
strict Data.Strict.Maybe Yields True iff the argument is of the form Just _.
untilJust :: Monad m => m (Maybe a) -> m amonad-loops Control.Monad.Loops Run the supplied Maybe computation repeatedly until it returns a value. Returns that value.
whileJust :: Monad m => m (Maybe a) -> (a -> m b) -> m [b]monad-loops Control.Monad.Loops As long as the supplied Maybe expression returns "Just _", the loop body will be called and passed the value contained in the Just. Results are collected into a list.
whileJust' :: (Monad m, MonadPlus f) => m (Maybe a) -> (a -> m b) -> m (f b)monad-loops Control.Monad.Loops As long as the supplied Maybe expression returns "Just _", the loop body will be called and passed the value contained in the Just. Results are collected into an arbitrary MonadPlus container.
whileJust_ :: Monad m => m (Maybe a) -> (a -> m b) -> m ()monad-loops Control.Monad.Loops As long as the supplied Maybe expression returns "Just _", the loop body will be called and passed the value contained in the Just. Results are discarded.
adjust :: (Eq k, Hashable k) => (v -> v) -> k -> HashMap k v -> HashMap k vrio RIO.HashMap Adjust the value tied to a given key in this map only if it is present. Otherwise, leave the map alone.
_Just :: forall a a' f . Applicative f => (a -> f a') -> Maybe a -> f (Maybe a')rio RIO.Lens _Just targets the value contained in a Maybe, provided it's a Just. See documentation for _Left (as these 2 are pretty similar). In particular, it can be used to write these:
- Unsafely extracting a value from a Just:
fromJust = (^?! _Just)
- Checking whether a value is a Just:
isJust = has _Just
- Converting a Maybe to a list (empty or consisting of a single element):
maybeToList = (^.. _Just)
- Gathering all Justs in a list:
catMaybes = (^.. each . _Just)
adjust :: Ord k => (a -> a) -> k -> Map k a -> Map k ario RIO.Map Update a value at a specific key with the result of the provided function. When the key is not a member of the map, the original map is returned.
adjust ("new " ++) 5 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "new a")] adjust ("new " ++) 7 (fromList [(5,"a"), (3,"b")]) == fromList [(3, "b"), (5, "a")] adjust ("new " ++) 7 empty == empty