takeWhile package:utility-ht
Alternative version of
reverse . takeWhile p . reverse.
forAllPredicates $ \p xs -> Rev.takeWhile p xs == reverse (List.takeWhile p (reverse xs))
forAllPredicates $ \p xs -> Rev.takeWhile p xs == reverse (List.takeWhile p (reverse xs))
\x xs pad -> defined $ Rev.takeWhile ((x::Char)/=) $ Match.replicate (pad::[()]) undefined ++ x:xs
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
Take while first predicate holds, then continue taking while second
predicate holds, and so on.
Deprecated: Use takeWhile from Data.List.Reverse.StrictElement or
Data.List.Reverse.StrictSpine instead