Comment

Comment by andrepd

The tl;dr is that instead of representing emails as type String and manually sprinkling is_email(str) throughout your code, you represent as type Email, which has a function parse(String) -> Option<Email>. The type system then ensures the checks are present whenever they have to be, and nowhere else.

This is extremely natural to do in a language like Haskell or Rust. And incredibly unnatural to do in C++ for instance.

parent andrepd 6 months ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton