Object

com.thoughtworks.raii

invariant

Related Doc: package raii

Permalink

object invariant

The namespace that contains the invariant ResourceT.

Usage:

import com.thoughtworks.raii.invariant._
Source
covariant.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. invariant
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. trait Releasable[F[_], A] extends AnyRef

    Permalink

    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

  2. type ResourceT[F[_], A] = invariant.OpacityTypes.ResourceT[F, A]

    Permalink

    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.invariant.ResourceT, ResourceT._
      type RAII[A] = ResourceT[Name, A]

      Given a resource that creates temporary files

      import java.io.File
      val resource: RAII[File] = ResourceT(Name(new Releasable[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) = ResourceT.run(usingResouce).value
      tmpFile1 shouldNot exist
      tmpFile2 shouldNot exist
    Note

    This ResourceT type is an opacity alias to F[Releasable[F, A]]. All type classes and helper functions for this ResourceT type are defined in the companion object ResourceT

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. object ResourceT extends ResourceFactoryTInstances0 with ResourceFactoryTInvariantInstances

    Permalink

    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 run is called.

  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  11. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  12. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  13. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  14. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  15. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  16. val opacityTypes: OpacityTypes

    Permalink

    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.

  17. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  18. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  19. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  20. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped