Created
September 3, 2015 11:37
-
-
Save aoiroaoino/564981f668d03e272b4d to your computer and use it in GitHub Desktop.
Either3Optics sample code.
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
trait Either3Optics { | |
final def pLeft3[A, B, C, D]: PPrism[Either3[A, B, C], Either3[D, B, C], A, D] = | |
PPrism[Either3[A, B, C], Either3[D, B, C], A, D] { | |
case Left3(a) => \/-(a) | |
case Middle3(b) => -\/(Middle3(b)) | |
case Right3(c) => -\/(Right3(c)) | |
}(Left3.apply) | |
final def left3[A, B, C]: Prism[Either3[A, B, C], A] = | |
pLeft3[A, B, C, A] | |
final def pMiddle3[A, B, C, D]: PPrism[Either3[A, B, C], Either3[A, D, C], B, D] = | |
PPrism[Either3[A, B, C], Either3[A, D, C], B, D] { | |
case Left3(a) => -\/(Left3(a)) | |
case Middle3(b) => \/-(b) | |
case Right3(c) => -\/(Right3(c)) | |
}(Middle3.apply) | |
final def middle3[A, B, C]: Prism[Either3[A, B, C], B] = | |
pMiddle3[A, B, C, B] | |
final def pRight3[A, B, C, D]: PPrism[Either3[A, B, C], Either3[A, B, D], C, D] = | |
PPrism[Either3[A, B, C], Either3[A, B, D], C, D] { | |
case Left3(a) => -\/(Left3(a)) | |
case Middle3(b) => -\/(Middle3(b)) | |
case Right3(c) => \/-(c) | |
}(Right3.apply) | |
final def right3[A, B, C]: Prism[Either3[A, B, C], C] = | |
pRight3[A, B, C, C] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment