【发布时间】:2018-08-26 23:53:39
【问题描述】:
这是the problem的要点:
check_if_proceed configFolders = do
let emacsdf = "/home/jacek/.emacs.d"
traceM ("calling check_if_proceed " ++ show ("ccc",configFolders))
exists <- doesDirectoryExist emacsdf
symlink <- pathIsSymbolicLink emacsdf
let confemp = configFolders == []
let result = False
if exists
then do
{
if symlink
then do
{
putStrLn ("This action will overwrite the existing symlink\n"++
"poinitng to " ++ "SOMEWHERE-FINISH ME\n\n" )
}
else do
{
putStrLn (emacsdf ++ " is not a symlink\n"++
"to use this utility, in your terminal do soemthing like:\n"++
"$ mv " ++ emacsdf ++ " " ++ emacsdf ++ "-alternative-config\n" ++
"exiting..." )
}
}
else do
{
putStrLn ("no " ++ emacsdf ++ "found in your home folder")
if confemp
then do
{
putStrLn ("nor folders with the alternative emacs config\n" ++
"exiting..." )
}
else
do {
putStrLn "will try to symlink one of the found folders"
}
}
奖励积分用于指示如何向其中添加返回语句。
工作代码
此链接显示了一些有效的代码,允许我使用命令式样式探索问题空间。
【问题讨论】:
-
Haskell 有 no
return语句,它有一个return函数,它not 像命令式语言中的 return 语句一样工作. -
如果您从该代码中删除所有花括号,而不更改缩进,它应该修复解析错误。此外,花括号很少在 Haskell 中显式使用。
-
对工作代码的批评或改进建议属于 CodeReview,而不是 SO。 :)
标签: haskell syntax do-notation