Movatterモバイル変換


[0]ホーム

URL:


base-4.13.0.0: Basic libraries
Copyright(c) The University of Glasgow 2007
LicenseBSD-style (see the file libraries/base/LICENSE)
Maintainerlibraries@haskell.org
Stabilityexperimental
Portabilityportable
Safe HaskellTrustworthy
LanguageHaskell2010

Data.String

Contents

Description

TheString type and associated operations.

Synopsis

Documentation

typeString = [Char]Source#

AString is a list of characters. String constants in Haskell are values of typeString.

classIsString awhereSource#

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

Methods

fromString ::String -> aSource#

Instances

Instances details
a ~Char =>IsString [a]Source#

(a ~ Char) context was introduced in4.9.0.0

Since: 2.1

Instance details

Defined inData.String

Methods

fromString ::String -> [a]Source#

IsString a =>IsString (Identity a)Source#

Since: 4.9.0.0

Instance details

Defined inData.String

IsString a =>IsString (Const a b)Source#

Since: 4.9.0.0

Instance details

Defined inData.String

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

Thuslines s contains at least as many elements as newlines ins.

words ::String -> [String]Source#

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

>>>words "Lorem ipsum\ndolor"["Lorem","ipsum","dolor"]

unlines :: [String] ->StringSource#

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

>>>unlines ["Hello", "World", "!"]"Hello\nWorld\n!\n"

unwords :: [String] ->StringSource#

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

>>>unwords ["Lorem", "ipsum", "dolor"]"Lorem ipsum dolor"

Produced byHaddock version 2.23.0


[8]ページ先頭

©2009-2025 Movatter.jp