title: Haskell recursive function with if else block
body: <p>Hi I am new to Haskell and getting this error in my function doSomething</p>
  
  <blockquote>
    <p>Unexpected semi-colons in conditional:
           if (solveMaze
                 (x + 1) y ex ey arr wasHere correctPath) then do { replaceNth
                                                                      correctPath
                                                                    !! x y True;
                                                                    return True }; else Nothing
       Perhaps you meant to use -XDoAndIfThenElse?</p>
  </blockquote>
  
  <p>I have looked up on indentation and everything seems to be correct.</p>
  
  <p>Below is my code</p>
  
  <pre><code>replaceValue n newVal (x:xs)
       | n == 0 = newVal:xs
       | otherwise = x:replaceValue (n-1) newVal xs
  
  doSomething :: Int -&gt; Int -&gt; Int -&gt; Int -&gt; [String] -&gt; [[Bool]] -&gt; [[Bool]] -&gt; Bool
  doSomething x y a b arr visited correct = do
   if (x == a &amp;&amp; y == b) 
    then do return True   
    else if (arr !! y !! x  == 'A' || visited !! x !! y == True) 
     then do return False  
     else do
      replaceValue visited !! x y True   
      if (x /= 0) 
       then do 
        if(doSomething (x-1) y a b arr visited correct) 
         then do
          replaceValue correct !! x y True
          return True
         else do 
          Nothing   
       else if (x /= length arr !! 0) 
        then do  
         if(doSomething (x+1) y a b arr visited correct) 
          then do
           replaceValue correct !! x y True
           return True
         else Nothing   
       else if (y /= 0) 
        then do 
         if(doSomething x (y-1) a b arr visited correct) 
          then do
           replaceValue correct !! x y True
           return True
          else Nothing   
       else if (y /= length arr) 
        then do
         if (doSomething x (y+1) a b arr visited correct) 
          then do
           replaceValue correct !! x y True
           return True
          else Nothing   
       else Nothing
      return False
  </code></pre>
  
  <p>Thanks!</p>