Skip to content

Package no longer solves the problems portrayed in the readme.Β #67

@Helam24

Description

@Helam24

I realize i'm years late to this but the readme is incorrect now that the package has been changed to be less safe with the changes to how it stores things and more so the support for initialization via literals.

Aside from the fact that "A compile-time guarantee that a collection contains a value." is no longer true, the readme also presents multiple issues in code that illustrate the usefulness of this package, but a few of them are no longer valid.

The example in the section "Better interface with 3rd party APIs" is no longer correct. It states that we can prevent the problematic code from ever happening in the first place by using non empty sets instead but this is no longer true. Now the problematic code is not only still possible but also causes a crash.

image

The example in the section "More expressive data structures" is also no longer correct. It shows that trying to initialize with an empty array gives a compiler error and while it does, it is only because the initializer that takes a collection is fail-able and returns an optional, not because initializing with an empty array generates a compiler error. If instead it was .invalid([]) or .invalid(.init()) it would compile just fine and then crash at runtime.

image

Again I know this is years late to the party but I was really excited to have a compile-time guarantee of non emptiness after watching the original video in the pointfree series about NonEmpty, I included it in my project and started using it, only to later discover that it is no longer safe.

I feel the risk is too high that eventually even someone who is intimately familiar with this package will be dealing with an optional NonEmpty collection and accidentally use ?? [] without thinking about it and cause a crash in production in a scenario that isn't usually tested.

I understand that using [] with NonEmpty is being considered a programmer error, but force unwrapping .first! on a regular array when that array is empty is also a programmer error, and I thought the purpose of this package was to make that impossible in the first place.

Also completely understand if I don't like it I don't have to use it or I can modify it or whatever but I still wanted to voice that I feel the move away from the safety seems counter to what I thought the original goal of the package was, and point out that the readme is misleading in the current state.

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