无法将预期类型“Double”与实际类型“[c0]”匹配

时间:2012-10-21 11:16:48

标签: haskell

我有这个解释错误,我不知道出了什么问题

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.

任何人都可以提供帮助?提前谢谢!

1 个答案:

答案 0 :(得分:3)

很容易通过ghci找到答案:

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

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

我不知道出了什么问题

您的签名错误,编译器无法将您的签名与实际功能类型相匹配。