Last active
September 14, 2015 13:30
-
-
Save mattroberts297/34326ee4a098e1d1af96 to your computer and use it in GitHub Desktop.
Remove the Tie Fighter / Admiral Ackbar operator
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
// With Tie Fighter | |
(validNumberNel(keyJsOpt, _.toLongExact) |@| validNumberNel(valueJsOpt, _.toIntExact)) { | |
case (key, value) => Measurement(name, key, value) | |
} | |
// Without Tie Fighter | |
type V[T] = ValidationNel[String, T] | |
Apply[V].apply2[Long, Int, Measurement](validNumberNel(keyJsOpt, _.toLongExact), validNumberNel(valueJsOpt, _.toIntExact)) { | |
case (key, value) => Measurement(name, key, value) | |
} | |
// From ApplySyntax.scala#24: | |
// "Warning: each call to `|@|` leads to an allocation of wrapper object. | |
// For performance sensitive code, consider using [[scalaz.Apply]]`#applyN` directly."" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment