Does the following combinator have a name in Haskell? If not, can it be expressed in terms of simpler ones?
c f g x y = g (f x y) (f y x)
I have tried Hoogle and pointfree.io (which gives me back an unintelligible expression) but without success.
Does the following combinator have a name in Haskell? If not, can it be expressed in terms of simpler ones?
c f g x y = g (f x y) (f y x)
I have tried Hoogle and pointfree.io (which gives me back an unintelligible expression) but without success.
Copyright © 2021 Jogjafile Inc.
There is no known combinator for this as far as I know. We can however shorten this - with the help of @chepner - to:
The
uncurry :: (a -> b -> c) -> (a, b) -> cconverts a function with two parameters to one that takes one parameter: a 2-tuple with the two parameters.We then use
liftA2 gthat will applygon the result ofuncurry fanduncurry (flip f), and then wecurry :: ((a, b) -> c) -> a -> b -> cto convert it back to a function that takes two parameters.