Where is RealFrac located?

Where can I find the fromRealFrac function? According to a gentle introduction, the function must exist from a small number of search queries, I think it should be in Prelude, but ghci complains that it is not in the field.

I am using fromRational . toRational fromRational . toRational now, since according to a gentle introduction, as expected fromRealFrac .

+8
haskell
source share
3 answers

The function, formerly known as "fromRealFrac", was renamed to "realToFrac" in the Haskell 98 report.

In Haskell 1.4 Prelude we find

 fromRealFrac :: (RealFrac a, Fractional b) => a -> b fromRealFrac = fromRational . toRational 

However, Haskell 98 is known as

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

This change is noted in Haskell 98. Report an error :

 [Apr 2001] Page 84, Section 6.4, Fig 7; and bottom of page 86, Section 6.4.6. fromRealFrac :: (RealFrac a, Fractional b) => a -> b should be replaced by realToFrac :: (Real a, Fractional b) => a -> b 

The closest commit I could find was this in the report repo.

+19
source share

It appears , this feature is called realToFrac in the GHC Prelude.

+5
source share

According to Hoogle , there is no function named fromRealFrac in standard libraries. Perhaps this is the function that the authors of the gentle introduction composed? . Having looked at the link, they, of course, believe that it is somewhere in the library ... I am also confused.

+2
source share

All Articles