[Haskell-beginners] help with types and composition

Thomas Davie tom.davie at gmail.com
Mon Jul 6 10:41:08 EDT 2009


On 6 Jul 2009, at 16:30, Edward Z. Yang wrote:

> Excerpts from Dan Douglas's message of Mon Jul 06 09:30:46 -0400 2009:
>> So, basically any function's type will always be in curryfied form,  
>> and the
>> only time there's a tuple involved is if the function's argument is  
>> itself a
>> tuple? I'll have to ponder a bit how nesting functions are  
>> equivalent to a
>> function with multiple arguments.
>
> The easiest way to think about this is to add parentheses around the
> type declaration.
>
> Int -> Int -> Int
>
> becomes:
>
> Int -> (Int -> Int)

The other part of the story being the definition of functions.  First  
lets rewrite some syntactic sugar:

f x y = x + y
-- Rewrite to use lambda abstraction instead of the definition syntax
f = \x y -> x + y
-- Rewrite to remove multiple argument lambas
f = \x -> \y -> x + y
-- Add in the parentheses to show the currying going on
f = \x -> (\y -> x + y)

Bob


More information about the Beginners mailing list