I'm new to Haskell, and the following behavior confused me:
I have a function called dealWithIt. It looks like this:
dealWithIt :: (Show a) => [a] -> String
dealWithIt = foldl f ""
where f memo x = memo ++ (show x)
Everything is fine, it works as expected, it gets a list of shortcuts and combines them into one line.
As far as I understand, it doesn’t matter if I explicitly indicate the argument received, if it can be passed to the base chain of functions. This means that the following two definitions should be equivalent:
dealWithIt xs = foldl f "" xs
dealWithIt = foldl f ""
So far so good. Suppose I want to add a special script from the template now:
dealWithIt [] = "Empty list :("
Everything is strange here. If I do not specify an explicit xs argument, I get the following error:
Equations for ‘dealWithIt’ have different numbers of arguments
, , Haskell , , ?