Actually, all functions in Haskell take only one argument, although the
people writing the program usually don't think of it this
way.
scale
could alternatively have been defined with type
scale :: (Picture, Int) -> Picture
which
looks more like what we would expect in a function of two arguments. But
even here there is actually only a single argument, which happens to be a pair
of values.
The
given declaration
scale :: Picture -> Int ->
Picture
is
written in 'curried' form. This means that scale is a function of
one argument, 'Picture', and that its return value is a new function with
type Int -> Picture. That new function can immediately be applied to an
int value so that it appears as if you called scale with two values instead of
just one.
instead of writing
scale pic 3
for
example, you could have written
(scale pic) 3
or
even
let x = scale pic in x 3
Which
might make it a little easier to see what is actually
happening.
Hope
this helps,
--
Gary
|
- newbie syntax question Cagdas Ozgenc
- Re: newbie syntax question Hamilton Richards
- Re: newbie syntax question Memovich, Gary
- Re: newbie syntax question John Meacham