A wildcard pattern, written _, matches any input without binding that input to an identifier. Use it when a value is structurally required but its contents are irrelevant. section 3.3.1 section 4.1.2
Ignoring an unused function argument
A recursive line-numbering helper can ignore its first argument when processing an empty list: `go _ [] = []`. The counter is unnecessary in this case, so `_` keeps the pattern match clear without introducing an unused name. section 4.1.2
Providing a catch-all pattern
A filename parser can accept exactly one filename and handle every other list shape with a wildcard: `parseArguments [filePath] = filePath` followed by `parseArguments _ = undefined`. Because `_` always matches, a final wildcard makes pattern matching exhaustive, although this particular fallback still crashes for invalid input. section 3.3.1
Listing 4.3 A function that numbers every line in order
numberAllLines :: [String] -> NumberedLines
numberAllLines lines =
let go :: Int -> [String] -> NumberedLines #1
go _ [] = [] #2
go counter (x : xs) = (Just counter, x) : go (counter + 1) xs #3
in go 1 lines #4
Inspect the complete recursive line-numbering definition to see how a wildcard can hide an irrelevant argument while other patterns retain needed values. section 4.1.2







