[Haskell-cafe] Type error in final generator
loganathan.lingappan at yahoo.com
Sat Dec 8 20:47:44 EST 2007
Thanks Bryan and Derek. This works!
----- Original Message ----
From: Derek Elkins <derek.a.elkins at gmail.com>
To: Bryan O'Sullivan <bos at serpentine.com>
Cc: Loganathan Lingappan <loganathan.lingappan at yahoo.com>; haskell-cafe at haskell.org
Sent: Saturday, December 8, 2007 4:53:54 PM
Subject: Re: [Haskell-cafe] Type error in final generator
On Sat, 2007-12-08 at 16:39 -0800, Bryan O'Sullivan wrote:
> Loganathan Lingappan wrote:
> > main = do
> > hSetBuffering stdin LineBuffering
> > numList <- processInputs
> > foldr (+) 0 numList
> The type of main is understood to be IO (), so it can't return
> You could work around this by rewriting the last line above as
> print (foldr (+) 0 numList)
> This prints the number, which is presumably what you want, and print
> type IO (), so it works out nicely here.
Actually, as the error message says, the type of main is IO a so it can
'return' -anything- and that will be discarded as the type makes clear.
The issue is that foldr (+) 0 numList :: Integer and that's not IO a
any a. Either way, Bryan's suggestion is probably what you want.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe