Skip to content

Commit

Permalink
Option: remove compact
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti committed Feb 7, 2023
1 parent a4a6ebb commit bfb2249
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 16 deletions.
5 changes: 5 additions & 0 deletions .changeset/tender-bugs-shave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@fp-ts/core": patch
---

Option: remove `compact`
10 changes: 1 addition & 9 deletions src/Option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -727,20 +727,12 @@ export const Foldable: foldable.Foldable<OptionTypeLambda> = {
*/
export const toArray: <A>(self: Option<A>) => Array<A> = foldable.toArray(Foldable)

/**
* Alias of `flatten`.
*
* @category filtering
* @since 1.0.0
*/
export const compact: <A>(self: Option<Option<A>>) => Option<A> = flatten

/**
* @category instances
* @since 1.0.0
*/
export const Compactable: compactable.Compactable<OptionTypeLambda> = {
compact
compact: flatten
}

/**
Expand Down
7 changes: 0 additions & 7 deletions test/Option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ describe.concurrent("Option", () => {
expect(_.traverseTap).exist

expect(_.Compactable).exist
expect(_.compact).exist
expect(_.separate).exist

expect(_.Filterable).exist
Expand Down Expand Up @@ -288,12 +287,6 @@ describe.concurrent("Option", () => {
assertAlt(_.none(), _.none(), _.none())
})

it("compact", () => {
Util.deepStrictEqual(_.compact(_.none()), _.none())
Util.deepStrictEqual(_.compact(_.some(_.none())), _.none())
Util.deepStrictEqual(_.compact(_.some(_.some("123"))), _.some("123"))
})

it("filterMap", () => {
const f = (n: number) => (p(n) ? _.some(n + 1) : _.none())
Util.deepStrictEqual(pipe(_.none(), _.filterMap(f)), _.none())
Expand Down

0 comments on commit bfb2249

Please sign in to comment.