Skip to content

Instantly share code, notes, and snippets.

@mattroberts297
Last active September 14, 2015 13:30
Show Gist options
  • Save mattroberts297/34326ee4a098e1d1af96 to your computer and use it in GitHub Desktop.
Save mattroberts297/34326ee4a098e1d1af96 to your computer and use it in GitHub Desktop.
Remove the Tie Fighter / Admiral Ackbar operator
// 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