Let's assume I have a function f
in Haskell, It takes a Double and returns a Double, and I have function g
that also takes a Double and returns a Double.
Now, I can apply f to g like this: f . g
.
Now, let's take a higher-dimensional function f
, that
takes two Doubles and outputs one:f :: Double -> Double -> Double
orf :: (Double, Double) -> Double
And I have two g
functions as well:g1 :: Double -> Double
, g2 :: Double -> Double
Now, I want to compose the functions to get something like:composition x = f (g1 x) (g2 x)
Can this be achieved just by using the dot (.) operator?
composition = liftA2 f g1 g2
: hackage.haskell.org/package/base-4.14.0.0/docs/… – Willem Van Onsem