Why sum x y is of type (Num a) => a -> a -> a in Haskell?

后端 未结 5 1572
臣服心动
臣服心动 2021-01-02 07:39

I\'ve been reading about Haskell and I\'m having a hard time understanding how function definitions are handled in this language.

Let\'s say I\'m defining a su

5条回答
  •  盖世英雄少女心
    2021-01-02 08:29

    it is a -> a -> a rather than (a, a) -> a because of currying. Fun fact: Currying was (re)invented by Haskell Curry! Basically it means if you supply one one argument you'll get back another function of type a -> a, a partial application of sum.

提交回复
热议问题