Skip to content

lib/types.nix: add intBetween #27239

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
wants to merge 2 commits into from
Closed

Conversation

Profpatsch
Copy link
Member

Add a type for integers between a min and max value; also improve the type error message, see commit message.

  • tested manually

Sorry, something went wrong.

@mention-bot
Copy link

@Profpatsch, thanks for your PR! By analyzing the history of the files in this pull request, we identified @edolstra, @nbp and @ericsagnes to be potential reviewers.

@Profpatsch Profpatsch changed the title Int between lib/types.nix: add intBetween Jul 8, 2017
@Profpatsch Profpatsch requested review from nbp and shlevy July 8, 2017 12:22
Copy link
Contributor

@0xABAB 0xABAB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Port ranges have a smaller domain than the integers.

@0xABAB
Copy link
Contributor

0xABAB commented Jul 8, 2017

@volth Yeah, there is a whole range of such functions that would be of interest. E.g. postiveInteger (if Nix supports bignums).

Copy link
Member

@shlevy shlevy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK by me

Unverified

This user has not yet uploaded their public signing key.
An int type that checks the value range.
Before:
  <x> is not a integer between 0 and 100 (inclusively).
(notice that “a” is wrong, it should be “an”)
Now:
  <x> is not of type `integer between 0 and 100 (inclusively)'.

This sounds a bit more formal, but circumvents the grammatical problems.
Multi-word type descriptions are also easier to see.
@Profpatsch
Copy link
Member Author

Hm, before we merge we should maybe think about that:

there is a whole range of such functions that would be of interest

If so, a new namespace for these types should probably be created?

@Profpatsch
Copy link
Member Author

I’m thinking about maybe having types.ints.<subtype> to bundle all of these.

ints = rec {
  between = …
  uint16 = between 0 65535
  …
};

@Profpatsch
Copy link
Member Author

I will refactor and open a new PR.

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.

None yet

4 participants