Haskell错误:解析输入`='时的错误 [英] Haskell Error: parse error on input `='
本文介绍了Haskell错误:解析输入`='时的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
规格
GHC 6.12.1
GHC 6.12.1
Mac OS X 10.6.4 x64
Mac OS X 10.6.4 x64
MacBook Pro
MacBook Pro
问题
我在使用 let
语法时遇到问题.以下代码拒绝编译:
I'm having trouble using let
syntax. The following code refuses to compile:
module Main where
main = let x = 1
y = 2
z = 3
in putStrLn $ "X = " ++ show x ++ "\nY = " ++ show y ++ "\nZ = " ++ show z
我尝试在 y = 2
和 z = 3
中进行制表.没有骰子.
I tried tabbing in y = 2
and z = 3
even more. No dice.
(不受欢迎的)解决方案
我要编译代码的唯一方法是要么
The only way I've gotten the code to compile is either
- 用空格替换硬标签.
- 用
where
子句替换let
子句.
- Replacing hard tabs with spaces.
- Replacing the
let
clause with awhere
clause.
#haskell上的
推荐答案
Saizan解释说,let表达式中的赋值必须对齐,而不是 let 本身.只要任务排成一行,就可以使用硬标签或软标签.
Saizan on #haskell explains that the assignments in a let expression have to align, not let itself. As long as the assignments line up, it's okay to use hard tabs or soft tabs.
正确的代码:
module Main where
main = let
x = 1
y = 2
z = 3
in putStrLn $ "X = " ++ show x ++ "\nY = " ++ show y ++ "\nZ = " ++ show z
这篇关于Haskell错误:解析输入`='时的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文