Haskell: Function to determine the arity of functions?

后端 未结 6 621
一个人的身影
一个人的身影 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:26

    If id has arity 1, shouldn't id x have arity 0? But, for example, id map is identical to map, which would has arity 2 in your example.

    Have the following functions the same arity?

    f1 = (+)
    f2 = (\x y -> x + y)
    f3 x y = x + y
    

    I think your notion of "arity" is not well defined...

提交回复
热议问题