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
-----Original Message-----
From: Cagdas Ozgenc [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, July 24, 2001 1:07 PM
To: [EMAIL PROTECTED]
Subject: newbie syntax question

Hi,
 
I am extremely new to Haskell. This will be my first question, so go easy. I have just read Chapter 1 on Simon Thompson's book.
 
for example a function declaration is given as follows
 
scale : : Picture -> Int -> Picture
 
 
If the first two types are input variables why does the syntax require me to use arrows twice? I mean isn't the following syntax more readable (hypothetically)?
 
scale : : Picture , Int -> Picture
 
 
Is there a specific reason not to be able to distinguish the input parameters from the output parameter?
 
Thanks
 

Reply via email to