[Haskell-cafe] Type error in final generator

Loganathan Lingappan loganathan.lingappan at yahoo.com
Sat Dec 8 19:34:26 EST 2007

I am new to Haskell. I wrote the following code:

module Main

import IO

main = do
        hSetBuffering stdin LineBuffering
        numList <- processInputs
        foldr (+) 0 numList

processInputs = do
        putStrLn "Enter a number:"
        strNum <- getLine
        let num = read strNum
        if num == 0
                then return []
                else do
                        rest <- processInputs
                        return (num : rest)

And am getting the following errors:

ERROR "Ex310.hs":6 - Type error in final generator
*** Term           : foldr (+) 0 numList
*** Type           : Integer
*** Does not match : IO a

Any pointers to the source of this error would be appreciated.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20071208/22aa3acf/attachment.htm

More information about the Haskell-Cafe mailing list