Haskell错误:约束中的非类型变量参数:Num(a - > a - > a - > a)

jbl*_*ley 7 debugging haskell

我是Haskell的新手,我正在尝试从我的书中运行以下示例代码:

整个档案:

-- my name

splitAt1   ::  [a] -> ([a], [a])
splitAt1 xs = (take 2 xs, drop 2 xs) 
Run Code Online (Sandbox Code Playgroud)

我正在通过运行线路进行测试:

splitAt1 [1 2 3 4]
Run Code Online (Sandbox Code Playgroud)

想法是输入数组在索引2处被拆分为两个数组.但是,我收到以下错误:

Non type-variable argument
  in the constraint: Num (a -> a -> a -> a)
(Use FlexibleContexts to permit this)
When checking that ‘it’ has the inferred type
  it :: forall a a1 a2 a3.
        (Num a1, Num a2, Num a3, Num (a1 -> a2 -> a3 -> a)) =>
        ([a], [a])
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮我解码错误信息,也许代码有什么问题?

小智 16

功能很好,这是你的论点.

尝试splitAt1 [1,2,3,4]而不是splitAt1 [1 2 3 4]它应该工作.