I’m just starting to take a look at Haskell (my previous FP experience is in Scheme), and I came across this code:
do { putStrLn "ABCDE" ; putStrLn "12345" }
To me, this is procedural programming, if anything — especially because of the consecutive nature of side effects.
Would someone please explain how this code is “functional” in any respect?
While it appears to be a procedural program, the above syntax is translated into a functional program, like so:
That is, a series of nested functions that have a unique world parameter threaded through them, sequencing calls to primitive functions “procedurally”. This design supports an encoding of imperative programming into a functional language.
The best introduction to the semantic decisions underlying this design is “The Awkward Squad” paper,