cps.monads.catsEffect

Members list

Type members

Classlikes

class AsyncScopeInferArg[F[_], C <: CpsMonadContext[[A] =>> Resource[F, A]]](using am: Aux[[A] =>> Resource[F, A], C], mc: MonadCancel[F, Throwable])

part of asyncScope

part of asyncScope

Attributes

See also

asyncScope

Supertypes
class Object
trait Matchable
class Any
class CatsAsync[F[_]](using x$1: Async[F]) extends CatsMonadThrow[F], CpsAsyncEffectMonadInstanceContext[F]

Attributes

Supertypes
trait CpsAsyncEffectMonadInstanceContext[F]
trait CpsAsyncMonadInstanceContext[F]
trait CpsAsyncEffectMonad[F]
trait CpsTryEffectMonad[F]
trait CpsEffectMonad[F]
trait CpsAsyncMonad[F]
class CatsMonadThrow[F]
trait CpsTryMonadInstanceContext[F]
trait CpsTryMonad[F]
trait CpsTrySupport[F]
trait CpsThrowMonad[F]
trait CpsThrowSupport[F]
trait CatsMonad[F]
trait CpsMonad[F]
class Object
trait Matchable
class Any
Show all
Known subtypes
class CatsConcurrent[F[_]](using x$1: Concurrent[F], x$2: Async[F]) extends CatsAsync[F], CpsConcurrentEffectMonadInstanceContext[F]

Attributes

Supertypes
trait CpsConcurrentEffectMonadInstanceContext[F]
trait CpsConcurrentMonadInstanceContext[F]
trait CpsConcurrentEffectMonad[F]
trait CpsConcurrentMonad[F]
class CatsAsync[F]
trait CpsAsyncEffectMonadInstanceContext[F]
trait CpsAsyncMonadInstanceContext[F]
trait CpsAsyncEffectMonad[F]
trait CpsTryEffectMonad[F]
trait CpsEffectMonad[F]
trait CpsAsyncMonad[F]
class CatsMonadThrow[F]
trait CpsTryMonadInstanceContext[F]
trait CpsTryMonad[F]
trait CpsTrySupport[F]
trait CpsThrowMonad[F]
trait CpsThrowSupport[F]
trait CatsMonad[F]
trait CpsMonad[F]
class Object
trait Matchable
class Any
Show all
Known subtypes

CpsAsyncMonad for cats-effect.

CpsAsyncMonad for cats-effect.

Attributes

Supertypes
class CatsConcurrent[IO]
trait CpsConcurrentEffectMonadInstanceContext[IO]
trait CpsConcurrentMonadInstanceContext[IO]
trait CpsConcurrentEffectMonad[IO]
trait CpsConcurrentMonad[IO]
class CatsAsync[IO]
trait CpsAsyncEffectMonadInstanceContext[IO]
trait CpsAsyncMonadInstanceContext[IO]
trait CpsAsyncEffectMonad[IO]
trait CpsTryEffectMonad[IO]
trait CpsEffectMonad[IO]
trait CpsAsyncMonad[IO]
class CatsMonadThrow[IO]
trait CpsTryMonadInstanceContext[IO]
trait CpsTryMonad[IO]
trait CpsTrySupport[IO]
trait CpsThrowMonad[IO]
trait CpsThrowSupport[IO]
trait CatsMonad[IO]
trait CpsMonad[IO]
class Object
trait Matchable
class Any
Show all
trait CatsMonad[F[_]](using mf: Monad[F]) extends CpsMonad[F]

Attributes

Supertypes
trait CpsMonad[F]
class Object
trait Matchable
class Any
Known subtypes
class CatsMonadPure[F]
class CatsMonadThrow[F]
class CatsAsync[F]
class CatsConcurrent[F]
class CatsMonadPure[F[_]](using mf: Monad[F]) extends CatsMonad[F], CpsPureMonadInstanceContext[F]

Attributes

Supertypes
trait CpsPureMonadInstanceContext[F]
trait CatsMonad[F]
trait CpsMonad[F]
class Object
trait Matchable
class Any
Show all
class CatsMonadThrow[F[_]](using x$1: MonadThrow[F]) extends CatsMonad[F], CpsTryMonadInstanceContext[F]

Attributes

Supertypes
trait CpsTryMonadInstanceContext[F]
trait CpsTryMonad[F]
trait CpsTrySupport[F]
trait CpsThrowMonad[F]
trait CpsThrowSupport[F]
trait CatsMonad[F]
trait CpsMonad[F]
class Object
trait Matchable
class Any
Show all
Known subtypes
class CatsAsync[F]
class CatsConcurrent[F]

Value members

Concrete methods

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

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]]

Attributes

See also

[cps.monads.catsEffect.CpsResourceMonad]

Givens

Givens

given catsAsync[F[_]](using Async[F], NotGiven[Concurrent[F]]): CpsAsyncMonadInstanceContext[F]
given catsConcurrent[F[_]](using Concurrent[F], Async[F]): CpsConcurrentEffectMonadInstanceContext[F]
given catsMonadPure[F[_]](using Monad[F], NotGiven[MonadThrow[F]]): CpsPureMonadInstanceContext[F]
given catsMonadThrow[F[_]](using MonadThrow[F], NotGiven[Async[F]]): CpsTryMonadInstanceContext[F]
given ioToFutureConversion(using runtime: IORuntime): ioToFutureConversion
given resourceConversion[F[_]]: CpsMonadConversion[F, [A] =>> Resource[F, A]]

into F[T] to [A] =>> Resource[F,A] for using inside asyncScope

into F[T] to [A] =>> Resource[F,A] for using inside asyncScope

Attributes

Extensions

Extensions

extension [F[_], A](r: Resource[F, A])(using m: CpsMonad[F], cm: MonadCancel[F, Throwable])
transparent inline def useOn[B](inline f: A => B)(using CpsMonadContext[F]): 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.

Usage: assuming we have:

   def open(file: File): Resource[IO, BufferedReader]

we can

   async[IO] {
      ....
      open(file).useOn{ buffer =>
          await(doSomething)
          buffer.write(r)
          result
      }
   }

Attributes

extension (resourceSingleton: Resource.type)
transparent inline def using[F[_], A, B](r: Resource[F, A])(inline f: A => B)(using m: CpsMonad[F], cm: MonadCancel[F, Throwable], mc: CpsMonadContext[F]): 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] {
      ....
      using(openFile){ buffer =>
          await(doSomething)
          buffer.write(r)
          result
      }
   }

Attributes

transparent inline def using[F[_], A1, A2, B](r1: Resource[F, A1], r2: Resource[F, A2])(inline f: (A1, A2) => B)(using m: CpsMonad[F], cm: MonadCancel[F, Throwable], mc: CpsMonadContext[F]): 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] {
      ....
      using(openFile){ buffer =>
          await(doSomething)
          buffer.write(r)
          result
      }
   }

Attributes

transparent inline def using[F[_], A1, A2, A3, B](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], mc: CpsMonadContext[F]): 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] {
      ....
      using(openFile){ buffer =>
          await(doSomething)
          buffer.write(r)
          result
      }
   }

Attributes