There are two ways to pass arguments to a Haskell function:
-
Individual arguments
-
A tuple
Individual arguments are done the way that you have defined the function number_correction, with spaces between the arguments:
number_correction :: (Integral n, Show n) => [n] -> [n] -> String
number_correction [] _ = ""
number_correction (x:xs) num_array
The other way to do this is as a tuple, written in parentheses, thus: (a,b). Pattern matching means that the tuple is split up automatically:
number_correction :: (Integral n, Show n) => ([n],[n]) -> String
number_correction ([],_) = ""
number_correction ((x:xs),num_array)
When you call the function, you are using a tuple:
let new_string = number_correction(ordered_list, num_array)
This matches the tuple definition, but not the individual argument definition:
main.hs:30:42: error:• Couldn't match expected type ‘[n]’
with actual type ‘([Int], [Integer])’
Hence the error.
Individual arguments is the way to go. Try this instead:
let new_string = number_correction ordered_list num_array
And likewise for all of your function calls.
You also don’t need the semicolons.