text-short-0.1.3: Memory-efficient representation of Unicode text strings
Copyright© Herbert Valerio Riedel 2018
LicenseBSD3
Maintainerhvr@gnu.org
Stabilitystable
Safe HaskellTrustworthy
LanguageHaskell2010

Data.Text.Short.Partial

Description

Partial functions vocabulary

This module provides common partial functions for operating on ShortText.

The use of these functions is discouraged as they tend to be error-prone.

Since: 0.1.2

Synopsis

Documentation

head :: ShortText -> Char Source #

\(\mathcal{O}(1)\) Returns first character of a non-empty ShortText

>>> head "abcd"
'a'

Note: Will throw an error exception for empty ShortTexts. Consider using the total functions uncons or indexMaybe instead.

Since: 0.1.2

tail :: ShortText -> ShortText Source #

\(\mathcal{O}(n)\) Drop first character from non-empty ShortText.

>>> tail "abcd"
"bcd"

Note: Will throw an error exception for empty ShortTexts. Consider using the total functions uncons or drop instead.

Since: 0.1.2

init :: ShortText -> ShortText Source #

\(\mathcal{O}(n)\) Drop last character from non-empty ShortText.

>>> tail "abcd"
"bcd"

Note: Will throw an error exception for empty ShortTexts. Consider using the total functions unsnoc or dropEnd instead.

Since: 0.1.2

last :: ShortText -> Char Source #

\(\mathcal{O}(1)\) Return last character from non-empty ShortText.

>>> last "abcd"
'd'

Note: Will throw an error exception for empty ShortTexts. Consider using the total functions unsnoc or indexEndMaybe instead.

Since: 0.1.2

index :: ShortText -> Int -> Char Source #

\(\mathcal{O}(n)\) Retrieve \(i\)-th character (code-point)

>>> index "abcd" 1
'b'

Note: Will throw an error exception if index is out of bounds. Consider using the total functions indexMaybe or indexEndMaybe instead.

Since: 0.1.2

foldl1 :: (Char -> Char -> Char) -> ShortText -> Char Source #

\(\mathcal{O}(n)\) Reduces the characters of the ShortText with the binary operator.

>>> foldl1 max "abcdcba"
'd'
>>> foldl1 const "abcd"
'a'
>>> foldl1 (flip const) "abcd"
'd'

Note: Will throw an error exception if index is out of bounds.

Since: 0.1.2

foldl1' :: (Char -> Char -> Char) -> ShortText -> Char Source #

\(\mathcal{O}(n)\) Strict version of foldl1.

Since: 0.1.2

foldr1 :: (Char -> Char -> Char) -> ShortText -> Char Source #

\(\mathcal{O}(n)\) Reduces the characters of the ShortText with the binary operator.

>>> foldr1 max "abcdcba"
'd'
>>> foldr1 const "abcd"
'a'
>>> foldr1 (flip const) "abcd"
'd'

Note: Will throw an error exception if index is out of bounds.

Since: 0.1.2