Suggest PEP for mappable and chainable protocols and do expressions
suned opened this issue · comments
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}')))