01 02 03 04 05 06 01 02 03 04 05 06 07 08 09 10 11 12 13 14 ← →
module Main where
By using a where clause, we can make all of the needed definitions local to
hello
.
Note the use of indentation. Precise rules exist, and one could use braces instead. In practice one learns indentation styles from other people’s code, and through trial and error seeing what the compiler will accept.
concatMap
is a combination of concat
and map
.
concatMap ∷ (a → [b]) → [a] → [b]
hello ∷ String hello = concatMap endline [first, second, third] where endline = (++ "\n") first = "hello" second = "there" third = "world" main ∷ IO () main = putStr hello
hello there world