Haskell 不能';t匹配预期类型';整数->;t';实际类型

Haskell 不能';t匹配预期类型';整数->;t';实际类型,haskell,functional-programming,Haskell,Functional Programming,我正在尝试运行这个教科书示例,但不断出现以下错误: * Couldn't match expected type `Integer -> t' with actual type `[Char]' * The function `showPerson' is applied to two arguments, but its type `People -> [Char]' has only one In the expression: showPer

我正在尝试运行这个教科书示例,但不断出现以下错误:

* Couldn't match expected type `Integer -> t'
              with actual type `[Char]'
* The function `showPerson' is applied to two arguments,
  but its type `People -> [Char]' has only one
  In the expression: showPerson "charles" 18
  In an equation for `it': it = showPerson "charles" 18
* Relevant bindings include it :: t (bound at <interactive>:38:1)

声明的
showPerson
函数只有一个参数。此参数的类型为
People

但是,从您引用的错误判断,您试图用两个参数调用此函数-
“charles”
18
。第一个参数的类型为
String
,第二个参数的类型为
Int

这就是编译器试图告诉您的内容,它说:

The function `showPerson' is applied to two arguments, 
but its type `People -> [Char]' has only one
要正确调用函数,您需要首先创建一个
People
类型的值,然后将该值作为参数传递给函数:

p = Person "charles" 18
showPerson p
或者一行中的相同内容:

showPerson (Person "charles" 18)

声明的
showPerson
函数只有一个参数。此参数的类型为
People

但是,从您引用的错误判断,您试图用两个参数调用此函数-
“charles”
18
。第一个参数的类型为
String
,第二个参数的类型为
Int

这就是编译器试图告诉您的内容,它说:

The function `showPerson' is applied to two arguments, 
but its type `People -> [Char]' has only one
要正确调用函数,您需要首先创建一个
People
类型的值,然后将该值作为参数传递给函数:

p = Person "charles" 18
showPerson p
或者一行中的相同内容:

showPerson (Person "charles" 18)

现在明白了!谢谢现在明白了!谢谢