basvandijk / scientific

Arbitrary-precision floating-point numbers represented using scientific notation
BSD 3-Clause "New" or "Revised" License
73 stars 40 forks source link

Add predicates returning if the scientific is floating or integer #17

Closed watashi closed 10 years ago

watashi commented 10 years ago

This would be useful when we need to make decision only based on whether the scientific it's floating point or integer. Especially when warn-type-defaults is on, we can write

  if isFloating s then d else i

instead of

  either (const d) (const i) (floatingOrInteger s :: Either Double Integer)

or

  case floatingOrInteger s of
    Left (_ :: Double) -> d
    Right (_ :: Integer) -> i
basvandijk commented 10 years ago

Thanks for the patch!

These will be included in the next release.