Logo

Programming-Idioms

History of Idiom 53 > diff from v11 to v12

Edit summary for version 12 by :

Version 11

2015-09-03, 11:31:03

Version 12

2015-09-03, 11:34:31

Idiom #53 Join a list of strings

Concatenate elements of string list x joined by the separator ", " to create a single string y.

Idiom #53 Join a list of strings

Concatenate elements of string list x joined by the separator ", " to create a single string y.

Imports
import qualified Data.Text as T
Code
{-# LANGUAGE OverloadedStrings #-}
y :: T.Text
y = T.intercalate ", " x
Comments bubble
The first line allows the string literal ", " to be a type other then type String. In this case it is automatically converted to type Text.
This version uses Text as a common replacement for the built-in String type.

The type annotation on the second line is optional and could have been omitted.