Skip to content

What to do with 0 or negative values? #9

@vwwv

Description

@vwwv

Even though on the docs it says it should work only with positive values, sometimes it is easy missed introducing a hard to find bug (at least It happened to me :/ ). As an example, this can be unintuitive fromListOccur [(x,1),(x,-1)] == fromListOccur [(x,0)] /= fromListOccur [] . I think it might be a good idea either:

  • Detect when a zero or negative has been used and throw an error "negative or zero occurrences not supported".
  • Extend the implementation such it handle zero and negative values. (Internally only storing elements with an occurrence different than 0 ).

I think the second option is more interesting cause it eliminates the problem and makes the library useful for new use-cases; but it would slightly change the current semantics of some functions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions