Packages

object covariant extends CovariantResourceTInstances0

The namespace that contains the covariant ResourceT.

Usage:

import com.thoughtworks.raii.covariant._
Source
covariant.scala
Linear Supertypes
CovariantResourceTInstances0, CovariantResourceTInstances1, CovariantResourceTInstances2, CovariantResourceTInstances3, AnyRef, Any
Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. covariant
  2. CovariantResourceTInstances0
  3. CovariantResourceTInstances1
  4. CovariantResourceTInstances2
  5. CovariantResourceTInstances3
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. implicit final class CovariantResourceTOps[F[+_], A] extends AnyRef
  2. 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.

  3. trait Resource[F[+_], +A] extends AnyRef

    A container of a value and a function to release the value.

    A container of a value and a function to release the value.

    F

    the monadic type of release

    A

    the type of value

    Note

    This Resource will become a case class. Use Resource.apply instead of new Resource[F, A] { ... }.

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

    Example:
    1. ResourceT can be used as a monad transformer for scalaz.Name

      import 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 a for / 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 to F[Resource[F, A]]. All type classes and helper functions for this ResourceT type are defined in the companion object ResourceT

  5. type Releasable[F[+_], +A] = Resource[F, A]
    Annotations
    @deprecated
    Deprecated

    (Since version 3.0.0) Use Resource instead.

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. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  6. implicit def covariantResourceTApplicative[F[+_]](implicit arg0: Applicative[F]): Applicative[[β$0$]covariant.OpacityTypes.ResourceT[F, β$0$]]

    Definition Classes
    CovariantResourceTInstances3
  7. implicit def covariantResourceTMonad[F[+_]](implicit arg0: Monad[F]): Monad[[β$1$]covariant.OpacityTypes.ResourceT[F, β$1$]]

    Definition Classes
    CovariantResourceTInstances2
  8. implicit def covariantResourceTMonadError[F[+_], S](implicit F0: MonadError[F, S]): MonadError[[β$3$]covariant.OpacityTypes.ResourceT[F, β$3$], S]

    Definition Classes
    CovariantResourceTInstances0
  9. implicit def covariantResourceTNondeterminism[F[+_]](implicit F0: Nondeterminism[F]): Nondeterminism[[β$2$]covariant.OpacityTypes.ResourceT[F, β$2$]]

    Definition Classes
    CovariantResourceTInstances1
  10. implicit def covariantResourceTParallelApplicative[F[+_]](implicit F0: Applicative[[A]AnyRef { ... /* 2 definitions in type refinement */ }]): Applicative[[A]AnyRef { ... /* 2 definitions in type refinement */ }]

  11. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  12. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  13. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  14. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  15. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  16. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  17. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  18. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  19. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  20. val opacityTypes: OpacityTypes

    The type-level Pimpl in order to prevent the Scala compiler seeing the actual type of ResourceT

    The type-level Pimpl in order to prevent the Scala compiler seeing the actual type of ResourceT

    Note

    For internal usage only.

  21. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  22. def toString(): String
    Definition Classes
    AnyRef → Any
  23. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  24. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  25. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  26. object Resource
  27. 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.

Inherited from CovariantResourceTInstances0

Inherited from CovariantResourceTInstances1

Inherited from CovariantResourceTInstances2

Inherited from CovariantResourceTInstances3

Inherited from AnyRef

Inherited from Any

Type classes

Ungrouped