numeric-prelude-0.4.3.3: An experimental alternative hierarchy of numeric type classes
Safe HaskellNone
LanguageHaskell98

Algebra.ToRational

Synopsis

Documentation

class (C a, C a, Ord a) => C a where Source #

This class allows lossless conversion from any representation of a rational to the fixed Rational type. "Lossless" means - don't do any rounding. For rounding see Algebra.RealRing. With the instances for Float and Double we acknowledge that these types actually represent rationals rather than (approximated) real numbers. However, this contradicts to the Transcendental class.

Laws that must be satisfied by instances:

 fromRational' . toRational === id

Methods

toRational :: a -> Rational Source #

Lossless conversion from any representation of a rational to Rational

Instances

Instances details
C Double Source # 
Instance details

Defined in Algebra.ToRational

C Float Source # 
Instance details

Defined in Algebra.ToRational

C Int Source # 
Instance details

Defined in Algebra.ToRational

C Int8 Source # 
Instance details

Defined in Algebra.ToRational

C Int16 Source # 
Instance details

Defined in Algebra.ToRational

C Int32 Source # 
Instance details

Defined in Algebra.ToRational

C Int64 Source # 
Instance details

Defined in Algebra.ToRational

C Integer Source # 
Instance details

Defined in Algebra.ToRational

C Word Source # 
Instance details

Defined in Algebra.ToRational

C Word8 Source # 
Instance details

Defined in Algebra.ToRational

C Word16 Source # 
Instance details

Defined in Algebra.ToRational

C Word32 Source # 
Instance details

Defined in Algebra.ToRational

C Word64 Source # 
Instance details

Defined in Algebra.ToRational

C T Source # 
Instance details

Defined in Number.Peano

(Ord a, C a) => C (T a) Source # 
Instance details

Defined in Number.NonNegative

Methods

toRational :: T a -> Rational Source #

(C a, C a) => C (T a) Source # 
Instance details

Defined in Algebra.ToInteger

Methods

toRational :: T a -> Rational Source #

Real a => C (T a) Source # 
Instance details

Defined in MathObj.Wrapper.Haskell98

Methods

toRational :: T a -> Rational Source #

(C a, C a) => C (T a) Source # 
Instance details

Defined in Number.NonNegativeChunky

Methods

toRational :: T a -> Rational Source #

C a => C (T a) Source # 
Instance details

Defined in MathObj.Wrapper.NumericPrelude

Methods

toRational :: T a -> Rational Source #

realToField :: (C a, C b) => a -> b Source #

It should hold

realToField = fromRational' . toRational

but it should be much more efficient for particular pairs of types, such as converting Float to Double. This achieved by optimizer rules.