2012-10-21 119 views
0

我有这种解释错误,我不知道什么是错无法比拟预期型`双师型“与实际类型`[C0]”

module Series where 

series :: Double -> Double 
series i1 = zipWith (/) (map (i1^)[1..]) (map(\x -> product[1..x]) [1..]) 

我的错误是

Couldn't match expected type `Double' with actual type `[c0]' 
    In the return type of a call of `zipWith' 
    In the expression: 
     zipWith 
     (/) (map (i1 ^) [1 .. ]) (map (\ x -> product [1 .. x]) [1 .. ]) 
    In an equation for `series': 
     series i1 
      = zipWith 
       (/) (map (i1 ^) [1 .. ]) (map (\ x -> product [1 .. x]) [1 .. ]) 
Failed, modules loaded: none. 

任何人都可以帮忙吗?提前致谢!

+2

zipWith的结果类型是List。 – arrowd

+0

哦!哈哈确定它运行!谢谢! – edelweiss

回答

3

这很容易将自己与ghci中找到了答案:

> let series i1 = zipWith (/) (map (i1^)[1..]) (map(\x -> product[1..x]) [1..]) 

> :t series 
series :: (Enum c, Fractional c) => c -> [c] 

我不知道什么是错

您的签名是错误的,编译器不能与实际功能类型相匹配您的一。

相关问题