Skip to content

How is phantom-types different from beartype? #211

Answered by antonagestam
majidaldo asked this question in Q&A
Discussion options

You must be logged in to vote

@majidaldo Hi 👋

Generally speaking beartype is a runtime type-checker and phantom-types is a category of types.

I did not know beartype supports Annotated[basetype, <predicates>], but I suspect the main difference to that would be that phantom types have full compatibility with static type checkers, that's really the main selling point of phantom types: to "store" results from runtime type checks in the static type system.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by antonagestam
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #210 on June 02, 2022 07:19.