Created
May 5, 2022 20:48
-
-
Save dgjustice/2a93b55db10b0d08e1fac905e702adfe to your computer and use it in GitHub Desktop.
`returns` weird `lash`
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
from returns import context, result, curry, pipeline, pointfree | |
def some(s): | |
def factory(deps): | |
print('in factory', deps) | |
return result.Success(42) | |
return context.RequiresContextResult(factory) | |
def plusone(arg): | |
print('in plusone', arg) | |
return result.Failure(arg + 1) | |
def lashable(arg): | |
def factory(_): | |
print('in lashable', arg) | |
return result.Success('failed successfully') | |
return context.RequiresContextResult(factory) | |
def other(arg): | |
def factory(deps): | |
print(deps) | |
return pipeline.flow( | |
some(42), | |
pointfree.bind_result(plusone), | |
pointfree.lash(lashable), | |
)('innerdep') | |
return context.RequiresContextResult(factory) | |
print( | |
other(99)('deps') | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment