Thanks a ton Hal for the quick clarification. It worked . Cheers Karthik.
--- Hal Daume III <[EMAIL PROTECTED]> wrote: > Hi, > > On Mon, 3 Nov 2003, Karthik Kumar wrote: > > -- Convert a string to an integer. > > -- This works perfectly fine. > > atoi :: [Char] -> Int > > atoi (h : []) = if isDigit h then digitToInt h else 0 > > atoi (h : t) = if isDigit h then digitToInt h * ( 10 ^ length t) + > > atoi t else 0 > > you can use "read" for this. > > > -- validateBoardSize > > -- To validate the board size > > validateBoardSize :: Int -> Bool > > validateBoardSize d = (d == 9 || d == 13 || d == 19 ) > > this looks fine > > > getBoardSize :: IO Bool > > -- TODO : What could be the type of getBoardSize > > getBoardSize = do c <- getLine > > validateBoardSize ( atoi c ) > > > > ERROR "test1.hs":21 - Type error in final generator > > *** Term : validateBoardSize (atoi c) > > *** Type : Bool > > *** Does not match : IO a > > this is telling you something important. it's saying that the final > generator, "validateBoardSize (atoi c)" has type Bool, but it's > expecting > it to have type IO something. You need to "lift" the pure Bool value > into > IO by saying return: > > > getBoardSize = do > > c <- getLine > > return (validateBoardSize (read c)) > > -- > Hal Daume III | [EMAIL PROTECTED] > "Arrest this man, he talks in maths." | > www.isi.edu/~hdaume > __________________________________ Do you Yahoo!? Exclusive Video Premiere - Britney Spears http://launch.yahoo.com/promos/britneyspears/ _______________________________________________ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
