
Alexander Dunlap wrote:
Couple of suggestions:
- You should put an (Integer i) => constraint on the halve function so that it becomes impossible to create invalid HalfIntegers.
Right. Currently you can *make* such a HalfInteger. You just won't be able to *do* anything with it afterwards. It would probably be more sensible to just add a constraint there.
- The documentation for toHalfInteger is truncated. Also, why can't you make the rounding more predictable?
...wow. OK, I'm looking at the source, and it seems I must have got distracted at that moment or something, because I just 100% didn't actually finish writing the documentation! o_O That's pretty special. ;-) As I *should* have written, the rounding for something like toHalfInteger 0.25 is kind of unpredictable; but if you do toHalfInteger 0.5, the result is *guaranteed* to be exact. All the functions are carefully tuned to work correctly on things which really are half integers, and to give plausible results otherwise. Just don't let your life depend on 0.25 being mapped to exactly a half or to exactly zero...
Nice work!
Heh, thanks.