Haskell 使用 'let' 使用 ghci 解析错误
Haskell parse error with ghci with 'let'
我已经在这里坐了很长一段时间了,我的问题无法通过谷歌搜索、尝试和错误来解决。我有以下代码片段:
data Prozess = Prozess { pid :: Int, arrival :: Int, computing :: Int } deriving (Show)
let idle = Prozess{pid=1, arrival=5, computing=10}
所以我尝试用 ghci 编译它,但它一直在 "let idle ..." 行给我一个 "parse error (possibly incorrect indentation or mismatched brackets)"。奇怪的是,我尝试使用我们的 Jupyter-Server 进行编译,这似乎运行良好。此外,如果我在没有 "let" 行的情况下编译它,然后通过 *Main> 中的终端输入 - 完全相同的行,它也工作正常。
那么ghci有什么问题呢?认为我为此失去了理智。
你的 let
没有任何功能是吗?
如果您只是定义全局 "constant",您只需:
idle :: Prozess
idle = Prozess{pid=1, arrival=5, computing=10}
另请注意,您不需要记录符号。您可以将其换成:
idle = Prozess 1 5 10
我已经在这里坐了很长一段时间了,我的问题无法通过谷歌搜索、尝试和错误来解决。我有以下代码片段:
data Prozess = Prozess { pid :: Int, arrival :: Int, computing :: Int } deriving (Show)
let idle = Prozess{pid=1, arrival=5, computing=10}
所以我尝试用 ghci 编译它,但它一直在 "let idle ..." 行给我一个 "parse error (possibly incorrect indentation or mismatched brackets)"。奇怪的是,我尝试使用我们的 Jupyter-Server 进行编译,这似乎运行良好。此外,如果我在没有 "let" 行的情况下编译它,然后通过 *Main> 中的终端输入 - 完全相同的行,它也工作正常。
那么ghci有什么问题呢?认为我为此失去了理智。
你的 let
没有任何功能是吗?
如果您只是定义全局 "constant",您只需:
idle :: Prozess
idle = Prozess{pid=1, arrival=5, computing=10}
另请注意,您不需要记录符号。您可以将其换成:
idle = Prozess 1 5 10