Last active
August 17, 2020 10:44
-
-
Save kryptt/0e65d7de2da4429059a1d4455a0fe326 to your computer and use it in GitHub Desktop.
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
/* It is common for the system to have more complex structures that house transactions, and these complex structures are what the system is dealing with | |
It could be balance sheets as defined earlier, but lets pretend there are other structures used for Fraud detection as well... | |
They are optionally there along with some arbitray metadata, and we need to run a verifier across the transactions inside these structures | |
It would seem like a lot of very specific code is needed to get all this done; but in reality we already have all the combinators we need: | |
*/ | |
def systemVerifier[S, Metadata](traversal: Traversal[S, Transaction], verifier: Pipe[IO, Transaction, Transaction]): Pipe[IO, (Option[S], Metadata), (Option[S], Metadata)] = | |
_.flatMap( | |
_1[(Option[S], Metadata), Option[S]] | |
.composePrism(some) | |
.composeTraversal(traversal) | |
.modifyF(Stream.emit(_).through(verifier))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment