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

iso8601Show $ CalendarDiffTime (-1) (-1) fails with "*** Exception: formatShow: bad value" #260

Closed
tysonzero opened this issue Jul 22, 2024 · 1 comment

Comments

@tysonzero
Copy link

tysonzero commented Jul 22, 2024

Parsing of course has the equivalent issue:

iso8601ParseM @IO @CalendarDiffTime "P-1MT-1S"
*** Exception: user error (no parse of "P-1MT-1S")

Whilst it seems like the ISO8601 standard may not explicitly support negative interval durations, the Haskell type does, and a variety of tools including PostgreSQL understand negative values within intervals, so I think crashing here is a greater evil than extending the formatting standard to support values the type already supports.

As an example reference: PostgreSQL specifically supports minus signs in the components but not a preceding sign over the entire time interval:

select 'P-1MT1H-1S' :: interval;
P-1MT59M59S

select 'P-1MT1S' :: interval;
P-1MT1S

select 'P-1MT-1S' :: interval;
P-1MT-1S

select '-P1MT1S' :: interval;
ERROR:  invalid input syntax for type interval: "-P1MT1S"
@tysonzero
Copy link
Author

Ah ok looks like this has been fixed in 1.14, and luckily it seems like you can use time-1.14 with ghc-9.8.2/ghc-9.10.1, which I was not aware was possible given the whole boot package thing (https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/libraries/version-history).

Didn't see anything in the changelog so I initially assumed the upgrade wouldn't fix it, I suppose the "fix show of CalendarDiffTime" may have also included iso8601 show/parseM instances as well?

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

2 participants