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 [])
Run Code Online (Sandbox Code Playgroud)
我已经将完全相同的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 …Run Code Online (Sandbox Code Playgroud)