Skip to content

Commit 6411fc9

Browse files
committed
chore: sniper kill tuple
1 parent 077932f commit 6411fc9

File tree

139 files changed

+486
-741
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+486
-741
lines changed

.changeset/light-turkeys-taste.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@tsplus/stdlib": patch
3+
---
4+
5+
Kill Tuple

packages/stdlib/_examples/associative.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ main()
22

33
function main() {
44
/* one namespace per module with "aliased" constructor! */
5-
const map0 = VoteMap(HashMap(Tuple("TsPlus", Votes(1)), Tuple("Effect", Votes(2))))
5+
const map0 = VoteMap(HashMap(["TsPlus", Votes(1)], ["Effect", Votes(2)]))
66

77
/* configure global imports that are still tree-shakeable */
8-
const map1 = VoteMap(HashMap(Tuple("TsPlus", Votes(4)), Tuple("Effect-2", Votes(2))))
8+
const map1 = VoteMap(HashMap(["TsPlus", Votes(4)], ["Effect-2", Votes(2)]))
99

1010
/* custom binary operators */
1111
console.assert(map0.sum(map1) == (map0 + map1))

packages/stdlib/_examples/recursive.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,22 @@ function main() {
2626
// use the string's length to lookup neighboring cells and the answer pops out at the head
2727
function editDistance(s: string, t: string) {
2828
return pipe(
29-
Tuple(s, t),
29+
[s, t],
3030
Recursive.unfold(Functor, substrings(s)),
3131
Recursive.$.foldAnnotated(Functor, editDistanceAnnotatedAlgebra(s.length))
3232
)
3333
}
3434
function substrings(s0: string): Unfolder.Fn<ListF, Carrier> {
35-
return ({ tuple: [s, t] }) => {
35+
return ([s, t]) => {
3636
const [, ...ss] = s
3737
const [, ...ts] = t
3838
switch (s.length) {
3939
case 0:
4040
return t.length == 0 ?
41-
new Leaf(Tuple("", "")) :
42-
new Node(Tuple("", t), Tuple(s0, ts.join("")))
41+
new Leaf(["", ""]) :
42+
new Node(["", t], [s0, ts.join("")])
4343
default:
44-
return new Node(Tuple(s, t), Tuple(ss.join(""), t))
44+
return new Node([s, t], [ss.join(""), t])
4545
}
4646
}
4747
}
@@ -54,7 +54,7 @@ function editDistanceAnnotatedAlgebra(len: number): Annotated.Fn<ListF, number>
5454
"cons": minDistance
5555
})
5656

57-
function minDistance({ head: { tuple: [[a], [b]] }, tail }: AnnotatedNode): number {
57+
function minDistance({ head: [[a], [b]], tail }: AnnotatedNode): number {
5858
return Math.min(
5959
lookup(0, tail) + 1, // insert
6060
lookup(len, tail) + 1, // delete
@@ -72,7 +72,7 @@ function editDistanceAnnotatedAlgebra(len: number): Annotated.Fn<ListF, number>
7272
}
7373
// Type definitions
7474
type MyNonEmptyList<A> = Leaf<A> | Node<A>
75-
type Carrier = Tuple<[string, string]>
75+
type Carrier = readonly [string, string]
7676
interface ListF extends HKT {
7777
readonly type: MyNonEmptyList<this["A"]>
7878
}

packages/stdlib/_src/collections.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ export * as immutableArray from "@tsplus/stdlib/collections/ImmutableArray"
66
export * as immutableMap from "@tsplus/stdlib/collections/ImmutableMap"
77
export * as immutableQueue from "@tsplus/stdlib/collections/ImmutableQueue"
88
export * as list from "@tsplus/stdlib/collections/List"
9-
export * as map from "@tsplus/stdlib/collections/Map"
109
export * as mutable from "@tsplus/stdlib/collections/mutable"
1110
export * as nonEmptyImmutableArray from "@tsplus/stdlib/collections/NonEmptyImmutableArray"
1211
export * as parSeq from "@tsplus/stdlib/collections/ParSeq"

packages/stdlib/_src/collections/Chunk/operations/forEachWithIndexF.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const forEachWithIndexF = ForEachWithIndex.implementForEachWithIndexF<num
1010
let base = succeed<Chunk<typeof _.B>, typeof _.R, typeof _.E>(Chunk.empty())
1111
for (let i = 0; i < fa.length; i = i + 1) {
1212
base = G.map(
13-
({ tuple: [bs, b] }: Tuple<[Chunk<typeof _.B>, typeof _.B]>) => bs.append(b)
13+
([bs, b]: readonly [Chunk<typeof _.B>, typeof _.B]) => bs.append(b)
1414
)(G.both(f(i, fa.unsafeGet(i)!))(base))
1515
}
1616
return base

packages/stdlib/_src/collections/Chunk/operations/mapAccum.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { concreteChunkId } from "@tsplus/stdlib/collections/Chunk/definition"
66
* @tsplus static Chunk.Aspects mapAccum
77
* @tsplus pipeable Chunk mapAccum
88
*/
9-
export function mapAccum<A, B, S>(s: S, f: (s: S, a: A) => Tuple<[S, B]>) {
10-
return (self: Chunk<A>): Tuple<[S, Chunk<B>]> => {
9+
export function mapAccum<A, B, S>(s: S, f: (s: S, a: A) => readonly [S, B]) {
10+
return (self: Chunk<A>): readonly [S, Chunk<B>] => {
1111
const iterator = concreteChunkId(self)._arrayLikeIterator()
1212
let next
1313
let s1 = s
@@ -20,12 +20,12 @@ export function mapAccum<A, B, S>(s: S, f: (s: S, a: A) => Tuple<[S, B]>) {
2020
while (i < len) {
2121
const a = array[i]!
2222
const x = f(s1, a)
23-
s1 = x.get(0)
24-
builder = builder.append(x.get(1))
23+
s1 = x[0]
24+
builder = builder.append(x[1])
2525
i++
2626
}
2727
}
2828

29-
return Tuple(s1, builder)
29+
return [s1, builder]
3030
}
3131
}

packages/stdlib/_src/collections/Chunk/operations/partition.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
* @tsplus pipeable Chunk partition
66
*/
77
export function partition<A>(f: Predicate<A>) {
8-
return (self: Chunk<A>): Tuple<[Chunk<A>, Chunk<A>]> => self.partitionWithIndex((_, a: A) => f(a))
8+
return (self: Chunk<A>): readonly [Chunk<A>, Chunk<A>] =>
9+
self.partitionWithIndex((_, a: A) => f(a))
910
}

packages/stdlib/_src/collections/Chunk/operations/partitionMap.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
* @tsplus pipeable Chunk partitionMap
77
*/
88
export function partitionMap<A, B, C>(f: (a: A) => Either<B, C>) {
9-
return (self: Chunk<A>): Tuple<[Chunk<B>, Chunk<C>]> => self.partitionMapWithIndex((_, a) => f(a))
9+
return (self: Chunk<A>): readonly [Chunk<B>, Chunk<C>] =>
10+
self.partitionMapWithIndex((_, a) => f(a))
1011
}

packages/stdlib/_src/collections/Chunk/operations/partitionMapWithIndex.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @tsplus pipeable Chunk partitionMapWithIndex
77
*/
88
export function partitionMapWithIndex<A, B, C>(f: (i: number, a: A) => Either<B, C>) {
9-
return (self: Chunk<A>): Tuple<[Chunk<B>, Chunk<C>]> => {
9+
return (self: Chunk<A>): readonly [Chunk<B>, Chunk<C>] => {
1010
const left: Array<B> = []
1111
const right: Array<C> = []
1212
for (let i = 0; i < self.length; i++) {
@@ -17,6 +17,6 @@ export function partitionMapWithIndex<A, B, C>(f: (i: number, a: A) => Either<B,
1717
right.push(e.right)
1818
}
1919
}
20-
return Tuple(Chunk.from(left), Chunk.from(right))
20+
return [Chunk.from(left), Chunk.from(right)]
2121
}
2222
}

packages/stdlib/_src/collections/Chunk/operations/partitionWithIndex.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @tsplus pipeable Chunk partitionWithIndex
77
*/
88
export function partitionWithIndex<A>(f: PredicateWithIndex<number, A>) {
9-
return (self: Chunk<A>): Tuple<[Chunk<A>, Chunk<A>]> => {
9+
return (self: Chunk<A>): readonly [Chunk<A>, Chunk<A>] => {
1010
const left: Array<A> = []
1111
const right: Array<A> = []
1212
for (let i = 0; i < self.length; i++) {
@@ -17,6 +17,6 @@ export function partitionWithIndex<A>(f: PredicateWithIndex<number, A>) {
1717
left.push(a)
1818
}
1919
}
20-
return Tuple(Chunk.from(left), Chunk.from(right))
20+
return [Chunk.from(left), Chunk.from(right)]
2121
}
2222
}

0 commit comments

Comments
 (0)