Skip to content

Instantly share code, notes, and snippets.

@dgjustice
Created May 5, 2022 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgjustice/2a93b55db10b0d08e1fac905e702adfe to your computer and use it in GitHub Desktop.
Save dgjustice/2a93b55db10b0d08e1fac905e702adfe to your computer and use it in GitHub Desktop.
`returns` weird `lash`
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