Closed
Description
Compiler version
3.3.1
and 3.4.0-RC1
both.
Minimized code
//> using dep "org.typelevel::log4cats-slf4j:2.6.0"
//> using dep "org.typelevel::cats-effect:3.5.2"
//> using dep "io.github.apimorphism::telegramium-core:8.69.0"
//> using dep "io.github.apimorphism::telegramium-high:8.69.0"
//> using scala "3.4.0-RC1"
import org.typelevel.log4cats.Logger
import org.typelevel.log4cats.slf4j.Slf4jLogger
import org.http4s.blaze.client.BlazeClientBuilder
import cats.effect.{IO, IOApp}
import cats.effect.kernel.Sync
import cats.effect.ExitCode
import cats.effect.kernel.Async
import cats.Parallel
import telegramium.bots.high.Api
import telegramium.bots.high.LongPollBot
import telegramium.bots.Message
import telegramium.bots.ChatIntId
import telegramium.bots.high.BotApi
import telegramium.bots.BotCommand
import telegramium.bots.high.implicits._
class Bot[F[_]: Logger](implicit
bot: Api[F],
asyncF: Async[F],
parallel: Parallel[F]
) extends LongPollBot[F](bot) {
import cats.syntax.functor.*
override def onMessage(msg: Message): F[Unit] =
import cats.implicits._
sendMessage(
chatId = ChatIntId(msg.chat.id),
text = msg.text.getOrElse("")
).exec.void.handleErrorWith(e => Logger[F].error(e)("failed to send message"))
}
object HelloWorld extends IOApp {
import cats.implicits._
implicit def logger[F[_]: Sync]: Logger[F] = Slf4jLogger.getLogger[F]
override def run(args: List[String]): IO[ExitCode] = {
BlazeClientBuilder[IO].resource.use { httpClient =>
implicit val api: Api[IO] =
BotApi(httpClient, baseUrl = s"https://api.telegram.org/botSometoken")
// implicit val logger: Logger[IO] = Slf4jLogger.getLogger[IO]
val bot = new Bot()
bot.start().as(ExitCode.Success)
}
}
}
Output
Output is correct, but it takes a very long time to compile.
Expectation
File compiled and returns an error about a missing implicit.