Newbie's question: I want to ls the filenames of a directory. The program in C is something like:
#include <direnet.h>
int main(){
DIR *dp;
struct dirent *dirp;
dp = opendir("/");
while((dirp = readdir(dp)) != NULL)
printf("%s\n", dirp->d_name);
closedir(dp);
}
and I write that in haskell:
-----
import System.Posix
import System.IO
main = do
dp <- openDirStream "/"
df <- readDirStream dp
putStrLn df
closeDirStream dp
------
It can print the first entry of the dir, but how can we list it all like the C prog? map ? list comperhension?