Skip to content

Commit

Permalink
Make Tuple.Map/FlatMap pass bounds checks
Browse files Browse the repository at this point in the history
Similar to how TupleMap, in pos/9890, had to deal with the bounds check
of the head, and how inserts, in pos/10867, had to deal with the
Tuple.Map functor argument.
  • Loading branch information
dwijnand committed May 27, 2023
1 parent a1eb832 commit 42ac960
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/src/scala/Tuple.scala
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ object Tuple {
/** Converts a tuple `(T1, ..., Tn)` to `(F[T1], ..., F[Tn])` */
type Map[Tup <: Tuple, F[_ <: Union[Tup]]] <: Tuple = Tup match {
case EmptyTuple => EmptyTuple
case h *: t => F[h] *: Map[t, F]
case h *: t => F[h & Union[Tup]] *: Map[t, [x <: Union[t]] =>> F[x & Union[Tup]]]
}

/** Converts a tuple `(T1, ..., Tn)` to a flattened `(..F[T1], ..., ..F[Tn])` */
type FlatMap[Tup <: Tuple, F[_ <: Union[Tup]] <: Tuple] <: Tuple = Tup match {
case EmptyTuple => EmptyTuple
case h *: t => Concat[F[h], FlatMap[t, F]]
case h *: t => Concat[F[h & Union[Tup]], FlatMap[t, [x <: Union[t]] =>> F[x & Union[Tup]]]]
}

/** Filters out those members of the tuple for which the predicate `P` returns `false`.
Expand Down

0 comments on commit 42ac960

Please sign in to comment.