hunk ./src/Data/List/HT/Private.hs 197
-breakAfter p =
+breakAfter = breakAfterRec
+
+breakAfterRec :: (a -> Bool) -> [a] -> ([a], [a])
+breakAfterRec p =
hunk ./src/Data/List/HT/Private.hs 209
+{-
+The use of 'foldr' might allow for fusion,
+but unfortunately this simple implementation would copy the tail of the list.
+-}
+breakAfterFoldr :: (a -> Bool) -> [a] -> ([a], [a])
+breakAfterFoldr p =
+ forcePair .
+ foldr
+ (\x yzs -> mapFst (x:) $ if p x then ([], uncurry (++) yzs) else yzs)
+ ([],[])
+
+breakAfterBreak :: (a -> Bool) -> [a] -> ([a], [a])
+breakAfterBreak p xs =
+ case break p xs of
+ (ys, []) -> (ys, [])
+ (ys, z:zs) -> (ys++[z], zs)
+
hunk ./src/Test/Data/List.hs 45
+breakAfterAppend :: (Eq a) => (a -> Bool) -> [a] -> Bool
+breakAfterAppend p xs =
+ uncurry (++) (ListHT.breakAfter p xs) == xs
+
+breakAfter0 :: (Eq a) => (a -> Bool) -> [a] -> Bool
+breakAfter0 p xs =
+ ListHT.breakAfterRec p xs == ListHT.breakAfterFoldr p xs
+
+breakAfter1 :: (Eq a) => (a -> Bool) -> [a] -> Bool
+breakAfter1 p xs =
+ ListHT.breakAfterRec p xs == ListHT.breakAfterBreak p xs
+
hunk ./src/Test/Data/List.hs 133
+ ("breakAfterAppend", elemCheck (\a -> breakAfterAppend (a>=))) :
+ ("breakAfter0", elemCheck (\a -> breakAfter0 (a>=))) :
+ ("breakAfter1", elemCheck (\a -> breakAfter1 (a>=))) :
hunk ./src/Data/List/HT.hs 14
+ L.takeUntil,
hunk ./src/Data/List/HT/Private.hs 226
+breakAfterTakeUntil :: (a -> Bool) -> [a] -> ([a], [a])
+breakAfterTakeUntil p xs =
+ forcePair $
+ (\ys -> (map fst ys, maybe [] (snd . snd) $ viewR ys)) $
+ takeUntil (p . fst) $ zip xs $ tail $ tails xs
+
+{- |
+Take all elements until one matches.
+The matching element is returned, too.
+This is the key difference to @takeWhile (not . p)@.
+It holds @takeUntil p xs == fst (breakAfter p xs)@.
+-}
+takeUntil :: (a -> Bool) -> [a] -> [a]
+takeUntil p = foldr (\x ys -> x : if p x then [] else ys) []
+
hunk ./src/Test/Data/List.hs 57
+breakAfter2 :: (Eq a) => (a -> Bool) -> [a] -> Bool
+breakAfter2 p xs =
+ ListHT.breakAfterRec p xs == ListHT.breakAfterTakeUntil p xs
+
+breakAfterUntil :: (Eq a) => (a -> Bool) -> [a] -> Bool
+breakAfterUntil p xs =
+ ListHT.takeUntil p xs == fst (ListHT.breakAfter p xs)
+
+
hunk ./src/Test/Data/List.hs 145
+ ("breakAfter2", elemCheck (\a -> breakAfter2 (a>=))) :
+ ("breakAfterUntil", elemCheck (\a -> breakAfterUntil (a>=))) :
hunk ./src/Test/Data/List.hs 15
-takeWhileRev0 :: (Ord a) => (a -> Bool) -> [a] -> Bool
+takeWhileRev0 :: (Eq a) => (a -> Bool) -> [a] -> Bool
hunk ./src/Test/Data/List.hs 19
-takeWhileRev1 :: (Ord a) => (a -> Bool) -> [a] -> Bool
+takeWhileRev1 :: (Eq a) => (a -> Bool) -> [a] -> Bool
hunk ./src/Test/Data/List.hs 23
-takeWhileRev2 :: (Ord a) => (a -> Bool) -> [a] -> Bool
+takeWhileRev2 :: (Eq a) => (a -> Bool) -> [a] -> Bool
hunk ./src/Test/Data/List.hs 27
-dropWhileRev :: (Ord a) => (a -> Bool) -> [a] -> Bool
+dropWhileRev :: (Eq a) => (a -> Bool) -> [a] -> Bool
changepref test
runhaskell Setup configure --user --enable-tests && runhaskell Setup build && runhaskell Setup haddock && runhaskell Setup test --show-details=always
runhaskell Setup configure --user --enable-tests && runhaskell Setup build && runhaskell Setup haddock && runhaskell Setup test --show-details=streaming