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.Match

  • 10 values
valuetake :: [b] -> [a] -> [a]
#

Make a list as long as another one

Property
\(Shape xs) (List ys) -> Match.take xs ys == List.take (length xs) ys
valuedrop :: [b] -> [a] -> [a]
#

Drop as many elements as the first list is long

Property
\(Shape xs) (List ys) -> Match.drop xs ys == List.drop (length xs) ys
Property
\(Shape xs) (List ys) -> Match.take xs ys ++ Match.drop xs ys == ys
valuesplitAt :: [b] -> [a] -> ([a], [a])
#
Property
\(Shape xs) (List ys) -> Match.splitAt xs ys == (Match.take xs ys, Match.drop xs ys)
Property
\(Shape xs) (List ys) -> Match.splitAt xs ys == List.splitAt (length xs) ys
valuetakeRev :: [b] -> [a] -> [a]
#
Property
\(Shape xs) (List ys) -> Match.takeRev xs ys == reverse (Match.take xs (reverse ys))
valuedropRev :: [b] -> [a] -> [a]
#
Property
\(Shape xs) (List ys) -> Match.dropRev xs ys == reverse (Match.drop xs (reverse ys))
valuereplicate :: [a] -> b -> [b]
#

Specialisation of $>.

valueequalLength :: [a] -> [b] -> Bool
#

Check whether two lists with different element types have equal length. It holds

Property
\(Shape xs) (List ys) -> equalLength xs ys == (length xs == length ys)

but equalLength is more efficient.

valuecompareLength :: [a] -> [b] -> Ordering
#

Compare the length of two lists over different types. It holds

Property
\(Shape xs) (List ys) -> compareLength xs ys == compare (length xs) (length ys)

but compareLength is more efficient.

valuelessOrEqualLength :: [a] -> [b] -> Bool
#

lessOrEqualLength x y is almost the same as compareLength x y <= EQ, but

Example1 expression
lessOrEqualLength "" undefinedTrue

whereas compareLength [] undefined <= EQ = undefined.

valueshorterList :: [a] -> [a] -> [a]
#

Returns the shorter one of two lists. It works also for infinite lists as much as possible. E.g.

Example1 expression
shorterList (shorterList (repeat 'a') (repeat 'b')) "abc""abc"

The trick is, that the skeleton of the resulting list is constructed using zipWith without touching the elements. The contents is then computed (only) if requested.