Search code examples
haskellinfinity

In Haskell, is there infinity :: Num a => a?


I'm trying to implement a data structure where if I had the use of infinity for numerical comparison purposes, it would simply things greatly. Note this isn't maxBound/minBound, because a value can be <= maxbound, but all values would be < infinity.

No hope?


Solution

  • Maybe you want a Maybe type?

    data Infinite a = Infinite | Only a
    

    then write a Num instance for Num a => Infinite a, with the numeric rules you need.