Data.String.Compat

base-compat-0.9.1: A compatibility layer for base

Safe Haskell | Safe
Language | Haskell98

Data.String.Compat

Synopsis

- type String = [Char]
- lines :: String -> [String]
- words :: String -> [String]
- unlines :: [String] -> String
- unwords :: [String] -> String

# Documentation

type String = [Char] #

A `String` is a list of characters. String constants in Haskell are values of type `String`.

lines :: String -> [String] #

`lines` breaks a string up into a list of strings at newline characters. The resulting strings do not contain newlines.

Note that after splitting the string at newline characters, the last part of the string is considered a line even if it doesn't end with a newline. For example,

    lines "" == []
    lines "\n" == [""]
    lines "one" == ["one"]
    lines "one\n" == ["one"]
    lines "one\n\n" == ["one",""]
    lines "one\ntwo" == ["one","two"]
    lines "one\ntwo\n" == ["one","two"]

Thus ``lines` s` contains at least as many elements as newlines in `s`.

words :: String -> [String] #

`words` breaks a string up into a list of words, which were delimited by white space.

unlines :: [String] -> String #

`unlines` is an inverse operation to `lines`. It joins lines, after appending a terminating newline to each.

unwords :: [String] -> String #

`unwords` is an inverse operation to `words`. It joins words with separating spaces.