Skip to content

Commit

Permalink
Merge pull request #362 from lichess-org/refactor/0
Browse files Browse the repository at this point in the history
Use cats syntax for MonadThrow
  • Loading branch information
lenguyenthanh authored Nov 9, 2024
2 parents cfa5d85 + 434e62c commit 855094c
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions modules/elastic/src/main/scala/ESClient.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package lila.search

import cats.MonadThrow
import cats.effect.*
import cats.syntax.all.*
import com.sksamuel.elastic4s.ElasticDsl.*
Expand Down Expand Up @@ -76,10 +75,10 @@ object ESClient:
.map(_.status)

private def toResult[A](response: Response[A]): F[A] =
response.fold(MonadThrow[F].raiseError[A](response.error.asException))(MonadThrow[F].pure)
response.fold(response.error.asException.raiseError)(r => r.pure[F])

private def unitOrFail[A](response: Response[A]): F[Unit] =
response.fold(MonadThrow[F].raiseError[Unit](response.error.asException))(_ => MonadThrow[F].unit)
response.fold(response.error.asException.raiseError)(_ => ().pure[F])

def search[A](query: A, from: From, size: Size)(using q: Queryable[A]): F[List[Id]] =
metric
Expand Down

0 comments on commit 855094c

Please sign in to comment.