Library to help in Python functional programing. Itβs asyncio compatible.
Basic idea behind it is Railway Oriented Programing.
This allows us to:
- simplify our code.
- improve error management.
- be cool! be functional!
Examples:
Old code example:
async def create_user_handler(request) -> Response:
try:
user = check_valid_user(request)
create_user(user)
except InvalidBody:
return_422('Invalid body')
except UserAlreadyExists:
return_409('User already exists')
return_201(user)
ROP example:
async def create_user_handler(request) -> Response:
return await compose(
check_valid_user,
create_user,
return_201
)(request)