ZManagedCpsMonad

cps.monads.zio.ZManagedCpsMonad
class ZManagedCpsMonad[R, E] extends CpsTryMonad[[X] =>> ZManaged[R, E, X]] with CpsMonadInstanceContext[[X] =>> ZManaged[R, E, X]]

CpsMonad which encapsulate effects with automatic resource management.

Example of usage:

 asyncRManaged[R] {
     val input = FileChannel.open(inputPath)
     val output = FileChannel.open(outputPath)
     input.transformTo(0,Long.MaxValue,output)
 }

Attributes

Graph
Supertypes
trait CpsMonadInstanceContext[[X] =>> ZManaged[R, E, X]]
trait CpsTryMonad[[X] =>> ZManaged[R, E, X]]
trait CpsMonad[[X] =>> ZManaged[R, E, X]]
trait CpsAwaitable[[X] =>> ZManaged[R, E, X]]
class Object
trait Matchable
class Any
Known subtypes

Members list

Concise view

Type members

Types

type F[T] = ZManaged[R, E, T]

Inherited types

type Context = CpsMonadInstanceContextBody[F]

Attributes

Inherited from:
CpsMonadInstanceContext
type WF[X] = F[X]

Attributes

Inherited from:
CpsMonad

Value members

Concrete methods

def error[A](e: Throwable): F[A]

represent error e in monadic context.

represent error e in monadic context.

Attributes

def flatMap[A, B](fa: F[A])(f: A => F[B]): F[B]

bind combinator, which compose f over fa

bind combinator, which compose f over fa

Attributes

def flatMapTry[A, B](fa: F[A])(f: Try[A] => F[B]): F[B]

flatMap over result of checked evaluation of A

flatMap over result of checked evaluation of A

Attributes

def map[A, B](fa: F[A])(f: A => B): F[B]

map a function f over fa

map a function f over fa

Attributes

def pure[A](x: A): ZManaged[R, E, A]

Pure - wrap value t inside monad.

Pure - wrap value t inside monad.

Note, that pure use eager evaluation, which is different from Haskell.

Attributes

Inherited methods

def adoptAwait[A](fa: ZManaged[R, E, A]): F[A]

If is it statically known, that monad is evaluated in this context, then this call is completely eliminated by dotty-cps-async macro

If is it statically known, that monad is evaluated in this context, then this call is completely eliminated by dotty-cps-async macro

Attributes

Returns:

fa

Inherited from:
CpsMonadInstanceContext
def apply[T](op: Context => ZManaged[R, E, T]): F[T]

run with this instance

run with this instance

Attributes

Inherited from:
CpsMonadInstanceContext
def fromTry[A](r: Try[A]): F[A]

transform r into pure value or error.

transform r into pure value or error.

Attributes

Inherited from:
CpsTryMonad
def lazyPure[T](op: => T): F[T]

Lazy variant of pure, which by default - create monadic expression according to the choosen monad types. (i.e. delaing for effect monads, starting for eager monand, pure by defiault)

Lazy variant of pure, which by default - create monadic expression according to the choosen monad types. (i.e. delaing for effect monads, starting for eager monand, pure by defiault)

Attributes

Inherited from:
CpsMonad
def mapTry[A, B](fa: ZManaged[R, E, A])(f: Try[A] => B): F[B]

map over result of checked evaluation of A

map over result of checked evaluation of A

Attributes

Inherited from:
CpsTryMonad
def mapTryAsync[A, B](fa: ZManaged[R, E, A])(f: Try[A] => ZManaged[R, E, B]): F[B]

synonym for flatMapTry needed for processing awaits inside mapTry.

synonym for flatMapTry needed for processing awaits inside mapTry.

Attributes

Inherited from:
CpsTryMonad
def restore[A](fa: ZManaged[R, E, A])(fx: Throwable => ZManaged[R, E, A]): F[A]

restore fa, ie if fa sucessful - return fa, otherwise apply fx to received error.

restore fa, ie if fa sucessful - return fa, otherwise apply fx to received error.

Attributes

Inherited from:
CpsTryMonad
def tryImpure[A](a: => ZManaged[R, E, A]): F[A]

try to evaluate async operation and wrap successful or failed result into F.

try to evaluate async operation and wrap successful or failed result into F.

Attributes

Inherited from:
CpsTryMonad
def tryPure[A](a: => A): F[A]

try to evaluate synchonious operation and wrap successful or failed result into F.

try to evaluate synchonious operation and wrap successful or failed result into F.

Attributes

Inherited from:
CpsTryMonad
def tryPureAsync[A](a: () => ZManaged[R, E, A]): F[A]

async shift of tryPure.

async shift of tryPure.

Attributes

Inherited from:
CpsTryMonad
def withAction[A](fa: ZManaged[R, E, A])(action: => Unit): F[A]

ensure that action will run before getting value from fa

ensure that action will run before getting value from fa

Attributes

Inherited from:
CpsTryMonad
def withActionAsync[A](fa: ZManaged[R, E, A])(action: () => ZManaged[R, E, Unit]): F[A]

async shift of withAction.

async shift of withAction.

This method is substituted instead withAction, when we use await inside withAction argument.

Attributes

Inherited from:
CpsTryMonad
def withAsyncAction[A](fa: ZManaged[R, E, A])(action: => ZManaged[R, E, Unit]): F[A]

return result of fa after completition of action.

return result of fa after completition of action.

Attributes

Inherited from:
CpsTryMonad