[Haskell-cafe] Re: First Question

Pete Chown 1 at 234.cx
Mon Mar 20 08:42:32 EST 2006

Neil Rutland wrote:

> stops :: int->int->int
> I think that says that the function stops takes two integers and returns 
> an integer.

This is correct (though as someone else pointed out, Haskell types start 
with a capital letter).

> What i'm not entirely sure of is how i'd then write the function itself 
> because i literally want it to have the following form
> stops (x,y) = x+y

As "stops" just adds numbers, it is equivalent to the + operator, so you 
don't have to write a function at all.  It doesn't do any harm to write 
a function, but the simplest way of expressing "stops" is this:

stops :: Int -> Int -> Int
stops = (+)

One of the benefits of a functional language is that you can assign 
functions as well as data!


More information about the Haskell-Cafe mailing list