MR K P SCHUPKE wrote:
Double already has +Inf and -Inf; it's just that Haskell doesn't have (AFAIK) syntax to write them as constants.
In the source for the GHC libraries it uses 1/0 for +Infinity and -1/0 for -Infinity, so I assume these are the "official" way to do it.
Personally I would define nicer names:
positiveInfinity :: Double positiveInfinity = 1/0
negativeInfinity :: Double negativeInfinity = -1/0
Or just: infinity = 1/0 and use -infinity for the negative. One other nit: isn't the read/show syntax for Haskell98 types supposed to valid Haskell syntax?
From http://www.haskell.org/onlinereport/derived.html#derived-text
The result of show is a syntactically correct Haskell expression containing only constants, given the fixity declarations in force at the point where the type is declared. [Note: the above sentecne refers specifically to derived instances, but induction would require that it also holds for base types.] However: Prelude> let infinity = 1/0 :: Double Prelude> show infinity "Infinity" Prelude> read (show infinity) :: Double Infinity Prelude> Infinity <interactive>:1: Data constructor not in scope: `Infinity' -- Glynn Clements <glynn@gclements.plus.com>