How is phantom-types different from beartype? #211
-
how is this functionally different from beartype? in beartype you can check |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
@majidaldo Hi 👋 Generally speaking beartype is a runtime type-checker and phantom-types is a category of types. I did not know beartype supports |
Beta Was this translation helpful? Give feedback.
-
@majidaldo Also, I forgot to mention, phantom-types are compatible with beartype (and other runtime type checkers), as mentioned here: https://github.com/antonagestam/phantom-types#runtime-type-checking |
Beta Was this translation helpful? Give feedback.
@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.