Haskell lazy I/O and closing files

前端 未结 7 873
攒了一身酷
攒了一身酷 2020-12-07 23:35

I\'ve written a small Haskell program to print the MD5 checksums of all files in the current directory (searched recursively). Basically a Haskell version of md5deep

7条回答
  •  生来不讨喜
    2020-12-07 23:57

    EDIT: sorry, thought the problem was with the files, not diectory reading/traversal. Ignore this.

    No problem, just explicitly open the file (openFile), read the contents (Data.ByteString.Lazy.hGetContents), perform the md5 hash (let !h = md5 contents), and explicitly close the file (hClose).

提交回复
热议问题