[Haskell-cafe] newbie help

Tomasz Zielonka tomasz.zielonka at gmail.com
Fri Nov 4 02:52:16 EST 2005


On 11/4/05, Abhijit Ray <avizit at gmail.com> wrote:
> I wrote the following program and it dint compile.
> what's wrong with it
>
> module Main
>         where
>
> import IO
>
> main = do
>         hSetBuffering stdin LineBuffering
>         let testList = makeList
>         let sum = foldr (+) 0 testList
>         putStrLn "Sum is " ++ show(sum)

Write either

  testList <- makeList

or

  sum <- liftM (foldr (+) 0) testList

You probably want the former form.

BTW, there is a sum function in Haskell prelude.

Best regards
Tomasz


More information about the Haskell-Cafe mailing list