-2

This is the gist of 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"
          }
    }

bonus points for the indication how to add the return statements to that.

working code

This link shows a somewhat working code that allows me to explore problem space using imperative style.

ruby_object
  • 1,229
  • 1
  • 12
  • 30
  • 2
    Haskell has *no* `return` statement, it has a `return` function, and it does *not* work like the return statement in imperative languages. – Willem Van Onsem Aug 27 '18 at 00:11
  • 1
    If you remove all of the curly braces from that code, without changing the indentation, it should fix the parse error. Also, curly braces are rarely explicitly used in Haskell. – David Young Aug 27 '18 at 01:55
  • critique or improvement suggestions for working code belong on CodeReview, not on SO. :) – Will Ness Aug 27 '18 at 19:20

1 Answers1

3

You are missing one semicolon, on line 31, between the putStrLn and an if:

    ....
    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..." )

        }
    ....

The template to follow is

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

Explicit braces and semicolons will prevent any parsing errors due to mis-indentation (possibly due to tabs/spaces issues) in your code.

The fully explicit notation always uses ; between each of the do block statements. if ... then ... else ... makes up for one expression / do statement, even if spread across several lines of code.

Will Ness
  • 70,110
  • 9
  • 98
  • 181