Jonplussed / purescript-number-format

Number-to-String formatting functions for PureScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Safety

garyb opened this issue · comments

Not to rain on your parade, but the reason these don't exist in the core libraries is they're actually a bit tricky to get right. ;)

We did have them at one point, and then later removed them because they only work with certain arguments, and we didn't want to wrap them in an Eff with an exception or something.

The rules according to MDN:

  • toExponential and toFixed throw a RangeError if the digits provided is not between 0 and 20
  • toPrecision throws a RangeError if the precision provided is not between 0 and 100
  • toString throws a RangeError if the radix provided is not between 2 and 36

Thanks for the feedback! I've made duplicates that wrap the results in either a Maybe or Eff. Are there any changes that should be made (namespacing or otherwise) so this matches other PureScript modules?

Handled better in PR #4.