Open
Description
Is your feature request related to a problem? Please describe.
I have found NonEmptyList
from the Scala Cats library very useful in the past. I'd like to implement a similar collection type in Expression. Is this something you would be open to @dbrattli ?
Describe the solution you'd like
Just a few examples outlined below. Overall I'd see it working in a similar way to expression.collections.Block
(i.e. an immutable collection).
list(NonEmptyList.one(1)) == [1]
list(NonEmptyList.of(1, 2, 3)) == [1, 2, 3]
NonEmptyList.from([1, 2, 3]).map(list) == Some([1, 2, 3])
NonEmptyList.from([]) == Nothing
def do_something_with_list_that_must_be_non_empty(l: NonEmptyList):
# do things with elements in `l`
Describe alternatives you've considered
Doing this everywhere in your code:
def do_something_with_list_that_must_be_non_empty(l: list):
if l:
# do things with elements in `l`
Metadata
Metadata
Assignees
Labels
No labels