I am reading the book 'Learn You a Haskell for Great Good!' by Miran Lipovaca and learning about higher-order functions in Chapter 5.
One of the examples involves the following function:
applyTwice :: (a -> a) -> a -> a
applyTwice f x = f (f x)
The following are examples of the function's output:
ghci> applyTwice (++ " HAHA") "HEY"
"HEY HAHA HAHA"
ghci> applyTwice ("HAHA " ++) "HEY"
"HAHA HAHA HEY"
For the first example, I understand that the string was produced by using the concatenation operator in the following manner:
"HEY" ++ " HAHA"
"HEY HAHA" ++ " HAHA"
"HEY HAHA HAHA"
However, I don't understand how the concatenation operator works in the second example. How is the output string "HAHA HAHA HEY" produced? Any insights are appreciated.