Logo

Programming-Idioms

History of Idiom 53 > diff from v16 to v17

Edit summary for version 17 by :

Version 16

2015-09-09, 08:38:04

Version 17

2015-09-09, 08:49:28

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
Imports
import qualified Data.Text as T
Code
{-# LANGUAGE OverloadedStrings #-}
y :: T.Text
y = T.intercalate ", " x
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.
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 can be omitted.