Skip to content

evaluate should support dataclasses #322

@eb8680

Description

@eb8680

This is needed in some downstream use cases of effectful. It should only take a few lines of code thanks to the is_dataclass, as_dict and replace helpers from dataclasses:

def evaluate(expr, intp):
    ...
    if dataclasses.is_dataclass(expr) and not isinstance(expr, type):
        return dataclasses.replace(expr, **evaluate(dataclasses.as_dict(expr), intp=intp))
    else:
        return expr

It's possible we may need to address #296 first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions