Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggest PEP for mappable and chainable protocols and do expressions #32

Open
suned opened this issue Nov 20, 2019 · 0 comments
Open

Suggest PEP for mappable and chainable protocols and do expressions #32

suned opened this issue Nov 20, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@suned
Copy link
Owner

suned commented Nov 20, 2019

A mappable type is something that implemets __map__(self, f).
A chainable type is something that implements __chain__(self, f).

A type T that implements both can be used in do expressions as

fullname = do user_id('sad') as uid, first_name(uid) as first, last_name(uid) as last in f'{first} {last}'

Which will translate to

fullname = user_id('sad').__chain__(lambda uid: first_name(uid).__chain__(lambda first: last_name(uid).__map__(lambda last: f'{first} {last}')))
@suned suned added the enhancement New feature or request label Nov 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant