A bug of dropWhileR in Data.Sequence
The document of dropWhileR says: dropWhileR p xs is equivalent to reverse (dropWhileL p (reverse xs)).
However,
reverse $ dropWhileL (==4) $ reverse $ fromList [1,2,3,4]
==> fromList [1,2,3]
dropWhileR (==4) $ fromList [1,2,3,4]
==> fromList [1,2]
I guess the cause of bug is in breakl.
Original:
breakl p xs = foldr (\ i _ -> S.splitAt i xs) (xs, empty) (findIndicesL p xs)
Fixed:
breakl p xs = foldr (\ i _ -> S.splitAt (i+1) xs) (xs, empty) (findIndicesL p xs)