Skip to content

Instantly share code, notes, and snippets.

@Svetixbot
Last active March 16, 2018 06:39
Show Gist options
  • Save Svetixbot/5ca9160f37eb02b7c64b75f110f9b0ea to your computer and use it in GitHub Desktop.
Save Svetixbot/5ca9160f37eb02b7c64b75f110f9b0ea to your computer and use it in GitHub Desktop.
d1, d2, d3 are functions to deconstruct the {data}
t1, t2, t3 are functions to transform each of the destructed pieces
<*> apply function from Applicative.
// The <*> function is from Applicative and enables apply array of functions to an argument.
// The A[x] would hold a value of computation of an exception/null in case something went wrong.
var resultOfDestruct = [d1, d2, d3] <*> data // [A[a], A[b], A[c]]
var resultOfTransform = (resultDestruct) zip [t1, t2, t3] (<*>) // [A[a1], A[b1], A[c1]]
var transformation = resultOfTransform.filterFailures.Reduce(merge);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment