I was reading here, and I noticed that, for example, if I have the following function definitions:
a :: Integer->Integer->Integer
b :: Integer->Bool
The following expression is invalid:
(b . a) 2 3
It's quite strange that the functions of the composition must have only one parameter.
Is this restriction because some problem in defining the most generic one in Haskell or have some other reason?
I'm new to Haskell, so I'm asking maybe useless questions.
When you do a 2 3
, you're not applying a
to 2 arguments. You're actually applying a
to it's only argument, resulting in a function, then take that function and apply it to 3. So you actually do 2 applications. So in a sense, what you have is not equivalent to this:
a :: (Integer, Integer) -> Integer
b :: Integer -> Integer
(b . a) (2, 3)
You could've done this, btw
(b . a 2) 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With