Created
January 4, 2015 16:55
-
-
Save tomprince/dd82d7b093ee8e988c0a 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
| def from_effect(f): | |
| @wraps | |
| def wrapper(self, *args, **kwargs): | |
| return self._performer(f(*args, **kwargs)) | |
| wrapper.effectfully = f | |
| return wrapper | |
| class Stuff(object): | |
| def __init__(self, stuff, performer=sync_performer): | |
| self._performer = performer | |
| @from_effect | |
| def remote_call(self, args): | |
| return RemoteCall() | |
| @from_effect | |
| def composite_call(self, args): | |
| effect = self.remote_call.effectfully(args) | |
| effect.on(success=lambda result: result * 2) | |
| return effect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment