int to float problem
Lennart Augustsson
lennart@augustsson.net
Fri, 28 Feb 2003 21:39:26 +0100
Use the Prelude function realToFrac.
-- Lennart
Mike T. Machenry wrote:
>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
>_______________________________________________
>Haskell mailing list
>Haskell@haskell.org
>http://www.haskell.org/mailman/listinfo/haskell
>
>
>