Another currying and lambda question

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

Another currying and lambda question

Lawrence Bottorff-2
In Learn You... I'm seeing this

flipA :: (a -> b -> c) -> b -> a -> c
flipA f x y = f y x

and this

flipB :: (a -> b -> c) -> b -> a -> c  
flipB f = \x y -> f y x

What is it specifically about currying that makes flipA possible? Also, with flipB, could someone explain the beta reduction? It looks like f is not being acted on, just passed along, Would it look more like this in lambda calculus?

(\x \y -> f y x)
then
(\x \y -> f y x) g a b 

gives

g b a  ?

LB

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

Re: Another currying and lambda question

Francesco Ariis
Il 22 dicembre 2020 alle 11:48 Lawrence Bottorff ha scritto:
> flipA :: (a -> b -> c) -> b -> a -> c
> flipA f x y = f y x
>
> What is it specifically about currying that makes flipA possible?

I do not see how currying is involved here! Maybe when you pass
a function to an higher order one?

> flipB :: (a -> b -> c) -> b -> a -> c
> flipB f = \x y -> f y x
>
> Also, with flipB, could someone explain the beta reduction? It looks
> like f is not being acted on, just passed along, Would it look more
> like this in lambda calculus?

Indeed `f` is not being acted on (i.e. it is «outside» of the lambda)

    (λx. λy. f y x) b a
    (λy. f y b) a          beta
    f a b                  beta

fully expressed with lambdas would be:

    (λf. λx. λy. f y x) g b a

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

Re: Another currying and lambda question

Lawrence Bottorff-2
Thanks again!

On Tue, Dec 22, 2020 at 11:59 AM Francesco Ariis <[hidden email]> wrote:
Il 22 dicembre 2020 alle 11:48 Lawrence Bottorff ha scritto:
> flipA :: (a -> b -> c) -> b -> a -> c
> flipA f x y = f y x
>
> What is it specifically about currying that makes flipA possible?

I do not see how currying is involved here! Maybe when you pass
a function to an higher order one?

> flipB :: (a -> b -> c) -> b -> a -> c
> flipB f = \x y -> f y x
>
> Also, with flipB, could someone explain the beta reduction? It looks
> like f is not being acted on, just passed along, Would it look more
> like this in lambda calculus?

Indeed `f` is not being acted on (i.e. it is «outside» of the lambda)

    (λx. λy. f y x) b a
    (λy. f y b) a          beta
    f a b                  beta

fully expressed with lambdas would be:

    (λf. λx. λy. f y x) g b a

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

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