Skip to content

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

@suned

Description

@suned

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}')))

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions