Data.String

Data.String

Copyright (c) The University of Glasgow 2007
License BSD-style (see the file libraries/base/LICENSE)
Maintainer libraries@haskell.org
Stability experimental
Portability portable
Safe Haskell Trustworthy
Language Haskell2010

Description

The String type and associated operations.

type String = [Char] Source

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

class IsString a where Source

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

Minimal complete definition

fromString

Methods

fromString :: String -> a Source

Instances

(~) * a Char => IsString [a]

Methods

fromString :: String -> [a] Source

IsString a => IsString (Identity a)

Methods

fromString :: String -> Identity a Source

IsString a => IsString (Const * a b)

Methods

fromString :: String -> Const * a b Source

Functions on strings

lines :: String -> [String] Source

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] Source

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

unlines :: [String] -> String Source

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

unwords :: [String] -> String Source

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

© The University of Glasgow and others
Licensed under a BSD-style license (see top of the page).
https://downloads.haskell.org/~ghc/8.0.1/docs/html/libraries/base-4.9.0.0/Data-String.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部