suned / pfun

Functional, composable, asynchronous, type-safe Python.

Home Page:https://pfun.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Effect.map can't handle generators

suned opened this issue · comments

map currently uses asyncio.iscoroutine to determine if the result of a continuation function must be awaited. When a continuation returns a generator `asyncio.iscoroutine mistakes this generator for a coroutine:

from pfun import success


def f(_):
    yield from [1, 2, 3]

success(0).map(f).run(None)  # TypeError: object generator can't be used in 'await' expression