diff options
| -rw-r--r-- | src/Plugins/Monitors/CoreCommon.hs | 24 | 
1 files changed, 12 insertions, 12 deletions
| diff --git a/src/Plugins/Monitors/CoreCommon.hs b/src/Plugins/Monitors/CoreCommon.hs index eb3e17f..f866d31 100644 --- a/src/Plugins/Monitors/CoreCommon.hs +++ b/src/Plugins/Monitors/CoreCommon.hs @@ -64,9 +64,9 @@ data CompOrSep = Slash  -- | Function to turn a list of of strings into a list of path components  pathComponents :: [String] -> [Comp] -pathComponents = joinComps . drop 2 . concat . intersperse [Space] . map splitParts +pathComponents = joinComps . drop 2 . intercalate [Space] . map splitParts    where -    splitParts p | (l, _:r) <- break (== '/') p = (Comp l):Slash:splitParts r +    splitParts p | (l, _:r) <- break (== '/') p = Comp l : Slash : splitParts r                   | otherwise                    = [Comp p]      joinComps = uncurry joinComps' . partition isComp @@ -101,24 +101,24 @@ findFiles path lbl  =  catMaybes                         )    where      addLabel (i, f) = maybe (return $ Just (f, Left i)) -                            (\(s, t) -> justIfExists f s t) +                            (uncurry (justIfExists f))                              lbl      justIfExists f s t = let f' = take (length f - length s) f ++ s -                         in  ifthen (Just (f, Right (f', t))) Nothing <$> (io $ doesFileExist f') +                         in  ifthen (Just (f, Right (f', t))) Nothing <$> io (doesFileExist f')      recFindFiles [] d  =  ifthen [d] [] -                      <$> (io $ if null d then return False else doesFileExist d) +                      <$> io (if null d then return False else doesFileExist d)      recFindFiles ps d  =  ifthen (recFindFiles' ps d) (return []) -                      =<< (io $ if null d then return True else doesDirectoryExist d) +                      =<< io (if null d then return True else doesDirectoryExist d)      recFindFiles' []         _  =  error "Should not happen"      recFindFiles' (Fix p:ps) d  =  recFindFiles ps (d ++ "/" ++ p)      recFindFiles' (Var p:ps) d  =  concat -                               <$> (     mapM (recFindFiles ps) -                                      .  map (\f -> d ++ "/" ++ f) -                                      .  filter (matchesVar p) -                                     =<< (io $ getDirectoryContents d) +                               <$> ((mapM (recFindFiles ps +                                           . (\f -> d ++ "/" ++ f)) +                                      . filter (matchesVar p)) +                                     =<< io (getDirectoryContents d)                                     )      matchesVar []     _  = False @@ -135,8 +135,8 @@ findFiles path lbl  =  catMaybes  readFiles :: (String, Either Int (String, String -> Int))            -> Monitor (Int, String)  readFiles (fval, flbl) = (,) <$> either return (\(f, ex) -> liftM ex -                                                          $ io $ readFile f) flbl -                             <*> (io $ readFile fval) +                                                            $ io $ readFile f) flbl +                             <*> io (readFile fval)  -- | Function that captures if-then-else  ifthen :: a -> a -> Bool -> a | 
