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

EatsKittens temporalabstraction at gmail.com
Thu Dec 12 19:55:45 UTC 2013


Ah, I had no ideal the real typeclass existed, that completely solves my
issue.


On 12 December 2013 20:39, Ben Gamari <bgamari.foss at gmail.com> wrote:

> 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 --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20131212/916d468f/attachment.html>


More information about the Haskell-Cafe mailing list