Re:The type system is a programmer's best friend
by Smaug123 on Saturday November 05, 2022 @12:24PM
(#33482942)
In fairness this takes an unusually strong type system to express, doesn't it? Typescript can do it, but I don't think e.g. Haskell98 can do it out of the box in an analogous way? (Of course, it's hard to prove a negative and I'm not super familiar with Haskell, but my evidence is that I'm pretty certain F# can't.)
[ Parent
| on HN ]
Re:The type system is a programmer's best friend
by hither_shores on Saturday November 05, 2022 @01:29PM
(#33483559)
> but I don't think e.g. Haskell98 can do it out of the box in an analogous way?
This is basically the runtime representation of `data Email = Verified { email :: string } | Unverified { email :: string }`, but promoting `Verified` and `Unverified` to type level requires an extension:
data Email (verified :: bool) where
Verified :: string -> Email true
Unverified :: string -> Email false