-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.hs
More file actions
32 lines (27 loc) · 744 Bytes
/
hello.hs
File metadata and controls
32 lines (27 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import System.IO
import Data.Char(toUpper)
main = do
putStrLn "Enter name: "
line <- getLine
let t = checkname line
putStrLn t
inh <- openFile "input.txt" ReadMode
outh <- openFile "output.txt" WriteMode
mainloop inh outh
hClose inh
hClose outh
mainloop :: Handle -> Handle -> IO ()
mainloop inh outh =
do ineof <- hIsEOF inh
if ineof
then
return ()
else do inpStr <- hGetLine inh
hPutStrLn outh (map toUpper inpStr)
mainloop inh outh
checkname :: String -> String
checkname s
| s == "jeff" = "Haskell is great"
| s == "simon" = "Haskell is ok"
| s == "greg" = "Haskell sucks"
| otherwise = "I'm not sure"