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

closed as the division remainder #9

Open
mjgpy3 opened this issue Nov 7, 2023 · 2 comments
Open

closed as the division remainder #9

mjgpy3 opened this issue Nov 7, 2023 · 2 comments

Comments

@mjgpy3
Copy link

mjgpy3 commented Nov 7, 2023

I'm working with times (:grimacing:) and I'd like to go from something like akin to

newtype QuantityOfMinutes = QuantityOfMinutes Natural

to something like

data HoursWithLeftOverMinutes = HoursWithLeftOverMinutes {
  hours :: Natural
  , leftOverMinutes :: Closed 0 59
}

Whether or not dealing with time is something I should be doing, it struck me that it should be safe to construct a Closed as the remainder of a division.

divWithRemainder
  :: Natural
  -- ^ Divisor
  -> (Natural,   Closed 0 _numerator)
  --  ^ Result    ^ Remainder
@pbrisbin
Copy link
Member

pbrisbin commented Nov 7, 2023

Neat. Is there something in this library preventing that, or something missing you're suggesting we add?

@mjgpy3
Copy link
Author

mjgpy3 commented Nov 7, 2023

Is there something in this library preventing that, or something missing you're suggesting we add?

The latter. It looks like we have divMod which is close but I'm not convinced it's useful since it makes the result Closed 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