Skip to content

Fix RealFrac Seconds instance #89

Merged
CetinSert merged 3 commits intocorsis:masterfrom
amesgen:fix-tests
Aug 9, 2023
Merged

Fix RealFrac Seconds instance #89
CetinSert merged 3 commits intocorsis:masterfrom
amesgen:fix-tests

Conversation

@amesgen
Copy link
Copy Markdown
Contributor

@amesgen amesgen commented Aug 8, 2023

Closes #87, see #87 (comment) for an analysis.

Consider the law of properFraction:

The function properFraction takes a real fractional number x and returns a pair (n,f) such that x = n+f, and:

  • n is an integral number with the same sign as x; and
  • f is a fraction with the same type and sign as x, and with absolute value less than 1.

Before this change, we had

 Λ properFraction (-1 :: Seconds)
(0,Seconds {toTimeSpec = TimeSpec {sec = -1, nsec = 0}})

which violates the second property above, as f = Seconds {toTimeSpec = TimeSpec {sec = -1, nsec = 0}} has absolute value 1, which is not less than 1.

With this change, we correctly get:

 Λ properFraction (-1 :: Seconds)
(-1,Seconds {toTimeSpec = TimeSpec {sec = 0, nsec = 0}})

@CetinSert CetinSert merged commit 1b41f50 into corsis:master Aug 9, 2023
@amesgen amesgen deleted the fix-tests branch August 9, 2023 20:18
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

Successfully merging this pull request may close these issues.

Test failure with QuickCheck 2.14.3

2 participants