困惑于haskell中的点运算符

时间:2017-06-27 06:20:58

标签: haskell

(head.group) "1234"

有效。

head.group "1234"

我收到错误:

<interactive>:8:6:
Couldn't match expected type `a0 -> [c0]'
            with actual type `[[Char]]'
In the return type of a call of `group'
Probable cause: `group' is applied to too many arguments
In the second argument of `(.)', namely `group "1234"'
In the expression: head . group "1234"

我认为(head.group)与head.group相同,为什么(head.group)工作,head.group没有。

1 个答案:

答案 0 :(得分:4)

由于

(head . group) "1234" = f "12345"
  where
    f = head . group

,而

head . group "1234" = head . (group "1234") 
                    = head . f
  where
    f = group "1234"

group "1234"不是一个功能。请记住,功能应用程序比运营商更强大。