Skip to content

NonEmpty<NonEmpty<C>> doesn't mean the collection has at least 2 valuesย #44

@RemiBardon

Description

@RemiBardon

I really like the safety of NonEmpty. I am writing a fully type-safe geographical library, also providing GeoJSON mapping, and I need to store arrays that have at least four values for example (see RFC 7946, section 3.1.6 for example).

I thought I'd use NonEmpty<NonEmpty<NonEmpty<NonEmpty<[MyType]>>>>, but I was surprised to se it's not how the library works. NonEmpty.swift#L9-L10 shows that the collection is stored as-is, not cut into a head value and a tail Slice.

Is it a conscious choice? Wouldn't it be semantically better to make NonEmpty behave as I thought?

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