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.

  1. tryJust_ :: (SomeException -> Maybe b) -> IO a -> IO (Either b a)

    extra Extra

    Like catch_ but for tryJust

  2. untilJustM :: Monad m => m (Maybe a) -> m a

    extra Extra

    Keep running an operation until it becomes a Just, then return the value inside the Just as the result of the overall loop.

  3. 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
    

  4. whenJustM :: Monad m => m (Maybe a) -> (a -> m ()) -> m ()

    extra Extra

    Like whenJust, but where the test can be monadic.

  5. whileJustM :: (Monad m, Monoid a) => m (Maybe a) -> m a

    extra Extra

    Keep running an operation until it becomes a Nothing, accumulating the monoid results inside the Justs as the result of the overall loop.

  6. breakJust :: (a -> Maybe b) -> [a] -> ([a], Maybe (b, [a]))

    utility-ht Data.List.HT

    forAllMaybeFn $ \f xs -> snd (breakJust f xs) == dropWhileNothing f xs
    

  7. 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')],"---")
    

  8. 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',"---")])
    

  9. spanJust :: (a -> Maybe b) -> [a] -> ([b], [a])

    utility-ht Data.List.HT

    No documentation available.

  10. 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
    

Page 33 of many | Previous | Next