How to produce infinity in Haskell?

Asked by At

Similarily to How to produce a NaN in Haskell ...

In C, there is the INFINITY macro, defined by math.h.

Again, in I can see falicities to test for infnity, but not to produce one.

Therefore, is my only choice something like 1/0?

1 Answers

Cubic On Best Solutions

The iee754 package has functions and constants specific to that floating point format.

In particular, it has the Numeric.IEEE.infinity constant for members for the IEEE class (which float and double belong to). It is pretty much just implemented as 1/0 though, so your call if you want the package dependency for a prettier name.