This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //> using scala 3.3.4 | |
| //> using dep org.typelevel::cats-core:2.12.0 | |
| //> using dep org.typelevel::cats-effect:3.5.5 | |
| // Code accompanying the blog entry 'Understanding Kleisli: using it to pass context info' | |
| // at https://lrodero.hashnode.dev/understanding-kleisli-using-it-to-pass-context-info | |
| // Run using scala-cli: | |
| // $ scala-cli PassingContextUsingKleisli.scala |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //> using scala 3.3.4 | |
| //> using dep org.typelevel::cats-effect:3.5.5 | |
| import cats.effect.{IO, IOApp} | |
| object Main extends IOApp.Simple: | |
| override val run = IO.println("Hello world") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //> using scala 3.3 | |
| //> using dep org.typelevel::cats-effect::3.5.4 | |
| // Code accompanying this blog entry 'Convert Future instances to cats-effect IO' | |
| // at https://lrodero.hashnode.dev/convert-future-instances-to-cats-effect-io | |
| // Run using scala-cli: | |
| // $ scala-cli FutureToIO.scala | |
| // Small code snippet to show how to convert Scala and Java Futures to cats-effect IO instances |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Licensed under the Apache License, Version 2.0: http: //www.apache.org/licenses/LICENSE-2.0 | |
| // Microlib that implements retries for cats-effect (CE). Note that at the time this code was | |
| // developed no retries functionality was included in the latest version of CE (3.5.4). Newer | |
| // versions can have such functionality, if so it's recommended to use it instead. | |
| // Code developed in this blog entry 'Micro library for retries in cats-effect using Scala extensions': | |
| // https://lrodero.hashnode.dev/micro-library-for-retries-in-cats-effect-using-scala-extensions | |
| // Run using: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //> using scala 3.3 | |
| //> using dep org.typelevel::cats-effect:3.5.4 | |
| import cats.effect.std.{Random, Semaphore} | |
| import cats.syntax.all.* | |
| import cats.effect.{IO, IOApp} | |
| import scala.concurrent.duration.* | |
| object DiningPhilosophers extends IOApp.Simple: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //> using scala 3.3 | |
| //> using dep org.typelevel::cats-effect:3.5.4 | |
| import cats.syntax.all.* | |
| import cats.effect.{IO, IOApp} | |
| import cats.effect.std.MapRef | |
| import java.util.concurrent.{ConcurrentHashMap => JConcurrentHashMap} | |
| object FullControlMapRef extends IOApp.Simple: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //> using scala 3.3 | |
| //> using dep org.typelevel::cats-effect:3.5.4 | |
| import cats.syntax.all.* | |
| import cats.effect.{IO, IOApp} | |
| import cats.effect.std.MapRef | |
| object ConcurrencyMapRef extends IOApp.Simple: | |
| private val concurrencySample = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //> using scala 3.3 | |
| //> using dep org.typelevel::cats-effect:3.5.4 | |
| import cats.effect.{IO, IOApp} | |
| import cats.effect.std.MapRef | |
| object SimpleMapRef extends IOApp.Simple: | |
| private val simpleSample = | |
| for |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //> using scala "2.13.11" | |
| //> using lib "org.typelevel::cats-effect::3.5.1" | |
| import cats.effect._ | |
| import cats.effect.std.{Console, Queue} | |
| import cats.instances.list._ | |
| import cats.syntax.all._ | |
| object ProducerConsumerWithStdQueue extends IOApp { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //> using scala "2.13.11" | |
| //> using lib "org.typelevel::cats-effect::3.5.1" | |
| import cats.effect.{Async, Deferred, ExitCode, IO, IOApp, Ref, Sync} | |
| import cats.effect.std.Console | |
| import cats.instances.list._ | |
| import cats.syntax.all._ | |
| import java.util.concurrent.ScheduledThreadPoolExecutor | |
| import scala.collection.immutable.Queue |
NewerOlder