-3

这是问题的要点:

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"
          }
    }

指示如何向其中添加返回语句的奖励积分。

工作代码

这个链接显示了一个有点工作的代码,它允许我使用命令式风格探索问题空间。

4

1 回答 1

3

您在第 31 行的 the和 an之间缺少一个分号:putStrLnif

    ....
    else do
    {
      putStrLn ("no " ++ emacsdf ++ "found in your home folder")
    ;                                                            -- HERE
      if confemp
      then do
        {
          putStrLn ("nor folders with the alternative emacs config\n" ++
                    "exiting..." )

        }
    ....

要遵循的模板是

    do { ... ; ... ; ... }

显式大括号分号将防止由于代码中的错误缩进(可能是由于制表符/空格问题)而导致的任何解析错误。

完全显式的符号总是;在每个do块语句之间使用。if ... then ... else ...弥补一个表达式/do语句,即使分布在几行代码中。

于 2018-08-27T06:21:19.560 回答