causeRecursiveMods decl origFile origModName destModName
 =do let pns  = nub $ concatMap definedPNs decl
     clients<-clientModsAndFiles origModName
     servers <-serverModsAndFiles destModName 
     let clientMods1 = map fst clients
         clientFiles =map snd clients
         serverMods = map fst servers
         serverFiles =map snd servers
     if elem destModName clientMods1
      then do let ms = origFile:(clientFiles `intersect` serverFiles)
              parsedMods<-mapM parseSourceFile ms
              let (_,_,origMod,_) = ghead "causeRecursiveMods" parsedMods
              return ( isUsedBy pns (hsDecls origMod \\ decl) ||
                       (any (\ (_,_,mod,_)->isUsedByMod pns mod) (tail parsedMods)))
      else if elem destModName serverMods
             then do clients <- clientModsAndFiles destModName
                     let ms = origModName : (map fst clients `intersect` serverMods)                            
                         r  = map fromJust (filter isJust (map hasModName $ nub (map pNTtoPN (hsPNTs decl)) \\ pns))
                     return $ any (\m-> elem m r ) ms
             else return False  
causeRecursiveMods decl origFile origModName destModName
 =do let pns  = nub $ concatMap definedPNs decl
     clients<-clientModsAndFiles origModName
     servers <-serverModsAndFiles destModName 
     let clientMods1 = map fst clients
         clientFiles =map snd clients
         serverMods = map fst servers
         serverFiles =map snd servers
     if elem destModName clientMods1
      then do let ms = origFile:(clientFiles `intersect` serverFiles)
              parsedMods<-mapM parseSourceFile ms
              let (_,_,origMod,_) = ghead "causeRecursiveMods" parsedMods
              return ( isUsedBy pns (hsDecls origMod \\ decl) ||
                       (any (\ (_,_,mod,_)->isUsedByMod pns mod) (tail parsedMods)))
      else if elem destModName serverMods
             then do clients <- clientModsAndFiles destModName
                     let ms = origModName : (map fst clients `intersect` serverMods)                            
                         r  = map fromJust (filter isJust (map hasModName $ nub (map pNTtoPN (hsPNTs decl)) \\ pns))
                     return $ any (\m-> elem m r ) ms
             else return False  
causeRecursiveMods decl origFile origModName destModName
 =do let pns  = nub $ concatMap definedPNs decl
     clients<-clientModsAndFiles origModName
     servers <-serverModsAndFiles destModName 
     let clientMods1 = map fst clients
         clientFiles =map snd clients
         serverMods = map fst servers
         serverFiles =map snd servers
     if elem destModName clientMods1
      then do let ms = origFile:(clientFiles `intersect` serverFiles)
              parsedMods<-mapM parseSourceFile ms
              let (_,_,origMod,_) = ghead "causeRecursiveMods" parsedMods
              return ( isUsedBy pns (hsDecls origMod \\ decl) ||
                       (any (\ (_,_,mod,_)->isUsedByMod pns mod) (tail parsedMods)))
      else if elem destModName serverMods
             then do clients <- clientModsAndFiles destModName
                     let ms = origModName : (map fst clients `intersect` serverMods)                            
                         r  = map fromJust (filter isJust (map hasModName $ nub (map pNTtoPN (hsPNTs decl)) \\ pns))
                     return $ any (\m-> elem m r ) ms
             else return False  