Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
1.75/5 (3 votes)
See more:
C++
--Compute for Rectangular Area
main = do
        putStr $ "Length: "
        len <- getLine
        putStr $ "Width: "
        wid <- getLine
        putStr $ getArea len wid

getArea a b = a * b


this is my code..

when i load it in WinHugs..

MSIL
ERROR file:{Hugs}\packages\bin\RecArea.hs:2 - Unresolved top-level overloading
*** Binding             : main
*** Outstanding context : Num [Char]



what should i do?..
Posted

I guess the problem is that getLine gives you a string, but you need a number to do the multiplication. Check out the read function.

And, by the way, asking Google is really faster...
 
Share this answer
 
You should learn to use google. When you search for "haskell", you get back over 8 million hits. Surely, there's a web site or forum somewhere that indicates an answer.
 
Share this answer
 
Comments
jovhenni19 21-Mar-11 10:12am    
can't find an answer...
maybe someone here would help me..
Thanks for replying!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900