This file contains hidden or 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
| scala> val a = "Hello".successNel[String] | |
| a: scalaz.ValidationNel[String,String] = Success(Hello) | |
| scala> val b = "this".successNel[String] | |
| b: scalaz.ValidationNel[String,String] = Success(this) | |
| scala> val c = "is".successNel[String] | |
| c: scalaz.ValidationNel[String,String] = Success(is) | |
| scala> val d = "test".successNel[String] |
This file contains hidden or 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
| scala> val a = "Hello".successNel[String] | |
| a: scalaz.ValidationNel[String,String] = Success(Hello) | |
| scala> val b = "this".successNel[String] | |
| b: scalaz.ValidationNel[String,String] = Success(this) | |
| scala> val c = "is".successNel[String] | |
| c: scalaz.ValidationNel[String,String] = Success(is) | |
| scala> val d = "test".successNel[String] |
This file contains hidden or 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
| scala> def eitherToValidation(input:Either[String, Double]): Validation[String, Double] = { | |
| | val month = input match { | |
| | case Right(l) => l | |
| | case Left(l) => l | |
| | } | |
| | ((month.toString).toDouble).success | |
| | } | |
| eitherToValidation: (input: Either[String,Double])scalaz.Validation[String,Double] |
This file contains hidden or 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
| scala> def eitherToValidation(input:Either[com.snowplowanalytics.forex.oerclient.OerResponseError,org.joda.money.Money]): Validation[String, Double] = { | |
| | val month = input match { | |
| | case Right(l) => l | |
| | case Left(l) => l | |
| | } | |
| | ((month.toString).toDouble).success | |
| | } | |
| eitherToValidation: (input: Either[com.snowplowanalytics.forex.oerclient.OerResponseError,org.joda.money.Money])scalaz.Validation[String,Double] |
This file contains hidden or 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
| scala> def eitherToValidation(input:Either[String, Double]): Validation[String, Double] = { | |
| | val month = input match { | |
| | case Right(l) => l | |
| | case Left(l) => "Error for" + l + " occurred." | |
| | } | |
| | ((month.toString).toDouble).success | |
| | } | |
| eitherToValidation: (input: Either[String,Double])scalaz.Validation[String,Double] | |
| scala> "aa".toString |
This file contains hidden or 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
| def eitherToValidation(input:Either[String, Double]): Validation[String, Double] = { | |
| input match { | |
| case Right(l) => (l.toString).toDouble.success | |
| case Left(l) => l.failure | |
| } | |
| } |
This file contains hidden or 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
| scala> val t: Option[Double] = None | |
| t: Option[Double] = None | |
| scala> val p: Option[Double] = None | |
| p: Option[Double] = None | |
| scala> def toRight[Ok, Err](x: Option[Ok], orElse: => Err): Either.RightProjection[Err, Ok] = { | |
| | val either = | |
| | x match { | |
| | case Some(x) => Right(x) |
This file contains hidden or 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
| scala> def eitherToValidation(input:Either[com.snowplowanalytics.forex.oerclient.OerResponseError,org.joda.money.Money]): Validation[String, Double]= { | |
| | input match { | |
| | case Right(l) => (l.getAmount().doubleValue()).success[String] | |
| | case Left(l) => "Some error occurred".failure | |
| | } | |
| | } | |
| eitherToValidation: (input: Either[com.snowplowanalytics.forex.oerclient.OerResponseError,org.joda.money.Money])scalaz.Validation[String,Double] | |
| scala> newCurrency_tr |
This file contains hidden or 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
| def eitherToValidation(input:Either[com.snowplowanalytics.forex.oerclient.OerResponseError,org.joda.money.Money]): [String, Double]= { | |
| input match { | |
| case Right(l) => (l.getAmount().doubleValue()).success[String] | |
| case Left(l) => "Error is type ${l.errorType} message: ${l.errorMessage}".failure | |
| } | |
| } | |
| def eitherToValidation(input:Either[com.snowplowanalytics.forex.oerclient.OerResponseError,org.joda.money.Money]): Validation[String, Double]= { | |
| input match { | |
| case Right(l) => (l.getAmount().doubleValue()).success[String] |
This file contains hidden or 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
| def tryParse(s: Either[com.snowplowanalytics.forex.oerclient.OerResponseError,org.joda.money.Money]):String = { | |
| eitherToValidation(s) match { | |
| case Success(pass) => { | |
| pass.toString() | |
| } | |
| case Failure(failure) => { | |
| failure | |
| } | |
| } | |
| } |