Composing function composition: How does (.).(.) work?

后端 未结 7 1633
温柔的废话
温柔的废话 2020-11-29 06:36

(.) takes two functions that take one value and return a value:

(.) :: (b -> c) -> (a -> b) -> a -> c

7条回答
  •  醉酒成梦
    2020-11-29 07:21

    You're right, (.) only takes two arguments. You just seem to be confused with the syntax of haskell. In the expression (.).(.), it's in fact the dot in the middle that takes the other two dots as argument, just like in the expression 100 + 200, which can be written as (+) 100 200.

    (.).(.) === (number the dots)
    (1.)2.(3.) === (rewrite using just syntax rules)
    (2.)(1.)(3.) === (unnumber and put spaces)
    (.) (.) (.) ===
    

    And it should be even more clear from (.) (.) (.) that the first (.) is taking the second (.) and third (.) as it's arguments.

提交回复
热议问题