I'm following an online tutorial on Haskell. We define a function to add two-dimensional vectors, represented by tuple pairs of numbers. The following is the explicit type declaration, that ensures both inputs are two-dimensional vectors.
addVectors :: (Num a) => (a, a) -> (a, a) -> (a, a)
I understand why the following function definition uses pattern matching: it describes the patterns that input data should conform to.
addVectors (x1, y1) (x2, y2) = (x1 + x2, y1 + y2)
Why does the following alternative function definition not use pattern matching? (fst) and (snd) are guaranteed to work, because the inputs are explicitly declared to be tuples of length two.
What is the difference between the two function definitions?
addVectors a b = (fst a + fst b, snd a + snd b)