Packages

object Resource extends ResourceFOInstances0 with ResourceHOInstances0 with ResourcePlatform

Source
Resource.scala
Linear Supertypes
ResourcePlatform, Serializable, ResourceHOInstances0, ResourceHOInstances1, ResourceHOInstances2, ResourceHOInstances3, ResourceHOInstances4, ResourceHOInstances5, ResourceFOInstances0, ResourceFOInstances1, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Resource
  2. ResourcePlatform
  3. Serializable
  4. ResourceHOInstances0
  5. ResourceHOInstances1
  6. ResourceHOInstances2
  7. ResourceHOInstances3
  8. ResourceHOInstances4
  9. ResourceHOInstances5
  10. ResourceFOInstances0
  11. ResourceFOInstances1
  12. AnyRef
  13. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. final case class Allocate[F[_], A](resource: (Poll[F]) => F[(A, (ExitCase) => 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. final case class Eval[F[_], A](fa: F[A]) extends Resource[F, A] with Product with Serializable
  4. sealed trait ExitCase extends Product with Serializable

    Type for signaling the exit condition of an effectful computation, that may either succeed, fail with an error or get canceled.

    Type for signaling the exit condition of an effectful computation, that may either succeed, fail with an error or get canceled.

    The types of exit signals are:

  5. implicit final class NestedSyntax[F[_], A] extends AnyVal
  6. type Par[F[_], A] = T[[β$19$]Resource[F, β$19$], A]
  7. final case class Pure[F[_], +A](a: A) extends Resource[F, A] with Product with Serializable

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) => 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. def applyFull[F[_], A](resource: (Poll[F]) => F[(A, (ExitCase) => 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.

    The action takes a Poll[F] to allow for interruptible acquires, which is most often useful when acquiring lock-like structure: it should be possible to interrupt a fiber waiting on a lock, but if it does get acquired, release need to be guaranteed.

    Note that in this case the acquire action should know how to cleanup after itself in case it gets canceled, since Resource will only guarantee release when acquire succeeds (and when the actions in use or flatMap fail, succeed, or get canceled)

    TODO make sure this api, which is more general than makeFull, doesn't allow for interruptible releases

    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, where acquisition can potentially be interrupted

    See also

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

  7. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  8. def both[F[_], A, B](rfa: Resource[F, A], rfb: Resource[F, B])(implicit arg0: Concurrent[F]): Resource[F, (A, B)]

    Allocates two resources concurrently, and combines their results in a tuple.

  9. def canceled[F[_]](implicit F: MonadCancel[F, _]): Resource[F, Unit]
  10. implicit def catsEffectAsyncForResource[F[_]](implicit F0: Async[F]): Async[[β$25$]Resource[F, β$25$]]
    Definition Classes
    ResourceHOInstances0
  11. implicit def catsEffectClockForResource[F[_]](implicit F0: Clock[F], FA: Applicative[[β$29$]Resource[F, β$29$]]): Clock[[β$30$]Resource[F, β$30$]]
    Definition Classes
    ResourceHOInstances2
  12. implicit def catsEffectConcurrentForResource[F[_]](implicit F0: Concurrent[F]): Concurrent[[β$28$]Resource[F, β$28$]]
    Definition Classes
    ResourceHOInstances2
  13. implicit final def catsEffectDeferForResource[F[_]]: Defer[[β$31$]Resource[F, β$31$]]
    Definition Classes
    ResourceHOInstances2
  14. implicit def catsEffectMonadCancelForResource[F[_]](implicit F0: MonadCancel[F, Throwable]): MonadCancel[[β$32$]Resource[F, β$32$], Throwable]
    Definition Classes
    ResourceHOInstances3
  15. implicit def catsEffectMonadErrorForResource[F[_], E](implicit F0: MonadError[F, E]): MonadError[[β$33$]Resource[F, β$33$], E]
    Definition Classes
    ResourceHOInstances4
  16. implicit def catsEffectMonadForResource[F[_]]: Monad[[β$34$]Resource[F, β$34$]]
    Definition Classes
    ResourceHOInstances5
  17. implicit def catsEffectMonoidForResource[F[_], A](implicit A0: Monoid[A]): Monoid[Resource[F, A]]
    Definition Classes
    ResourceFOInstances0
  18. implicit def catsEffectSemigroupForResource[F[_], A](implicit A0: Semigroup[A]): ResourceSemigroup[F, A]
    Definition Classes
    ResourceFOInstances1
  19. implicit def catsEffectSemigroupKForResource[F[_], A](implicit F0: MonadCancel[F, Throwable], K0: SemigroupK[F], G0: Make[F]): ResourceSemigroupK[F]
    Definition Classes
    ResourceHOInstances0
  20. implicit def catsEffectSyncForResource[F[_]](implicit F0: Sync[F]): Sync[[β$27$]Resource[F, β$27$]]
    Definition Classes
    ResourceHOInstances1
  21. implicit def catsEffectTemporalForResource[F[_]](implicit F0: Temporal[F]): Temporal[[β$26$]Resource[F, β$26$]]
    Definition Classes
    ResourceHOInstances1
  22. def cede[F[_]](implicit F: GenSpawn[F, _]): Resource[F, Unit]
  23. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  24. implicit def commutativeApplicativeForResource[F[_]](implicit arg0: Concurrent[F]): CommutativeApplicative[[β$23$]T[[β$19$]Resource[F, β$19$], β$23$]]
  25. def cont[F[_], K, R](body: Cont[[β$15$]Resource[F, β$15$], K, R])(implicit F: Async[F]): Resource[F, R]
  26. def deferred[F[_], A](implicit F: GenConcurrent[F, _]): Resource[F, Deferred[[β$13$]Resource[F, β$13$], A]]
  27. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  28. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  29. def eval[F[_], A](fa: F[A]): 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

  30. def executionContext[F[_]](implicit F: Async[F]): Resource[F, ExecutionContext]
  31. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  32. 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.

    In most real world cases, implementors of AutoCloseable are blocking as well, so the close action runs in the blocking context.

    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

    Examples:
    1. import cats.effect._
      import scala.io.Source
      
      def reader(data: String): Resource[IO, Source] =
        Resource.fromAutoCloseable(IO.blocking {
          Source.fromString(data)
        })
    2. ,
    3. import cats.effect._
      import scala.io.Source
      
      def reader[F[_]](data: String)(implicit F: Sync[F]): Resource[F, Source] =
        Resource.fromAutoCloseable(F.blocking {
          Source.fromString(data)
        })
  33. 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.

    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
    Examples:
    1. import java.security.KeyStore.PasswordProtection
      import cats.effect.{IO, Resource}
      
      def passwordProtection(getPassword: IO[Array[Char]]): Resource[IO, PasswordProtection] =
        Resource.fromDestroyable(
          getPassword.map(new PasswordProtection(_))
        )
    2. ,
    3. import java.security.KeyStore.PasswordProtection
      import cats.effect.{Resource, Sync}
      import cats.syntax.all._
      
      def passwordProtection[F[_]](getPassword: F[Array[Char]])(implicit F: Sync[F]): Resource[F, PasswordProtection] =
        Resource.fromDestroyable(
          getPassword.map(new PasswordProtection(_))
        )
  34. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  35. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  36. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  37. def liftK[F[_]]: ~>[F, [β$9$]Resource[F, β$9$]]

    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.

  38. 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.

    F

    the effect type in which the resource is acquired and released

    A

    the type of the resource

    acquire

    an effect to acquire a resource

    release

    a function to effectfully release the resource returned by acquire

  39. def makeCase[F[_], A](acquire: F[A])(release: (A, ExitCase) => 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.

    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

  40. def makeCaseFull[F[_], A](acquire: (Poll[F]) => F[A])(release: (A, ExitCase) => F[Unit])(implicit F: Functor[F]): Resource[F, A]

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

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

    The acquiring effect takes a Poll[F] to allow for cancelable acquires, which is most often useful when acquiring lock-like structures: it should be possible to interrupt a fiber waiting on a lock, but if it does get acquired, release need to be guaranteed.

    Note that in this case the acquire action should know how to cleanup after itself in case it gets canceled, since Resource will only guarantee release when acquire succeeds (and when the actions in use or flatMap fail, succeed, or get canceled)

    F

    the effect type in which the resource is acquired and released

    A

    the type of the resource

    acquire

    an effect to acquire a resource, possibly interruptibly

    release

    a function to effectfully release the resource returned by acquire

  41. def makeFull[F[_], A](acquire: (Poll[F]) => F[A])(release: (A) => F[Unit])(implicit F: Functor[F]): Resource[F, A]

    Creates a resource from a possibly cancelable acquiring effect and a release function.

    Creates a resource from a possibly cancelable acquiring effect and a release function.

    The acquiring effect takes a Poll[F] to allow for cancelable acquires, which is most often useful when acquiring lock-like structures: it should be possible to interrupt a fiber waiting on a lock, but if it does get acquired, release need to be guaranteed.

    Note that in this case the acquire action should know how to cleanup after itself in case it gets canceled, since Resource will only guarantee release when acquire succeeds (and when the actions in use or flatMap fail, succeed, or get canceled)

    F

    the effect type in which the resource is acquired and released

    A

    the type of the resource

    acquire

    an effect to acquire a resource, possibly interruptibly

    release

    a function to effectfully release the resource returned by acquire

  42. def monotonic[F[_]](implicit F: Clock[F]): Resource[F, FiniteDuration]
  43. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  44. def never[F[_], A](implicit F: GenSpawn[F, _]): Resource[F, A]
  45. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  46. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  47. def onFinalize[F[_]](release: F[Unit])(implicit arg0: Applicative[F]): Resource[F, Unit]

    Lifts a finalizer into a resource.

    Lifts a finalizer into a resource. The resource has a no-op allocation.

  48. def onFinalizeCase[F[_]](release: (ExitCase) => F[Unit])(implicit arg0: Applicative[F]): Resource[F, Unit]

    Creates a resource that allocates immediately without any effects, but calls release when closing, providing the the usage completed with.

  49. implicit def parallelForResource[F[_]](implicit arg0: Concurrent[F]): Aux[[β$20$]Resource[F, β$20$], [β$21$]T[[β$19$]Resource[F, β$19$], β$21$]]
  50. def pure[F[_], A](a: A): 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

  51. def race[F[_], A, B](rfa: Resource[F, A], rfb: Resource[F, B])(implicit arg0: Concurrent[F]): Resource[F, Either[A, B]]

    Races the evaluation of two resource allocations and returns the result of the winner, except in the case of cancelation.

  52. def raiseError[F[_], A, E](e: E)(implicit F: ApplicativeError[F, E]): Resource[F, A]
  53. def realTime[F[_]](implicit F: Clock[F]): Resource[F, FiniteDuration]
  54. def ref[F[_], A](a: A)(implicit F: GenConcurrent[F, _]): Resource[F, Ref[[β$14$]Resource[F, β$14$], A]]
  55. def sleep[F[_]](time: Duration)(implicit F: GenTemporal[F, _]): Resource[F, Unit]
  56. def suspend[F[_], A](hint: Type)(thunk: => A)(implicit F: Sync[F]): Resource[F, A]
  57. def suspend[F[_], A](fr: F[Resource[F, A]]): Resource[F, A]

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

  58. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  59. def toString(): String
    Definition Classes
    AnyRef → Any
  60. def uncancelable[F[_], A](body: (Poll[[β$11$]Resource[F, β$11$]]) => Resource[F, A])(implicit F: MonadCancel[F, Throwable]): Resource[F, A]
  61. def unique[F[_]](implicit F: Unique[F]): Resource[F, Token]
  62. def unit[F[_]]: Resource[F, Unit]

    A resource with a no-op allocation and a no-op release.

  63. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  64. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  65. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  66. object ExitCase extends Serializable

Deprecated Value Members

  1. def catsEffectMonadForResource[F[_]](F: Monad[F]): Monad[[β$35$]Resource[F, β$35$]]
    Definition Classes
    ResourceHOInstances5
    Annotations
    @deprecated
    Deprecated

    (Since version 3.4.0) Use overload without constraint

  2. def catsEffectMonoidForResource[F[_], A](F0: Monad[F], A0: Monoid[A]): Monoid[Resource[F, A]]
    Definition Classes
    ResourceFOInstances0
    Annotations
    @deprecated
    Deprecated

    (Since version 3.4.0) Use overload without monad constraint

  3. def catsEffectSemigroupForResource[F[_], A](F0: Monad[F], A0: Semigroup[A]): ResourceSemigroup[F, A]
    Definition Classes
    ResourceFOInstances1
    Annotations
    @deprecated
    Deprecated

    (Since version 3.4.0) Use overload without monad constraint

  4. def sleep[F[_]](time: FiniteDuration, F: GenTemporal[F, _]): Resource[F, Unit]
    Annotations
    @deprecated
    Deprecated

    (Since version 3.4.0) Use overload with Duration

Inherited from ResourcePlatform

Inherited from Serializable

Inherited from ResourceHOInstances0

Inherited from ResourceHOInstances1

Inherited from ResourceHOInstances2

Inherited from ResourceHOInstances3

Inherited from ResourceHOInstances4

Inherited from ResourceHOInstances5

Inherited from ResourceFOInstances0

Inherited from ResourceFOInstances1

Inherited from AnyRef

Inherited from Any

Ungrouped