Hoogle Search
Within LTS Haskell 24.38 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
tryJust_ :: (SomeException -> Maybe b) -> IO a -> IO (Either b a)extra Extra untilJustM :: Monad m => m (Maybe a) -> m aextra Extra Keep running an operation until it becomes a Just, then return the value inside the Just as the result of the overall loop.
whenJust :: Applicative m => Maybe a -> (a -> m ()) -> m ()extra Extra Perform some operation on Just, given the field inside the Just. This is a specialized for_.
whenJust Nothing print == pure () whenJust (Just 1) print == print 1
whenJustM :: Monad m => m (Maybe a) -> (a -> m ()) -> m ()extra Extra Like whenJust, but where the test can be monadic.
whileJustM :: (Monad m, Monoid a) => m (Maybe a) -> m aextra Extra Keep running an operation until it becomes a Nothing, accumulating the monoid results inside the Justs as the result of the overall loop.
breakJust :: (a -> Maybe b) -> [a] -> ([a], Maybe (b, [a]))utility-ht Data.List.HT forAllMaybeFn $ \f xs -> snd (breakJust f xs) == dropWhileNothing f xs
segmentAfterJust :: (a -> Maybe b) -> [a] -> ([([a], b)], [a])utility-ht Data.List.HT >>> segmentAfterJust (\c -> toMaybe (isLetter c) (toUpper c)) "123a5345b---" ([("123",'A'),("5345",'B')],"---")segmentBeforeJust :: (a -> Maybe b) -> [a] -> ([a], [(b, [a])])utility-ht Data.List.HT >>> segmentBeforeJust (\c -> toMaybe (isLetter c) (toUpper c)) "123a5345b---" ("123",[('A',"5345"),('B',"---")])spanJust :: (a -> Maybe b) -> [a] -> ([b], [a])utility-ht Data.List.HT No documentation available.
takeWhileJust :: [Maybe a] -> [a]utility-ht Data.List.HT This is the cousin of takeWhile analogously to catMaybes being the cousin of filter.
>>> takeWhileJust [Just 'a', Just 'b', Nothing, Just 'c'] "ab"
Example: Keep the heads of sublists until an empty list occurs.>>> takeWhileJust $ map (fmap fst . viewL) ["abc","def","","xyz"] "ad"
For consistency with takeWhile, partitionMaybe and dropWhileNothing it should have been:takeWhileJust_ :: (a -> Maybe b) -> a -> [b]
However, both variants are interchangeable:takeWhileJust_ f == takeWhileJust . map f takeWhileJust == takeWhileJust_ id