Object

com.thoughtworks.tryt

invariant

Related Doc: package tryt

Permalink

object invariant

The namespace that contains the invariant TryT.

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. type TryT[F[_], A] = invariant.OpacityTypes.TryT[F, A]

    Permalink

    A monad transformer for exception handling.

    A monad transformer for exception handling.

    Example:
    1. As a monad transformer, TryT should be used with another monadic data type, like scalaz.Name.

      import scalaz.Name
      import com.thoughtworks.tryt.invariant.TryT, TryT._
      type TryName[A] = TryT[Name, A]

      Given a validate function,

      def validate(s: String): Int = s.toInt

      when creating a TryT-transformed scalaz.Name from the validate,

      import scalaz.syntax.all._
      val invalidTry: TryName[Int] = validate("invalid input").point[TryName]

      then the exceptions thrown in validate call should be converted to a scala.util.Failure;

      import com.thoughtworks.tryt.invariant.TryT._
      val TryT(Name(failure)) = invalidTry
      import scala.util._
      failure should be(an[Failure[_]])

      and when there is no exception thrown in validate call,

      val validTry: TryName[Int] = validate("42").point[TryName]

      then the result of validate call should be converted to a scala.util.Success;

      val TryT(Name(success)) = validTry
      success should be(Success(42))

      and when the TryT-transformed scalaz.Name is built from a for-comprehension,

      val invalidForComprehension: TryName[Int] = for {
        i <- validate("42").point[TryName]
        j <- validate("invalid input").point[TryName]
      } yield i + j

      then the exceptions thrown in the for-comprehension should be converted to a scala.util.Failure;

      val TryT(Name(failure2)) = invalidTry
      failure2 should be(an[Failure[_]])
    Note

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

    See also

    This TryT transfomer is similar to scalaz.EitherT, except TryT handles exceptions thrown in callback functions passed to map, bind or point.

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 TryT extends TryTInstances0 with InvariantInstances

    Permalink
  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. final def synchronized[T0](arg0: ⇒ T0): T0

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

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

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

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

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

Inherited from AnyRef

Inherited from Any

Ungrouped