Alternative floating point support for GHC.

Latest on Hackage:0.3.1

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow to host generated Haddocks.

OtherLicense licensed by Nick Bowler
Maintained by

A replacement for the standard Haskell floating point types and supporting functions. There are a number of shortcomings which I feel severely hinder Haskell's utility for numerical computation. These shortcomings include

  • There is no way to sanely convert between Haskell's floating types -- not even between Double and CDouble. The implementation of the realToFrac function goes through Rational, which loses information as Rational cannot represent all floating point values.

  • Making floating types an instance of Ord makes no sense. Ord is for totally ordered data types, which floats are not. As a result, a number of library functions (such as max and sort) produce nonsensical results.

  • The Enum instance for floating types similarly makes little sense. While fromEnum and toEnum functions use Int instead of Integer, limiting their usefulness, pred and succ can be defined in a much more useful way.

  • Functions that should care about negative zeros, such as signum and abs, do not.

  • Some functions, such as floor, have nonsensical behaviour for non-finite input.

  • The selection of floating point library functions pales in comparison to C. This problem is made worse since, as noted above, it is impossible to convert losslessly from Double to CDouble in order to use the FFI.

  • There is no mechanism for handling rounding modes or exceptions.

This package is intended to address all of the above issues, and more. Also provided, for convenience, is an alternative to the standard Prelude which includes features from this library and the non-overlapping parts of the standard Prelude.

Depends on 3 packages:
Used by 1 package:
comments powered byDisqus