tcStmt ret (IfStatement l condE thenS (Just elseS)) = tcStmtBlock l "if statement" $ do
    condE' <- tcStmtBlock l "if statement" $ tcGuard condE
    (thenS',StmtType cs1) <- tcLocal l "tcStmt if then" $ tcNonEmptyStmt ret thenS
    (elseS',StmtType cs2) <- tcLocal l "tcStmt if else" $ tcNonEmptyStmt ret elseS 
    let t = StmtType $ cs1 `Set.union` cs2
    return (IfStatement (notTyped "tcStmt" l) condE' thenS' (Just elseS'),t)
tcStmt ret (IfStatement l condE thenS (Just elseS)) = tcStmtBlock l "if statement" $ do
    condE' <- tcStmtBlock l "if statement" $ tcGuard condE
    (thenS',StmtType cs1) <- tcLocal l "tcStmt if then" $ tcNonEmptyStmt ret thenS
    (elseS',StmtType cs2) <- tcLocal l "tcStmt if else" $ tcNonEmptyStmt ret elseS 
    let t = StmtType $ cs1 `Set.union` cs2
    return (IfStatement (notTyped "tcStmt" l) condE' thenS' (Just elseS'),t)
tcStmt ret (IfStatement l condE thenS (Just elseS)) = tcStmtBlock l "if statement" $ do
    condE' <- tcStmtBlock l "if statement" $ tcGuard condE
    (thenS',StmtType cs1) <- tcLocal l "tcStmt if then" $ tcNonEmptyStmt ret thenS
    (elseS',StmtType cs2) <- tcLocal l "tcStmt if else" $ tcNonEmptyStmt ret elseS 
    let t = StmtType $ cs1 `Set.union` cs2
    return (IfStatement (notTyped "tcStmt" l) condE' thenS' (Just elseS'),t)