HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleutility-ht-0.0.17.2Haskell98

Data.List.Reverse.StrictSpine

The functions in this module process the list from the end. They do not access elements at the beginning if not necessary. You can apply the function only to finite lists. Use these functions if the list is short and the test is expensive.

  • 3 values
Example8 expressions
import Test.Utility (forAllPredicates, defined)import qualified Data.List.Reverse.StrictSpine as Revimport qualified Data.List.Match as Matchimport qualified Data.List as Listimport Data.Tuple.HT (mapFst, mapPair, swap)_suppressUnusedImportWarning :: (a -> Bool) -> [a] -> [a]_suppressUnusedImportWarning = Data.List.Reverse.StrictSpine.dropWhile
valuedropWhile :: (a -> Bool) -> [a] -> [a]
#
Property
forAllPredicates $ \p xs -> Rev.dropWhile p xs == reverse (List.dropWhile p (reverse xs))
Property
\x xs pad -> defined $ length $ Rev.dropWhile ((x::Char)/=) $ Match.replicate (pad::[()]) undefined ++ x:xs
valuetakeWhile :: (a -> Bool) -> [a] -> [a]
#
Property
forAllPredicates $ \p xs -> Rev.takeWhile p xs == reverse (List.takeWhile p (reverse xs))
Property
\x xs pad -> defined $ Rev.takeWhile ((x::Char)/=) $ Match.replicate (pad::[()]) undefined ++ x:xs
valuespan :: (a -> Bool) -> [a] -> ([a], [a])
#
Property
forAllPredicates $ \p xs -> Rev.span p xs == swap (mapPair (reverse, reverse) (List.span p (reverse xs)))
Property
forAllPredicates $ \p xs -> Rev.span p xs == (Rev.dropWhile p xs, Rev.takeWhile p xs)
Property
\x xs pad -> defined $ mapFst length $ Rev.span ((x::Char)/=) $ Match.replicate (pad::[()]) undefined ++ x:xs