Create in Haskell

Find this useful? Support us: Star on GitHub 6
Category: String | Language: Haskell

In Haskell, a string is a list of characters. We can create a string in Haskell using double quotes (") or single quotes ('). Here are a few examples:

Using Double Quotes:

We can create a string using double quotes. For example:

myString1 = "Hello, World!"

Using Single Quotes:

We can create a string using single quotes too. For example:

myString2 = 'Haskell is awesome!'

Using List of Characters:

As a string is a list of characters in Haskell, we can simply define a list of characters as a string. For example:

myString3 = ['H', 'a', 's', 'k', 'e', 'l', 'l']

In Haskell, these three examples are equivalent and we can perform string operations on them in the same way.