Hacker News new | past | comments | ask | show | jobs | submit login

> If this is something you need, it smells like "runtime checking" not amending the type system.

This is both! The primary point of branded types is to allow you to use the type system to ensure that a particular runtime check has taken place.




> The primary point of branded types is to allow you to use the type system to ensure that a particular runtime check has taken place.

I see. This is kind of cool, though the branding can still be broken via down-the-stream mutations. Would be nice to enforce re-branding every time a variable is changed, but that seems like a lot of overhead.


> the branding can still be broken via down-the-stream mutations

Only for mutable values! A branded string should be as immutable as they come, right?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: