Last active
August 13, 2016 10:12
-
-
Save RonnyPfannschmidt/809d37809eca426643c252dccd2e706e 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
| @tagged | |
| class Maybe(object): | |
| @construct | |
| def Nothing(self): | |
| pass | |
| @construct | |
| def Just(self, data: int): | |
| pass | |
| Maybe = attr.union('Maybe') | |
| @Maybe.register | |
| @attr.s | |
| class Nothing(object): | |
| def map(self, func): | |
| return self | |
| @Maybe.register | |
| @attr.s | |
| class Just(object): | |
| data = attr.ib() | |
| def map(self, func): | |
| return Just(func(self.data)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment