Object

com.thoughtworks.zerocost

tryt

Related Doc: package zerocost

Permalink

object tryt extends TryTInstances0 with Serializable

The namespace that contains the covariant TryT.

Source
tryt.scala
Linear Supertypes
Serializable, Serializable, TryTInstances0, TryTInstances1, TryTInstances2, TryTInstances3, AnyRef, Any
Ordering
  1. Grouped
  2. Alphabetic
  3. By Inheritance
Inherited
  1. tryt
  2. Serializable
  3. Serializable
  4. TryTInstances0
  5. TryTInstances1
  6. TryTInstances2
  7. TryTInstances3
  8. AnyRef
  9. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. type TryT[F[+_], +A] = tryt.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 scala.Function0.

      import cats.instances.function._
      import scala.util._
      import com.thoughtworks.zerocost.tryt._
      type TryName[+A] = TryT[Function0, A]

      Given a validate function,

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

      when creating a TryT-transformed scala.Function0 from the validate,

      import cats.syntax.all._
      val invalidTry: TryName[Int] = TryT(() => Try(validate("invalid input")))

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

      val TryT(failure) = invalidTry
      failure() should be(an[Failure[_]])

      and when there is no exception thrown in validate call,

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

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

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

      and when the TryT-transformed scala.Function0 is built from a for-comprehension,

      val invalidForComprehension: TryName[Int] = validate("42").pure[TryName].flatMap { i =>
        validate("invalid input").pure[TryName].map { j =>
          i + j
        }
      }

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

      val TryT(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 cats.data.EitherT, except TryT handles exceptions thrown in callback functions passed to map, flatMap or pure.

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 Serializable

    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. implicit final def tryTFunctor[F[+_]](implicit F0: Functor[F]): Functor[[β$15$]tryt.OpacityTypes.TryT[F, β$15$]]

    Permalink

    Definition Classes
    TryTInstances0
  19. implicit final def tryTLiftIO[F[+_]](implicit F0: LiftIO[F]): LiftIO[[β$14$]tryt.OpacityTypes.TryT[F, β$14$]]

    Permalink

    Definition Classes
    TryTInstances0
  20. implicit final def tryTMonadError[F[+_]](implicit F0: Monad[F]): MonadError[[+β$13$]tryt.OpacityTypes.TryT[F, β$13$], Throwable]

    Permalink

    Definition Classes
    TryTInstances1
  21. implicit final def tryTParallelApply[F[+_]](implicit F0: Apply[[β$9$]Parallel[F, β$9$]], E0: Semigroup[Throwable]): Apply[[β$11$]Parallel[[+β$10$]tryt.OpacityTypes.TryT[F, β$10$], β$11$]]

    Permalink

    Definition Classes
    TryTInstances2
  22. implicit final def tryTParallelLiftIO[F[+_]](implicit F0: LiftIO[[β$5$]Parallel[F, β$5$]]): LiftIO[[β$7$]Parallel[[+β$6$]tryt.OpacityTypes.TryT[F, β$6$], β$7$]]

    Permalink

    Definition Classes
    TryTInstances2
  23. implicit final def tryTParallelMonadError[F[+_]](implicit F0: Monad[[β$0$]Parallel[F, β$0$]], E0: Semigroup[Throwable]): MonadError[[β$2$]Parallel[[+β$1$]tryt.OpacityTypes.TryT[F, β$1$], β$2$], Throwable]

    Permalink

    Definition Classes
    TryTInstances3
  24. final def wait(): Unit

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

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

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

Inherited from Serializable

Inherited from Serializable

Inherited from TryTInstances0

Inherited from TryTInstances1

Inherited from TryTInstances2

Inherited from TryTInstances3

Inherited from AnyRef

Inherited from Any

Type classes

Ungrouped