Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace use of Integer with fixed-sized types #80

Open
AshleyYakeley opened this issue Jan 9, 2018 · 4 comments
Open

Replace use of Integer with fixed-sized types #80

AshleyYakeley opened this issue Jan 9, 2018 · 4 comments
Milestone

Comments

@AshleyYakeley
Copy link
Member

Packs more predictably.

  • Day contains Integer
    • Int32 days is ± 5.8 million years
    • probably want Int64
  • DiffTime and NominalDiffTime contain Pico (Fixed) which contains Integer
    • Int64 picoseconds is ±106 days, not big enough
    • Int128?
@AshleyYakeley AshleyYakeley added this to the 2.0 milestone Jan 9, 2018
@AshleyYakeley
Copy link
Member Author

Integer to represent year should be replaced with Int.

@charles-cooper
Copy link

Maybe a reasonable compromise is to defer choosing the representation by defining

newtype RawDay a = Day a -- a is some sort of integer

then make the API all based on Integral constraints and specialize for the common cases. That way an end user still has the flexibility to use RawDay Integer if they so choose but the recommended representation would be something like type Day = RawDay Int32. Just a suggestion, not sure it's worth the code overhead (and giving the optimizer a harder job).

@joeyh
Copy link

joeyh commented May 19, 2018

Int64 days is twenty-five quadrillion years, enough for most purposes.

A pair of Word64s is ten quintillion years, ditto. And allows a nice split between the seconds and fractional seconds.

However, POSIXTime does get used a lot in contexts where such a wide span is not called for. On unix the modern expectation is a few hundred billion years. Using a pair of Word64 may be less efficient than Integer for typical POSIXTimes (since for small values gmp uses efficient types).

@dcoutts
Copy link
Contributor

dcoutts commented Mar 26, 2019

Using a pair of Word64 may be less efficient than Integer for typical POSIXTimes (since for small values gmp uses efficient types).

But if an Integer field is contained in any other record (as a strict field), then the pair of Word64s wins by 2 words to 3 words because it can be unpacked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants