我正在编写一个具有非常复杂的循环的脚本:
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子句.问题是,许多这些...包含读/写语句到两个把手inFH和outFH,使用where的语句将呈现这两个名字断章取义.我每次使用where语句时都必须发送这两个变量.
有没有更好的方法来解决这个问题?