Attributes
- Companion
- class
- Source
- Resource.scala
- Graph
-
- Supertypes
-
trait Sumtrait Mirrortrait Serializableclass Objecttrait Matchableclass AnyShow all
- Self type
-
Resource.type
Members list
Type members
Classlikes
Resource
data constructor that wraps an effect allocating a resource, along with its finalizers.
Resource
data constructor that wraps an effect allocating a resource, along with its finalizers.
Attributes
- Source
- Resource.scala
- Supertypes
Resource
data constructor that encodes the flatMap
operation.
Resource
data constructor that encodes the flatMap
operation.
Attributes
- Source
- Resource.scala
- Supertypes
Attributes
- Source
- Resource.scala
- Supertypes
Attributes
- Companion
- trait
- Source
- Resource.scala
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
ExitCase.type
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:
Attributes
- Companion
- object
- Source
- Resource.scala
- Supertypes
- Known subtypes
Attributes
- Source
- Resource.scala
- Supertypes
-
class AnyValtrait Matchableclass Any
Types
Attributes
- Source
- Resource.scala
Inherited types
The names of the product elements
The name of the type
Value members
Concrete methods
Creates a resource from an allocating effect.
Creates a resource from an allocating effect.
Type parameters
- A
-
the type of the resource
- F
-
the effect type in which the resource is acquired and released
Value parameters
- resource
-
an effect that returns a tuple of a resource and an effect to release it
Attributes
- See also
-
make for a version that separates the needed resource with its finalizer tuple in two parameters
- Source
- Resource.scala
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.
Type parameters
- A
-
the type of the resource
- F
-
the effect type in which the resource is acquired and released
Value parameters
- resource
-
an effect that returns a tuple of a resource and an effectful function to release it
Attributes
- See also
-
makeCase for a version that separates the needed resource with its finalizer tuple in two parameters
- Source
- Resource.scala
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
Type parameters
- A
-
the type of the resource
- F
-
the effect type in which the resource is acquired and released
Value parameters
- resource
-
an effect that returns a tuple of a resource and an effectful function to release it, where acquisition can potentially be interrupted
Attributes
- See also
-
makeFull for a version that separates the needed resource with its finalizer tuple in two parameters
- Source
- Resource.scala
Allocates two resources concurrently, and combines their results in a tuple.
Allocates two resources concurrently, and combines their results in a tuple.
Attributes
- Source
- Resource.scala
Attributes
- Source
- Resource.scala
Attributes
- Source
- Resource.scala
Attributes
- Source
- Resource.scala
Attributes
- Source
- Resource.scala
Lifts an applicative into a resource. The resource has a no-op release. Preserves interruptibility of fa
.
Lifts an applicative into a resource. The resource has a no-op release. Preserves interruptibility of fa
.
Value parameters
- fa
-
the value to lift into a resource
Attributes
- Source
- Resource.scala
Attributes
- Source
- Resource.scala
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.
Type parameters
- A
-
the type of the autocloseable resource
- F
-
the type of the effect
Value parameters
- F
-
the effect type in which the resource was acquired and will be released
- acquire
-
The effect with the resource to acquire.
Attributes
- Returns
-
a Resource that will automatically close after use
- Example
-
import cats.effect._ import scala.io.Source def reader(data: String): Resource[IO, Source] = Resource.fromAutoCloseable(IO.blocking { Source.fromString(data) })
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) })
- Source
- Resource.scala
Lifts an applicative into a resource as a FunctionK
. The resource has a no-op release.
Lifts an applicative into a resource as a FunctionK
. The resource has a no-op release.
Attributes
- Source
- Resource.scala
Creates a resource from an acquiring effect and a release function.
Creates a resource from an acquiring effect and a release function.
Type parameters
- A
-
the type of the resource
- F
-
the effect type in which the resource is acquired and released
Value parameters
- acquire
-
an effect to acquire a resource
- release
-
a function to effectfully release the resource returned by
acquire
Attributes
- Source
- Resource.scala
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.
Type parameters
- A
-
the type of the resource
- F
-
the effect type in which the resource is acquired and released
Value parameters
- acquire
-
a function to effectfully acquire a resource
- release
-
a function to effectfully release the resource returned by
acquire
Attributes
- Source
- Resource.scala
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)
Type parameters
- A
-
the type of the resource
- F
-
the effect type in which the resource is acquired and released
Value parameters
- acquire
-
an effect to acquire a resource, possibly interruptibly
- release
-
a function to effectfully release the resource returned by
acquire
Attributes
- Source
- Resource.scala
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)
Type parameters
- A
-
the type of the resource
- F
-
the effect type in which the resource is acquired and released
Value parameters
- acquire
-
an effect to acquire a resource, possibly interruptibly
- release
-
a function to effectfully release the resource returned by
acquire
Attributes
- Source
- Resource.scala
Attributes
- Source
- Resource.scala
Attributes
- Source
- Resource.scala
Lifts a finalizer into a resource. The resource has a no-op allocation.
Lifts a finalizer into a resource. The resource has a no-op allocation.
Attributes
- Source
- Resource.scala
Creates a resource that allocates immediately without any effects, but calls release
when closing, providing the the usage completed with.
Creates a resource that allocates immediately without any effects, but calls release
when closing, providing the the usage completed with.
Attributes
- Source
- Resource.scala
Lifts a pure value into a resource. The resource has a no-op release.
Lifts a pure value into a resource. The resource has a no-op release.
Value parameters
- a
-
the value to lift into a resource
Attributes
- Source
- Resource.scala
Races the evaluation of two resource allocations and returns the result of the winner, except in the case of cancelation.
Races the evaluation of two resource allocations and returns the result of the winner, except in the case of cancelation.
Attributes
- Source
- Resource.scala
Attributes
- Source
- Resource.scala
Attributes
- Source
- Resource.scala
Attributes
- Source
- Resource.scala
Attributes
- Source
- Resource.scala
Given a Resource
suspended in F[_]
, lifts it in the Resource
context.
Given a Resource
suspended in F[_]
, lifts it in the Resource
context.
Attributes
- Source
- Resource.scala
Attributes
- Source
- Resource.scala
Attributes
- Source
- Resource.scala
Attributes
- Source
- Resource.scala
A resource with a no-op allocation and a no-op release.
Deprecated methods
Attributes
- Deprecated
- true
- Source
- Resource.scala
Inherited methods
Creates a Resource by wrapping a Java Destroyable.
Creates a Resource by wrapping a Java Destroyable.
Type parameters
- A
-
the type of the destroyable resource
- F
-
the type of the effect
Value parameters
- F
-
the effect type in which the resource was acquired and will be released
- acquire
-
The effect with the resource to acquire.
Attributes
- Returns
-
a Resource that will automatically destroy after use
- Example
-
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(_)) )
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(_)) )
- Inherited from:
- ResourcePlatform (hidden)
- Source
- ResourcePlatform.scala
Deprecated and Inherited methods
Attributes
- Deprecated
- true
- Inherited from:
- ResourceHOInstances5 (hidden)
- Source
- Resource.scala
Attributes
- Deprecated
- true
- Inherited from:
- ResourceFOInstances0 (hidden)
- Source
- Resource.scala
Attributes
- Deprecated
- true
- Inherited from:
- ResourceFOInstances1 (hidden)
- Source
- Resource.scala
Implicits
Implicits
Attributes
- Source
- Resource.scala
Attributes
- Source
- Resource.scala
Attributes
- Source
- Resource.scala
Inherited implicits
Attributes
- Inherited from:
- ResourceHOInstances0 (hidden)
- Source
- Resource.scala
Attributes
- Inherited from:
- ResourceHOInstances2 (hidden)
- Source
- Resource.scala
Attributes
- Inherited from:
- ResourceHOInstances2 (hidden)
- Source
- Resource.scala
Attributes
- Inherited from:
- ResourceHOInstances2 (hidden)
- Source
- Resource.scala
Attributes
- Inherited from:
- ResourceHOInstances3 (hidden)
- Source
- Resource.scala
Attributes
- Inherited from:
- ResourceHOInstances4 (hidden)
- Source
- Resource.scala
Attributes
- Inherited from:
- ResourceHOInstances5 (hidden)
- Source
- Resource.scala
Attributes
- Inherited from:
- ResourceFOInstances0 (hidden)
- Source
- Resource.scala
Attributes
- Inherited from:
- ResourceFOInstances1 (hidden)
- Source
- Resource.scala
Attributes
- Inherited from:
- ResourceHOInstances0 (hidden)
- Source
- Resource.scala
Attributes
- Inherited from:
- ResourceHOInstances1 (hidden)
- Source
- Resource.scala
Attributes
- Inherited from:
- ResourceHOInstances1 (hidden)
- Source
- Resource.scala