【发布时间】:2013-06-01 07:03:22
【问题描述】:
我正在编写一些 Haskell 代码来学习该语言,但遇到了语法错误:
Vec2.hs:33:27: parse error on input '='
我在这里写的代码如下。错误指向vec2Normalize iLength = ... 中的第二个术语我没有看到语法错误
-- Get the inverse length of v and multiply the components by it
-- Resulting in the normalized form of v
vec2Normalize :: Vec2 -> Vec2
vec2Normalize v@(x,y) = (x * iLength, y * iLength)
where length = vec2Length v
iLength = if length == 0 then 1 else (1 / length)
【问题讨论】:
-
这不是您粘贴的第 33 行。错误很可能在其他地方,并且仅在第 33 行报告。无论第 33 行是什么。
-
它所在文件的第 33 行,我只发布了相关部分。当我注释掉这个函数时,错误就消失了。