Closed akefirad closed 6 months ago
Is this a bug or feature?
Neither, NewType
is a completely distinct feature from this library. You could say it's a feature of NewTypes that they work this way though.
A better way to look at it is that phantom types are a more powerful alternative than new types. I've written this blog post that discusses some related things.
If you want the resulting type to have the parse method, what you should do rather than using NewType is likely this:
class MoneyAmount(Natural): ...
Is this a bug or feature:
Calling the
parse
method ofMoneyAmount
fails withAny way to make phantom types compatible with
NewType
? Thanks.