まだ終わらんよ
この前(4/1)作ったソースがあまりにもアレだったんで書き直そうと思う。ていうか、あらためて見ると汚いし長いしスゴイ恥ずかしいソースだ。自戒のためにのっけたまんまにしておこう。今日は疲れたので、とりあえずfindするところまで。これなら恥ずかしくない、かな?
module Main where import Control.Monad import System.Directory main = do hs <- find ".." isHs mapM_ putStrLn hs isHs = \x -> reverse (take 3 (reverse x)) == ".hs" find :: String -> (FilePath -> Bool) -> IO [FilePath] find dir f = return . filter f =<< (ls_r dir) where ls_r [] = return [] ls_r dir = do all <- getDirectoryContents dir >>= return . filter notParentAndCurrent let all' = map (add dir) all in do dirs <- filterM doesDirectoryExist all' mapM ls_r dirs >>= return . (++ all') . concat notParentAndCurrent = \x -> and $ map (/= x) ["..", "."] add = (++) . flip (++) "/"
ようやくHaskellらしい書き方になってきたかなぁ、とご満悦だ。