Strings
In Gren, strings are zero or more characters contained within double quotes:
name : Stringname = "Laura"
empty : Stringempty = ""
Character literals are exactly one character contained within single quotes:
key : Charkey = 'a'
Multi-line strings can be contained within three double quotes. Leading whitespace will be removed from the resulting string, but newlines will be preserved:
story : Stringstory = """ Once upon a time, there was a long string. It was alright. """
To include a double quote inside a string, it must be escaped with \
:
name : Stringname = "Dwayne \"The Rock\" Johnson."
A single quote character literal can also be escaped:
singleQuote : CharsingleQuote = '\''
And you can escape the \
itself with a preceding \
:
backslash : Charbackslash = '\\'
path : Stringpath = "c:\\my\\file"
You do not need to escape double quotes from multiline strings:
"""I was like "Whoa"and they were like "Yeah""""
You can combine two strings into one with ++
:
greet : String -> Stringgreet name = "Hello, " ++ name
To see what else you can do with strings, check the String module documentation.