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