refacTypeSig args
  = do let fileName   = args!!0

       AbstractIO.putStrLn "refacTypeSig"
       modName1 <- fileNameToModName fileName 

       let modName = convertModName modName1

       -- Parse the input file.
       (inscps, exps, mod, tokList) <- parseSourceFile fileName
       
       let newRefactoredDecls = hsDecls mod
       sigs <- mapM (getSig fileName modName) (filter (/="") (map declToName newRefactoredDecls))

       res <- applyRefac (addTypes (dropWhile (\x -> x == defaultPN) (map (declToPName (map declToName newRefactoredDecls)) newRefactoredDecls)) sigs) (Just (inscps, exps, mod, tokList)) fileName
       -- ((_,m), (newToks, newMod)) <- applyRefac (addType ses modName ) (Just (inscps, exps, mod, tokList)) fileName
           
           
    --   res <- findDefsWithType ses mod
       
    --   AbstractIO.putStrLn $ show res    
        
       writeRefactoredFiles True [res]
       
       (inscps5, exps5, mod5, tokList5) <- parseSourceFile fileName

              
       (mod',((tokList'',modified),_))<-(doCommenting (dropWhile (\x -> x == defaultPN) (map (declToPName (map declToName newRefactoredDecls)) newRefactoredDecls))) fileName mod5 tokList5
              
              
       writeRefactoredFiles True [((fileName, True), (tokList'', mod'))]
           
       AbstractIO.putStrLn "Completed."
refacTypeSig args
  = do let fileName   = args!!0

       AbstractIO.putStrLn "refacTypeSig"
       modName1 <- fileNameToModName fileName 

       let modName = convertModName modName1

       -- Parse the input file.
       (inscps, exps, mod, tokList) <- parseSourceFile fileName
       
       let newRefactoredDecls = hsDecls mod
       sigs <- mapM (getSig fileName modName) (filter (/="") (map declToName newRefactoredDecls))

       res <- applyRefac (addTypes (dropWhile (\x -> x == defaultPN) (map (declToPName (map declToName newRefactoredDecls)) newRefactoredDecls)) sigs) (Just (inscps, exps, mod, tokList)) fileName
       -- ((_,m), (newToks, newMod)) <- applyRefac (addType ses modName ) (Just (inscps, exps, mod, tokList)) fileName
           
           
    --   res <- findDefsWithType ses mod
       
    --   AbstractIO.putStrLn $ show res    
        
       writeRefactoredFiles True [res]
       
       (inscps5, exps5, mod5, tokList5) <- parseSourceFile fileName

              
       (mod',((tokList'',modified),_))<-(doCommenting (dropWhile (\x -> x == defaultPN) (map (declToPName (map declToName newRefactoredDecls)) newRefactoredDecls))) fileName mod5 tokList5
              
              
       writeRefactoredFiles True [((fileName, True), (tokList'', mod'))]
           
       AbstractIO.putStrLn "Completed."
refacTypeSig args
  = do let fileName   = args!!0

       AbstractIO.putStrLn "refacTypeSig"
       modName1 <- fileNameToModName fileName 

       let modName = convertModName modName1

       -- Parse the input file.
       (inscps, exps, mod, tokList) <- parseSourceFile fileName
       
       let newRefactoredDecls = hsDecls mod
       sigs <- mapM (getSig fileName modName) (filter (/="") (map declToName newRefactoredDecls))

       res <- applyRefac (addTypes (dropWhile (\x -> x == defaultPN) (map (declToPName (map declToName newRefactoredDecls)) newRefactoredDecls)) sigs) (Just (inscps, exps, mod, tokList)) fileName
       -- ((_,m), (newToks, newMod)) <- applyRefac (addType ses modName ) (Just (inscps, exps, mod, tokList)) fileName
           
           
    --   res <- findDefsWithType ses mod
       
    --   AbstractIO.putStrLn $ show res    
        
       writeRefactoredFiles True [res]
       
       (inscps5, exps5, mod5, tokList5) <- parseSourceFile fileName

              
       (mod',((tokList'',modified),_))<-(doCommenting (dropWhile (\x -> x == defaultPN) (map (declToPName (map declToName newRefactoredDecls)) newRefactoredDecls))) fileName mod5 tokList5
              
              
       writeRefactoredFiles True [((fileName, True), (tokList'', mod'))]
           
       AbstractIO.putStrLn "Completed."