[Haskell-cafe] Parameters and patterns

José Romildo Malaquias j.romildo at gmail.com
Sat Oct 1 16:27:27 CEST 2011


Hello.

When studing programming languages I have learned that parameter is a
variable (name) that appears in a function definition and denotes the
value to which the function is applied when the function is called.

Argument is the value to which the function is applied.

The parameter allows the manipulation of the argument in the body of the
funtion definition in order to produce the result.

Now I am not sure how to apply these concepts to Haskell, as Haskell
uses pattern matching to deal with argument passing to functions.

For instance, in the definition

  f x = 2 * x + 1

x is a parameter, and in the application

  f 34

34 is an argument.

But in the definition

  g (_:xs) = xs

what is the parameter of the function g? Is it the pattern (_:xs)? If so
then a parameter is not necessarily a variable anymore, and that seems
very strange. And what is xs? Is it a parameter, although it does not
denote the value to which the function is aplied, but just part of it?

I am writing some slides to use in my functional programming classes,
but I am not sure how to deal with these terms.

Any comments?

Romildo
--
DECOM - ICEB - UFOP



More information about the Haskell-Cafe mailing list