![](https://secure.gravatar.com/avatar/5dc484e83f87a994a4c21c21e8b9c1b0.jpg?s=120&d=mm&r=g)
I have been using Anton's library for quite some time now. Mostly together with my own library: typeclasses (FP concept) https://classes.readthedocs.io/en/latest/pages/concept.html#delegates It is a great tool. I can highly recommend it. The main problem is that it does not work with mutable types by design. Why? What? For example, you want to write a phantom type called "ListOfPositiveInt". So it can be used like so: `isinstance(arg, ListOfPositiveInt)`. But, the problem is: `list` is mutable. After this check passes, you can call `arg.append(-100)` and ruin your precise type. That's why it is limited to immutable types only. сб, 25 дек. 2021 г. в 02:22, Eric Traut <eric@traut.com>:
I haven't heard the term "phantom type" previously, but I like the idea. It's conceptually simple and yet quite powerful. Anton, it looks like this is a relatively new library. What has the feedback been so far? Is it getting significant uptake? Do you know if it has been adopted in any large code bases other than your own?
If I understand the motivations behind the "NotType" proposal, it seems to me that phantom types could solve most (all?) of the intended use cases without all of the downsides that I previously raised.
Are there any changes to the current type system, the runtime, or the current static type checker implementations that are needed to support phantom types? From the above discussion and the documentation , it sounds like the answer might be "no".
-Eric _______________________________________________ Typing-sig mailing list -- typing-sig@python.org To unsubscribe send an email to typing-sig-leave@python.org https://mail.python.org/mailman3/lists/typing-sig.python.org/ Member address: n.a.sobolev@gmail.com