ZManagedCpsMonad

cps.monads.zio.ZManagedCpsMonad
class ZManagedCpsMonad[R, E] extends CpsTryMonad[[X] =>> ZManaged[R, E, X]], 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 CpsTryMonadInstanceContext[[X] =>> ZManaged[R, E, X]]
trait CpsTryMonad[[X] =>> ZManaged[R, E, X]]
trait CpsTrySupport[[X] =>> ZManaged[R, E, X]]
trait CpsThrowMonad[[X] =>> ZManaged[R, E, X]]
trait CpsThrowSupport[[X] =>> ZManaged[R, E, X]]
trait CpsMonad[[X] =>> ZManaged[R, E, X]]
class Object
trait Matchable
class Any
Show all
Known subtypes

Members list

Type members

Types

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

Inherited types

override type Context = CpsTryMonadInstanceContextBody[[X] =>> ZManaged[R, E, X]]

Attributes

Inherited from:
CpsTryMonadInstanceContext
type WF[X] = [X] =>> ZManaged[R, E, X][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

override def apply[T](op: Context => ZManaged[R, E, T]): [X] =>> ZManaged[R, E, X][T]

run op in the context environment.

run op in the context environment.

Attributes

Definition Classes
CpsTryMonadInstanceContext -> CpsMonad
Inherited from:
CpsTryMonadInstanceContext
def flatWrap[T](op: => ZManaged[R, E, T]): [X] =>> ZManaged[R, E, X][T]

Wrap and flatten of monadic expression..

Wrap and flatten of monadic expression..

Attributes

Inherited from:
CpsMonad
def flatten[T](ffa: ZManaged[R, E, ZManaged[R, E, T]]): [X] =>> ZManaged[R, E, X][T]

Attributes

Inherited from:
CpsMonad
def fromTry[A](r: Try[A]): [X] =>> ZManaged[R, E, X][A]

transform r into pure value or error.

transform r into pure value or error.

Attributes

Inherited from:
CpsTryMonad
def mapTry[A, B](fa: ZManaged[R, E, A])(f: (Try[A]) => B): [X] =>> ZManaged[R, E, X][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]): [X] =>> ZManaged[R, E, X][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]): [X] =>> ZManaged[R, E, X][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]): [X] =>> ZManaged[R, E, X][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): [X] =>> ZManaged[R, E, X][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]): [X] =>> ZManaged[R, E, X][A]

async shift of tryPure.

async shift of tryPure.

Attributes

Inherited from:
CpsTryMonad
def withAction[A](fa: ZManaged[R, E, A])(action: => Unit): [X] =>> ZManaged[R, E, X][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]): [X] =>> ZManaged[R, E, X][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]): [X] =>> ZManaged[R, E, X][A]

return result of fa after completition of action.

return result of fa after completition of action.

Attributes

Inherited from:
CpsTryMonad
def withAsyncErrorHandler[A](fa: => ZManaged[R, E, A])(f: Throwable => ZManaged[R, E, A]): [X] =>> ZManaged[R, E, X][A]

Attributes

Inherited from:
CpsTrySupport
def withAsyncFinalizer[A](fa: => ZManaged[R, E, A])(f: => ZManaged[R, E, Unit]): [X] =>> ZManaged[R, E, X][A]

Attributes

Inherited from:
CpsTrySupport
def wrap[T](op: => T): [X] =>> ZManaged[R, E, X][T]

Create monadic expression according to the default operation of choosen monad types. (i.e. delaying for effect monads, starting for eager monand, pure by default)

Create monadic expression according to the default operation of choosen monad types. (i.e. delaying for effect monads, starting for eager monand, pure by default)

Attributes

Inherited from:
CpsMonad