Skip to content

Commit 6c805a1

Browse files
authored
Updated code examples (#380)
1 parent c6a61e4 commit 6c805a1

9 files changed

+14
-52
lines changed

README.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ sbt dependency:
1818
libraryDependencies += "org.augustjune" %% "canoe" % "<version>"
1919
```
2020
You can find the latest version in [releases](https://github.com/augustjune/canoe/releases) tab
21-
or by clicking on the maven-central badge. The library is available for Scala 2.12, 2.13, and Scala.js.
21+
or by clicking on the maven-central badge. The library is available for Scala 2.12, 2.13, Scala 3 and Scala.js.
2222

2323
Imports:
2424
```scala
@@ -40,14 +40,15 @@ More samples can be found [here](https://github.com/augustjune/canoe/tree/master
4040
```scala
4141
import canoe.api._
4242
import canoe.syntax._
43-
import cats.effect.ConcurrentEffect
43+
import cats.effect.Async
4444
import fs2.Stream
4545

46-
def app[F[_]: ConcurrentEffect]: F[Unit] =
46+
def app[F[_]: Async]: F[Unit] =
4747
Stream
48-
.resource(TelegramClient.global[F](token))
49-
.flatMap { implicit client => Bot.polling[F].follow(greetings) }
50-
.compile.drain
48+
.resource(TelegramClient[F](token))
49+
.flatMap(implicit client => Bot.polling[F].follow(greetings))
50+
.compile
51+
.drain
5152

5253
def greetings[F[_]: TelegramClient]: Scenario[F, Unit] =
5354
for {

examples/src/main/scala/samples/DiceExample.scala

+2-5
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,15 @@ import canoe.syntax._
66
import cats.effect.{IO, IOApp}
77
import fs2.Stream
88

9-
/**
10-
* Example of echos bot that will send both possible dice messages in response
9+
/** Example of echos bot that will send both possible dice messages in response
1110
*/
1211
object DiceExample extends IOApp.Simple {
1312
val token: String = "<your telegram token>"
1413

1514
def run: IO[Unit] =
1615
Stream
1716
.resource(TelegramClient[IO](token))
18-
.flatMap { implicit client =>
19-
Bot.polling[IO].follow(echos)
20-
}
17+
.flatMap(implicit client => Bot.polling[IO].follow(echos))
2118
.compile
2219
.drain
2320

examples/src/main/scala/samples/ErrorHandling.scala

+1-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ object ErrorHandling extends IOApp.Simple {
3131
def run: IO[Unit] =
3232
Stream
3333
.resource(TelegramClient[IO](token))
34-
.flatMap { implicit client =>
35-
Bot.polling[IO].follow(order(amazon))
36-
}
34+
.flatMap(implicit client => Bot.polling[IO].follow(order(amazon)))
3735
.compile
3836
.drain
3937

examples/src/main/scala/samples/Recursive.scala

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ object Recursive extends IOApp.Simple {
1515
def run: IO[Unit] =
1616
Stream
1717
.resource(TelegramClient[IO](token))
18-
.flatMap { implicit client =>
19-
Bot.polling[IO].follow(learnNaturals)
20-
}
18+
.flatMap(implicit client => Bot.polling[IO].follow(learnNaturals))
2119
.compile
2220
.drain
2321

examples/src/main/scala/samples/Registration.scala

+1-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ object Registration extends IOApp.Simple {
2929
def run: IO[Unit] =
3030
Stream
3131
.resource(TelegramClient[IO](token))
32-
.flatMap { implicit client =>
33-
Bot.polling[IO].follow(signup(service))
34-
}
32+
.flatMap(implicit client => Bot.polling[IO].follow(signup(service)))
3533
.compile
3634
.drain
3735

examples/src/main/scala/samples/Run.scala

-25
This file was deleted.

examples/src/main/scala/samples/SemanticBlocking.scala

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ object SemanticBlocking extends IOApp.Simple {
1919
def run: IO[Unit] =
2020
Stream
2121
.resource(TelegramClient[IO](token))
22-
.flatMap { implicit client =>
23-
Bot.polling[IO].follow(count)
24-
}
22+
.flatMap(implicit client => Bot.polling[IO].follow(count))
2523
.compile
2624
.drain
2725

examples/src/main/scala/samples/Webhook.scala

+1-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ object Webhook extends IOApp.Simple {
3232
def run: IO[Unit] =
3333
Stream
3434
.resource(TelegramClient[IO](token))
35-
.flatMap { implicit client =>
36-
Stream.resource(Bot.hook[IO](url)).flatMap(_.follow(greetings))
37-
}
35+
.flatMap(implicit client => Stream.resource(Bot.hook[IO](url)).flatMap(_.follow(greetings)))
3836
.compile
3937
.drain
4038

project/plugins.sbt

-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "1.2.0")
44
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.10.0")
55
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "1.1.0")
66
addSbtPlugin("com.codecommit" % "sbt-github-actions" % "0.14.2")
7-
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.1.0")

0 commit comments

Comments
 (0)