base-4.6.0.1: Basic libraries

Portability | portable
Stability | experimental
Maintainer | libraries@haskell.org
Safe Haskell | Trustworthy

Data.String

Contents

- Functions on strings

Description

The `String` type and associated operations.

Synopsis

- type String = [Char]
- class IsString a where
  - fromString :: String -> a
- 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`.

class IsString a where

Class for string-like datastructures; used by the overloaded string extension (-foverloaded-strings in GHC).

Methods

fromString :: String -> a

Instances

IsString [Char] |

# Functions on strings

lines :: String -> [String]

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

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.