domingo, 26 de abril de 2015

Files

In programming, we will inadvertently come across files and file input and output.

Create a small text file called "foo.txt"

In my case, I have created a file with the contents:

abc
def
ghi
jlk
mno

and saved it in the same directory where I shall save my file-input code.

Now create a file called "file-input-1.hs" as follows:

-- | file-input-1.hs

import qualified Data.ByteString as Str

main = do contents <- Str.readFile "foo.txt"
          Str.putStr contents


Run the code:



This is not the only way we cold have written our file-input program.


No hay comentarios.:

Publicar un comentario