Skip to content

Missing instance Random Natural #197

Open

Description

@andreasabel

I am missing instance Random Natural; there is an instance for Integer, so by the principle of least surprise there should also be one for Natural.

Activity

  1. lehins commented on Aug 21, 2026

    @lehins
    Contributor

    There used to be a ticket like that, which was closed with a comment: #44 (comment)

    I personally don't mind adding an instance, but what should be the range when random is called?

    1. [0, maxBound :: Int64] for consistency with Integer
    2. or [0, maxBound :: Word64]
    3. or bottom
    4. or something else?

    None of these are correct, but in favor of consistently ugly behavior, second option seems most reasonable.

  2. andreasabel commented on Aug 21, 2026

    @andreasabel
    MemberAuthor

    For consistency with Integer, maybe [0, maxBound :: Int]?

    I don't want to push this in a specific direction.
    The alternative would be to deprecate the instance for Integer in favor of the UniformRange instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions