
In *Learn You... http://learnyouahaskell.com/higher-order-functions *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

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

Thanks again!
On Tue, Dec 22, 2020 at 11:59 AM 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 Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
participants (2)
-
Francesco Ariis
-
Lawrence Bottorff