HfT 01 02 03 04 05 06     01 02 03 04 05 06 07 08 09 10 11 12 13 14        

module Main where

There are various ways that we can combine and output several strings.

first, second, third  String

first = "hello"
second = "there"
third = "world"

We can use map to apply endline to each element of a list. map has the type

map  (a  b)  [a]  [b]

where a and b are type variables. hello is now a list of strings.

endline  String  String
endline = (++ "\n")

hello  [String]
hello = map endline [first, second, third]

concat concatenates our lists into a single string.

concat  [[a]]  [a]
main  IO ()
main = putStr $ concat hello
hello
there
world

Main.hs