object covariant extends CovariantResourceTInstances0
- Source
- covariant.scala
- Grouped
- Alphabetic
- By Inheritance
- covariant
- CovariantResourceTInstances0
- CovariantResourceTInstances1
- CovariantResourceTInstances2
- CovariantResourceTInstances3
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
- implicit final class CovariantResourceTOps[F[+_], A] extends AnyRef
-
trait
MonadicCloseable[F[+_]] extends Any
An object that may hold resources until it is closed.
An object that may hold resources until it is closed.
Similar to java.lang.AutoCloseable except the close operation is monadic.
- trait Resource[F[+_], +A] extends AnyRef
-
type
ResourceT[F[+_], +A] = covariant.OpacityTypes.ResourceT[F, A]
The data structure that provides automatic resource management.
The data structure that provides automatic resource management.
ResourceT
can be used as a monad transformer for scalaz.Nameimport scalaz.Name import com.thoughtworks.raii.covariant._ type RAII[A] = ResourceT[Name, A]
Given a resource that creates temporary files
import java.io.File val resource: RAII[File] = ResourceT(Name(new Resource[Name, File] { override val value: File = File.createTempFile("test", ".tmp"); override val release: Name[Unit] = Name { val isDeleted = value.delete() } }))
when using temporary file created by
resouce
in afor
/yield
block, those temporary files should be available.import scalaz.syntax.all._ val usingResouce = for { tmpFile1 <- resource tmpFile2 <- resource } yield { tmpFile1 shouldNot be(tmpFile2) tmpFile1 should exist tmpFile2 should exist (tmpFile1, tmpFile2) }
and those files should have been deleted after the
for
/yield
block.val (tmpFile1, tmpFile2) = usingResouce.run.value tmpFile1 shouldNot exist tmpFile2 shouldNot exist
- Note
This
ResourceT
type is an opacity alias toF[Resource[F, A]]
. All type classes and helper functions for thisResourceT
type are defined in the companion object ResourceT
Example: -
type
Releasable[F[+_], +A] = Resource[F, A]
- Annotations
- @deprecated
- Deprecated
(Since version 3.0.0) Use Resource instead.
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
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
implicit
def
covariantResourceTApplicative[F[+_]](implicit arg0: Applicative[F]): Applicative[[β$0$]covariant.OpacityTypes.ResourceT[F, β$0$]]
- Definition Classes
- CovariantResourceTInstances3
-
implicit
def
covariantResourceTMonad[F[+_]](implicit arg0: Monad[F]): Monad[[β$1$]covariant.OpacityTypes.ResourceT[F, β$1$]]
- Definition Classes
- CovariantResourceTInstances2
-
implicit
def
covariantResourceTMonadError[F[+_], S](implicit F0: MonadError[F, S]): MonadError[[β$3$]covariant.OpacityTypes.ResourceT[F, β$3$], S]
- Definition Classes
- CovariantResourceTInstances0
-
implicit
def
covariantResourceTNondeterminism[F[+_]](implicit F0: Nondeterminism[F]): Nondeterminism[[β$2$]covariant.OpacityTypes.ResourceT[F, β$2$]]
- Definition Classes
- CovariantResourceTInstances1
- implicit def covariantResourceTParallelApplicative[F[+_]](implicit F0: Applicative[[A]AnyRef { ... /* 2 definitions in type refinement */ }]): Applicative[[A]AnyRef { ... /* 2 definitions in type refinement */ }]
-
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] )
-
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
-
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()
-
val
opacityTypes: OpacityTypes
The type-level Pimpl in order to prevent the Scala compiler seeing the actual type of ResourceT
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
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( ... )
- object Resource
-
object
ResourceT
The companion object of ResourceT that contains converters and type classes.
The companion object of ResourceT that contains converters and type classes.
- Note
There are some implicit method that provides scalaz.Monads as monad transformers of
F
. Those monads running will collect all resources, which will be open and release altogether when ResourceT.run is called.