“‘节点’应用于太少的参数”即使有确切的数字
"‘Node’ is applied to too few arguments" even though there are exact number
s
和 a
是类型变量。
在构造函数中,前两个参数是数据,然后是它的父级,它在图中的级别,然后是它的子级列表。
data Node s a = Root | Node s a (Node s a) Int [Node s a]
createRoot :: (ProblemState s a) => s-> a -> Node s a
createRoot state act= Node (state act Root 0 [])
并且我已经将完全相同数量的 5 个参数传递给 Node 构造函数,但是我遇到了错误。
• Couldn't match expected type ‘Node s a’
with actual type ‘a1
-> Node s1 a1 -> Int -> [Node s1 a1] -> Node s1 a1’
• Probable cause: ‘Node’ is applied to too few arguments
In the expression: Node (state act Root 0 [])
In an equation for ‘createRoot’:
createRoot state act = Node (state act Root 0 [])
• Relevant bindings include
act :: a (bound at Search.hs:43:24)
state :: s (bound at Search.hs:43:18)
createRoot :: s -> a -> Node s a (bound at Search.hs:43:1)
括号用于对表达式进行分组。 (length "hello" + 2)
是单个值,不是 4。
类似地,Node (...)
将 Node
应用于单个参数:(state act Root 0 [])
。显然这是错误的(并且需要 state
是一个带四个参数的函数)。
解决方法是去掉括号:
Node state act Root 0 []
现在 Node
应用于五个参数。
s
和 a
是类型变量。
在构造函数中,前两个参数是数据,然后是它的父级,它在图中的级别,然后是它的子级列表。
data Node s a = Root | Node s a (Node s a) Int [Node s a]
createRoot :: (ProblemState s a) => s-> a -> Node s a
createRoot state act= Node (state act Root 0 [])
并且我已经将完全相同数量的 5 个参数传递给 Node 构造函数,但是我遇到了错误。
• Couldn't match expected type ‘Node s a’
with actual type ‘a1
-> Node s1 a1 -> Int -> [Node s1 a1] -> Node s1 a1’
• Probable cause: ‘Node’ is applied to too few arguments
In the expression: Node (state act Root 0 [])
In an equation for ‘createRoot’:
createRoot state act = Node (state act Root 0 [])
• Relevant bindings include
act :: a (bound at Search.hs:43:24)
state :: s (bound at Search.hs:43:18)
createRoot :: s -> a -> Node s a (bound at Search.hs:43:1)
括号用于对表达式进行分组。 (length "hello" + 2)
是单个值,不是 4。
类似地,Node (...)
将 Node
应用于单个参数:(state act Root 0 [])
。显然这是错误的(并且需要 state
是一个带四个参数的函数)。
解决方法是去掉括号:
Node state act Root 0 []
现在 Node
应用于五个参数。