Motivation
Edited TL;DR
Floats can be seen as a representation of extended reals. In that regard, they are bounded between -∞ and +∞. When seeing -1/0 as a representation of -∞ and 1/0 as a representation of +∞, we get a bounded instance for floats.
Initial motivation
Having a Bounded instance for Double is generally useful as soon as one uses 1/0 and -1/0 to represent infinity. For instance , it allows to represent whole intervals (see ekmett/intervals#27 or msakai/data-interval#46)
This was previously discussed here. This Stack Overflow answer suggests the following explanation as to why those instances do not exist :
>>> let nan = 0/0; infinity = 1/0 in (nan > infinity, infinity > nan)
(False,False)
which means that 1/0 and -1/0 are not actual bounds.
However, the exact same argument can be used to say that there should not even be an Ord instance in a first place, as this means that Double is not totally ordered.
Proposal
Add the following instances to base :
instance Bounded Double where
minBound = negate (1/0)
maxBound = 1/0
instance Bounded Float where
minBound = negate (1/0)
maxBound = 1/0
as well as the corresponding derived instances for CFloat and CDouble.
Disclaimer
I'm completely new to the CLC process. I'm willing to implement this, but I will probably need guidance, which I would be very grateful for.
Motivation
Edited TL;DR
Floats can be seen as a representation of extended reals. In that regard, they are bounded between -∞ and +∞. When seeing -1/0 as a representation of -∞ and 1/0 as a representation of +∞, we get a bounded instance for floats.
Initial motivation
Having a
Boundedinstance forDoubleis generally useful as soon as one uses1/0and-1/0to represent infinity. For instance , it allows to represent whole intervals (see ekmett/intervals#27 or msakai/data-interval#46)This was previously discussed here. This Stack Overflow answer suggests the following explanation as to why those instances do not exist :
which means that
1/0and-1/0are not actual bounds.However, the exact same argument can be used to say that there should not even be an
Ordinstance in a first place, as this means thatDoubleis not totally ordered.Proposal
Add the following instances to base :
as well as the corresponding derived instances for
CFloatandCDouble.Disclaimer
I'm completely new to the CLC process. I'm willing to implement this, but I will probably need guidance, which I would be very grateful for.