import Control.Monad.ListT.Funcs (repeatM) import Data.List.Class (execute, scanl, takeWhile, mapL) import Prelude hiding (scanl, takeWhile) main = execute . mapL print . scanl (+) 0 . fmap (fst . head) . takeWhile (not . null) . fmap reads $ repeatM getLineNote: The transformers package also has a ListT type, which oddly enough it is not a list monad transformer. This module was deliberately named differently from transformers's module.
-- List of files under "." or subfolders with ".markdown" extension, -- except for those with a name starting with "_" somewhere in their path. (like "_cache/index.markdown") markdownFiles :: ListT IO FilePath markdownFiles = filter ((== ".markdown") . takeExtension) -- only take files with a ".markdown" extension . lastL -- get the leaves of the tree (files, not directories) . scanl1 appendPath -- transform tree nodes to filenames including path . prune (not . isPrefixOf "_") -- ignore directories or files whose name starts with "_" $ directoryTree "." -- directory tree starting at "."Module name System.Directory.Tree is a better fit but it is taken by "directory-tree", a read-directory-tree-in-bulk module.