[Haskell-cafe] Newbie question -- fromInt

Tim Rowe digitig at gmail.com
Thu Apr 28 11:13:54 EDT 2005

I'm working through "The craft of functional programming" , and I've
come to excercise 3.14: "Give a function to return the average of
three integers".

My attempt at an answer is:

averageThree :: Int -> Int -> Int -> Float
averageThree a b c = fromInt(a + b + c) / 3

but when I try to load this file I get an error, "Undefined variable fromInt".  

I get the error on winHugs version Nov 2003 and on Hugs version Nov
2003 (in both cases in Hugs mode).  Curiously, when I found a machine
with an old (2002) version of Hugs on it the file loaded fine.

Has something changed between versions of Hugs, is my code reasonable,
and how /do/ I convert an Int to a Float in Hugs version Nov 2003?

Thanks in advance,

Tim Rowe

More information about the Haskell-Cafe mailing list