01 02 03 04 05 06 01 02 03 04 05 06 07 08 09 10 11 12 13 14 ← →
module Main where
Now, suppose that we want to accumulate output as we go. addline
is a
function which adds a line of text t
to the string s
.
addline ∷ String → String → String addline s t = s ++ t ++ "\n"
Using addline
, we can build our message in stages.
first, second, hello ∷ String first = addline "" "hello" second = addline first "there" hello = addline second "world" main ∷ IO () main = putStr hello
hello there world