Created
January 3, 2012 23:39
-
-
Save bmjames/1557596 to your computer and use it in GitHub Desktop.
totally non-complex way to list files in a directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val openFile: String => IO[File] | |
= path => io { new File(path) } | |
val fileName: File => String | |
= _.toString | |
val putStrLn: String => IO[Unit] | |
= s => io { println(s) } | |
val listFiles: File => IO[Seq[File]] | |
= f => io { f.listFiles } | |
val result = openFile(".") >>= listFiles >>= (_ traverse_ (fileName map putStrLn)) | |
result.unsafePerformIO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment