Haskell: Is there a simpler way to express the function (\f g x y -> f (g x) (g y))? Using Applicative ((->) r)?

92 Views Asked by At
combinator :: (b -> b -> c) -> (a -> b) -> a -> a -> c
combinator f g x y = f (g x) (g y)

Is there a simpler way to express this function? I find myself using it quite frequently.

I tried using the Applicative instance for (r->) but the best I could get was (<*>) : (r -> a -> b) -> (r -> a) -> (r -> b), f <*> g = (\r -> f r (g r))

0

There are 0 best solutions below