purescript-contrib/purescript-argonaut

+Infinity, -Infinity, NaN are representable by Json

Opened this issue · 3 comments

The Json type includes these values, however they are not allowed in JSON.

Some possible solutions, with their downsides:

  1. Make fromNumber immediately return null on such inputs. This is breaking without a type change.
  2. Make fromNumber return Maybe Json, and add fromNumber' which immediately returns null. This may confuse people.
  3. Make stringify return Maybe String. This is annoying.

As @garyb pointed out on Slack, not just fromNumber, but also jsonParser may return infinities; when a number is outside of the range of Number.

This issue is stale because it has been open for 60 days with no activity. Remove the stale label or comment to keep this issue open. Otherwise, this issue will be closed in 14 days.