Closed felixSchl closed 3 years ago
I would love to get some help with this: https://github.com/pure-c/purescript-integers/blob/c/src/Data/Int.c. What's a good way to handle NaN? Treat it strictly as a number, or some sort of hybrid? How to deal with partiality and type mismatches? The latest commit details the state of the C FFI for purescript-integers:
(WIP) Implement C FFI
Noteworty:
* Drop dependency on purescript-global
* Data.Int.toStringAs currently only supports radix 8, 10, and 16.
The function is partial, and so is the JS FFI, since only values in
range 2 to 32 are allowed in JS. We further limit to 8, 10, and 16
for no particular reason other than no developer time to implement.
* Data.Int.rem returns NaN when divisor is 0 to mimic JS.
This requires storing it as a PURS_ANY_TAG_NUM, which invalidates
the type signature (it's supposed to return an Int)
* (WIP) Data.Int.quot: what should happen when divided by 0?
* (WIP) Data.Int.Bits.*: NOT IMPLEMENTED YET
Edit:
Re radix related partiality, I just noticed that Radix
does not export it's constructor, so while the function itself remains partial, there's no way to produce an invalid radix in the first place, since the radix
ensures only valid values are available. I guess for the C fork, we could change the radix
function as a quick measure until someone devotes time to adding support for other bases.
Alright, purescript-integers passes it's test suite now, but a few things are unchecked for, so still a bit of guess work involved.
Updated notes:
Required by #12