Doubt regarding Types
Karthik Kumar
kaykaydreamz at yahoo.com
Mon Nov 3 19:32:33 EST 2003
Hi All,
I was trying to write go program in haskell - My code fragment looks
like this -
<---- >
getBoardSize :: IO Bool
-- TODO : What could be the type of getBoardSize
getBoardSize = do c <- getLine
validateBoardSize ( atoi c )
-- 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
-- validateBoardSize
-- To validate the board size
validateBoardSize :: Int -> Bool
validateBoardSize d = (d == 9 || d == 13 || d == 19 )
<---->
ERROR "test1.hs":21 - Type error in final generator
*** Term : validateBoardSize (atoi c)
*** Type : Bool
*** Does not match : IO a
Actually i guess there is something wrong with the type mentioned for
getBoardSize function , but am clueless abt this.
Thanks in advance for your help in this regard.
Cheers
Karthik
__________________________________
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/
More information about the Haskell-Cafe
mailing list