[Haskell-cafe] numerical subtyping

David Roundy droundy at abridgegame.org
Wed Dec 8 07:22:54 EST 2004

On Wed, Dec 08, 2004 at 11:11:44AM +0000, Keean Schupke wrote:
> You can also do this in a way that statically guarantees the property...
> First you need to lift the numeric argument to the type level... This is
> harder for a double than an integer, but not impossible... First convert
> the double to a pair of Integers (an infintite precision rational
> number)... Then each Integer can be represented as a uniary number (this
> is the simplest but you will run out of context reduction stack on any
> kind of real number, so binary or decimal representation is better). The
> definitions required for this are in the attached library.

Alternatively, you could just use atan or erfc to map between the complete
set of real numbers and the range from 0 to 1.  This sort of trick is
sometimes helpful to convert a constrained minimization into an
unconstrained one.
David Roundy

More information about the Haskell-Cafe mailing list