[Haskell-cafe] Way to implement toFloat :: (Num a) => a -> Float

Ben Gamari bgamari.foss at gmail.com
Thu Dec 12 19:39:59 UTC 2013


EatsKittens <temporalabstraction at gmail.com> writes:

> Is there a way to add a method to a typeclass like num to implement this
> concept? A function that converts any number to floats?
> 
Does the following do what you expect?

realToFrac :: (Fractional b, Real a) => a -> b

realToFrac' :: (Real a) => a -> Float
realToFrac' = realToFrac :: (Real a) => a -> Float

Cheers,

- Ben
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20131212/f3844053/attachment.sig>


More information about the Haskell-Cafe mailing list