In the previous chapters, you mainly worked with predefined functions from different libraries in Haskell. Now, it’s time to write your own functions. In this chapter, you will learn about pattern matching, guards, clauses, higher-order functions, and lambda expressions used in functions.
© Stefania Loredana Nita and Marius Mihailescu 2019Stefania Loredana Nita and Marius MihailescuHaskell Quick Syntax Referencehttps://doi.org/10.1007/978-1-4842-4507-1_7
Let’s start with a simple function that adds two numbers.
add :: Integer -> Integer -> Integer
add x y = x + y
main = do
putStrLn "Adding two numbers:"
print(add 3 7)
On the first line is the function declaration, ...