object Resource extends ResourceInstances with ResourcePlatform
- Source
- Resource.scala
- Alphabetic
- By Inheritance
- Resource
- ResourcePlatform
- ResourceInstances
- ResourceInstances0
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
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. -
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 theflatMap
operation. -
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
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
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
-
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
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
implicit
def
catsEffectLiftIOForResource[F[_]](implicit F00: LiftIO[F], F10: Applicative[F]): LiftIO[[β$1$]Resource[F, β$1$]]
- Definition Classes
- ResourceInstances
-
implicit
def
catsEffectMonadErrorForResource[F[_], E](implicit F0: MonadError[F, E]): MonadError[[β$0$]Resource[F, β$0$], E]
- Definition Classes
- ResourceInstances
-
implicit
def
catsEffectMonadForResource[F[_]](implicit F0: Monad[F]): Monad[[β$2$]Resource[F, β$2$]]
- Definition Classes
- ResourceInstances0
-
implicit
def
catsEffectMonoidForResource[F[_], A](implicit F0: Monad[F], A0: Monoid[A]): Monoid[Resource[F, A]]
- Definition Classes
- ResourceInstances
-
implicit
def
catsEffectSemigroupForResource[F[_], A](implicit F0: Monad[F], A0: Semigroup[A]): ResourceSemigroup[F, A]
- Definition Classes
- ResourceInstances0
-
implicit
def
catsEffectSemigroupKForResource[F[_], A](implicit F0: Monad[F], K0: SemigroupK[F]): ResourceSemigroupK[F]
- Definition Classes
- ResourceInstances0
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
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 java.io._ import cats.effect._ def reader[F[_]](file: File)(implicit F: Sync[F]): Resource[F, BufferedReader] = Resource.fromAutoCloseable(F.delay { new BufferedReader(new FileReader(file)) })
- 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
-
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
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
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.
- fa
the value to lift into a resource
-
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
-
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
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
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 resouce has a no-op release.
- a
the value to lift into a resource
-
def
suspend[F[_], A](fr: F[Resource[F, A]]): Resource[F, A]
Given a
Resource
suspended inF[_]
, lifts it in theResource
context. -
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
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 thecats.Monad
type class. -
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
This is the API documentation for the cats-effect library.
See the cats.effect package for a quick overview.
Links
Canonical documentation links:
Related Cats links (the core):