小编Wal*_*erM的帖子

我如何处理多级缩进?

我正在编写一个具有非常复杂的循环的脚本:

main = do
    inFH <- openFile "..." ReadMode
    outFH <- openFile "..." WriteMode

    forM myList $ \ item ->
        ...
        if ... 
            then ...
            else do
                ...
                case ... of
                    Nothing -> ...
                    Just x  -> do
                        ...
                            ...
Run Code Online (Sandbox Code Playgroud)

代码很快就会飞到右边,所以我想把它分成几块,使用例如where子句.问题是,许多这些...包含读/写语句到两个把手inFHoutFH,使用where的语句将呈现这两个名字断章取义.我每次使用where语句时都必须发送这两个变量.

有没有更好的方法来解决这个问题?

haskell code-organization indentation

4
推荐指数
2
解决办法
296
查看次数

标签 统计

code-organization ×1

haskell ×1

indentation ×1