Skip to content

Commit

Permalink
Remove ~ syntax for desugaring tuple
Browse files Browse the repository at this point in the history
lenguyenthanh committed Feb 27, 2024

Verified

This commit was signed with the committer’s verified signature.
lenguyenthanh Thanh Le
1 parent 34bb3b6 commit 1dcb8a8
Showing 2 changed files with 15 additions and 17 deletions.
27 changes: 15 additions & 12 deletions src/main/scala/Lila.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package lila.ws

import cats.syntax.all.*
import com.typesafe.config.Config
import com.typesafe.scalalogging.Logger
import io.lettuce.core.*
@@ -53,18 +54,20 @@ final class Lila(config: Config)(using Executor):
)

private def connectAll: Future[Emits] =
connect[LilaIn.Site](chans.site) zip
connect[LilaIn.Tour](chans.tour) zip
connect[LilaIn.Lobby](chans.lobby) zip
connect[LilaIn.Simul](chans.simul) zip
connect[LilaIn.Team](chans.team) zip
connect[LilaIn.Swiss](chans.swiss) zip
connect[LilaIn.Study](chans.study) zip
connect[LilaIn.Round](chans.round) zip
connect[LilaIn.Challenge](chans.challenge) zip
connect[LilaIn.Racer](chans.racer) map:
case site ~ tour ~ lobby ~ simul ~ team ~ swiss ~ study ~ round ~ challenge ~ racer =>
Emits(site, tour, lobby, simul, team, swiss, study, round, challenge, racer)
(
connect[LilaIn.Site](chans.site),
connect[LilaIn.Tour](chans.tour),
connect[LilaIn.Lobby](chans.lobby),
connect[LilaIn.Simul](chans.simul),
connect[LilaIn.Team](chans.team),
connect[LilaIn.Swiss](chans.swiss),
connect[LilaIn.Study](chans.study),
connect[LilaIn.Round](chans.round),
connect[LilaIn.Challenge](chans.challenge),
connect[LilaIn.Racer](chans.racer)
).mapN:
case (site, tour, lobby, simul, team, swiss, study, round, challenge, racer) =>
Emits(site, tour, lobby, simul, team, swiss, study, round, challenge, racer)

private def connect[In <: LilaIn](chan: Chan): Future[Emit[In]] =

5 changes: 0 additions & 5 deletions src/main/scala/package.scala
Original file line number Diff line number Diff line change
@@ -17,10 +17,5 @@ type ClientBehavior = Behavior[ipc.ClientMsg]
type Client = ActorRef[ipc.ClientMsg]
type ClientEmit = Emit[ipc.ClientIn]

type ~[+A, +B] = Tuple2[A, B]
object `~`:
def apply[A, B](x: A, y: B) = Tuple2(x, y)
def unapply[A, B](x: Tuple2[A, B]): Option[Tuple2[A, B]] = Some(x)

def nowSeconds: Int = (System.currentTimeMillis() / 1000).toInt
val startedAtMillis = System.currentTimeMillis()

0 comments on commit 1dcb8a8

Please sign in to comment.