Strings

Haskell has a legacy type for text called String, which is defined as [Char], i.e. a list of characters. This is almost never a good representation of text, and should be avoided. Instead, use Text from the module Data.Text, after adding the package text to your requirements.

Normally, Text is used in conjunction with the extension

{-# LANGUAGE OverloadedStrings #-}

which allows you to write text in the obvious way:

exampleText :: Text
exampleText = "blahblah"

You may also use OverloadedStrings for other text representations, such as ByteString.

Comments