How do I implement `cat` in Haskell?

后端 未结 4 778
悲哀的现实
悲哀的现实 2021-01-11 12:24

I am trying to write a simple cat program in Haskell. I would like to take multiple filenames as arguments, and write each file sequentially to STDOUT

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-11 12:48

    catHandle, which is indirectly called from catFileArray, calls exitWith when it reaches the end of the first file. This terminates the program, and further files aren't read anymore.

    You should instead just return normally from the catHandle function when the end of the file has been reached. This probably means you shouldn't do the reading forever.

提交回复
热议问题