ZVON > References > Haskell reference
| Indexes | Syntax | >> Prelude << | Ratio | Complex | Numeric | Ix | Array | List | Maybe | Char | Monad | IO | Directory | System | Time | Locale | CPUTime | Random

Module: Prelude
Function: readFile
Type: FilePath -> IO String
Description:
Related: appendFile, writeFile

Example 1
File: /tmp/foo : 

BBBCCC
Program source: 

main = do x <- readFile "/tmp/foo.txt"
	  putStr x

Output: BBBCCC

Example 2
File: /tmp/foo.txt : 

[1,2,4,6,7]
Program source: 

main = do x <- readFile "/tmp/foo.txt"
	  y <- rList x
	  print (sum y)

rList :: String -> IO [Int]	  
rList = readIO

Output: 20