Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .sbtopts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-J-Xmx5G
-J-Xms1G
-J-Xss2M
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,20 @@ Mode.Accumulating.either[String, List].locally {
```

...where repeatedly referring to the `F` wrapper becomes really unwieldly - that type is known to the compiler at each call site so we make it work for us in conjunction with `Mode.current` which summons the `Mode[F]` instance in the current implicit scope.

@:callout(info)

Since the introduction of [SIP-56 - Proper Specification for Match Types](https://docs.scala-lang.org/sips/match-types-spec.html) in Scala 3.4+ some usages of `Mode.Self` became illegal - the example above is one of those cases (more information as to why this is the case can be found [here](https://github.com/scala/scala3/discussions/21534)).

This construct can be reproduced in Scala 3.4+ by using an extension method, like so:

```scala mdoc
extension [A <: Tuple](self: A)
inline def parTupled[F[+x]](using Mode.Accumulating[F]) =
self.fallibleTo[Tuple.InverseMap[A, F]]

Mode.Accumulating.either[String, List].locally {
source.parTupled
}
```
@:@
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import scala.annotation.unused
class FUnwrappingSuite extends DucktapeSuite {

test("F-unwrapping works with match type syntax") {
extension [A <: Tuple](self: A) {
inline def parTupled[F[+x]](using mode: Mode.Accumulating[F]) =
self.fallibleTo[Tuple.InverseMap[A, F]]
}

val source =
(
Right(1),
Expand All @@ -18,7 +23,7 @@ class FUnwrappingSuite extends DucktapeSuite {

Mode.Accumulating.either[String, List].locally {
val expected = Right((1, 2, 3, 4))
val actual = source.fallibleTo[Tuple.InverseMap[source.type, Mode.current.Self]]
val actual = source.parTupled
assertEquals(actual, expected)
}

Expand Down