A string that cannot be empty. The head and tail can be accessed without Maybes. Most other string functions are available.
A string with at least one character.
length : NonemptyString -> Basics.Int
Get the length of a nonempty string.
reverse : NonemptyString -> NonemptyString
Reverse a string.
append : String -> NonemptyString -> NonemptyString
Append a string onto the beginning of a nonempty string.
append_ : NonemptyString -> String -> NonemptyString
Append a string onto the end of a nonempty string.
concat : List.Nonempty.Nonempty NonemptyString -> NonemptyString
Concatenate many nonempty strings into one.
fromString : String -> Maybe NonemptyString
Create a nonempty string from an ordinary string, failing on the empty string.
toString : NonemptyString -> String
Convert to an ordinary string.
slice : Basics.Int -> Basics.Int -> NonemptyString -> String
Take a substring given a start and end index. Negative indexes are taken starting from the end of the list.
text = NonemptyString 's' "nakes on a plane!"
slice 7 9 text == "on"
slice 0 6 text == "snakes"
slice 0 -7 text == "snakes on a"
slice -6 -1 text == "plane"
left : Basics.Int -> NonemptyString -> String
Take n characters from the left side of a nonempty string.
right : Basics.Int -> NonemptyString -> String
Take n characters from the right side of a nonempty string.
dropLeft : Basics.Int -> NonemptyString -> String
Drop n characters from the left side of a nonempty string.
dropRight : Basics.Int -> NonemptyString -> String
Drop n characters from the right side of a nonempty string.
head : NonemptyString -> Char
Get the first character in the nonempty string.
tail : NonemptyString -> String
Return all the characters after the first one.
contains : String -> NonemptyString -> Basics.Bool
See if the second string contains the first one.
startsWith : String -> NonemptyString -> Basics.Bool
See if the second string starts with the first one.
endsWith : String -> NonemptyString -> Basics.Bool
See if the second string ends with the first one.
indexes : String -> NonemptyString -> List Basics.Int
Get all of the indexes for a substring in another string.
indexes "i" (NonemptyString 'M' "ississippi") == [ 1, 4, 7, 10 ]
indexes "ss" (NonemptyString 'M' "ississippi") == [ 2, 5 ]
indices : String -> NonemptyString -> List Basics.Int
Alias for indexes
.
toInt : NonemptyString -> Maybe Basics.Int
Try to convert a string into an int, failing on improperly formatted nonempty strings.
fromInt : Basics.Int -> NonemptyString
Convert an Int
to a NonemptyString
.
toFloat : NonemptyString -> Maybe Basics.Float
Try to convert a string into a float, failing on improperly formatted nonempty strings.
fromFloat : Basics.Float -> NonemptyString
Convert a Float
to a NonemptyString
.
fromChar : Char -> NonemptyString
Create a string from a given character.
fromChar 'a' == NonemptyString 'a' ""
cons : Char -> NonemptyString -> NonemptyString
Add a character to the beginning of a nonempty string.
uncons : NonemptyString -> ( Char, String )
Split a nonempty string into its head and tail. This lets you pattern match on strings exactly as you would with lists.
toNonemptyList : NonemptyString -> List.Nonempty.Nonempty Char
Convert a nonempty string to a nonempty list of characters.
fromNonemptyList : List.Nonempty.Nonempty Char -> NonemptyString
Convert a nonempty list of characters into a nonempty string.
Cosmetic operations such as padding with extra characters or trimming whitespace.
toUpper : NonemptyString -> NonemptyString
Convert a string to all upper case. Useful for case-insensitive comparisons and VIRTUAL YELLING.
toLower : NonemptyString -> NonemptyString
Convert a string to all lower case. Useful for case-insensitive comparisons.
pad : Basics.Int -> Char -> NonemptyString -> NonemptyString
Pad a nonempty string on both sides until it has a given length.
padLeft : Basics.Int -> Char -> NonemptyString -> NonemptyString
Pad a nonempty string on the left until it has a given length.
padRight : Basics.Int -> Char -> NonemptyString -> NonemptyString
Pad a nonempty string on the right until it has a given length.
trim : NonemptyString -> String
Get rid of whitespace on both sides of a nonempty string.
trimLeft : NonemptyString -> String
Get rid of whitespace on the left of a nonempty string.
trimRight : NonemptyString -> String
Get rid of whitespace on the right of a nonempty string.
map : (Char -> Char) -> NonemptyString -> NonemptyString
Transform every character in a nonempty string
filter : (Char -> Basics.Bool) -> NonemptyString -> String
Keep only the characters that pass the test.
foldl : (Char -> b -> b) -> b -> NonemptyString -> b
Reduce a nonempty string from the left.
foldr : (Char -> b -> b) -> b -> NonemptyString -> b
Reduce a nonempty string from the right.
any : (Char -> Basics.Bool) -> NonemptyString -> Basics.Bool
Determine whether any characters pass the test.
all : (Char -> Basics.Bool) -> NonemptyString -> Basics.Bool
Determine whether all characters pass the test.