2011-12-13 90 views
0

在我的调试器ex中,haskell指向dropWhile中间的一个奇怪错误: 解析错误输入'=' 加载模块失败。Haskell编译错误

代码:

identifyFilter :: String -> (Filter, String) 
identifyFilter ('"':xs) | not null rest = (filter, rest1) 
         | otherwise  = error "Invalid input" 
        where (field, rest) = break (=='"') xs 
          (cond, rest1) = break (=='"') (tail (dropWhile (/= '"') (tail rest))) 
          filter = (FieldName field , identifyParsers cond)      
identifyFilter ('@':xs) | not null rest = (filter, rest1) 
         | otherwise = error "Invalid input" 
        where (index, rest)(reads xs) :: [(Int,String)] 
          (cond, rest1) = break (=='"') (tail (dropWhile (/= '"') (tail rest))) 
          filter = (FieldIndex index , identifyParsers cond) 
identifyFilter (x:xs) = error "Invalid input" 

我有没有可能什么线索可能是一个特别引起错误时,它指向到一个字的中间。 如果需要更多,请询问。 任何建议将有助于

+0

GHCi接受我的线(用'let'代替'where')。问题可能在其他地方。 – ibid

+1

一个简短但完整的代码示例在编译时会产生精确的错误,这很好。 – sepp2k

+0

是否有任何前面/后面的行在'dropWhile'中间的上方/下方有一个'='?如果是这样,他们是什么? – dave4420

回答

3
where (index, rest)(reads xs) :: [(Int,String)] 

被完全打破,也许(index, rest) = head (reads xs :: [(Int, String)])?无论如何,这会导致该行或下面的解析错误。

在另一方面,条件

| not null rest = ... 

需要括号

| not (null rest) = ... 

但应该给出一个类型的错误,而不是解析错误。

+0

谢谢!这有帮助,但由于某种原因,还存在另一个错误,抱怨在不存在的线上的indentaation ... – DustBunny

+0

混合的标签和空间也许? –

+0

我尝试了所有可能的标签组合,每次都会出现非常奇怪的错误,其中一个甚至像位置1:1,无效输入';' – DustBunny