从哪里可以获得完整的 Haskell 代码编写缩进规则集?
与我的以下问题类似的过去 SO 问题导致我提出上述问题。错误消息背后的原因是什么:parse error on input 'something'
?
我得到的错误信息:
baby.hs:103:2:输入“myList”时解析错误(此行错误)
我正在尝试编译的代码:
myList = ["aeroplane", "Aeroplane", "AeRoPlAne", "helicopter", "HELICOPTER", "Zebra"]
quicksort :: (Ord a) => [a] -> [a]
quicksort [] = []
quicksort (x:xs) =
let smallerSorted = quicksort [a | a <- xs, a <= x]
biggerSorted = quicksort [a | a <- xs, a > x]
in smallerSorted ++ [x] ++ biggerSorted
优化编辑:
我将问题中的代码转移到新的 .hs 文件并尝试编译它。仍然存在类似的错误消息。详情如下:
错误
quickSort.hs:5:62:输入“=”时解析错误失败,加载模块:无。(0.02 秒,0 字节)代码快速排序 :: (Ord a) => [a] -> [a]
quicksort [] = [] quicksort (x:xs) = let smallSorted = quicksort [a | a <- xs, a <= x]
大排序 = 快速排序 [a | a <- xs, a > x]
in smallSorted ++ [x] ++ largeSorted
myList = ["aeroplane", "Aeroplane", "AeRoPlAne", "helicopter", "HELICOPTER", "Zebra", "America"]