Functions are the building blocks
A function takes an input and gives back an output. It changes nothing else, which makes it a Blox you can trust.
Save this in a file called lesson1.hs, then run ghci lesson1.hs in a terminal.
double x = x * 2Now ask GHCi to run it with double 21. It answers 42.
Snapping functions together
The . operator joins two functions. The output of the right-hand function becomes the input of the left-hand one.
addThree x = x + 3
pipeline = addThree . doubleRead pipeline from right to left: double first, then add three.
Predict the output
pipeline 5Show answer
13Predict the output
double (double 3)Show answer
12Try the same idea with coloured blocks in the Blox Lab. It writes the Haskell for you as you build.