输入' - >'上的解析错误使用案例时

时间:2014-08-25 09:32:49

标签: haskell

我正在学习haskell,通过学习你的haskell非常好,教程中的一个函数似乎没有编译。我无法弄清楚为什么,我认为它可能是缩进但它似乎没有什么区别。大多数SE问题似乎都是指ghci并尝试设置变量。

describeList :: [a] -> String
describeList xs = "The list is " ++ case xs of [] -> "empty."
                                               [x] -> "a singleton list."
                                               xs -> "a longer list."

我得到的错误是:

describeList.hs:4:95: parse error on input '->'
Failed, modules loaded: none.

1 个答案:

答案 0 :(得分:2)

原来问题在于我在VIM上的标签设置。事实证明,Haskell与缩进非常相似。我将我的vimrc文件更改为这些设置。

" Tab specific option
set tabstop=8                   "A tab is 8 spaces
set expandtab                   "Always uses spaces instead of tabs
set softtabstop=4               "Insert 4 spaces when tab is pressed
set shiftwidth=4                "An indent is 4 spaces
set shiftround                  "Round indent to nearest shiftwidth multiple

来源:http://www.haskell.org/haskellwiki/Vim