Lambda calc version of Haskell lambda function

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Lambda calc version of Haskell lambda function

Lawrence Bottorff-2
Here is a function declaration

makeAddress :: Int -> String -> String -> (Int, String, String)
makeAddress number street town = (number,street,town)

and here is a lambda function version

makeAddressLambda =  (\number -> (\street -> (\town -> (number, street, town))))

How would this lambda version look in lambda calculus? Like this?

\number.\street.\town.(number street town)

then

(\number.\street.\town.(number street town) (123 "Sunny St." "Fergus")
(\street.\town.(123 street town) ("Sunny St." "Fergus")
(\town.(123 "Sunny St.") ("Fergus")
(123 "Sunny St." "Fergus")

Not always sure.

LB

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Lambda calc version of Haskell lambda function

Francesco Ariis
Il 31 dicembre 2020 alle 22:33 Lawrence Bottorff ha scritto:
> Here is a function declaration
>
> makeAddress :: Int -> String -> String -> (Int, String, String)
> makeAddress number street town = (number,street,town)
>
> and here is a lambda function version
>
> makeAddressLambda =  (\number -> (\street -> (\town -> (number, street,
> town))))

You can lose most of the parentheses:

    makeAddressLambda =  \number -> \street -> \town -> (number, street, town)

> How would this lambda version look in lambda calculus? Like this?
>
> \number.\street.\town.(number street town)

Yes.

> then
>
> (\number.\street.\town.(number street town) (123 "Sunny St." "Fergus")

Wait! You have lost a ‘)’ on the lambdas (remember λ goes as far right as
possible). Also

    (123, "Sunny St.", "Fergus")

makes it look like it is a single argument, which leads to a wrong result:

    (λnumber. λstreet. λtown. number street town) (123, "Sunny St.", "Fergus")
    λstreet. λtown. (123, "Sunny St.", "Fergus") street town
    -- woops!

Instead, keeping in mind Haskell follows a beta-nu-mu strategy, we have
a series of 3 βs:

    (λnumber. λstreet. λtown. (number, street, town)) 123 "Sunny St." "Fergus"
    (λstreet. λtown. (123, street, town) "Sunny St." "Fergus"
    (λtown. (123, "Sunny St.", town) "Fergus"
    (123, "Sunny St.", "Fergus")

_______________________________________________
Beginners mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners