-
-
Notifications
You must be signed in to change notification settings - Fork 512
Open
Description
π Feature request
Current Behavior
readonlyNonEmptyArray.union() does not allow ReadonlyArray as second curried argument.
pipe([1, 2], readonlyNonEmptyArray.union(N.Eq)([])) // does not compileIn my code, I had to do some workaround like this in order to keep the ReadonlyNonEmptyArray type when unioning a ReadonlyNonEmptyArray with a ReadonlyArray
const doUnion = (nonEmptyArray: ReadonlyNonEmptyArray<number>, array: ReadonlyArray<number>) =>
pipe(
array,
readonlyNonEmptyArray.fromReadonlyArray,
option.match(
() => nonEmptyArray,
(array) => readonlyNonEmptyArray.union(N.Eq)(array)(nonEmptyArray)
)
)EDIT 10.10 : Simpler workaround : use concat and then uniq
const doUnion = (
nonEmptyArray: ReadonlyNonEmptyArray<number>,
array: ReadonlyArray<number>,
) =>
pipe(
nonEmptyArray,
readonlyNonEmptyArray.concat(N.Eq)(array),
readonlyNonEmptyArray.uniq(N.Eq),
);Desired Behavior
pipe([1, 2], readonlyNonEmptyArray.union(N.Eq)([])) // should work fineand I could rewrite doUnion like this :
const doUnion = (nonEmptyArray: ReadonlyNonEmptyArray<number>, array: ReadonlyArray<number>) =>
pipe(nonEmptyArray, readonlyNonEmptyArray.union(N.Eq)(array))Suggested Solution
Change signature of readonlyNonEmptyArray to accept ReadonlyArray as second.
Who does this impact? Who is this for?
People using readonlyNonEmptyArray
Describe alternatives you've considered
Additional context
Your environment
| Software | Version(s) |
|---|---|
| fp-ts | 2.15 |
| TypeScript | 5.0.4 |
Metadata
Metadata
Assignees
Labels
No labels