{-# LANGUAGE DataKinds #-} module Numeric.Rounded.Hardware.Internal.Conversion ( roundedFromInteger_default , roundedFromRational_default , intervalFromInteger_default , intervalFromIntegral , intervalFromRational_default ) where import Data.Functor.Product import Numeric.Floating.IEEE import Numeric.Floating.IEEE.Internal (fromIntegerR, fromIntegralR, fromRationalR, roundTowardNegative, roundTowardPositive) import Numeric.Rounded.Hardware.Internal.Rounding roundedFromInteger_default :: RealFloat a => RoundingMode -> Integer -> a roundedFromInteger_default :: forall a. RealFloat a => RoundingMode -> Integer -> a roundedFromInteger_default RoundingMode ToNearest = forall a. RealFloat a => Integer -> a fromIntegerTiesToEven roundedFromInteger_default RoundingMode TowardZero = forall a. RealFloat a => Integer -> a fromIntegerTowardZero roundedFromInteger_default RoundingMode TowardInf = forall a. RealFloat a => Integer -> a fromIntegerTowardPositive roundedFromInteger_default RoundingMode TowardNegInf = forall a. RealFloat a => Integer -> a fromIntegerTowardNegative {-# INLINE roundedFromInteger_default #-} roundedFromRational_default :: RealFloat a => RoundingMode -> Rational -> a roundedFromRational_default :: forall a. RealFloat a => RoundingMode -> Rational -> a roundedFromRational_default RoundingMode ToNearest = forall a. RealFloat a => Rational -> a fromRationalTiesToEven roundedFromRational_default RoundingMode TowardZero = forall a. RealFloat a => Rational -> a fromRationalTowardZero roundedFromRational_default RoundingMode TowardInf = forall a. RealFloat a => Rational -> a fromRationalTowardPositive roundedFromRational_default RoundingMode TowardNegInf = forall a. RealFloat a => Rational -> a fromRationalTowardNegative {-# INLINE roundedFromRational_default #-} intervalFromInteger_default :: RealFloat a => Integer -> (Rounded 'TowardNegInf a, Rounded 'TowardInf a) intervalFromInteger_default :: forall a. RealFloat a => Integer -> (Rounded 'TowardNegInf a, Rounded 'TowardInf a) intervalFromInteger_default Integer x = case forall a (f :: * -> *). (RealFloat a, RoundingStrategy f) => Integer -> f a fromIntegerR Integer x of Pair RoundTowardNegative a a RoundTowardPositive a b -> (forall (r :: RoundingMode) a. a -> Rounded r a Rounded (forall a. RoundTowardNegative a -> a roundTowardNegative RoundTowardNegative a a), forall (r :: RoundingMode) a. a -> Rounded r a Rounded (forall a. RoundTowardPositive a -> a roundTowardPositive RoundTowardPositive a b)) {-# INLINE intervalFromInteger_default #-} intervalFromRational_default :: RealFloat a => Rational -> (Rounded 'TowardNegInf a, Rounded 'TowardInf a) intervalFromRational_default :: forall a. RealFloat a => Rational -> (Rounded 'TowardNegInf a, Rounded 'TowardInf a) intervalFromRational_default Rational x = case forall a (f :: * -> *). (RealFloat a, RoundingStrategy f) => Rational -> f a fromRationalR Rational x of Pair RoundTowardNegative a a RoundTowardPositive a b -> (forall (r :: RoundingMode) a. a -> Rounded r a Rounded (forall a. RoundTowardNegative a -> a roundTowardNegative RoundTowardNegative a a), forall (r :: RoundingMode) a. a -> Rounded r a Rounded (forall a. RoundTowardPositive a -> a roundTowardPositive RoundTowardPositive a b)) {-# INLINE intervalFromRational_default #-} intervalFromIntegral :: (Integral i, RealFloat a) => i -> (Rounded 'TowardNegInf a, Rounded 'TowardInf a) intervalFromIntegral :: forall i a. (Integral i, RealFloat a) => i -> (Rounded 'TowardNegInf a, Rounded 'TowardInf a) intervalFromIntegral i x = case forall i a (f :: * -> *). (Integral i, RealFloat a, RoundingStrategy f) => i -> f a fromIntegralR i x of Pair RoundTowardNegative a a RoundTowardPositive a b -> (forall (r :: RoundingMode) a. a -> Rounded r a Rounded (forall a. RoundTowardNegative a -> a roundTowardNegative RoundTowardNegative a a), forall (r :: RoundingMode) a. a -> Rounded r a Rounded (forall a. RoundTowardPositive a -> a roundTowardPositive RoundTowardPositive a b)) {-# INLINE intervalFromIntegral #-}