Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is fromRealFrac?

Tags:

haskell

Where can I find the fromRealFrac function? According to the gentle intro the function should exist and from a bit of googling around, I gather it should be in Prelude - yet ghci complains that it's not in scope.

I'm using fromRational . toRational for the time being, as according to the gentle intro that's how fromRealFrac is meant to be defined.

like image 411
jaymmer - Reinstate Monica Avatar asked Mar 11 '13 03:03

jaymmer - Reinstate Monica


People also ask

What is Realtrac?

Realtrac is an on-premise job management solution designed for job shop manufacturers and modular machine shops. It helps small and midsize manufacturers to schedule workflows, manage shop operations, track inventories, manage purchases and report business operations.

What does MLS stand for in real estate?

REALTORS® have spent millions of dollars to develop Multiple Listing Services (MLS) and other real estate technologies that make the transaction more efficient. An MLS is a private offer of cooperation and compensation by listing brokers to other real estate brokers.


2 Answers

The function formerly known as "fromRealFrac" was renamed "realToFrac" in the Haskell 98 Report.

In the Haskell 1.4 Prelude we find

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

However, by Haskell 98 it is known as

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

This change is listed in the Haskell 98 Report Errata:

[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.

like image 127
Don Stewart Avatar answered Sep 29 '22 18:09

Don Stewart


It appears this function is called realToFrac in the GHC Prelude.

like image 20
Alexey Romanov Avatar answered Sep 29 '22 19:09

Alexey Romanov