News for hackers. Stuff that matters.
Re:The type system is a programmer's best friend by gilbetron on Sunday November 06, 2022 @10:21AM (#33493543)
But then you can just have a "makeEmailVerified" that takes an UnverifiedEmail and converts it to a VerifiedEmail without verification. Then the "send" function still needs to check things.
Re:The type system is a programmer's best friend by tel on Sunday November 06, 2022 @10:53PM (#33500937)
Typically, the owner of the VerifiedEmail type restricts your ability to construct new values of that type by making the constructor private and then only "blessing" a small number of public constructors, each one performing that verification.

If any type could be converted to any other (compatible) type for any reason whatsoever then types would have no semantic value. But fortunately, we can control how types are constructed and used.