3 Main Features of Curry

3.8 Strings

Although “String” is a predefined type (see Section 3.3), there are no special operations on strings. The reason is that “String” is just another name for “[Char]”, i.e., strings are considered as lists of characters. In addition, Curry provides a handy notation for string constants, i.e., the string constant

"hello world"

is identical to the character list

[’h’,’e’,’l’,’l’,’o’,’ ’,’w’,’o’,’r’,’l’,’d’]

Thus, any operation applicable to arbitrary lists can also be applied to strings. For instance, the prelude defines an infix operator “++” to concatenate lists and the function “reverse” to reverse the order of all lists elements (similarly to conc and rev in Section 3.7). Thus, we can also use them to operate on strings:


Prelude> "Hi"++"Hi"
"HiHi"
Prelude> reverse "hello"
"olleh"