Bounded and floating types

Henning Thielemann lemming at
Tue Dec 4 07:46:47 EST 2007

On Mon, 3 Dec 2007, Conal Elliott wrote:

> I'm using the bounds for event occurrence times.  Or, from another angle,
> for times associated with when values can become known.  Pure values have
> time minBound, while eternally unknowable values (non-occurring events) have
> time maxBound.  Hm.  Now that I put it that way, I realize that I don't want
> to use existing minBound and maxBound if they're finite.  (My event types
> are temporally polymorphic.)  I'm mainly interested in Float/Double times,
> which have infinities in practice but apparently not guaranteed by the
> language standard.  I guess I'll either (a) bake in Double (temporally
> monomorphic) and rely on infinities not guaranteed by the standard, or (b)
> keep temporal polymorphism and add infinities to time parameter.  For now,
> (b).

Since you cannot rely on the existence of an infinity value for a floating
point type with a particular behaviour - you can simply define you own type:

data InfinityClosure a  =  NegativeInfinity | Finite a | PositiveInfinity

More information about the Libraries mailing list