Question

Is there a more elegant way of expressing positive and negative infinities in haskell other than let posInf = 1 / 0 and let negInf = -1 / 0 respectively?

Was it helpful?

Solution

For Double and Float: no, not really. For other types: yes! Those types that do not yet have an infinity may be given one via PosInf and NegInf type constructors. Some types may also have their own special infinity, but to say more than that we'd need to know what type specifically you want to use.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top