-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added Ior syntax * Removed examples on ior syntax comments * Removed toValidatedNel functions * Added syntax to list for IorNel and ValidatedNel * Added test for toValidated function * Added newline to end of ior.scala file * Added toIor functions to option syntax * Added fromIor to ValidatedFunctions and toIor function to Validated datatype * Corrected error on duplicated implicit defs on syntax.ior.scala * Added tests for new functions in Validated and Ior * Added examples to list syntax functions * Corrected errors on list syntax examples * Added corrected examples to ior syntax * Corrected names for IorNel syntax functions * Redifined the IorNel type alias * Fixed test descriptions on IorTests * Removed some functions from ior syntax object, deleted functions from list syntax object
- Loading branch information
1 parent
388acd1
commit e77bb99
Showing
10 changed files
with
159 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package cats.syntax | ||
|
||
import cats.data.Ior | ||
|
||
trait IorSyntax { | ||
implicit def catsSyntaxIorId[A](a: A): IorIdOps[A] = new IorIdOps(a) | ||
} | ||
|
||
final class IorIdOps[A](val a: A) extends AnyVal { | ||
/** | ||
* Wrap a value in `Ior.Right`. | ||
* | ||
* Example: | ||
* {{{ | ||
* scala> import cats.data.Ior | ||
* scala> import cats.implicits._ | ||
* | ||
* scala> "hello".rightIor[String] | ||
* res0: Ior[String, String] = Right(hello) | ||
* }}} | ||
*/ | ||
def rightIor[B]: Ior[B, A] = Ior.right(a) | ||
|
||
/** | ||
* Wrap a value in `Ior.Left`. | ||
* | ||
* Example: | ||
* {{{ | ||
* scala> import cats.data.Ior | ||
* scala> import cats.implicits._ | ||
* | ||
* scala> "error".leftIor[String] | ||
* res0: Ior[String, String] = Left(error) | ||
* }}} | ||
*/ | ||
def leftIor[B]: Ior[A, B] = Ior.left(a) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters