[Haskell-cafe] Yet another stupid question about numeric conversion

Lennart Augustsson lennart at augustsson.net
Tue Aug 21 13:09:23 EDT 2007


How can you hope to convert an arbitrary Num to a Float?
Num contains things like complex numbers that don't have any reasonable
translation to a Float.
But anyway, realToFrac is a good conversion function.

  -- Lennart

On 8/21/07, Peter Verswyvelen <bf3 at telenet.be> wrote:
>
> Does a general approach exist to convert any non-constant (Num a) to a
> Float? Not using type annotation of course.
>
> Now I wrote a Convert class that has a toFloat function which I
> instantiate
> for all different numeric types, but as all these toFloat/toInt functions
> disappeared a long time ago from Haskell, it feels like a bad idea to
> reintroduce them locally in my code...
>
> Thanks (again!)
> Peter Verswyvelen
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070821/724c54da/attachment.htm


More information about the Haskell-Cafe mailing list