Skip to content

Support for literal type annotations#512

Merged
eb8680 merged 7 commits intomasterfrom
kg-literal
Jan 27, 2026
Merged

Support for literal type annotations#512
eb8680 merged 7 commits intomasterfrom
kg-literal

Conversation

@kiranandcode
Copy link
Contributor

@kiranandcode kiranandcode commented Jan 27, 2026

I am not familiar enough with the internals to determine if this change is well-founded or fits within the design scope of effectful but opening a PR to discuss. This PR makes a small change to _simple_type to make Literal annotations at least work with uninterpreted ops and evaluate

from effectful.ops.syntax import ObjectInterpretation, implements
from effectful.ops.syntax import defop, NotHandled
from typing import Literla

@defop
def Price() -> Literal[5,10,20,50,80,120,150,200]:
    raise NotHandled

t = Price()
print(t)

with handler({Price: lambda: 10}):
    print(evaluate(t))

@kiranandcode kiranandcode requested a review from jfeser January 27, 2026 15:47
@kiranandcode kiranandcode linked an issue Jan 27, 2026 that may be closed by this pull request
Copy link
Contributor

@eb8680 eb8680 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some unit tests? You might also want to add Literal patterns for internals.unification.canonicalize and internals.unification.nested_type that do more or less the same thing.

@kiranandcode
Copy link
Contributor Author

@eb8680 added one more toplevel test for unify working with literals, now done! ready to merge.

@kiranandcode kiranandcode removed the request for review from jfeser January 27, 2026 17:06
@eb8680 eb8680 merged commit e33873d into master Jan 27, 2026
6 checks passed
@eb8680 eb8680 deleted the kg-literal branch January 27, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for terms with Literal types

2 participants