int to float problem

Mike T. Machenry dskippy@ccs.neu.edu
Fri, 28 Feb 2003 14:42:03 -0500


Hello,

  I am having a problem. I recently desided I wanted a bunch function to return
float instead of Int. I changed their type and wrote a new function that
returned a float. I figured it'd be okay if all the others still returned
Int since it's trivial to convert Int to Float. Sadly Haskell won't let me do
this. What should I do? I attempted to cast all of the values in the functions
that returned Int to Float, but I found no way to do this. I found fromInteger
but it didn't seem to work on the return value of the cardinality function for
instance. I guess cardinality much return Int. This is one of my functions.

smallestSet :: GameState -> Float
smallestSet s = (-1 * cardinality (fLocations s))

This function is an error because it infer's an Int.

Thanks,
-mike