流れを読まずに質問。

サブディレクトリの中身も取得するgetDirectoryContentsを書いたのだが
どうもコードに無駄があるように思える。

Haskellらしく簡潔に書くにはどう書いたらいいんだ?

--

module GetRecursiveContents (getRecursiveContents) where
import System.Directory
import Data.List

getRecursiveContents :: FilePath -> IO [FilePath]
getRecursiveContents p = do cs <- getDirectoryContents p
                  result <- mapM (getRecursiveContents' p) $ filter (not . isSuffixOf ".") cs
                  return $ concat result

getRecursiveContents' :: FilePath -> FilePath -> IO [FilePath]
getRecursiveContents' p c = do let newPath = mergePath p c
                    dir <- doesDirectoryExist newPath
                    if dir then getRecursiveContents newPath
                       else return [newPath]

mergePath :: FilePath -> String -> FilePath
mergePath a b
  | "\\" `isSuffixOf` a = a ++ b
  | otherwise = a ++ "\\" ++ b