Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add transform for SameRunTime trait #49

Merged

Conversation

lenguyenthanh
Copy link
Member

With this We can have a better ergonomic code with implicit context, which We use exclusively for SameRuntime in lila. for example, with this PR We can refactor as follow:

   extension [A](m: Mapping[A])
-    def into[B](using sr: SameRuntime[A, B], rs: SameRuntime[B, A]): Mapping[B] =
-      m.transform(sr.apply, rs.apply)
+    def into[B](using SameRuntime[A, B], SameRuntime[B, A]): Mapping[B] =
+      m.transform(_.transform, _.transform)

(Refactor for https://github.com/lichess-org/lila/blob/master/modules/common/src/main/Form.scala#L287-L289)

With this We can have a better ergonomic code with implicit context,
which We use exclusively for SameRuntime in lila. for example, with
this PR We can refactor as follow:

```diff
   extension [A](m: Mapping[A])
-    def into[B](using sr: SameRuntime[A, B], rs: SameRuntime[B, A]): Mapping[B] =
-      m.transform(sr.apply, rs.apply)
+    def into[B](using SameRuntime[A, B], SameRuntime[B, A]): Mapping[B] =
+      m.transform(_.transform, _.transform)
```

(Refactor for https://github.com/lichess-org/lila/blob/master/modules/common/src/main/Form.scala#L287-L289)
@ornicar ornicar merged commit 4075fe6 into lichess-org:master Aug 4, 2024
1 check passed
@lenguyenthanh lenguyenthanh deleted the add-transform-to-samruntime branch August 4, 2024 12:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants