Haskell: Function to determine the arity of functions?

后端 未结 6 620
一个人的身影
一个人的身影 2021-02-05 07:00

Is it possible to write a function arity :: a -> Integer to determine the arity of arbitrary functions, such that

> arity map
2
> arity fol         


        
6条回答
  •  一生所求
    2021-02-05 07:05

    In Haskell, every "function" takes exactly one argument. What looks like a "multi-argument" function is actually a function that takes one argument and returns another function which takes the rest of the arguments. So in that sense all functions have arity 1.

提交回复
热议问题