Packages

object Resource extends ResourceInstances with ResourcePlatform

Source
Resource.scala
Linear Supertypes
ResourcePlatform, ResourceInstances, ResourceInstances0, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Resource
  2. ResourcePlatform
  3. ResourceInstances
  4. ResourceInstances0
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. final case class Allocate[F[_], A](resource: F[(A, (ExitCase[Throwable]) => F[Unit])]) extends Resource[F, A] with Product with Serializable

    Resource data constructor that wraps an effect allocating a resource, along with its finalizers.

  2. final case class Bind[F[_], S, +A](source: Resource[F, S], fs: (S) => Resource[F, A]) extends Resource[F, A] with Product with Serializable

    Resource data constructor that encodes the flatMap operation.

  3. type Par[+F[_], +A] = Type[F, A]

    Newtype encoding for a Resource datatype that has a cats.Applicative capable of doing parallel processing in ap and map2, needed for implementing cats.Parallel.

    Newtype encoding for a Resource datatype that has a cats.Applicative capable of doing parallel processing in ap and map2, needed for implementing cats.Parallel.

    Helpers are provided for converting back and forth in Par.apply for wrapping any IO value and Par.unwrap for unwrapping.

    The encoding is based on the "newtypes" project by Alexander Konovalov, chosen because it's devoid of boxing issues and a good choice until opaque types will land in Scala. alexknvl/newtypes.

  4. final case class Suspend[F[_], A](resource: F[Resource[F, A]]) extends Resource[F, A] with Product with Serializable

    Resource data constructor that suspends the evaluation of another resource value.

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def apply[F[_], A](resource: F[(A, F[Unit])])(implicit F: Functor[F]): Resource[F, A]

    Creates a resource from an allocating effect.

    Creates a resource from an allocating effect.

    F

    the effect type in which the resource is acquired and released

    A

    the type of the resource

    resource

    an effect that returns a tuple of a resource and an effect to release it

    See also

    make for a version that separates the needed resource with its finalizer tuple in two parameters

  5. def applyCase[F[_], A](resource: F[(A, (ExitCase[Throwable]) => F[Unit])]): Resource[F, A]

    Creates a resource from an allocating effect, with a finalizer that is able to distinguish between exit cases.

    Creates a resource from an allocating effect, with a finalizer that is able to distinguish between exit cases.

    F

    the effect type in which the resource is acquired and released

    A

    the type of the resource

    resource

    an effect that returns a tuple of a resource and an effectful function to release it

    See also

    makeCase for a version that separates the needed resource with its finalizer tuple in two parameters

  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. implicit def catsEffectCommutativeApplicativeForResourcePar[F[_]](implicit F: Sync[F], P: Parallel[F]): CommutativeApplicative[[β$17$]Type[F, β$17$]]
    Definition Classes
    ResourceInstances
  8. implicit def catsEffectLiftIOForResource[F[_]](implicit F00: LiftIO[F], F10: Applicative[F]): LiftIO[[β$16$]Resource[F, β$16$]]
    Definition Classes
    ResourceInstances
  9. implicit def catsEffectMonadErrorForResource[F[_], E](implicit F0: MonadError[F, E]): MonadError[[β$15$]Resource[F, β$15$], E]
    Definition Classes
    ResourceInstances
  10. implicit def catsEffectMonadForResource[F[_]](implicit F0: Monad[F]): Monad[[β$20$]Resource[F, β$20$]]
    Definition Classes
    ResourceInstances0
  11. implicit def catsEffectMonoidForResource[F[_], A](implicit F0: Monad[F], A0: Monoid[A]): Monoid[Resource[F, A]]
    Definition Classes
    ResourceInstances
  12. implicit def catsEffectParallelForResource[F0[_]](implicit arg0: Sync[F0], arg1: Parallel[F0]): Aux[[β$18$]Resource[F0, β$18$], [β$19$]Type[F0, β$19$]]
    Definition Classes
    ResourceInstances
  13. implicit def catsEffectSemigroupForResource[F[_], A](implicit F0: Monad[F], A0: Semigroup[A]): ResourceSemigroup[F, A]
    Definition Classes
    ResourceInstances0
  14. implicit def catsEffectSemigroupKForResource[F[_], A](implicit F0: Monad[F], K0: SemigroupK[F]): ResourceSemigroupK[F]
    Definition Classes
    ResourceInstances0
  15. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  16. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  17. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  18. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  19. def fromAutoCloseable[F[_], A <: AutoCloseable](acquire: F[A])(implicit F: Sync[F]): Resource[F, A]

    Creates a Resource by wrapping a Java AutoCloseable.

    Creates a Resource by wrapping a Java AutoCloseable.

    Example:

    import cats.effect._
    import scala.io.Source
    
    def reader[F[_]](data: String)(implicit F: Sync[F]): Resource[F, Source] =
      Resource.fromAutoCloseable(F.delay {
        Source.fromString(data)
      })
    F

    the type of the effect

    A

    the type of the autocloseable resource

    acquire

    The effect with the resource to acquire.

    F

    the effect type in which the resource was acquired and will be released

    returns

    a Resource that will automatically close after use

  20. def fromAutoCloseableBlocking[F[_], A <: AutoCloseable](blocker: Blocker)(acquire: F[A])(implicit arg0: Sync[F], arg1: ContextShift[F]): Resource[F, A]

    Creates a Resource by wrapping a Java AutoCloseable which is blocking in its adquire and close operations.

    Creates a Resource by wrapping a Java AutoCloseable which is blocking in its adquire and close operations.

    Example:

    import java.io._
    import cats.effect._
    
    def reader[F[_]](file: File, blocker: Blocker)(implicit F: Sync[F], cs: ContextShift[F]): Resource[F, BufferedReader] =
      Resource.fromAutoCloseableBlocking(blocker)(F.delay {
        new BufferedReader(new FileReader(file))
      })
    F

    the type of the effect

    A

    the type of the autocloseable resource

    blocker

    The blocking context that will be used to compute acquire and close

    acquire

    The effect with the resource to acquire

    returns

    a Resource that will automatically close after use

  21. def fromDestroyable[F[_], A <: Destroyable](acquire: F[A])(implicit F: Sync[F]): Resource[F, A]

    Creates a Resource by wrapping a Java Destroyable.

    Creates a Resource by wrapping a Java Destroyable.

    Example:

    import java.security.KeyStore.PasswordProtection
    import cats.effect._
    import cats.implicits._
    
    def passwordProtection[F[_]](getPassword: F[Array[Char]])(implicit F: Sync[F]): Resource[F, PasswordProtection] =
      Resource.fromDestroyable(
        getPassword.map(new PasswordProtection(_))
      )
    F

    the type of the effect

    A

    the type of the destroyable resource

    acquire

    The effect with the resource to acquire.

    F

    the effect type in which the resource was acquired and will be released

    returns

    a Resource that will automatically destroy after use

    Definition Classes
    ResourcePlatform
  22. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  23. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  24. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  25. def liftF[F[_], A](fa: F[A])(implicit F: Applicative[F]): Resource[F, A]

    Lifts an applicative into a resource.

    Lifts an applicative into a resource. The resource has a no-op release. Preserves interruptibility of fa.

    fa

    the value to lift into a resource

  26. def liftK[F[_]](implicit F: Applicative[F]): ~>[F, [β$12$]Resource[F, β$12$]]

    Lifts an applicative into a resource as a FunctionK.

    Lifts an applicative into a resource as a FunctionK. The resource has a no-op release.

  27. def make[F[_], A](acquire: F[A])(release: (A) => F[Unit])(implicit F: Functor[F]): Resource[F, A]

    Creates a resource from an acquiring effect and a release function.

    Creates a resource from an acquiring effect and a release function.

    This builder mirrors the signature of Bracket.bracket.

    F

    the effect type in which the resource is acquired and released

    A

    the type of the resource

    acquire

    a function to effectfully acquire a resource

    release

    a function to effectfully release the resource returned by acquire

  28. def makeCase[F[_], A](acquire: F[A])(release: (A, ExitCase[Throwable]) => F[Unit])(implicit F: Functor[F]): Resource[F, A]

    Creates a resource from an acquiring effect and a release function that can discriminate between different exit cases.

    Creates a resource from an acquiring effect and a release function that can discriminate between different exit cases.

    This builder mirrors the signature of Bracket.bracketCase.

    F

    the effect type in which the resource is acquired and released

    A

    the type of the resource

    acquire

    a function to effectfully acquire a resource

    release

    a function to effectfully release the resource returned by acquire

  29. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  30. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  31. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  32. def pure[F[_], A](a: A)(implicit F: Applicative[F]): Resource[F, A]

    Lifts a pure value into a resource.

    Lifts a pure value into a resource. The resource has a no-op release.

    a

    the value to lift into a resource

  33. def suspend[F[_], A](fr: F[Resource[F, A]]): Resource[F, A]

    Given a Resource suspended in F[_], lifts it in the Resource context.

  34. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  35. def tailRecM[F[_], A, B](a: A)(f: (A) => Resource[F, Either[A, B]])(implicit F: Monad[F]): Resource[F, B]

    Implementation for the tailRecM operation, as described via the cats.Monad type class.

  36. def toString(): String
    Definition Classes
    AnyRef → Any
  37. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  38. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  39. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  40. object Par

Inherited from ResourcePlatform

Inherited from ResourceInstances

Inherited from ResourceInstances0

Inherited from AnyRef

Inherited from Any

Ungrouped