Xie
Xie

Reputation: 627

Haskell: putStrLn ploblem

I have wrote a phone book program:

import System.IO

main = do
       putStrLn "Pls input the name: "
       handle <- openFile "phone.txt" ReadMode
       contents <- hGetContents handle
       name<-getLine
       putStrLn . findNumber name $ toDict contents

findNumber x [] = "not found"
findNumber x ((y,z):ys) = if x==y then z else findNumber x ys
toDict :: String -> [(String, String)]
toDict = map read . lines

I got a error when I compile it.

phoneNumber.hs : 7:16: parse error on input '<-'

What is wrong here?

Upvotes: 1

Views: 128

Answers (1)

Thomas M. DuBuisson
Thomas M. DuBuisson

Reputation: 64740

As d8d0d65b3f7cf42 said, this is almost certainly an indentation issue. Copy and pasting your code give no errors, so the re-formatting necessary to post the code on SO probably covered up your issue.

Upvotes: 2

Related Questions