Created
November 8, 2017 22:01
-
-
Save sepulchered/d65ad2e43106a4c0e0373f1a491bbf6a to your computer and use it in GitHub Desktop.
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
class Just: | |
def __init__(self, value): | |
self.value = value | |
def __repr__(self): | |
return f'Just {self.value}' | |
def maybe(fn): | |
@functools.wraps(fn) | |
def wrapper(*args, **kwargs): | |
try: | |
return Just(fn(*args, **kwargs)) | |
except Exception: | |
return None | |
return wrapper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment