cps.monads.catsEffect

Type members

Classlikes

class AsyncScopeInferArg[F[_]](using x$1: CpsTryMonad[[A] =>> Resource[F, A]], x$2: MonadCancel[F, Throwable])

part of asyncScope

part of asyncScope

See also

asyncScope

class CatsAsync[F[_]](using x$1: Async[F]) extends CatsMonadThrow[F] with CpsAsyncEffectMonad[F]
class CatsIOCpsAsyncMonad extends CatsAsync[[A] =>> IO[A]] with CpsAsyncEffectMonad[[A] =>> IO[A]]

CpsAsyncMonad for cats-effect.

CpsAsyncMonad for cats-effect.

class CatsMonad[F[_]](using x$1: Monad[F]) extends CpsMonad[F]
class CatsMonadThrow[F[_]](using x$1: MonadThrow[F]) extends CatsMonad[F] with CpsTryMonad[F]
class ResourceCpsMonad[F[_]](using cm: MonadCancel[F, Throwable]) extends CpsTryMonad[[A] =>> Resource[F, A]]

Monadic operations over F[] with brackets, can be used as main monad in case of deeple nested resources, to avoid nesting of scopes.

Monadic operations over F[] with brackets, can be used as main monad in case of deeple nested resources, to avoid nesting of scopes.

See also

asyncScope

Value members

Concrete methods

def asyncScope[F[_]](using CpsTryMonad[[A] =>> Resource[F, A]], MonadCancel[F, Throwable]): AsyncScopeInferArg[F]

Produce effect with resource-aware scope block.

Produce effect with resource-aware scope block.

val effect = asyncScope[IO] {
   val reader = await(openFile(input))
   val writer = await(openFile(output))
   writer.transformFrom(0,Long.MaxValue,reader)
}

Here evaluation of effect will open reader and wrier, transfer data and then close reader and writer. block inside asyncScope evaluated in CpsResourceMonad[[X]=>>Resource[F,X]]

See also

[cps.monads.catsEffect.CpsResourceMonad]

Concrete fields

final lazy val catsIO: CatsIOCpsAsyncMonad

Givens

Givens

given catsAsync: CpsAsyncMonad[F]
given catsMemoization[F[_]](using val x$1: Concurrent[F]): CpsMonadPureMemoization[F]
given catsMonad: CpsAwaitable[F]
given catsMonadThrow: CpsMonad[F]
given catsResourceMemoization[F[_]](using val x$1: Concurrent[[X] =>> Resource[F, X]]): CpsMonadPureMemoization[[X] =>> Resource[F, X]]
given ioToFutureConversion(using val runtime: IORuntime): CpsMonadConversion[[A] =>> IO[A], [T] =>> Future[T]]
given resourceCpsMonad: CpsMonad[F]

Extensions

Extensions

extension (resourceSingleton: Resource)
inline def using(r: Resource[F, A])(inline f: A => B)(using m: CpsMonad[F], cm: MonadCancel[F, Throwable]): B

Pseudo-synchronious syntax for resource, which can be used in async block.

Pseudo-synchronious syntax for resource, which can be used in async block.

   async[IO] {
      ....
      useing(openFile){ buffer =>
          await(doSomething)
          buffer.write(r)
          result
      }
   }
inline def using(r1: Resource[F, A1], r2: Resource[F, A2])(inline f: (A1, A2) => B)(using m: CpsMonad[F], cm: MonadCancel[F, Throwable]): B

Pseudo-synchronious syntax for resource, which can be used in async block.

Pseudo-synchronious syntax for resource, which can be used in async block.

   async[IO] {
      ....
      useing(openFile){ buffer =>
          await(doSomething)
          buffer.write(r)
          result
      }
   }
inline def using(r1: Resource[F, A1], r2: Resource[F, A2], r3: Resource[F, A3])(inline f: (A1, A2, A3) => B)(using m: CpsMonad[F], cm: MonadCancel[F, Throwable]): B

Pseudo-synchronious syntax for resource, which can be used in async block.

Pseudo-synchronious syntax for resource, which can be used in async block.

   async[IO] {
      ....
      useing(openFile){ buffer =>
          await(doSomething)
          buffer.write(r)
          result
      }
   }