kowainik / kowainik/relude

Make `Relude.List.permutations` return a `NonEmpty`.

Open
#385 5 comments 1 reaction 0 assignees View on GitHub
new question
Dominant language
Haskell
Stars
742
Forks
80
PR merge metrics
No merged PRs in 30d

Description

You may observe that any list has at least one permutation. The empty list's only permutation is the empty list itself, so:

```
λ Relude.List.permutations [ ]
[[]]
```

This behaviour is also theoretically sound since permutations of a list are a model of a symmetric group and a group always has at least one element.

It is nicer to have to drop from a `NonEmpty` to a list than to lift from a list to `NonEmpty`, since the latter requires the handling of the spurious case of the list being empty.

Contributor guide

Open the contributing guide

Research direction

Search the Relude.List.permutations definition and its existing tests or usage sites. Confirm the empty-list example remains valid while changing the result type to NonEmpty, then run the relevant test suite and check that callers can still obtain a list when needed.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
developer-experience
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.