| career | drupal | java | mac | mysql | perl | scala | uml | unix  

Scala example source code file (TryOps.scala)

This example Scala source code file (TryOps.scala) is included in the "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Scala by Example" TM.

Learn more about this Scala project at its project page.

Java - Scala tags/keywords

anyval, throwable, totryops, totryopsfromtry, try, tryops, validation, validationnel

The TryOps.scala Scala example source code

package scalaz
package syntax
package std

import scala.util.Try

import scalaz.std.{`try` => t}

final class TryOps[A](val self: Try[A]) extends AnyVal {

  final def cata[B](success: A => B, failure: Throwable => B): B =
    t.cata(self)(success, failure)

  final def toDisjunction: Throwable \/ A = t.toDisjunction(self)

  final def toValidation: Validation[Throwable, A] = t.toValidation(self)

  final def toValidationNel: ValidationNel[Throwable, A] = t.toValidationNel(self)

trait ToTryOps {
  implicit def ToTryOpsFromTry[A](a: Try[A]): TryOps[A] = new TryOps(a)

Other Scala examples (source code examples)

Here is a short list of links related to this Scala TryOps.scala source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller


new blog posts


Copyright 1998-2021 Alvin Alexander,
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.