packages feed

logfloat 0.10.0 → 0.11.0

raw patch · 3 files changed

+6/−86 lines, 3 filesdep ~base

Dependency ranges changed: base

Files

Data/Number/LogFloat.hs view
@@ -64,6 +64,7 @@     (     -- * Exceptional numeric values       module Data.Number.Transfinite+    , module Data.Number.RealToFrac          -- * @LogFloat@ data type and conversion functions     , LogFloat@@ -73,6 +74,7 @@  import Prelude hiding (log, realToFrac, isInfinite, isNaN) +import Data.Number.RealToFrac import Data.Number.Transfinite import Data.Number.PartialOrd 
Data/Number/Transfinite.hs view
@@ -1,10 +1,3 @@---- Needed to ensure correctness, and because we can't guarantee rules fire-{-# LANGUAGE MultiParamTypeClasses-           , OverlappingInstances-           , CPP-           #-}- -- Glasgow extensions needed to enable the # kind {-# OPTIONS_GHC -fglasgow-exts #-} @@ -18,7 +11,7 @@ -- License     :  BSD3 -- Maintainer  :  wren@community.haskell.org -- Stability   :  experimental--- Portability :  non-portable (CPP, MPTC, OverlappingInstances)+-- Portability :  portable --  -- This module presents a type class for numbers which have -- representations for transfinite values. The idea originated from@@ -47,25 +40,14 @@ module Data.Number.Transfinite     ( Transfinite(..)     , log-    , RealToFrac(..)     ) where -import Prelude hiding    (log, realToFrac,  isInfinite, isNaN)-import qualified Prelude (log, realToFrac)+import Prelude hiding    (log, isInfinite, isNaN)+import qualified Prelude (log) import qualified Hugs.RealFloat as Prelude (isInfinite, isNaN)  import Data.Number.PartialOrd -#ifdef __GLASGOW_HASKELL__-import GHC.Exts-    ( Int(..), Float(..), Double(..)-    , int2Double#-    , int2Float#-    , double2Float#-    , float2Double#-    )-#endif- ---------------------------------------------------------------- -- | Many numbers are not 'Bounded' yet, even though they can -- represent arbitrarily large values, they are not necessarily@@ -200,70 +182,6 @@ -- proves to be an onerous requirement on Transfinite, we could -- hack our way around without using PartialOrd by using isNaN, (== -- 0), ((>0).signum) but that would be less efficient.---------------------------------------------------------------------- | The 'Prelude.realToFrac' function is defined to pivot through--- a 'Rational' according to the haskell98 spec. This is non-portable--- and problematic as discussed above. Since there is some resistance--- to breaking from the spec, this class defines a reasonable variant--- which deals with transfinite values appropriately.------ N.B. The generic instance for transfinite types uses expensive--- checks to ensure correctness. On GHC there are specialized--- versions which use primitive converters instead. These instances--- are hidden from other compilers by the CPP. Be warned that the--- instances are overlapped, so you'll need to give type signatures--- if the arguments to 'realToFrac' are polymorphic.------ If any of these restrictions (CPP, GHC-only optimizations,--- OverlappingInstances) are onerous to you, contact the maintainer--- (we like patches).  Note that this /does/ work for Hugs with--- suitable options (e.g. @hugs -98 +o -F'cpp -P'@).--class (Real a, Fractional b) => RealToFrac a b where-    realToFrac :: a -> b--instance (Real a, Fractional a) => RealToFrac a a where-    realToFrac = id--instance (Real a, Transfinite a, Fractional b, Transfinite b)-    => RealToFrac a b-    where-    realToFrac x-        | isNaN      x = notANumber-        | isInfinite x = if x > 0 then infinity-                                  else negativeInfinity-        | otherwise    = Prelude.realToFrac x---#ifdef __GLASGOW_HASKELL__-instance RealToFrac Int Float where-    {-# INLINE realToFrac #-}-    realToFrac (I# i) = F# (int2Float# i)--instance RealToFrac Int Double where-    {-# INLINE realToFrac #-}-    realToFrac (I# i) = D# (int2Double# i)---instance RealToFrac Integer Float where-    -- TODO: is there a more primitive way?-    realToFrac j = Prelude.realToFrac j--instance RealToFrac Integer Double where-    -- TODO: is there a more primitive way?-    realToFrac j = Prelude.realToFrac j---instance RealToFrac Float Double where-    {-# INLINE realToFrac #-}-    realToFrac (F# f) = D# (float2Double# f)-    -instance RealToFrac Double Float where-    {-# INLINE realToFrac #-}-    realToFrac (D# d) = F# (double2Float# d)-#endif  ---------------------------------------------------------------- ----------------------------------------------------------- fin.
logfloat.cabal view
@@ -3,7 +3,7 @@ ----------------------------------------------------------------  Name:           logfloat-Version:        0.10.0+Version:        0.11.0 Cabal-Version:  >= 1.2 Build-Type:     Simple Stability:      experimental