A String represents a message as characters. In Haskell, it is a type synonym for a list of Char values: type String = [Char]. Quoted text is convenient syntax for that character list, so "Hello World" and ['H','e','l','l','o',' ','W','o','r','l','d'] are identical values. section 2.3.1
Write text as a String
Use quotes for readable text while retaining list behavior. A String can be printed as text, but its characters can also be handled individually when an algorithm needs to inspect or transform them. section 2.3.1
Because String is a list, familiar list operations apply directly:
- Append strings with (++), such as "Hello" ++ " " ++ "World!". section 2.3.3
- Use type synonyms to document intent: Alphabet can also mean [Char], even though it has the same underlying type as String. section 2.3.1
- Create character ranges for alphabets and digits, such as ['a' .. 'z'] or ['0' .. '9']. section 2.3.1
Strings support character-by-character transformations. For a Caesar cipher, transform the first character, recursively transform the remaining characters, and construct a new String. Immutability means the original value is not changed; the result is a newly built list. section 2.4 section 2.5
Rotate every character
The function caesar :: Int -> String -> String handles [] as empty and x : xs by placing rotChar n x before the recursively transformed tail. Rotating "Caesars Cipher!" by 13 produces "Pnrfnef Pvcure!". section 2.5
String is useful for simple text processing, but it can become a performance cost for large inputs: it is a heap-allocated linked list of Char values. When profiling shows string handling matters, Text and ByteString offer packed alternatives; choose algorithms and data structures before changing types. section 6.3.2
string1 :: String string1 = "Hello World" string2 :: String string2 = ['H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd']
Compare quoted String syntax with its explicit list-of-Char form. section 2.3.1























