On 25-Mar-2003, Tom Pledger <[EMAIL PROTECTED]> wrote:
>
> The floating point part of the GNU mp library looks difficult to fit
> into Haskell's numeric classes, because the type signatures in class
> Floating don't include a how-much-precision-do-you-want parameter.
How about using a function type which takes a precision and gives
you back an answer to that many digits, and making this function
type an instance of the numeric type classes?
E.g.
data MPF_T -- abstract, corresponds to GNU mp's mpf_t
type PRECISION = Int
type ARBITRARY_PRECISION_REAL = (PRECISION -> MPF_T)
instance Floating ARBITRARY_PRECISION_REAL where
sqrt x = (\prec -> mpf_sqrt_ui (x (prec + sqrt_lossage)))
where sqrt_lossage = 1 -- amount of precision lost by sqrt
...
Here mpf_sqrt_ui would be an interface to GMP's mpf_sqrt_ui() function,
which takes as input an mpf_t and a precision and produces an mpf_t as output.
--
Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell